Skip to content

Instantly share code, notes, and snippets.

sys = require('sys')
for(var n in ["foo", "bar"]) {
sys.puts(n)
}
require 'lib/string_util.rb'
require 'singleton'
require 'rubygems'
require 'active_support/core_ext/class/attribute_accessors'
class Tokenizer
include Singleton
def takes_an_optional_block(&block)
block_given_for_optional = block_given?
stash_block {
block_given_for_stash = block_given?
puts "block_given_for_optional: #{block_given_for_optional}"
puts "block_given_for_stash: #{block_given_for_stash}"
}
end
def stash_block(&block)
@ryanbriones
ryanbriones / gist:380808
Created April 27, 2010 14:51
Send via Mad Mimi to list with MadMailer
<?php
$mailer = new MadMailer('YOURUSERNAME', 'XXXXXXXX');
$params = array(
'promotion_name' => 'My Awesome Promotion',
'subject' => 'You Gotta Read This',
'from' => 'noreply@example.com',
'username' => 'YOURUSERNAME',
'api_key' => 'XXXXXXXX',
'list_name' => 'VIPs',
'raw_html' => 'foo [[unsubscribe]] [[tracking_beacon]]'
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
require 'webrick'
require 'webrick/httpproxy'
require 'fileutils'
require 'md5'
###
# FakeWebRecorder is an HTTP Proxy that records sessions as calls to FakeWeb.
# The code that FakeWebRecorder generates should be suitable for testing
# interaction with a particular website.
#
@ryanbriones
ryanbriones / Campfireanize.rb
Created February 17, 2010 05:51
Campfireanize
# mechanize just enough of campfire to get what i need
require 'mechanize'
class Campfireanize
def initialize(subdomain)
@subdomain = subdomain
@client = Mechanize.new
@logged_in = false
end
using System.Net;
using System.IO;
using System.Collections;
using System.Collections.Specialized;
using System;
using System.Web;
using System.Security.Cryptography.X509Certificates;
public class Program : ICertificatePolicy {
public bool CheckValidationResult (ServicePoint sp, X509Certificate certificate, WebRequest request, int error) {
# not sure if i like this or not
# but it was fun to write!
# :Foo => Foo, :Foo, :Bar => Foo::Bar, etc
def with_foo_like_class(*args)
klass = if args.size == 1
klass_obj = Class.new
Object.const_set(args[0], klass_obj)
else
klass_sym = args.pop
@ryanbriones
ryanbriones / gist:299271
Created February 9, 2010 14:56
Capistrano task to find out what will be deployed on the next release; git only
namespace :deploy do
desc "What will be deployed on the next release"
task :what do
puts run_locally "git log --color #{current_revision}..#{real_revision}"
end
end