Skip to content

Instantly share code, notes, and snippets.

@lloeki
lloeki / gist:3951273
Created October 25, 2012 07:56
Something like Ruby's modules in Python
# dynamically injecting into the multiple inheritance chain, like ruby's modules.
# can we stop fighting already?
class Foo(object):
pass
class Bar(Foo):
pass
class Baz(object):
@lloeki
lloeki / gist:4696484
Last active December 12, 2015 02:08
Safari DOS
(function(){
_textarea=document.createElement('TEXTAREA');
_textarea.setAttribute('class', 'crashtest');
document.getElementsByTagName('body')[0].appendChild(_textarea);
_textarea.focus();
_evt = document.createEvent("TextEvent");
_evt.initTextEvent("textInput", true, true, window, 'file:///');
_textarea.dispatchEvent(_evt);
}
)()
@lloeki
lloeki / gist:6439796
Created September 4, 2013 17:02
Google Music Fluid userscript
// pattern: *play.google.com/music*
setTimeout(removeTopBar, 100);
setTimeout(removeUser, 100);
var $ = function () {
return document.getElementById.apply(document, arguments);
}
function removeTopBar() {
@lloeki
lloeki / example.sym
Created September 8, 2013 09:02
$ nm -a example | grep -i glfw
0000000004071c1a t +[GLFWContentView initialize]
000000000407276b t -[GLFWApplication sendEvent:]
0000000004071c10 t -[GLFWApplicationDelegate applicationDidChangeScreenParameters:]
0000000004071b98 t -[GLFWApplicationDelegate applicationDidHide:]
0000000004071bc4 t -[GLFWApplicationDelegate applicationDidUnhide:]
0000000004071b6c t -[GLFWApplicationDelegate applicationShouldTerminate:]
0000000004071dbc t -[GLFWContentView acceptsFirstResponder]
0000000004071db1 t -[GLFWContentView canBecomeKeyView]
0000000004071d5c t -[GLFWContentView dealloc]
00000000040724b9 t -[GLFWContentView flagsChanged:]
@lloeki
lloeki / nokogiri_builders.rb
Created September 27, 2013 08:34
Using Nokogiri::XML::Builder in lieu of stock pure ruby Builder for Rails builder templates
# config/initializers/nokogiri_builders.rb
# Using Nokogiri::XML::Builder in lieu of stock pure ruby Builder for Rails builder templates
# unrelated, but you might want this too to enable parsing
# XML params with Nokogiri
#ActiveSupport::XmlMini.backend = 'Nokogiri'
module Nokogiri
module XML
class Builder
@lloeki
lloeki / Settings
Last active February 15, 2016 21:04
PS3 controller setting for Fez on OSX
~/Library/Application Support/FEZ/Settings
--8<-- Default (Xbox 360)
gamepadMapping Jump=1 GrabThrow=0 CancelTalk=2 OpenMap=8 OpenInventory=3 MapZoomIn=5 MapZoomOut=4 Pause=9 RotateLeft=6 RotateRight=7 FpViewToggle=10 ClampLook=11
--8<-- Sony PS3 DualShock3 / Logitech RumblePad 2
gamepadMapping Jump=14 GrabThrow=15 CancelTalk=13 OpenMap=0 OpenInventory=12 MapZoomIn=9 MapZoomOut=8 Pause=3 RotateLeft=10 RotateRight=11 FpViewToggle=1 ClampLook=2
--8<--
@lloeki
lloeki / monad_id.rb
Created September 1, 2014 11:52
Identity monad in Ruby
# http://moonbase.rydia.net/mental/writings/programming/monads-in-ruby/01identity
# Identity monad
class Identity
def initialize(value)
@value = value
end
# unit operation: Haskell 'return'
def self.munit(value)
@lloeki
lloeki / clean_up_boot.sh
Last active May 14, 2018 05:09
Clean up /boot of unused Ubuntu (and Debian?) kernels
# Ubuntu has a stupid policy of not cleaning up boots because they deem
# unknowable whether a kernel is valid or not (even if booted). Combined with
# the default Ubuntu setup that creates a ridiculously small /boot that is
# bound to be filled in a few months worth of updates, you have a recipe for a
# failure during upgrade, leading to being unable to update or remove anything
# and having to mess with apt and dpkg innards by hand.
# This may work for Debian too.
# This one liner keeps /boot fresh and clean by removing the currently
# running kernel version as well as the latest one (which may not be
@lloeki
lloeki / arch-xhyve.sh
Created August 27, 2015 17:22
Run Arch Linux in xhyve
#!/bin/bash
tmp=$(mktemp -d)
pushd "$tmp"
iso=/Users/lloeki/Downloads/archlinux-2015.08.01-dual.iso
echo "fixing disk"
dd if=/dev/zero bs=2k count=1 of=tmp.iso
dd if=$iso bs=2k skip=1 >> tmp.iso
echo "mounting disk"
@lloeki
lloeki / main.go
Created May 1, 2015 10:32
Using GopherJS and Electron together
// Electron's quick start sample, naively ported to Go
// https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md
//
// go get -u gopherjs
// gopherjs build main.go
// electron $(pwd)
package main
import (