Skip to content

Instantly share code, notes, and snippets.

@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 / 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: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 / boot.rb
Created July 9, 2012 12:59
Monkeypatching Rails 2.3.14 to boot Thin by default
# ...8<...
Rails.boot!
# default to Thin
if $0 == "script/server"
# commands/server.rb (#45) is not cooperative, so we patch Rack itself
require 'rack'
module Rack::Handler
puts "Patching Rack for Thin as default"
@lloeki
lloeki / boot.rb
Created July 9, 2012 12:57
Monkeypatching rails 2.x to load Mongrel with bundler
# ...8<...
Rails.boot!
# see http://gembundler.com/rails23.html to make Bundler work with Rails 2.x (tested with 2.1, 2.2 and 2.3)
# bundler with rails 2.x prevents finding mongrel_rails in PATH
if $0 == "script/server"
# ensure active_support is loaded
require 'active_support'

SORT in Redis

Now that Hurl is open source I thought I'd talk a bit about one of my favorite open source projects: Redis.

In Hurl we keep track of all the hurls you make, then show them to you on the "your hurls" page:

*image*
@lloeki
lloeki / foo_controller.rb
Created May 29, 2012 07:05
Streaming (CSV) data in Rails 3.2
class FooController
respond_to :csv
def index
@foos = Foo.scoped
if stale?(:last_modified => Foo.something)
respond_with @gta do |format|
format.csv { stream_csv @foo }
end
end
@lloeki
lloeki / battery.py
Last active January 10, 2023 16:04
Battery status script for Mac OS X
#!/usr/bin/env python
from __future__ import print_function
from __future__ import division
from subprocess import Popen, PIPE
def ioreg_battery_info():
output = Popen(["ioreg", "-r", "-k", "LegacyBatteryInfo", "-w", "0"], stdout=PIPE).communicate()[0]
try: #python3
@lloeki
lloeki / file_check.py
Created April 25, 2012 20:08
list comprehensions
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, division
import os
import sys
import re
from glob import iglob as glob
import time
from datetime import datetime, timedelta