Skip to content

Instantly share code, notes, and snippets.

@mdellavo
mdellavo / sqlalchemy-typed-eav.py
Created March 23, 2011 21:45
A Typed Entity-Attribute-Value Pattern for SQLAlchemy
# CREATE TABLE foos (
# id INTEGER IDENTITY(1,1) NOT NULL PRIMARY KEY,
# );
# CREATE TABLE foo_data (
# foo_id INTEGER NOT NULL REFERENCES proposals(id),
# [key] VARCHAR(50) NOT NULL,
# [type] CHAR(1) NOT NULL DEFAULT 's' CHECK(type IN ('s', 'b', 'i', 'f'))
@russss
russss / paypal2ofx.py
Created August 7, 2011 22:15
Convert a paypal CSV export to an OFX file
import csv
import sys
from collections import namedtuple
rows = csv.reader(sys.stdin)
fields = [field.strip().lower().replace(' ', '_').replace('/', '_')
for field in rows.next() if field.strip() != '']
PaypalRecord = namedtuple('PaypalRecord', fields)
@thoas
thoas / puller.py
Created January 10, 2012 15:04
Migration script from MySQL to PostgreSQL via SQLAlchemy
#!/usr/bin/env python
import getopt
import sys
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.dialects.mysql.base import TINYINT
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.exc import ProgrammingError
@geoffalday
geoffalday / secretkey.py
Created March 12, 2012 12:28
How to generate a secret key with Python
# How to generate a secret key with Python
# via http://flask.pocoo.org/docs/quickstart/
import os
os.urandom(24)
@mbinna
mbinna / hack.sh
Created April 11, 2012 05:57 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2357277/hack.sh | sh
#
@satiani
satiani / app.py
Last active December 28, 2015 10:59
How to work around the caching of wtforms validator message translations
from flask import Flask, request, jsonify
from flask.ext.wtf import Form, TextField, Email
from flask.ext.babel import get_translations, lazy_gettext as __
from flask.json import JSONEncoder
from speaklater import make_lazy_string, is_lazy_string
class CustomTranslations(object):
def babel_gettext(self, s):
return get_translations().ugettext(s)
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 19, 2024 17:40
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

{% if form.errors %}
<div class="alert alert-danger">
<ul>
{% for field_name, field_errors in form.errors|dictsort if field_errors %}
{% for error in field_errors %}
<li>{{ form[field_name].label }}: {{ error }}</li>
{% endfor %}
{% endfor %}
</ul>
</div>
@soemarko
soemarko / RoastLoggerMax6675-Behmor.ino
Last active December 9, 2021 18:08
RoastLogger + MAX6675 + Behmor 1600
/****************************************************************************
RoastLoggerMax6675.ino
This sketch is for use with MAX 6675 thermocouple interface chips. A separate sketch
is available for MAX 31855 chips.
See the "Contributed Libraries" section of http://www.arduino.cc/en/Reference/Libraries
for details of how to install it.
@mrjoes
mrjoes / base.py
Created March 27, 2015 00:05
CSV export for Flask-Admin
class BaseModelView(ModelView):
list_template = 'admin/model_list.html'
export_columns = None
# Exporting
def _get_data_for_export(self):
view_args = self._get_list_extra_args()
# Map column index to column name