Skip to content

Instantly share code, notes, and snippets.

@rjhornsby
rjhornsby / show-dhcp-leases.sh
Last active April 16, 2023 05:46
Show EdgeOS DHCP lease table
#!/bin/bash
# Quickly show the Ubiquity EdgeOS (ie EdgeRouter Lite)
# DHCP leases to identify devices (ie headless raspberrypi)
# without having to go through the EdgeOS web UI.
#
# Thanks to @matthew1471 for API docs
# https://github.com/matthew1471/EdgeOS-API
# requires jq - `brew install jq` on macOS
#!/bin/bash
echo "waiting for input"
read a
echo "value of a: $a"
echo "done."
== 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 ==
$ ./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"}}
def to_h
{
:title => title,
:artist => artist,
:album => album,
:remarks => remarks,
:url => url,
:short_url => short_url,
}
end
def to_h
super.merge(
{
:asin => @asin
})
end
def to_json(*a)
{
:json_class => self.class.name,
#!/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 September 6, 2015 05:10
Output the GFNB temperature readings
#!/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"]'
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 March 5, 2016 14:15
Shell script to notify if the GFNB software version changes
#!/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