Skip to content

Instantly share code, notes, and snippets.

@r2k0
r2k0 / app.py
Created July 2, 2016 05:15 — forked from maccman/app.py
Stripe Flask Example
import os
from flask import Flask, render_template, request
import stripe
stripe_keys = {
'secret_key': os.environ['SECRET_KEY'],
'publishable_key': os.environ['PUBLISHABLE_KEY']
}
stripe.api_key = stripe_keys['secret_key']
@r2k0
r2k0 / flask-upload
Last active August 29, 2015 14:07 — forked from dAnjou/flask-upload
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
@r2k0
r2k0 / permutations
Created October 20, 2014 01:21
itertools permutations example
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('hat')]
>>> perms
['hat', 'hta', 'aht', 'ath', 'tha', 'tah']
>>> print sorted(perms)
['aht', 'ath', 'hat', 'hta', 'tah', 'tha']
>>> print ','.join(sorted(perms))
aht,ath,hat,hta,tah,tha
@r2k0
r2k0 / app.py
Last active August 29, 2015 14:07 — forked from vgoklani/app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def index(chartID = 'chart_ID', chart_type = 'bar', chart_height = 350):
chart = {"renderTo": chartID, "type": chart_type, "height": chart_height,}
series = [{"name": 'Label1', "data": [1,2,3]}, {"name": 'Label2', "data": [4, 5, 6]}]
title = {"text": 'My Title'}
from SimpleCV import *
img = Image('stega.jpg')
msg = "Stegosaurus is a genus of armored stegosaurid dinosaur. They lived during the Late Jurassic period (Kimmeridgian to early Tithonian), some 155 to 150 million years ago in what is now western North America. In 2006, a specimen of Stegosaurus was announced from Portugal, showing that they were present in Europe as well.[2] Due to its distinctive tail spikes and plates, Stegosaurus is one of the most recognizable dinosaurs. At least three species have been identified in the upper Morrison Formation and are known from the remains of about 80 individuals.[3]A large, heavily built, herbivorous quadruped, Stegosaurus had a distinctive and unusual posture, with a heavily rounded back, short forelimbs, head held low to the ground and a stiffened tail held high in the air. Its array of plates and spikes has been the subject of much speculation. The spikes were most likely used for defense, while the plates have also been proposed as a defensive mechanism, as well
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
#Serve current directory tree at http://$HOSTNAME:8000/
python -m SimpleHTTPServer
#swap
b, a = a, b
#
a = [1,2,3,4,5]
a[::2] # iterate over the whole list in 2-increments [1,3,5]
a[::-1] # reversed [5,4,3,2,1]
declare upper;
input period = AggregationPeriod.DAY;
input length = 252;
def periodHigh = Highest(imp_volatility(period = period), length = length);
def periodLow = Lowest(imp_volatility(period = period), length = length);
def ivRange = periodHigh - periodLow;
def ivp = round(100*(imp_volatility(period=period)-periodLow)/ivRange, 0);
AddLabel(1, Concat("IV%", ivp), color.DARK_ORANGE);
@r2k0
r2k0 / IV_Ver3
Created May 5, 2014 23:16
IV_Ver3
declare upper;
input period = AggregationPeriod.DAY;
input length = 252;
def ivGapHi = if isnan(imp_volatility(period=period)) then 999999999999 else imp_volatility(period=period);
def ivGapLo = if isnan(imp_volatility(period=period)) then -999999999999 else imp_volatility(period=period);
def periodHigh = highest(ivGapLo,length=length);
def periodLow = lowest(ivGapHi,length=length);
def ivRange = periodHigh - periodLow;
@r2k0
r2k0 / 0_reuse_code.js
Created April 23, 2014 14:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console