Skip to content

Instantly share code, notes, and snippets.

View thiagolcks's full-sized avatar

Thiago Locks thiagolcks

  • St Catharines, ON, Canada
View GitHub Profile
@radarsat1
radarsat1 / parbrute.py
Created January 2, 2012 18:33
Parallelized scipy.optimize.brute
#!/usr/bin/env python
"""Provide a parallelized version of scipy.optimize.brute for 1-, 2-, or 3-dimensional arguments.
Needed to parallelize the steps of a grid-based global optimization, so I copied the "brute" code, replaced "vectorize" with nested maps for specific numbers of arguments, and replaced the outer-most map() with a ThreadPool.map(). Likely this could be generalized to any number of arguments (e.g. by zipping the grid and iterating in parallel over the tuples) but I didn't feel like figuring that out just now.
This should perform help for routines that spend a lot of time in numpy code, but I imagine that a pure Python routine might get caught-up by the GIL. Possibly using a process pool instead of a thread pool would fix it. Currently I'm using it for a routine that spends all its time in fftconvolve() so it wasn't a problem for me.
parbrute() takes the same arguments as scipy.optimize.brute(), with the addition of thread=N for the number of threads you want in the pool. Defaults to 4
@oodavid
oodavid / README.md
Created March 26, 2012 17:05
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

## {{{ http://code.activestate.com/recipes/577654/ (r1)
#!/usr/bin/env python
# Send DDE Execute command to running program
import time
from ctypes import POINTER, WINFUNCTYPE, c_char_p, c_void_p, c_int, c_ulong, c_char_p
from ctypes.wintypes import BOOL, DWORD, BYTE, INT, LPCWSTR, UINT, ULONG
# DECLARE_HANDLE(name) typedef void *name;
HCONV = c_void_p # = DECLARE_HANDLE(HCONV)
HDDEDATA = c_void_p # = DECLARE_HANDLE(HDDEDATA)
@jaxbot
jaxbot / gist:5748513
Created June 10, 2013 12:58
Block nginx from serving .git directories
location ~ /\.git {
deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
location ~ /\. {
deny all;
}
@CMCDragonkai
CMCDragonkai / DecoratorAbstract.php
Last active June 23, 2019 22:58
PHP: DecoratorAbstract - Allows the creation of flexible nested decorators.
<?php
/**
* DecoratorAbstract allows the creation of flexible nested decorators. All decorators must extend from DecoratorAbstract.
* Decorators can be stacked. They can also have methods that overwrite each other.
* Decorators can omit methods that parent decorators have defined and/or child decorators have defined.
* Methods will cascade to the original child object.
* Properties will read and set from the original child object except when your instance has the property defined.
*/
abstract class DecoratorAbstract{
@ipepe
ipepe / install-chrome-headless.sh
Last active June 12, 2024 13:34
Installing headless chrome on Ubuntu.
#!/bin/bash
# from https://chromium.woolyss.com/
# and https://gist.github.com/addyosmani/5336747
# and https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:canonical-chromium-builds/stage
sudo apt-get update
sudo apt-get install chromium-browser
chromium-browser --headless --no-sandbox http://example.org/