Skip to content

Instantly share code, notes, and snippets.

View berkerpeksag's full-sized avatar

Berker Peksag berkerpeksag

  • Helsinki, Finland
View GitHub Profile
@dfm
dfm / _chi2.c
Created August 3, 2012 13:41
How to wrap C code in Python
#include <Python.h>
#include <numpy/arrayobject.h>
#include "chi2.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating chi-squared using C.";
static char chi2_docstring[] =
"Calculate the chi-squared of some data given a model.";
@jeffgca
jeffgca / server.py
Created July 17, 2012 19:07 — forked from anonymous/gist:3131316
Webapp Servage
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-p",
"--port",
@wutali
wutali / cuisine_python.py
Created July 12, 2012 09:23
Cuisine extension for Python.
from os import path
from fabric.api import cd, prefix, lcd
from fabric.api import run, sudo as run_as_root, local as run_on_local
from cuisine import package_install_apt, file_exists
def _run(command, sudo=False, local=False):
if sudo:
return run_as_root(command)
@evildmp
evildmp / gist:3094281
Last active June 30, 2023 10:55
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@coffeesnake
coffeesnake / serve.py
Created July 11, 2012 21:19
quick'n'dirty multithreaded wsgiref sample
from wsgiref.simple_server import make_server, WSGIServer
from SocketServer import ThreadingMixIn
from time import sleep
def simple_app(env, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain')]
start_response(status, headers)
@wutali
wutali / fabric.rb
Created July 10, 2012 12:30
Vagrant provisioner of Fabric.
module Vagrant
module Provisioners
class Fabric < Base
class Config < Vagrant::Config::Base
attr_accessor :fabfile_path
attr_accessor :fabric_path
attr_accessor :python_path
attr_writer :tasks
def _default_fabfile_path
# Get a list of all the bugs you fixed:
hg log -u [email protected] --template '{date|isodate}: {desc}\n'
# it doesn't filter out the merges, backouts, etc.
# Add this to your hgrc:
[alias]
mybugs = log -u [email protected] --template '{date|isodate}: {desc}\n'
hg mybugs
@joewalker
joewalker / bootstrap.js
Created June 17, 2012 13:56
Hello Command
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Components.utils.import("resource:///modules/devtools/gcli.jsm");
var helloCommandSpec = {
name: 'hello',
description: 'Show a message',
params: [
{
def _simple_processor(processor, ext_private, ext_public):
if not request.path.endswith(ext_public):
return
public_file = request.path[len(config.app.static_url_path) + 1:]
public_file_path = os.path.join(config.app.static_folder, public_file)
private_file_path = public_file_path[:-len(ext_public)] + ext_private
# File does not exist in app static - check blueprints.
if not os.path.isfile(private_file_path):
for blueprint_name, blueprint in config.app.blueprints.iteritems():
if request.path.startswith(blueprint.static_url_path):
@akheron
akheron / python-tracker-stats.py
Created May 18, 2012 07:42
Python tracker statistic plotter
# Search for statistic messages from the Python trakcer robot in
# python-dev archives and plot the result.
#
# $ python-traker-stats.py collect
#
# Collects statistics from the mailing list and saves to
# python-tracker-stats.json
#
# $ python-tracker-stats.py plot
#