Skip to content

Instantly share code, notes, and snippets.

View nutrun's full-sized avatar

George Malamidis nutrun

View GitHub Profile
@nutrun
nutrun / ngx_http_hello_world_module.c
Created October 6, 2012 11:57
nginx hello world
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
static char *ngx_http_hello_world(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static ngx_command_t ngx_http_hello_world_commands[] = {
{ ngx_string("hello_world"),
NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
@nutrun
nutrun / ngx_http_hello_world_module.c
Created October 6, 2012 11:52
nginx hello world
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
static char *ngx_http_hello_world(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static ngx_command_t ngx_http_hello_world_commands[] = {
{ ngx_string("hello_world"),
NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
@nutrun
nutrun / fs.go
Created June 25, 2012 16:42
golang filsystem
package main
import (
"os"
"io"
)
var fs fileSystem = osFS{}
type file interface {
# To reproduce, start cap shell and run a command, e.g. `cap> ls'
require "thread"
Thread.abort_on_exception = true
set :application, "foo"
role :app, "0.0.0.0"
@nutrun
nutrun / distributed_process_balancing_example.rb
Created June 1, 2011 01:24
Distributed process balancing example
jobs = [
{:id => :job1, :weight => 3},
{:id => :job2, :weight => 2},
{:id => :job3, :weight => 2},
{:id => :job4, :weight => 4},
{:id => :job5, :weight => 4},
{:id => :job6, :weight => 1}
]
nodes = [
@nutrun
nutrun / earl.rb
Created March 3, 2011 02:49
Ruby strings that do web things
# Earl: Strings that do web things
#
#
# Examples:
#
# text = "Blah blah http://tinyurl.com/4bnjzbu blah http://tinyurl.com/4tefu9f"
#
# text.urls # => ["http://tinyurl.com/4bnjzbu", "http://tinyurl.com/4tefu9f"]
#
# text.locations # => ["http://nutrun.com/weblog/2010/11/17/supercharged-ruby-console-output.html", "http://nutrun.com"]
@nutrun
nutrun / pimped_console_string.rb
Created November 17, 2010 19:50
Pimp my console strings
# Do something like: puts "ROCK".blink.bright.cyan
class String
def red
"\e[31m#{self}\e[0m"
end
def blue
"\e[34m#{self}\e[0m"
end
@nutrun
nutrun / s3curl
Created November 1, 2010 18:24
s3curl, without the 5 second sleep when you pass it cmd line creds
#!/usr/bin/perl -w
# This software code is made available "AS IS" without warranties of any
# kind. You may copy, display, modify and redistribute the software
# code either by itself or as incorporated into your code; provided that
# you do not remove any proprietary notices. Your use of this software
# code is at your own risk and you waive any claim against Amazon
# Digital Services, Inc. or its affiliates with respect to your use of
# this software code. (c) 2006 Amazon Digital Services, Inc. or its
# affiliates.
@nutrun
nutrun / sinatra_reloader.rb
Created June 24, 2010 00:56
Code reloading for Sinatra
# For "Classic" style/top-level type of apps do something like:
#
# configure :development do
# require File.join(File.dirname(__FILE__), 'sinatra_reloader')
# set :reload_paths, [File.join(File.dirname(__FILE__), '**', '*.rb')]
# end
#
# For "Modular" style/Sinatra::Base subclasses:
#
# configure :development do
@nutrun
nutrun / gist:252619
Created December 9, 2009 17:32
Add public SSH key to a remote server's authorized_keys
# twitter.com/michael_jones wrote me
# Put in ~/.profile, or similar
# Use like "authme someuser@someserver"
function authme {
ssh $1 'cat >>~/.ssh/authorized_keys' <~/.ssh/id_rsa.pub
}