Skip to content

Instantly share code, notes, and snippets.

@jehiah
jehiah / gist:b747bf4ac069fccc3b89aec5cc8a1307
Created May 25, 2023 19:11
NYPD Parking Facilities geojson
View gist:b747bf4ac069fccc3b89aec5cc8a1307
cat City\ Owned\ and\ Leased\ Property\ \(COLP\)\ \ \ Shapefile.geojson | jq -c '{type:"FeatureCollection", features:[(.features[] | select(.properties.agency == "NYPD") | select(.properties.usecode | in({"0100": true, "0130":true, "0510":true, "0110":true, "0120":true, "0690":true}) )) ]}' > NYPD_parking.geojson
@jehiah
jehiah / notify.sh
Created January 19, 2014 21:45
email notify at system boot time
View notify.sh
#!/bin/bash
#
# *************************************************
# chkconfig: 2345 99 99
# description: notify email address on system boot.
# *************************************************
# Installing:
# 1) save as /etc/rc.d/init.d/notify
# 2) set the desired email address in "MAILADD" variable
# 3) chmod a+w /etc/rc.d/init.d/notify
@jehiah
jehiah / git-branch-status
Last active May 4, 2023 02:47
show git ahead/behind info for branches
View git-branch-status
moved to github --> https://github.com/bill-auger/git-branch-status/
@jehiah
jehiah / simple_args_parsing.sh
Created March 4, 2011 16:56
a simple way to parse shell script arguments
View simple_args_parsing.sh
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@jehiah
jehiah / strange_bash_feature.sh
Created May 22, 2012 21:17
Weird (annoying) feature of bash
View strange_bash_feature.sh
#!/bin/bash
COUNT=1
FILE=$0
# run this script with bash
# i bet you can't predict the outcome
function printsleep {
echo COUNT=$(( COUNT++ ))
echo printsleep >> $FILE
@jehiah
jehiah / strnchr.c
Created March 4, 2011 17:20
strnchr because it doesn't exist for some reason
View strnchr.c
#include <stdlib.h>
/*
Returns a pointer to the first occurrence of character in the C string str.
The terminating null-character is considered part of the C string. Therefore,
it can also be located to retrieve a pointer to the end of a string.
@param str the string to be searched
@param len the number of characters to search
@param character the character to search for
@jehiah
jehiah / minimal_cidr_list.py
Created July 6, 2021 18:58
minify a list of CIDrs to the largest CID listed
View minimal_cidr_list.py
#!/usr/bin/env python
import sys
from ipaddress import IPv4Network
from collections import defaultdict
if __name__ == "__main__":
inputs = defaultdict(list)
for line in sys.stdin:
cidr = line.strip().decode('utf-8')
View misspell_test.sh
#!/bin/bash
# run https://github.com/client9/misspell linter
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=`dirname "$SCRIPT"`
# get to repo root
cd $SCRIPTPATH/../../..
WRITE=""
while [ "$1" != "" ]; do
PARAM=${1%%=*}
@jehiah
jehiah / svg_abs_to_rel.py
Created February 9, 2021 23:00
Resize SVG images
View svg_abs_to_rel.py
from decimal import Decimal
from xml.dom import minidom
import sys
import os
import re
import simplejson as json
import string
import tornado.options
import logging
@jehiah
jehiah / iphone_messages_dump.py
Last active September 28, 2020 03:53
Script to dump out messages to csv from an iPhone Backup sqlite file
View iphone_messages_dump.py
# Copyright Jehiah Czebotar 2013
# http://jehiah.cz/
import tornado.options
import glob
import os
import sqlite3
import logging
import datetime
import csv