Skip to content

Instantly share code, notes, and snippets.

View Answeror's full-sized avatar

Cosmo Du Answeror

View GitHub Profile
@Manu343726
Manu343726 / haskell_function.cpp
Created May 3, 2014 16:00
Haskell-like partial function calls for C++11
/****************************************************************************
* Haskell-like automatic partial functions *
* *
* Copyright © 2014 Manuel Sánchez Pérez *
* *
* This program is free software. It comes without any warranty, to *
* the extent permitted by applicable law. You can redistribute it *
* and/or modify it under the terms of the Do What The Fuck You Want *
* To Public License, Version 2, as published by Sam Hocevar. See *
* http://www.wtfpl.net/ for more details. *
@gear11
gear11 / main.py
Created December 17, 2013 14:54
Simple Python proxy server based on Flask and Requests. See: http:/python-proxy-server/gear11.com/2013/12/python-proxy-server/
"""
A simple proxy server. Usage:
http://hostname:port/p/(URL to be proxied, minus protocol)
For example:
http://localhost:8080/p/www.google.com
"""
@marselester
marselester / resize_animated_gif.py
Created July 18, 2013 14:06
Resize animated gif by Wand (ctypes-based simple ImageMagick binding for Python).
# http://docs.wand-py.org
from wand.image import Image
with Image(filename='original.gif') as img:
img.rotate(90)
img.resize(150, 150)
img.save(filename='converted.gif')
@jzempel
jzempel / application:__init__.py
Created July 29, 2012 20:37
Flask with Celery 3.0
from blueprint import example
from extensions import mail
from flask import Flask
import settings
def create_app(settings=settings):
ret_val = Flask(__name__)
ret_val.config.from_object(settings)
# initialize extensions...
@garydoranjr
garydoranjr / quadprog.py
Created February 21, 2012 20:35
MATLAB style quadprog from CVXOPT qp
from cvxopt import matrix as cvxmat, sparse, spmatrix
from cvxopt.solvers import qp, options
import numpy as np
def quadprog(H, f, Aeq, beq, lb, ub):
"""
minimize:
(1/2)*x'*H*x + f'*x
subject to:
Aeq*x = beq
@dharFr
dharFr / jquery.pinger-0.2.js
Created July 26, 2011 15:43
$.pinger : jQuery plugin for ping-URL process
/**
* $.pinger
*
* If your page runs into an iframe hosted by another domain, you may want to keep the session open.
* This plugin automates the "ping URL" process and provides some options.
*
* The pinger will ask the given URL every 'interval' minutes if it detects
* some activity by listening to the events listed in 'listen' parameter.
*
* Have a look to the 'defaults' variable below for further details about available parameters and default values.
@andrix
andrix / iunzip.py
Created July 4, 2011 13:33
python iterable unzip
import itertools
from operator import itemgetter
def iunzip(iterable):
"""Iunzip is the same as zip(*iter) but returns iterators, instead of
expand the iterator. Mostly used for large sequence"""
_tmp, iterable = itertools.tee(iterable, 2)
iters = itertools.tee(iterable, len(_tmp.next()))
return (itertools.imap(itemgetter(i), it) for i, it in enumerate(iters))
@hpiwowar
hpiwowar / bibtex_to_csv.py
Created July 1, 2011 22:20
For exporting bibtex info into csv for running stats
#!/usr/bin/env python
# Initially written by Heather Piwowar, June 2011
# Public domain: have at it!
# For exporting bibtex info into csv for running stats
import csv
import re
from pybtex.database.input import bibtex as bibtex_in
from pybtex.database.output import bibtex as bibtex_out
from operator import itemgetter, attrgetter
@jhasse
jhasse / main.cpp
Created May 25, 2011 10:18
SHA-1 With Boost
#include <iostream>
#include <boost/uuid/sha1.hpp>
void display(char* hash)
{
std::cout << "SHA1: " << std::hex;
for(int i = 0; i < 20; ++i)
{
std::cout << ((hash[i] & 0x000000F0) >> 4)
<< (hash[i] & 0x0000000F);
@e000
e000 / socks.py
Created March 14, 2011 20:21
socksipy + urllib2 handler
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,