Skip to content

Instantly share code, notes, and snippets.

from sqlalchemy import create_engine, Column, Integer, Unicode, ForeignKey, and_, bindparam
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///:memory:', echo=True)
Base = declarative_base()
Session = sessionmaker(engine)
@Javex
Javex / server.c
Created September 29, 2015 15:16
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
struct ucred {
import subprocess
import re
import os
#
# Description
# This script is to be used when you have a RAW vmdk disk and fear that
# the drive identifier, i.e. PHYSICALDRIVEX might change during reboots.
# This script finds the correct name matching to a configured serial and
# will remove the old drive and remove it, create a new one and attach it.
def bsearch(items, x, L=None, R=None):
if L is None:
L = 1
if R is None:
R = len(items)
if L > R:
return None
mitte = (L + R) // 2
assert mitte == int(mitte)
if x < items[mitte-1][1]:
@Javex
Javex / session.py
Last active December 19, 2015 02:49
Demonstrates how an `InvalidRequestError` is raised where it shouldn't be.
from sqlalchemy import orm
from sqlalchemy.engine import create_engine
from sqlalchemy.ext.declarative.api import declarative_base
from sqlalchemy.orm.scoping import scoped_session
from sqlalchemy.orm.session import sessionmaker
from sqlalchemy.schema import Column
from sqlalchemy.types import String
from zope.sqlalchemy.datamanager import ZopeTransactionExtension
import binascii
import os
function submit_phone_no()
{
$.ajax({
url: "...", // your server URL here
type: "get",
dataType: "jsonp", // important for cross-domain!!
data: {phone_number: 01233 }, // figure out where to get this data!
});