This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "pagination" do | |
| before(:each) do | |
| sign_in user | |
| visit users_path | |
| end | |
| context 'When user has 30 microposts' do | |
| let!(:Micropost) { 30.times { FactoryGirl.create(:micropost, user: user) } } | |
| # micropost にあたるタグが30個ある |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # interrupt_handler.rb | |
| trap :INT do | |
| puts '\nInterrupted!' | |
| exit | |
| end | |
| loop do | |
| sleep 1 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function peco_select_rake_task_all() { | |
| local tasks="bundle exec rake -AT" | |
| task=$(eval $tasks | peco --query "$LBUFFER" ) | |
| task_split=("${(s/ /)task}") | |
| BUFFER=$task_split[1,2] | |
| CURSOR=$#BUFFER | |
| zle -R -c | |
| } | |
| zle -N peco_select_rake_task_all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [mysqlのユーザ作成まわり] | |
| exec { 'create_user_mysql': | |
| require => Service['mysqld'], | |
| path => ['/usr/bin','/bin'], | |
| command => 'mysql -u root -e "grant select,alter,index,create,insert,update,delete on *.* to \'gussan\'@\'localhost\' identified by \'gussan\';"', | |
| # unless => 'mysql -u root -e "select User, Host from mysql.user where User=\'gussan\' and Host=\'localhost\'" | grep gussan' | |
| } | |
| ・トラブル |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hsh1 = {first:"Satoshi",last:"Tanaka",age:"25"} | |
| hsh2 = {last:"Suzuki",age:"30"} | |
| #show the newest values | |
| puts hsh1.merge(hsh2) | |
| #show old value when the key duplicated | |
| puts hsh1.merge(hsh2){|key,oldv,newv|oldv} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| person1 = {first:"coca",last:"cola"} | |
| person2 = {first:"ginger",last:"ale"} | |
| person3 = {first:"dr.",last:"pepper"} | |
| params = {} | |
| params[:father] = person1 | |
| params[:mother] = person2 | |
| params[:child] = person3 | |
| puts params[:father][:first] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class String | |
| def shuffle | |
| self.split('').shuffle.join | |
| end | |
| end | |
| puts "asdffdsa".shuffle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def string_shuffle(s) | |
| s.split('').shuffle.join | |
| end | |
| puts string_shuffle("asdffdsa") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $graduates = array("okkun","kitak","takeo","gussan"); | |
| shuffle($graduates); | |
| print_r($graduates); | |
| ?> |
NewerOlder