Skip to content

Instantly share code, notes, and snippets.

This is an authenticated test
#!/usr/bin/env ruby
# Made by Pieter de Bie <frimmirf@gmail.com>
# Based on a "Pastie" task by someone
require "tempfile"
GIST_URL = 'http://gist.github.com/gists'
GIST_LOGIN_URL = 'https://gist.github.com/session'
USERNAME = "pieter"
TOKEN = "SweetTokenPower"
http://thesaurus.reference.com/browse/thesaurus
#!/usr/bin/env python
# earl, 2008-07-22
from __future__ import with_statement
import stringtemplate3, simplejson, sys
def main():
with open(sys.argv[1]) as template_file:
template = stringtemplate3.StringTemplate(template_file.read())
template.attributes = simplejson.load(sys.stdin)
sys.stdout.write(unicode(template).encode('utf-8'))
@chl
chl / renderst.py
Created July 22, 2008 15:10 — forked from earl/renderst
#!/usr/bin/env python
# earl, 2008-07-22
from __future__ import with_statement
import stringtemplate3, simplejson, sys
def main():
with open(sys.argv[1]) as template_file:
template = stringtemplate3.StringTemplate(template_file.read())
template.attributes = simplejson.load(sys.stdin)
sys.stdout.write(unicode(template).encode('utf-8'))
# user and group to run as
user abcde abcde;
# number of nginx workers
worker_processes 4;
# pid of nginx master process
pid /var/run/nginx.pid;
# Number of worker connections. 1024 is a good default
@nakajima
nakajima / a-better-try.rb
Created July 22, 2008 15:26
A version of Object#try that allows arguments and a block
class Object
def try(method, *args, &block)
respond_to?(method) ? send(method, *args, &block) : nil
end
end
We couldn’t find that file to show.
@wataken44
wataken44 / regexp_escape.rb
Created July 22, 2008 15:31
regexp escape with ruby
#!/usr/bin/ruby
ARGV.each { |arg|
printf("%s\n", Regexp.escape(arg))
}
@nakajima
nakajima / gist:1084
Created July 22, 2008 15:32
Curry args on a proc. Probably buggy.
class Proc
def curry(*arguments)
if arguments.empty?
return self
else
_proc = self.dup
return lambda do |*args|
return _proc.call(*arguments.concat(args))
end
end