[gpetrie] $ ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin11.4.2]
[gpetrie] $ ruby wunderground.rb
Current temperature in Cedar Rapids is: 77.0| <?php | |
| $x = 100; | |
| for ( $i = 1; $i <= $x; $i++ ) | |
| { | |
| if ( ( $i % 5 == 0 ) && ( $i % 3 == 0 ) ) | |
| { | |
| echo "fizzbuzz\n"; |
| for i in range(1, 101): | |
| if i % 5 == 0 and i % 3 == 0: | |
| print "fizzbuzz" | |
| elif i % 5 == 0: | |
| print "fizz" | |
| elif i % 3 == 0: | |
| print "buzz" | |
| else: | |
| print i |
| for i in 1..100 | |
| if i % 5 == 0 and i % 3 == 0 | |
| puts "fizzbuzz" | |
| elsif i % 5 == 0 | |
| puts "fizz" | |
| elsif i % 3 == 0 | |
| puts "buzz" | |
| else | |
| puts i | |
| end |
| 100.times do |i| | |
| if i % 5 === 0 and i % 3 === 0 | |
| puts 'fizzbuzz' | |
| elsif i % 5 === 0 | |
| puts 'fizz' | |
| elsif i % 3 === 0 | |
| puts 'buzz' | |
| else | |
| puts i |
| rogues = %w[Avdi Chuck David James Josh] | |
| rogues.shuffle! | |
| rogues.each { |rogue| puts "Thank you, #{rogue}!" } |
| // Euler input | |
| var numberString = "37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629 91942213363574161572522430563301811072406154908250 23067588207539346171171980310421047513778063246676 89261670696623633820136378418383684178734361726757 28112879812849979408065481931592621691275889832738 44274228917432520321923589422876796487670272189318 47451445736001306439091167216856844588711603153276 70386486105843025439939619828917593665686757934951 62176457141856560629502157223196586755079324193331 64906352462741904929101432445813822663347944758178 92575867718337217661963751590579239728245598838407 58203565325359399008402633568948830189458628227828 80181199384826282014278194139940567587151170094390 35398664372827112653829987240784473053190104293586 86515506006295864861532075273371959191420517255829 71693888707715466499115593487603532921714970056938 54370070576826684624621495650076471787294438377604 53282654108756828443 |
| <?php | |
| $my_array = array('apple', 'pear', 'cherry') | |
| // If I want to find out if a value is in an array with PHP I do this: | |
| if (in_array('apple', $my_array)) { | |
| echo 'Apple is in the array!'; // => Apple is in the array! | |
| } |
This gist shows the current state of a rails app I'm working on. I'm attempting to figure out the routing so that when a user submits a zipcode into the form on app/views/forecast/index.html.erb they get the same experience as if they had done http://localhost:3000/forecast/87120.
There are two main issues that I believe I am misunderstanding.
-
How can I make the default param with forecast routing be
:zipinstead of:id? (Is it possible for me to just useresources :forecastin theroutes.rbfile?) -
How do I properly redirect things when I know that the
params[:zip].blank?is not true so that theshowmethod/action of theforecastcontroller is sent the message.
I understand that I can just change my controller to behave with a params[:id] instead of params[:zip], but I feel that there is a piece I'm missing here, and it still doesn't help me with my redirect after form submission on the index.html.erb page.
| rbenv-deps: | |
| pkg.installed: | |
| - pkgs: | |
| - bash | |
| - git | |
| - openssl | |
| - make | |
| - curl | |
| ruby-2.0.0-p247: |