Skip to content

Instantly share code, notes, and snippets.

from flask import Flask, request, session
from sqlalchemy import create_engine, Table, MetaData
from sqlalchemy.orm import mapper, relationship, sessionmaker, scoped_session
from sqlalchemy.sql import select
app = Flask(__name__)
engine = create_engine('postgresql+psycopg2://kamal@localhost/clinic_dev')
metadata = MetaData(bind=engine)
DBSession = scoped_session(sessionmaker(bind=engine))
# Python OAuth example
import evernote.edam.userstore.constants as UserStoreConstants
import evernote.edam.type.ttypes as Types
from evernote.api.client import EvernoteClient
##
# Helper function to turn query string parameters into a
# Python dictionary
##

Keybase proof

I hereby claim:

  • I am ludwig on github.
  • I am ludwig1024 (https://keybase.io/ludwig1024) on keybase.
  • I have a public key whose fingerprint is 4D40 1C62 1AB8 C1D7 5C93 F20D 62F5 EA1C BD5C 7771

To claim this, I am signing this object:

# Inser this snippet into your ~/.bash_profile
# Set up the GPG Agent
# http://fvue.nl/wiki/Debian_4.0:_Installing_gpg-agent
if [ -f ${HOME}/.gpg-agent-info ] && \
kill -0 $(cut -d: -f 2 ${HOME}/.gpg-agent-info)
then
# Yes, '.gpg-agent-info' points to valid gpg-agent process;
# Indicate gpg-agent process
GPG_AGENT_INFO=$(cat ${HOME}/.gpg-agent-info | cut -c 16-)
@ludwig
ludwig / RemappingKeys.ahk
Last active August 29, 2015 14:23
My main AutoHotkey setup
#NoEnv
#SingleInstance Force
; Some reading to do:
; https://www.autohotkey.com/docs/Hotkeys.htm
; https://www.autohotkey.com/docs/misc/Remap.htm
; https://www.autohotkey.com/docs/KeyList.htm
; Turn caps-lock into ctrl key (for vim & emacs)
CapsLock::Ctrl

Generated private key

openssl genrsa -out server.key 2048

To generate a certificate

openssl req -new -x509 -key server.key -out server.pem -days 3650

https

@ludwig
ludwig / module_mocking.py
Created December 15, 2015 11:13 — forked from daragh/module_mocking.py
Example code for mocking a module in Python
'''
Example code to show how it is possible to mock an entire module by patching
the sys.modules dict using mock ( http://www.voidspace.org.uk/python/mock/ ).
'''
from mock import patch, MagicMock
def test_import_patching():
module_mock = MagicMock()
with patch.dict('sys.modules', **{
@ludwig
ludwig / contentsOfDirectoryAtPath.swift
Created December 22, 2015 07:34 — forked from kristopherjohnson/contentsOfDirectoryAtPath.swift
Using NSFileManager contentsOfDirectoryAtPath in Swift, with tuple result and CPS interfaces
import Foundation
// Tuple result
// Get contents of directory at specified path, returning (filenames, nil) or (nil, error)
func contentsOfDirectoryAtPath(path: String) -> (filenames: String[]?, error: NSError?) {
var error: NSError? = nil
let fileManager = NSFileManager.defaultManager()
let contents = fileManager.contentsOfDirectoryAtPath(path, error: &error)
@ludwig
ludwig / springer-free-maths-books.md
Created December 29, 2015 21:35 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links
@ludwig
ludwig / socket_file.sh
Created February 25, 2016 09:46 — forked from jadell/socket_file.sh
Read and write to a socket using only Bash
#!/bin/bash
#
# Bash must have been compiled with this ability: --enable-net-redirections
# The device files below do not actually exist.
# Use /dev/udp for UDP sockets
exec 3<>/dev/tcp/host/port
# Write to the socket as with any file descriptor
echo "Write this to the socket" >&3