Skip to content

Instantly share code, notes, and snippets.

View mk-qi's full-sized avatar
💭
I may be slow to respond.

mkqi mk-qi

💭
I may be slow to respond.
View GitHub Profile
@subtleGradient
subtleGradient / Paste to Gist_GitHub Anonymously.tmCommand
Created July 28, 2008 19:13 — forked from pieter/gistie.rb
gistie.rb Paste code to gist.github.com from the shell!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundleUUID</key>
<string>2E6B9F06-DDB6-4707-A2BB-8751CF1722A0</string>
<key>command</key>
<string>cat|gist -a "$TM_FILENAME"
// Answer to http://github.com/ry/http-parser/issues/#issue/1
// UNTESTED
struct line {
char *field;
size_t field_len;
char *value;
size_t value_len;
};
@mrrooijen
mrrooijen / Capistrano-Deployment-Recipe.rb
Created July 29, 2009 09:34
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@mislav
mislav / example.rb
Created May 2, 2010 14:20
Fetch full Atom feed from Google Reader
reader = Reader.new 'mislav.marohnic@gmail.com', PASSWORD
# fetch only unread items
feed = reader.fetch_all(FEED_URL, true) do |entry|
# something with each entry
end
puts feed
@rkumar
rkumar / gist:445735
Created June 20, 2010 10:47
ruby's OptionParser to get subcommands
#!/usr/bin/env ruby -w
## Using ruby's standard OptionParser to get subcommand's in command line arguments
## Note you cannot do: opt.rb help command
## other options are commander, main, GLI, trollop...
# run it as
# ruby opt.rb --help
# ruby opt.rb foo --help
# ruby opt.rb foo -q
# etc
@Burgestrand
Burgestrand / download-progress.rb
Created June 27, 2010 13:55
Ruby HTTP file download with progress measurement
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|
@guillermo
guillermo / learn_ruby_by_example.rb
Created September 27, 2010 17:20 — forked from raul/learn_ruby_by_example.rb
learn ruby with multi process
#!/usr/bin/env ruby
#
# This fork add support for running code in a forked process
#
# encoding: UTF-8
#
# LearnRubyByExample:
#
# Ruby is a highly expressive programming language.
# Testing software is an expressive way to communicate how it works.
@darkhelmet
darkhelmet / heroku.vcl
Created October 29, 2010 20:21 — forked from adamwiggins/heroku.vcl
Simplified Heroku Varnish config
director routing_mesh round-robin {
{
.backend = {
.host = "...some ip...";
.port = "...some port...";
.first_byte_timeout = 90s;
.between_bytes_timeout = 90s;
}
# ...more backends...
}
@mrtazz
mrtazz / couchdb.rb
Created December 12, 2010 15:58
simple couchdb API wrapper in ruby from the CouchDB wiki, with some adaptions for basic auth
require 'net/http'
module CouchDB
class Server
def initialize(host, port, options = nil)
@host = host
@port = port
@options = options
end
@ismasan
ismasan / purge.vcl
Created January 27, 2011 18:30
Varnish VCL example for purging wildcard URLs
# This goes in vcl_recv
# It gives you:
# curl -X PURGE http://some.example.com/.*
# curl -X PURGE http://some.example.com/blog/.*
# curl -X PURGE http://some.example.com/blog/2011/bar.html
# curl -X PURGE http://another.example.com/.*
#
if (req.request == "PURGE") {
# Wildcard, per-domain purging
purge("req.http.host == " req.http.host " && req.url ~ " req.url "$");