This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
def download(url) | |
Thread.new do | |
thread = Thread.current | |
body = thread[:body] = [] | |
url = URI.parse url | |
Net::HTTP.new(url.host, url.port).request_get(url.path) do |response| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */ | |
{ | |
/** | |
* Key modifiers | |
* ============= | |
* - ^ : Ctrl | |
* - $ : Shift | |
* - ~ : Option (Alt) | |
* - @ : Command (Apple) | |
* - # : Numeric Keypad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to render rails 3.0 views within rake tasks. | |
# | |
# Description: An example of how to render a view within a rake task, | |
# complete with instance variables, application & url helpers and I18n. | |
# | |
# License: X11 license | |
# | |
# Copyright (c) 2010 Kim Burgestrand <http://burgestrand.se/> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git filter-branch --index-filter 'git ls-files -i -x '"'"'*'"'"' -x '"'"'*.*'"'"' -x '"'"'!file'"'"' -z | xargs -0 git rm -f --cached' --prune-empty | |
# -> git rebase *root-SHA1* to remove merge commits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Child | |
attr_reader :socket | |
def initialize(socket) | |
@socket = socket | |
main_loop | |
end | |
def main_loop | |
Signal.trap("HUP") do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Config | |
$host = '127.0.0.1'; | |
$port = 0; // Random port | |
// Setup | |
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | |
$clients = array(); | |
// Bind, listen and disable blocking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# | |
# NOTE: Development moved to http://github.com/Burgestrand/vlad-nginx | |
# | |
### | |
# | |
# Vlad the Deployer recipe for NGiNX. | |
# | |
# Author: Kim Burgestrand <http://github.com/Burgestrand> | |
# Date: 24th September 2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake task for compiling CoffeeScript and SASS (Compass). | |
# | |
# Author: Kim Burgestrand <http://burgestrand.se/> | |
# Date: 6th October 2010 | |
# License: X11 License (MIT License) | |
# URL: http://gist.github.com/gists/613114 | |
desc "Compiles CoffeeScript using Barrista (but only if they changed)" | |
task 'coffee:compile' => :environment do | |
require 'barista' | |
abort "'#{Barista::Compiler.bin_path}' is unavailable." unless Barista::Compiler.available? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
class Object | |
def to_webapp | |
def self.call(env) | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func || :inspect, *attrs)] | |
end | |
self | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'tempfile' | |
require 'stringio' | |
img = StringIO.new(RestClient.get 'http://localhost:9393/img') | |
def img.path | |
'http://localhost:9393/img.png' | |
end |