Chủ Nhật, 31 tháng 7, 2016

Learning modern C++

#include <iostream>
#include <vector>
#include <string>
#include <deque>
  
using namespace std;

class OpenFile {
public:
       OpenFile(string filename) {cout<<"Open a file\n"<<filename ; }
       void destroyMe() { delete this; }

private:
       ~OpenFile() {cout<<"Destroy a file in deconstructor\n" ; }

};
//--------------------------------------------------------------------
class BigArray {
       vector<int > v;       //huge array
       int accessCounter;    //1st member
       int* v2;              //2nd member
public:
       int getItem(int indexconst {
           //accessCounter++; 
           //because using const -> can not change private member of class
           const_cast <BigArray*>(this)->accessCounter++;
           return v[index]; }
           //getItem did not change any value of v, just take a bit of index, 
                                                    getItem should be const 
       void setv2Item(int indexint xconst { *(v2 + index) = x; }
       //this func maintain bitwise const of BigArray class,
                           it does not change any member of class directly

}; 
//--------------------------------------------------------------------
//const and Function
class Dog {
       int age;
       string name;

public:
       Dog() { age = 3; name = "dummy"; }  //constructor
      
       //const parameter
       //void setAge(const int& a) { age = a; }   //func
       //void setAge(int a) { age = a;}   //overload func

       //const return value
       const string getName() { return name; }
        
       //const func
       void printDogName() const { cout << name <<"   const"<< endl; }   
       //does not change any member valuable of class
       void printDogName()  { cout << getName() <<"   non-const"<< endl; }   
       //does not change any value of member of class
};
//-------------------------------------------------------------------- 
class Dog_ {
public:
        ~Dog_() { cout << "Dog destroyed\n"; }
         void bark(){}
};
class YellowDog : public Dog_ {
public:
       ~YellowDog() { cout << "YellowDog destroyed\n"; }
};
class DogFactory{
public:
      
       static Dog_* createYellowDog() {  return (new YellowDog());}
};
//-------------------------------------------------------------------- 
int main() {
       
       OpenFile* f = new OpenFile(string("hello world\n"));  
       f->destroyMe();
       
       //-----------
       Dog d;
       d.printDogName();
       const Dog d2;
       d2.printDogName();

       //-----------
       Dog_* pd = DogFactory::createYellowDog();      
       delete pd;
       
       return 0;

}

//-------------------------------
//               7/31
//Avoid to call Virtual Function in Constructor or Destructor
class Cat {
public:
       Cat() { cout << "Cat born." << endl; say(); }
       virtual void say() { cout << "I am just a baby cat!" << endl; }
       void seeCat() { say(); }
       ~Cat() { say(); }
};

class Lion : public Cat{
public:
       Lion() { cout << "Lion born." << endl; }
       virtual void say() { cout << "I am just a yellow lion." << endl; }
};
int main() {

       Lion bucky;
       bucky.seeCat();
       //although we call seeCat() of Cat class,
       //say() func was called to Lion class
}

CAD website

CAD sketches:  
Cel Shading: 
Depth/Normal maps:
Hatching:
NPR: curve lines:
Mosaics:
Technical illustrations:
Triangle strips: tunnels        http://www.cs.queensu.ca/home/jstewart/strips/algorithm/
Triangle strips                       http://www.dlc.fi/~dkpa/strip/newstrip.pdf
Triangle strips: Hamiltonian http://w3.impa.br/~lvelho/h4k/papers/hts.pdf

MIT new 2016

Paragraph:

Blocks make programming more intuitive for people who don’t necessarily have the background. Some of the biggest issues the team has encountered are with interfaces that control zooming and scrolling. It’s easy to see that some of her inspiration comes from Japanese animator Hayao Miyazaki.
“Computer graphics is that in-between space,” she says. “You need to have some kind of aesthetic sensibility, since the whole point is still to tell a story, but you’re using computer science and math to do that.”

New Words:
more intuitive : Trực quan hơn
to complete a series of challenges:  hoàn thành chuỗi mục tiêu, thách thức
encounter : to have or experience (problems, difficulties, etc.) đương đầu,
interfaces: a connection between two pieces of electronic equipment, or between a person and a computer: giao tiếp
inspiration: a sudden good idea: cảm hứng
aesthetic sensibility: /esˈθet.ɪk/ nhạy cảm về thẩm mỹ

Paragraph:   http://news.mit.edu/2015/better-probabilistic-programming-0413

To make machine-learning applications easier to build, computer scientists have begun developing so-called probabilistic programming languages, which let researchers mix and match machine-learning techniques that have worked well in other contexts. In 2013, the U.S. Defense Advanced Research Projects Agency, an incubator of cutting-edge technology, launched a four-year program to fund probabilistic-programming research.
By the standards of conventional computer programs, those “models” can seem absurdly vague. One of the tasks that the researchers investigate, for instance, is constructing a 3-D model of a human face from 2-D images. Kulkarni and his colleagues considered four different problems in computer vision, each of which involves inferring the three-dimensional shape of an object from 2-D information.
New words:
an incubator of cutting-edge technology : vườn ươm công nghệ
probabilistic-programming: lập trình xác suất
pioneer: a person who is one of the first people to do something:  người tiên phong
By the standards of conventional computer programs: theo tiêu chuẩn của chương trình máy tính thông thường.
absurdly vague: vô lý mơ hồ
infer:  to form an opinion or guess that something is true because of the information that you have : suy luận

Example:
Everything will ultimately depend on what is said at the meeting with the directors next week.

Ultimately (adv) = the last but one:  /ˈʌl.tɪ.mət.li/ conclusion, finally

Thứ Bảy, 30 tháng 7, 2016

The element of Style

William Strunk, JR: 
http://www.bartleby.com/141/

Writing tips
https://people.eecs.berkeley.edu/~pattrsn/talks/writingtips.html

The 7 biggest problems facing science, according to 270 scientists

"Science, I had come to learn, is as political, competitive, and fierce a career as you can find, full of the temptation to find easy paths." - Paul Kalanithi, neurosurgeon and writer (1977–2015)
"Is the point of research to make other professional academics happy, or is it to learn more about the world?"  - Noah Grand, former lecturer in sociology, UCLA
(1)   Academia has a huge money problem
"When funding and pay structures are stacked against academic scientists," writes Alison Bernstein, a neuroscience postdoc at Emory University, "these problems are all exacerbated."
"As it stands, too much of the research funding is going to too few of the researchers," writes Gordon Pennycook, a PhD candidate in cognitive psychology at the University of Waterloo. "This creates a culture that rewards fast, sexy (and probably wrong) results."
"The NIH and NSF budgets are subject to changing congressional whims that make it impossible for agencies (and researchers) to make long term plans and commitments," M. Paul Murphy, a neurobiology professor at the University of Kentucky, writes. "The obvious solution is to simply make [scientific funding] a stable program, with an annual rate of increase tied in some manner to inflation."

(2)   Too many studies are poorly designed. Blame bad incentives.
"Science is a human activity and is therefore prone to the same biases that infect almost every sphere of human decision-making." - Jay Van Bavel, psychology professor, New York University

(3)   Replicating results is crucial. But scientists rarely do it.

(4)   Peer review is broken
"I think peer review is, like democracy, bad, but better than anything else."
—Timothy Bates, psychology professor, University of Edinburgh
"We need to recognize academic journals for what they are: shop windows for incomplete descriptions of research, that make semi-arbitrary editorial [judgments] about what to publish and often have harmful policies that restrict access to important post-publication critical appraisal of published research."
—Ben Goldacre, epidemiology researcher, physician, and author
(5)   Too much science is locked behind paywalls
"My problem is one that many scientists have: It's overly simplistic to count up someone's papers as a measure of their worth."
—Lex Kravitz, investigator, neuroscience of obesity, National Institutes of Health
"I personally spend a lot of time writing scientific Wikipedia articles because I believe that advances the cause of science far more than my professional academic articles."
—Ted Sanders, magnetic materials PhD student, Stanford University
(6)   Science is poorly communicated to the public
"Being able to explain your work to a non-scientific audience is just as important as publishing in a peer-reviewed journal, in my opinion, but currently the incentive structure has no place for engaging the public."
—Crystal Steltenpohl, PhD student, community psychology, DePaul University
(7)   Life as a young academic is incredibly stressful

Economist Jul 18th 2016

America’s growing temporary workforce
AMERICA’S temporary help industry first emerged after the second world war, when companies like Manpower and Kelly Girl Service began “renting out” office workers on a short-term basis. In those early years, temps numbered in the hundreds of thousands. Today, the industry employs some 2.9m people, over 2% of America’s total workforce. Since the country’s economic recovery began in 2009, temporary employment has been responsible for nearly one in ten net new jobs. But as temping has grown, the quality of the jobs it provides has deteriorated. According to government statistics, temps earn 20-25% less per hour than their permanent counterparts in similar roles. And few are covered by health-care or pension plans.


The proliferation of ill-paid temp work also affects permanent staff. Many of the costs that employers of temps avoid, such as health insurance, are now borne in part by taxpayers in the form of increased social-benefits spending. Temp work may also suppress the wages of permanent employees. In states where less than 2% of the workforce was employed by temping firms in 2000, full-time workers’ salaries grew by an average of 3% a year between 2000 and 2015. In contrast, they rose by just 2.6% annually in states with a higher proportion of temp workers. Such findings lend support to the view of David Autor of MIT that the use of temping agencies, while beneficial to individual workers and firms, “may exert a negative externality on the aggregate labour market—that is, it is a ‘public bad’.”

New words:

first emerged           : lần đầu xuất hiện
deteriorated             : xấu đi
pension                   : tiền trợ cấp =  allowance
wages                      : tiền lương
suppress                  : đàn áp
proliferation of       : sự gia tăng của 
According to government statistics:  theo thống kê của chính phủ

Economist Jul 20th 2016



FOR the first time in two decades the European Union is the biggest concern for voters, according to the July 2016 Economist/Ipsos MORI issues index. Ever since the referendum on EU membership was announced, Europe has been an increasingly important issue for Brits. But after the referendum result, worries about Europe jumped to their highest level since 1997 and, in doing so, overtook fears about health care and immigration.

In the build-up to the referendum Remain campaigners were hopeful that a new surge in registrations would help their cause. Many of the new voters were young and, supposedly, more likely to plump for Britain to stay in the EU. But data from the Electoral Commission reveals that, in the first six months of this year, those registering to vote were more likely to hail from Eurosceptic areas than Europhile ones. Small wonder the Brexiters won by a margin of more than 1m voters.

Vocabulary:
the European Union:    liên minh Châu Âu
the biggest concern:     vấn đề quan tâm lớn nhất
the referendum result : kết quả trưng cầu dân ý
a new surge:                 làn sóng mới
supposedly:                  giả định
data from ... reveals that: dữ liệu từ . . . cho thấy rằng



Task2 - Analysing an essay about happiness

Essays band 9:  

http://englishwithyeasir.blogspot.jp/2013/05/ielts-9-band-essays-writing-tasks-2.html


It is extraordinarily hard to find a single definition of happiness as many philosophers have discovered. This is partly because it is a complex concept and partly because individuals vary. Although it is equally difficult to be definitive about what factors are needed for it, money and a good relationship are two key components.


One reason why it is difficult to define happiness is that it comprises a variety of different states and emotions. At one level, it can be the gentle feeling of contentment which comes from being in a good relationship, but then it can also include for example  the more immediate feeling of joy when one passes an exam. Another problem in defining it is that it can vary with culture, age and personal preference. For example, a young male from a privileged background in the UK may view it quite differently from an older female in Africa living in circumstances where the next meal is rather more important than the latest Xbox.

It is not really possible to list all the factors that are necessary to happiness. I would say, however, that the two most universal are probably having enough money and being in a good relationshipMoney matters simply because a significant proportion of unhappiness is caused by poverty and it helps to have enough to get by on. Relationships matter because man is a social animal and we are most affected by the people we spend our life with.

In conclusion, I would say that although it is impossible to find one definition of happiness as it is so complex, it is possible to say that money and love are among the factors that help foster it.


Introduction 
             extraordinarily hard to find a single definition of happiness :  
Conclusion
             I would say that although it is impossible to find one definition of happiness as it is so complex
Paragraph 1
             one reason why - another problem - for example
Paragraph 2
             show the two factors