This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION public.hstore2json ( | |
hs public.hstore | |
) | |
RETURNS text AS | |
$body$ | |
DECLARE | |
rv text; | |
r record; | |
BEGIN | |
rv:=''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Lock file script written to ensure only once process at a time holds a lock | |
# Automatically kills zombie processes past the threshold | |
# https://gist.github.com/1350609 | |
if [ $# -ne 3 ]; then | |
echo "Usage: `basename $0` <lockfile> <timeout> <command>"; | |
exit 2; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Simple, scoped template rendering engine | |
* | |
* Variables may be passed to templates by setting dynamic | |
* properties of this class or by passing them at call time. | |
* | |
* @author Kenaniah Cerny <[email protected]> https://github.com/kenaniah/insight | |
* @license http://creativecommons.org/licenses/by-sa/3.0/ | |
* @copyright Copyright (c) 2009, Kenaniah Cerny |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Database abstraction and query result classes (requires PHP 5.3) | |
* | |
* This class is built primarily for PostgreSQL 8.4+ | |
* Compatibility with other database types is not guaranteed | |
* | |
* @author Kenaniah Cerny <[email protected]> | |
* @version 1.2.0 | |
* @license http://creativecommons.org/licenses/by-sa/3.0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$reader = fopen("file.csv", "r"); | |
$headers = null; | |
while($row = fgetcsv($reader)): | |
if(!$headers): | |
foreach($row as $k => $v) $row[$k] = trim(preg_replace("/\s+/", " ", $v)); | |
$headers = $row; | |
continue; | |
endif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This isn't really a git hook, but it's manually called it after every fetch run. | |
# This script essentially wraps the actual post-receive hook. | |
# Build the standard input for the post-receive hook | |
cat refs/heads/* | paste TRAC_HEAD - > post-fetch.tmp | |
find refs/heads/* | paste post-fetch.tmp - | awk '{print $1, $2, $3}' > post-fetch.stdin | |
# Call the post-receive hook just like the commits were pushed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Manages Shadow Groups in Active Directory | |
.DESCRIPTION | |
This script automatically manages the member users of groups placed in | |
"OU=Shadow Groups,DC=mydomain,DC=local". Users and computers that are contained | |
by OUs that match the name of a shadow group are automatically added to that group, | |
and users that are no longer contained by a matching OU are removed from | |
the group. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Launch the backend | |
exec('/bin/bash -c "nohup ' . $start_command . ' 1> >(logger -p user.warning -t accounting.py) 2> /dev/null &" > /dev/null 2>&1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Worker(object): | |
@staticmethod | |
def _irr(....): | |
... | |
def foo(): | |
with multiprocessing.Pool() as pool: | |
results = {} | |
results['gross_xirr'] = pool.apply_async(Worker._irr, (gross_stream, 0.115, 'xnpv')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Povides a function that allows files to be uploaded to an Amazon S3 bucket | |
function upload_to_s3 { | |
# Definitions | |
bucket=<bucket name> | |
resource=$2/`basename $1` | |
content_type="application/x-compressed" | |
date=`date -R` | |
md5=`openssl dgst -md5 -binary "$1" | openssl enc -e -base64` |
OlderNewer