def with_retry(retry_limit=3)
exception = nil
retry_limit.times do |i|
begin
return yield()
rescue Exception => ex
print "Attempt #{i + 1} of #{retry_limit} failed: #{ex}\n"
[core] | |
excludesfile = /Users/liyanage/.gitignore.global | |
[log] | |
date = local | |
[user] | |
name = Marc Liyanage | |
email = foo@example.com | |
[github] | |
user = liyanage | |
token = xxxxx |
// | |
// AppDelegate.h | |
// ThreadTest | |
// | |
// Created by Marc Liyanage on 9/23/12. | |
// | |
#import <Cocoa/Cocoa.h> | |
@interface AppDelegate : NSObject <NSApplicationDelegate> { |
# OS X-specific fix based on http://bugs.python.org/issue9033 | |
readline.parse_and_bind('bind {} rl_complete'.format('^I')) |
#!/usr/bin/env python | |
# Example for a mini web app that keeps its state in a custom class instance | |
import bottle | |
class Foo: | |
def main(self, value=0): | |
self.sum += value |
#!/usr/bin/env python | |
import email.mime.text | |
import email.header | |
import smtplib | |
email.Charset.add_charset('utf-8', email.Charset.QP, email.Charset.QP, 'utf-8') | |
me = u'Foo Bar <test@example.com>' | |
you = me |
class Foo: | |
def __unicode__(self): | |
return u'xx \u2192 xx' | |
def __repr__(self): | |
return unicode(self).encode('ascii', 'backslashreplace') | |
foo = Foo() |
import shutil | |
import os | |
def copy_item(source_path, destination_parent): | |
if os.path.isdir(source_path): | |
destination_path = os.path.join(destination_parent, os.path.basename(source_path)) | |
shutil.copytree(source_path, destination_path, ignore=shutil.ignore_patterns('.DS_Store', '*.pyc')) | |
else: | |
shutil.copy(source_path, destination_parent) |
javascript:$('#rightbar,%20.vendor-content-box,%20#relatedContent,%20#problemsVideo,%20#relatedResearchWidget,%20#header,%20#footer,%20#textlinks').remove() |
def merge(left, right): | |
nl = len(left) | |
nr = len(right) | |
merged = [] | |
il = 0 | |
ir = 0 | |
while il < nl and ir < nr: | |
l = left[il] | |
r = right[ir] |