This file contains 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:utf8 -*- | |
# 無駄にitertoolsを駆使したFizzBuzz | |
from itertools import repeat, ifilterfalse, starmap, count | |
N = 31 | |
LEN = range(1, N) | |
FIZZ, BUZZ = map(repeat, ("Fizz", "Buzz")) | |
fizz, buzz = ( |
This file contains 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
from datetime import datetime | |
from flask import * | |
from flaskext.wtf import * | |
from flaskext.sqlalchemy import * | |
from werkzeug import generate_password_hash, check_password_hash | |
app = Flask() | |
app.config.from_pyfile('app_settings.py') | |
db = SQLAlchemy(app) |
This file contains 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
from flask import Flask,request,g | |
#from middleware import SimpleMiddleware | |
app = Flask(__name__) | |
@app.before_request | |
def before_request(): | |
from uamobile import detect | |
g.d = detect({'HTTP_USER_AGENT': request.headers["User-Agent"]}) |
This file contains 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
import os | |
from PIL import Image | |
from flask import Flask, request, redirect, url_for | |
from werkzeug import secure_filename | |
from flaskext.uploads import (UploadSet, configure_uploads, IMAGES, | |
UploadNotAllowed) | |
app = Flask(__name__) | |
app.config['UPLOADED_PHOTOS_DEST'] = '/tmp/testuploadext' |
This file contains 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
;;; python-pep8.el --- minor mode for running `pep8' | |
;; Copyright (c) 2009, 2010 Ian Eure <ian.eure@gmail.com> | |
;; Author: Ian Eure <ian.eure@gmail.com> | |
;; Keywords: languages python | |
;; Last edit: 2010-02-12 | |
;; Version: 1.01 |
This file contains 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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains 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
# In myapp.tasks __init__.py | |
from celery import Celery | |
celery = Celery() | |
Task = celery.create_task_cls() | |
class MyBaseTask(Task): | |
abstract = True | |
# ... |
This file contains 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
""" | |
Sketch of proposed behaviour... make 'list of dicts' | |
create a (potentially) 'ragged' array, with autoguessed column names, | |
and sensible default values, where the keys don't match. | |
Current behaviour | |
In [215]: pandas.DataFrame([dict(a=1),dict(a=2)],columns=['a']) | |
Out[215]: | |
a |
This file contains 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
# I am a scientist who has been using R for about 2 years. Today I achieved a measure of enlightenment into | |
# the zen of R, and I want to share it with you. | |
# I was simulating a set of independent random walks, which are formed by a multiplicative process. Here is | |
# the code I had built up over a few months of working on it and modifying it on and off as research | |
# questions changed: | |
TimeSteps <- 1000 | |
Walks <- 100 | |
ErrorMagnitude <- 0.03 |
This file contains 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
#!/bin/ruby | |
show_unmerged = ARGV[0] == '-u' | |
branches = `git branch -r`.split("\n") | |
branches.each do |branch| | |
is_merged = `git branch --contains #{branch}` =~ /master/ | |
puts branch if show_unmerged ^ is_merged | |
end |
OlderNewer