Skip to content

Instantly share code, notes, and snippets.

View pipe_test.sh
#!/bin/bash
echo "waiting for input"
read a
echo "value of a: $a"
echo "done."
View animal_shelter_output_v2.txt
== 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 ==
View animal_shelter_output.txt
$ ./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"}}
View Song.rb
def to_h
{
:title => title,
:artist => artist,
:album => album,
:remarks => remarks,
:url => url,
:short_url => short_url,
}
end
View AmazonSong.rb
def to_h
super.merge(
{
:asin => @asin
})
end
def to_json(*a)
{
:json_class => self.class.name,
View google_check.sh
#!/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)"
@rjhornsby
rjhornsby / gfnb_temperature.sh
Last active Sep 6, 2015
Output the GFNB temperature readings
View gfnb_temperature.sh
#!/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"]'
View ar_test.rb
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
@rjhornsby
rjhornsby / gfnb_version.sh
Last active Mar 5, 2016
Shell script to notify if the GFNB software version changes
View gfnb_version.sh
#!/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
@rjhornsby
rjhornsby / songtest.rb
Created Jun 16, 2015
Song serialization test script
View songtest.rb
#!/usr/bin/ruby
require 'pp'
require 'json'
require_relative 'plugins/song'
song1 = Song.new
song1.title = 'New Title'
song1.artist = 'Artist 1'
You can’t perform that action at this time.