Skip to content

Instantly share code, notes, and snippets.

View neilmock's full-sized avatar

Neil Mock neilmock

View GitHub Profile
namespace :git do
desc "hack"
task :hack, [:target_branch] do |t, args|
require 'git'
# assume current working directory
g = Git.open('.')
args.with_defaults(:target_branch => "master")
current_branch = g.current_branch
`git checkout #{args.target_branch}`
namespace :fogbugz do
# Usage:
#
# sake fogbugz:branch[source_branch, "My Project"]
#
#
desc "Setup a branch for each case assigned to me."
task :branch, [:target_branch, :project] do |t, args|
#
# NOTE: set pem_file when loading
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PaypalRecurringGateway < Gateway
include PaypalCommonAPI
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
self.supported_countries = ['US']
self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside'
def self.transport_via_smtp(tmail, options={})
o = options[:smtp] || {}
smtp = Net::SMTP.new(o[:host], o[:port])
smtp.start(o[:domain], o[:user], o[:password], o[:auth])
smtp.send_message tmail.to_s, tmail.from, tmail.to
smtp.finish
end
require 'net/imap'
class Net::IMAP
def idle
cmd = "IDLE"
synchronize do
tag = generate_tag
put_string(tag + " " + cmd)
put_string(CRLF)
end
def teh_decorator(func):
def wrapped(*args, **kwargs):
if len(args) > 0:
func.new_thing = args[0]
return func(**kwargs)
return wrapped
@teh_decorator
def testmeyo():
pass
; python/django
(font-lock-add-keywords
'python-mode
'(("\\<\\(models.\\)\\(Admin\\|AutoField\\|BooleanField\\|CharField\\|CommaSeparatedIntegerField\\|DateField\\|DateTimeField\\|DecimalField\\|EmailField\\|FileField\\|FilePathField\\|FloatField\\|ForeignKey\\|ImageField\\|IntegerField\\|IPAddressField\\|ManyToManyField\\|NullBooleanField\\|OneToOneField\\|PhoneNumberField\\|PositiveIntegerField\\|PositiveSmallIntegerField\\|SlugField\\|SmallIntegerField\\|TextField\\|TimeField\\|URLField\\|USStateField\\|XMLField\\)\\>" (1 font-lock-keyword-face) (2 font-lock-keyword-face))))
def linebreaksul(value):
"""
Converts a series of newlines into list items enclosed in an unordered list.
"""
unordered_list = "<ul>"
# split value into individual elements separated by newline
list_items = value.split('\n')
for li in list_items:
unordered_list += "<li>%s</li>" % li
(font-lock-add-keywords
'ruby-mode
'(("\\([-,\\+\\*/%&|\\^~=>]\\)" . font-lock-keyword-face)))
require 'spec'
class Something
def initialize
do_something
end
def do_something
raise NotImplementedError.new("Not Yet Implemented")
end