Skip to content

Instantly share code, notes, and snippets.

View torufurukawa's full-sized avatar

Toru Furukawa torufurukawa

View GitHub Profile
from time import sleep
from threading import Event, Thread
def main():
# set
to_run = Event()
to_run.set()
# start thread
worker = Worker(to_run, 1)
@torufurukawa
torufurukawa / gist:9584318
Created March 16, 2014 14:48
libcloud で S3 へアップロード
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
ACCESS_KEY_ID, SECRET_ACCESS_KEY = 'chinko', 'manko'
driver_class = get_driver(Provider.S3_AP_NORTHEAST)
driver = driver_class(ACCESS_KEY_ID, SECRET_ACCESS_KEY)
container = driver.get_container(container_name='my-bucket-name')
with open('tenga.txt', 'rb') as iterator:
driver.upload_object_via_stream(iterator=iterator, container=container, object_name='tenga')
[color]
ui = auto
[alias]
glog = log --graph --date=short --decorate=short --pretty=format:'%h %Cblue%d%Creset %cd %cn %s'
st = status
# default virtualenv
export VIRTUAL_ENV_DISABLE_PROMPT=1; source ~/.virtualenvs/default/bin/activate
unset VIRTUAL_ENV_DISABLE_PROMPT
@torufurukawa
torufurukawa / Makefile
Last active January 1, 2016 23:09
俺のブートストラップ
.PHONY : all venv py-packages
VENV_DIR = venv
BIN_DIR = $(VENV_DIR)/bin
BASE_PYTHON = python3.4
PIP = $(BIN_DIR)/pip
ACTIVATE = $(BIN_DIR)/activate
PYTHON = $(BIN_DIR)/python
PIP_REQUIREMENTS = pip-requirements.txt
"""Provides patch for backloglib to work on Google App Engine
Usage:
>>> import backloglib
>>> import gaebackloglib
>>> gaebackloglib.patch(backloglib)
"""
import sys
import xmlrpclib
@torufurukawa
torufurukawa / gist:6161212
Last active December 20, 2015 16:28
angularjs service creation
angular.module('feiz', [], function($provide) {
$provide.factory('get', ['$http', function(http) {
return function(scope) {
http({url:'http://oldriver.org/index.html', method:'GET'}).
error(function(){
scope.hoge = "azuma";
});
};
}]);
});
{
"author": {
"name": "wozozo",
"position": "co-founder"
},
"message": "hello"
}
"""requests wrapper
>>> import curledrequests as requests
you can use this as requests module, but...
>>> requests.debug = True
>>> requests.get('http://example.com/')
curl http://example.com/
Hello
div#header-inner div.titlewrapper {
margin-left: 2px;
padding-bottom: 0px;
}
div.header-outer .descriptionwrapper {
width: 500px;
}
div#header-inner div.descriptionwrapper {