Skip to content

Instantly share code, notes, and snippets.

View dkam's full-sized avatar

Dan Milne dkam

View GitHub Profile
Sequel.extension(:pg_hstore, :pg_hstore_ops, :pg_array)
DB = Sequel.connect('postgres://user:pass@localhost/db')
class Messages < Sequel::Model
end
Messages.first
#=> #<Messages @values={:id=>1, :observable_name=>"testo", :observable_content=>{"key1"=>"value1", "key2"=>"value2", "key3"=>"value3"}, :created_at=>2014-03-25 15:37:30 +1100}>
@dkam
dkam / Technisat_TS35_lircd.conf
Created July 3, 2014 04:30
Technisat TS35 lircd.conf
begin remote
name /etc/lircd.conf
bits 13
flags RC5|CONST_LENGTH
eps 30
aeps 100
one 907 885
zero 907 885
gap 113935
toggle_bit 2
Oct 10 17:12:57 Nervous-Energy.local apsd[115]: Unrecognized leaf certificate
Oct 10 17:12:57 Nervous-Energy.local apsd[115]: Illegal subject name missing 'courier.push.apple.com' (2.5.4.3): ({
label = "2.5.4.6";
"localized label" = "2.5.4.6";
type = string;
value = US;
}, {
label = "2.5.4.8";
"localized label" = "2.5.4.8";
type = string;
@dkam
dkam / Social sharing
Last active August 29, 2015 14:11
Facebook sharing
From:
* http://stackoverflow.com/questions/10988815/facebook-twitter-and-google-1-buttons-using-only-html-no-javascript
* http://ar.zu.my/how-to-really-customize-the-deprecated-facebook-sharer-dot-php/
* http://www.sharelinkgenerator.com
Facebook:
http://www.facebook.com/sharer.php?s=100
&p[url]=https://booko.com.au/9781452129716/Josephine-The-Dazzling-Life-of-Josephine-Baker
&p[images][0]=https://covers.booko.info/9781452129716
&p[title]=My customized title
HTTP/1.1 302 Found
Server: nginx/1.8.0
Date: Sat, 13 Jun 2015 12:50:10 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 302 Found
cache-control: no-cache
x-xss-protection: 1; mode=block
x-request-id: 54fa26a0-60fa-4fa0-9191-f0af3ba8844e
@dkam
dkam / com.ozbargains.plist
Last active August 29, 2015 14:26
Desktop notifications for RSS stuff.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ozbargains</string>
<key>ProgramArguments</key>
<array>
<string>/Users/{username}/bin/ozb.rb</string>
@dkam
dkam / MasterCard.rb
Last active August 29, 2015 14:26
Get MasterCard's native currency exchange rates
require 'open-uri'
require 'nokogiri'
baseCurrency='AUD'
settlementDate=(Date.today - 4).strftime("%m/%d/%Y")
finalCurrency='USD'
url="https://www.mastercard.com/psder/eu/callPsder.do?service=getExchngRateDetails&baseCurrency=#{baseCurrency}&settlementDate=#{settlementDate}"
doc = Nokogiri::HTML(open(url))
rate = doc.xpath("//transaction_currency_dtl/alpha_curency_code[text()='#{finalCurrency}']/following-sibling::conversion_rate").text
Loading production environment (Rails 2.3.11)
ree-1.8.7-2011.03 :001 > Product.find_by_gtin("9781854309655")
ArgumentError: time out of range
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:635:in `local'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:635:in `each'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:635:in `select'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
from /usr/local/rvm/gems/ree-1.8.7-2011.03/gems/activerecord-2.3.11/lib/active_record/base.rb:665:in `find_by_sql'
from /usr/local/rvm/gems/ree-1.8.7-2011
@dkam
dkam / babushka.sh
Created November 16, 2011 03:42
Babusha shell provisioner for Vagrant
#!/bin/bash
# In your Vagrant file, add a shell provisioner, pointing to this file:
#
# config.vm.provision :shell, :path => "babushka.sh"
#
# Download and chmod the Babushka installer, if it's not already installed.
which babushka || bash -c "`wget -O - babushka.me/up/hard`"
@dkam
dkam / airvideo.conf
Created January 2, 2012 09:38
Upstart script for AirVideo (http://www.inmethod.com/)
description "Airvideo Server statup script"
author "Dan Milne"
start on startup
stop on shutdown
console output
respawn