This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/963965/how-is-this-strategy-pattern | |
# -written-in-python-the-sample-in-wikipedia | |
""" | |
In most of other languages Strategy pattern is implemented via creating some | |
base strategy interface/abstract class and subclassing it with a number of | |
concrete strategies (as we can see at | |
http://en.wikipedia.org/wiki/Strategy_pattern), however Python supports | |
higher-order functions and allows us to have only one class and inject | |
functions into it's instances, as shown in this example. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""""http://ginstrom.com/scribbles/2008/11/06/generic-adapter-class-in-python/""" | |
import os | |
class Dog(object): | |
def __init__(self): | |
self.name = "Dog" | |
def bark(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
""" | |
@author: Diogenes Augusto Fernandes Herminio <[email protected]> | |
https://gist.github.com/420905#file_builder_python.py | |
""" | |
class Director(object): | |
def __init__(self): | |
self.buider = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""http://ginstrom.com/scribbles/2007/10/08/design-patterns-python-style/ | |
An example of the Template pattern in Python""" | |
ingredients = "spam eggs apple" | |
line = '-' * 10 | |
# Skeletons | |
def iter_elements(getter, action): | |
"""Template skeletons that iterates items""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#repo/Berkshelf | |
cookbook 'nginx', '~> 0.1.0', path: 'site-cookbooks/nginx' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Uncomment these lines (and the ones in the generated Gemfile) if you want | |
# to live on the Edge: | |
# | |
# Vagrant.require_plugin "vagrant-berkshelf" | |
# Vagrant.require_plugin "vagrant-omnibus" | |
Vagrant.configure("2") do |config| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for row in csv.reader(data): | |
params = ', '.join(map(lambda s: '?', row)) | |
c.execute('''insert into %s values (%s) ''' % (table_name, params), row) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import json | |
import sqlite3 | |
JSON_FILE = "some.json" | |
DB_FILE = "some.db" | |
traffic = json.load(open(JSON_FILE)) | |
conn = sqlite3.connect(DB_FILE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ django-admin.py startproject django_test | |
$ cd django_test/ | |
$ python manage.py runserver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd yakju-jwr66v | |
$ adb reboot bootloader | |
$ ./flash-all.sh |