i learn scala during a class teaching java -.-“”.
i am reading ‘Seven Languages in Seven weeks’.
all the examples, code is sourced from this book
ok, lets start.
Expressions
1234567
vala=1Nilisaemptylist//we can't do thatif(0)if(Nil)
user can test different version of ruby, like Jruby, macRuby, ruby 1.9.2, 1.9.3, and changing between them using one command, so cool!
Here is the installation, you can find these in the offical site
RVM
installation
1234567891011121314151617
#you should install curl and git first!!
user$ sudo bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
user$ source .bash_profile
user$ type rvm | head -1
rvm is a function
user$ rvm list known #show rvm support version
user$ rvm list #show your installed version
user$ rvm install 1.9.3 # or 1.9.3-p0 that works for my ubuntu, if error have a try
user$ rvm use 1.9.3 --default #set default to 1.9.3 & use it
if you are ubuntu/other Linux user, edit the shell as login shell
in “Edit > profile preference > title command > command run as login shell”
thanks for the good site learnCodeTheHardWay
this site provide the basic?(to me) tutorials of ruby and c (i am going to learn), and a book of python (not free)
Good site (good = with sharing)
//print stringcharname[]="kyktommy";printf("my name is %s",name);sizeof(int);// 4intfour_num[4]={0};// 4 int is 0sizeof(four_num);// 4*4 = 16sizeof(four_num)/sizeof(int);// 4 - get the length of array//array of chars, using pointer for string, [] for arraychar*names[]={"mary","peter","joe"};//pointer to arraychar**cur_name=names;//cur_name[0] = *cur_name = names[0] = "mary"//argc is arguments count, argv is the real arguments//argv[0] is the script nameinti=0;for(i=0;i<argc;++i){printf("%d arg: %d",i,argv[i]);}
OK, take a rest here and continue more …
Code inside main
123456789101112131415
structPerson{char*name;intage;};//don't miss that ;//this is a mehtod that return [struct Person] typestructPerson*Person_create{...}//create a Person alloc into memorystructPerson*joe=malloc(sizeof(structPerson));joe->age=100;//edit its field using -> where pointer is used//release memory from memoryfree(joe->name);//release what you have alloc into memoryfree(joe);
Code inside main
12345678910111213141516
//function pointertypedefint(*compare)(inta,intb);//sort functionvoidsort(int*arr,comparecmp){...if(cmp(a,b)>0)......}//method for pointer use//the return and parameter is the same as "compare"intsorted_order(inta,intb){returna-b;}intreverse_order(inta,intb){returnb-a;}//int main()sort(arr,sorted_order)sort(arr,reverse_order)
rvm install 1.9.2 && rvm use 1.9.2
git clone git://github.com/imathis/octopress.git octopress
cd octopress # If you use RVM, You'll be asked if you trust the .rvmrc file (say yes).
ruby --version # Should report Ruby 1.9.2
gem install bundler
bundler install
rake install #install Octopress theme
New Post, Page & Deploy to Heroku
1234567891011121314151617
rake new_post["my new post"] #create new post
rake new_page["my new page"] #create new page, but not shown in menu
gem install heroku
heroku create kyktommy #kyktommy.heroku.com
git config branch.master.remote heroku
#remove "public" in .gitignore
rake generate #generate to public
git add .
git commit -m 'blog start'
git push heroku master
#if push heroku permission denied
ssh-keygen -C "you-email@email.com" -t rsa #rsa, dsa
heroku keys:add ~/.ssh/id_rsa.pub #id_dsa.pub
git push heroku master