Skip to content

Instantly share code, notes, and snippets.

@GrahamDumpleton
GrahamDumpleton / gist:dca226dcb67518a9454a
Last active August 29, 2015 14:08
Delegate only sub URL to embedded mode.
# This is example configuration of how a specific sub URL of a Python
# web application can be delegated to run in mod_wsgi embedded mode
# where the remainder of the site is delegated to run in mod_wsgi
# daemon mode.
#
# The particular example in this case is to work around the current
# issue that the optional enabling of non WSGI handling of chunked
# request content doesn't work for mod_wsgi daemon mode. A fix for
# that has been developed but hasn't yet been released. As Linux
# distributions ship older mod_wsgi versions and do not update them,
@ffried
ffried / NSOperationQueue+FFAdditions.h
Last active August 29, 2015 13:57
NSOperationQueue+FFAdditions
//
// NSOperationQueue+FFAdditions.h
//
// Created by Florian Friedrich on 22.03.14.
// Copyright (c) 2014 Florian Friedrich. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
@ento
ento / rauth_twitter_reverse_auth.py
Created December 26, 2013 02:35
Twitter reverse auth w/ rauth
# -*- coding: utf-8 -*-
import code
from rauth import OAuth1Service
from rauth import utils
# add x_auth_mode to optional oauth params
utils.OPTIONAL_OAUTH_PARAMS = utils.OPTIONAL_OAUTH_PARAMS + ('x_auth_mode',)
key = 'consumer key'
@kageurufu
kageurufu / models.py
Last active June 6, 2021 07:37
PostgreSQL JSON Data Type support for SQLAlchemy, with Nested MutableDicts for data change notifications To use, simply include somewhere in your project, and import JSON Also, monkey-patches pg.ARRAY to be Mutable @zzzeek wanna tell me whats terrible about this?
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Integer, Column
from postgresql_json import JSON
Base = declarative_base()
class Document(Base):
id = Column(Integer(), primary_key=True)
data = Column(JSON)
#do whatever other work
@sholloway
sholloway / PostGIS install
Created January 13, 2013 23:23
Set up a spatial database with PostGIS on EC2 using an EBS.
Steps:
Set up EBS
21Created 1 TB EBS
Created 64 Bit Amazon Linux AMI 2012.09 M1 Medium 3.7 gb ram, 2 ECUs
Connect to ec2 instance via ssh
chmod 400 IFS-KeyPair.pem
ssh -v -i IFS-KeyPair.pem ec2-user@ec2-54-234-14-65.compute-1.amazonaws.com
Note: Do not replace ec2-user with your user id. This is a AWS Amazon AMI requirement.
@akisute
akisute / gist:1141953
Created August 12, 2011 12:41
Create an animated gif file from images in iOS
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
- (void)exportAnimatedGif
{
UIImage *shacho = [UIImage imageNamed:@"shacho.png"];
UIImage *bucho = [UIImage imageNamed:@"bucho.jpeg"];
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"animated.gif"];
@artisonian
artisonian / simple_gridfs_server.py
Created July 27, 2010 19:24
A simple GridFS server built with Flask
from flask import Flask, request, redirect, url_for, make_response, abort
from werkzeug import secure_filename
from pymongo import Connection
from pymongo.objectid import ObjectId
from gridfs import GridFS
from gridfs.errors import NoFile
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
DB = Connection().gridfs_server_test
FS = GridFS(DB)