Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am hakon on github.
  • I am hakon (https://keybase.io/hakon) on keybase.
  • I have a public key ASDVn7i8_9Iu5uihr3eX7la497h78jv0GokROiLyeQcaJQo

To claim this, I am signing this object:

backend backend_1 {
.host = "server1";
.port = "80";
}
backend backend_2 {
.host = "server2";
.port = "80";
}
# set backend default
$.makeArray($(".song").map(function(){ var title = $(this).find(".title").text(); var artist = $(this).find(".details span").contents().first().text(); return title + " - " + artist; })).join("\n");
exec su -s /bin/sh -c 'exec "$0" "$@"' <username> -- /home/<username>/.dropbox-dist/dropboxd
start on startup
@Hakon
Hakon / lyrics.rb
Created September 10, 2012 20:25 — forked from clarkware/lyrics.rb
Random Lyrics
#!/usr/bin/env ruby
# API Documentation at http://api.wikia.com/wiki/LyricWiki_API
require 'open-uri'
require 'json'
require 'tmpdir'
def itunes_song
`osascript -e 'tell application "iTunes" to (get name of current track) & "\n" & (get artist of current track)' 2>/dev/null`.split("\n")
ActionView::Template::Error (Java heap space):
java.nio.HeapCharBuffer.<init>(HeapCharBuffer.java:39)
java.nio.CharBuffer.allocate(CharBuffer.java:312)
java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:775)
java.nio.charset.Charset.decode(Charset.java:771)
org.jruby.RubyEncoding$UTF8Coder.decode(RubyEncoding.java:246)
org.jruby.RubyEncoding.decodeUTF8(RubyEncoding.java:192)
org.jruby.RubyString.decodeString(RubyString.java:719)
org.jruby.RubyString.toString(RubyString.java:701)
org.jruby.RubyNameError$RubyNameErrorMessage.to_str(RubyNameError.java:120)
require 'openssl'
blk = "0)\x02\x01\x01`$\x02\x01\x03\x04\x17cn=admin,dc=test,dc=com\x80\x06secret"
asn1 = OpenSSL::ASN1::decode(blk)
protocolOp = asn1.value[1]
puts protocolOp.inspect
object with tag: 10 and value: 2 and val.class: org.jruby.RubyFixnum and impl: org.bouncycastle.asn1.DEREnumerated
WARNING: unimplemented method called: asn1data#toASN1
@Hakon
Hakon / rackup.ru
Created May 22, 2012 18:39
Jruby-rack with rails send_file bug
%w(action_controller/railtie).map &method(:require)
run JrubyRackTest ||= Class.new(Rails::Application) {
config.secret_token = routes.append { root to: 'send_file#deliver' }.inspect
initialize!
}
class SendFileController < ActionController::Base
def deliver
send_file Rails.root.join("testdata.jpeg")
# encoding: utf-8
require "json"
# Expected (and MRI behavior):
str = JSON.parse('{"a":"\u00f8"}')["a"]
str == "ø"
str.encoding.to_s == "UTF-8"
# Actual (jruby behavior):