Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -euo pipefail
declare -a PAT_ARGS
declare -a CAPTURE
declare PAT_COUNT=0
while (("$#" > 0)) && [ "$1" != "--" ]; do
PAT_ARGS+=("--arg" "pat${PAT_COUNT}" "$1")
CAPTURE+=("capture(\$pat${PAT_COUNT})")
@cwalv
cwalv / DefaultKeyBinding.dict
Last active January 8, 2020 19:37
~/Library/KeyBindings/DefaultKeyBinding.dict
/*
https://gist.github.com/trusktr/1e5e516df4e8032cbc3d
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
@cwalv
cwalv / del_vs_exit.ipynb
Last active September 27, 2016 16:38
python's `__init__` and `__del__` vs `__enter__` and `__exit__` methods
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am cwalv on github.
  • I am cwa (https://keybase.io/cwa) on keybase.
  • I have a public key whose fingerprint is B16E FF34 B76B 2D1E 8018 3F9C 712E AF67 DD21 D89D

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cwalv
cwalv / gist:9191377
Created February 24, 2014 16:17
gpServiceDeploy.py
#!/usr/bin/env python
'''
This script creates an .sd from a .pyt
.. It assumes that all tools can be called with no parameters (i.e.,
all parameters are "optional". Not ideal for all services, but
works fine for services that arn't called from ArcMap anyway.
If you are calling your service from ArcMap, publish the traditional
way ..
Downloading/unpacking pyzmq
Getting page https://pypi.python.org/simple/pyzmq/
URLs to search for versions for pyzmq:
* https://pypi.python.org/simple/pyzmq/
Analyzing links from page https://pypi.python.org/simple/pyzmq/
Skipping link https://pypi.python.org/packages/2.5/p/pyzmq/pyzmq-2.1.4-py2.5-macosx-10.6-i386.egg#md5=4bb441c6d8cf83a8eb5bd37b9663eed3 (from https://pypi.python.org/simple/pyzmq/); unknown archive format: .egg
Skipping link https://pypi.python.org/packages/2.6/p/pyzmq/pyzmq-2.1.11-py2.6-macosx-10.6-universal.egg#md5=c8c8085d4c04821b73892177b13f74a9 (from https://pypi.python.org/simple/pyzmq/); unknown archive format: .egg
Skipping link https://pypi.python.org/packages/2.6/p/pyzmq/pyzmq-2.1.4-py2.6-macosx-10.6-intel.egg#md5=690e09ef2770bb0ea9d248811d557e65 (from https://pypi.python.org/simple/pyzmq/); unknown archive format: .egg
Skipping link https://pypi.python.org/packages/2.6/p/pyzmq/pyzmq-2.1.4-py2.6-win32.egg#md5=5d50d7b13908fb757abaca28441a98ff (from https://pyp
@cwalv
cwalv / gist:6373593
Created August 29, 2013 02:16
python geohash
geoHashCharMap = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm',
'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z']
stdCharMap = [chr(ord('0') + i) for i in range(10)] + [chr(ord('A') + i) for i in range(26)]
geoHashCharToStdCharMap = dict(zip(geoHashCharMap, stdCharMap))
@cwalv
cwalv / ctypes_play.py
Created June 27, 2012 00:45
python ctypes win32 Get/SetTimeZoneInformation
from contextlib import contextmanager
import ctypes
from ctypes.wintypes import WORD, DWORD, LONG, WCHAR, HANDLE
k32 = ctypes.windll.kernel32
a32 = ctypes.windll.advapi32
class SYSTEMTIME(ctypes.Structure):
@cwalv
cwalv / test.java
Created September 8, 2011 21:34
get some data from the database into esper
import com.espertech.esper.client.*;
public class test {
public static void main(String[] args) throws InterruptedException {
Configuration configuration = new Configuration();
configuration.configure();