Skip to content

Instantly share code, notes, and snippets.

View dkam's full-sized avatar

Dan Milne dkam

View GitHub Profile
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
@dkam
dkam / WEBRick Cert generation
Last active October 5, 2015 20:15 — forked from nickyp/self_signed_cert.rb
create a self-signed certificate using ruby-openssl
# From https://github.com/ruby/ruby/blob/trunk/lib/webrick/ssl.rb
require 'openssl'
def create_self_signed_cert(bits, cn, comment)
rsa = OpenSSL::PKey::RSA.new(bits){|p, n|
case p
when 0; $stderr.putc "." # BN_generate_prime
when 1; $stderr.putc "+" # BN_generate_prime
when 2; $stderr.putc "*" # searching good prime,
# n = #of try,
@dkam
dkam / markdown.rb
Created October 11, 2015 09:08
Markdown previewer with Sinatra, Redcarpet and Rouge
#!/usr/bin/env ruby
# Originally from: https://coderwall.com/p/ftn1la/markdown-preview-using-ruby-and-sinatra-simple-script
# gem install sinatra redcarpet rouge --no-document
require 'sinatra'
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'
set :port, 3001
#/usr/bin/env ruby
# Original http://code.activestate.com/recipes/576590-fallout-3-terminal-hacking-minigame-cracker/
## Get all available words
words = []
loop do
print "word> "
line = gets.chomp
@dkam
dkam / gist:f9abd424b34a4707ac56
Created February 5, 2016 03:04
Converting video from Syma x5c camera to mp4 / iPhone compatible
The pixel format from the camera is 422 ( https://en.wikipedia.org/wiki/YUV ). FFMpeg can convert it to the more standard 420.
Additionally, I've added faststart to enable the video to play from the web prior to downloading the entire file
ffmpeg -i /Volumes/Untitled/VIDEO/MOVI0004.avi -movflags faststart -pix_fmt yuv420p ~/Movies/MOVI0004.mp4
class Fixnum
def to_pretty_time
a = self
case a
when 0 then 'just now'
when 1 then 'a second ago'
when 2..59 then a.to_s+' seconds ago'
when 60..119 then 'a minute ago' #120 = 2 minutes
when 120..3540 then (a/60).to_i.to_s+' minutes ago'
when 3541..7100 then 'an hour ago' # 3600 = 1 hour