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
| #!/bin/bash | |
| echo "waiting for input" | |
| read a | |
| echo "value of a: $a" | |
| echo "done." |
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
| == constructing a dog == | |
| == constructing an animal == | |
| Pets rendered as JSON: | |
| [{"json_class":"Dog","data":{"has_fur":true,"color":"black","name":"fido","bark":"loud"}}] | |
| === Recovering lost pets from the evil JSON Deville === | |
| Calling Dog::json_create | |
| {"json_class"=>"Dog", | |
| "data"=>{"has_fur"=>true, "color"=>"black", "name"=>"fido", "bark"=>"loud"}} | |
| == constructing a dog == |
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
| $ ./shelter.rb | |
| == constructing a dog == | |
| == constructing an animal == | |
| Pets rendered as JSON: | |
| [{"json_class":"Dog","data":{"has_fur":true,"color":"black","name":"fido","bark":"loud"}}] | |
| === Recovering lost pets from the evil JSON Deville === | |
| Calling Dog::json_create | |
| {"json_class"=>"Dog", | |
| "data"=>{"has_fur"=>true, "color"=>"black", "name"=>"fido", "bark"=>"loud"}} |
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 to_h | |
| { | |
| :title => title, | |
| :artist => artist, | |
| :album => album, | |
| :remarks => remarks, | |
| :url => url, | |
| :short_url => short_url, | |
| } | |
| 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
| def to_h | |
| super.merge( | |
| { | |
| :asin => @asin | |
| }) | |
| end | |
| def to_json(*a) | |
| { | |
| :json_class => self.class.name, |
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
| #!/bin/bash | |
| echo -n "[$(date)] " | |
| result=$(/usr/bin/time -p curl -s http://google.com 1> /dev/null 2> /tmp/timer) | |
| echo "exit:$? elapsed:$(awk '/^real/ {print $2}' /tmp/timer)" |
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
| #!/bin/bash | |
| # Set this to your router's address # | |
| gfnb_ip=192.168.2.1 | |
| # Don't change anything below this line # | |
| echo -n "$(date) " | |
| curl -s "http://$gfnb_ip/content.json?checksum=0&_=0" | ruby -rjson -e 'puts JSON.parse(STDIN.read)["temperature"]' |
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 Track < ActiveRecord::Base | |
| self.table_name = 'SONGLIST' | |
| has_one :supplemental | |
| end | |
| class Supplemental < ActiveRecord::Base | |
| self.table_name = 'amazon_metadata' | |
| belongs_to :track | |
| 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
| #!/bin/bash | |
| # We will try to determine your GFNB address automatically by using | |
| # your system's gateway address. | |
| # | |
| # If that doesn't work, or you want to override the detected | |
| # value, uncomment the following line and set the value you want | |
| # | |
| # gfnb_ip=192.168.1.1 |
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
| #!/usr/bin/ruby | |
| require 'pp' | |
| require 'json' | |
| require_relative 'plugins/song' | |
| song1 = Song.new | |
| song1.title = 'New Title' | |
| song1.artist = 'Artist 1' | |