This file contains hidden or 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
/* | |
* Populate and process arrays of structs in C, with error handling. | |
* | |
* Zero-Clause BSD (0BSD) | |
* --------------------------------------------------------------------- | |
* Permission to use, copy, modify, and/or distribute this software for | |
* any purpose with or without fee is hereby granted. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL | |
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
This file contains hidden or 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
function sqlplus { | |
socat READLINE,history=$HOME/.sqlplus_history EXEC:"$ORACLE_HOME/bin/sqlplus $(echo $@ | sed 's/\([\:]\)/\\\1/g')",pty,setsid,ctty | |
status=$? | |
} |
This file contains hidden or 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
ALIASES += license="\par License^^" | |
ALIASES += license{1}="\par \1\n" | |
ALIASES += licenseblock="\par License^^\parblock^^" | |
ALIASES += licenseblock{1}="\par \1^^\parblock^^" | |
ALIASES += endlicenseblock="\endparblock^^" |
This file contains hidden or 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
function ppjson { | |
test -f "${1}" && src="open('${1}')" || src="sys.stdin" | |
python -c "import json,sys;sys.stdout.write(json.dumps(json.load(${src}),indent=2)+'\n')" | |
} |
This file contains hidden or 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
# show the location of a Python module's .py | |
# usage: pyfn module.name [pyversion] | |
# example: "pyfn hashlib", "pyfn hashlib 3.5", "pyfn hashlib 2" | |
function pyfn { | |
test -z "${1}" && return 1 | |
fn=$(python${2} -c "import ${1},sys;sys.stdout.write(getattr(${1},'__file__').rsplit('.',1)[0]+'.py')") | |
test -f "${fn}" && echo "${fn}" | |
} | |
# open a Python module's .py in vi (read-only) |
This file contains hidden or 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
/* | |
* Copyright (c) 2009 Matthew Zipay | |
* | |
* 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: | |
* |
This file contains hidden or 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
/* | |
* @license CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/) | |
* | |
* Angular's $q.all works great for cases where a rejection of any one promise | |
* SHOULD cause all parallel promises to be rejected... but it's not so great | |
* when you've got a number of promises that need to run in parallel and you | |
* don't want a single rejection to reject the entire $q.all promise. | |
* (One example: think aggregating data from multiple APIs.) | |
* | |
* This gist shows one way to "partially resolve" parallel processes when at |
This file contains hidden or 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
/** | |
* @license CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/) | |
* | |
* The problem: | |
* You need to make a cross-domain request for JSON data, but the remote | |
* server doesn't send the necessary CORS headers, and it only supports | |
* simple JSON-over-HTTP GET requests (no JSONP support). | |
* | |
* One possible solution: | |
* Use 'jsonp-proxy-request-interceptor' to proxy the request through |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# Copyright (c) 2010, 2015 Matthew Zipay <[email protected]>. | |
# All rights reserved. | |
# Licensed under the MIT License <http://opensource.org/licenses/MIT>. | |
class PseudoStruct: | |
"""Base class for structure-like data objects. |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# Copyright (c) 2015 Matthew Zipay <[email protected]>. All rights reserved. | |
# Licensed under the MIT License <http://opensource.org/licenses/MIT>. | |
class lazy: | |
r"""Decorate a no-arg getter to have lazy initialization behavior. | |
The first time the property is accessed on an instance, the computed |