Skip to content

Instantly share code, notes, and snippets.

@jehiah
jehiah / simple_args_parsing.sh
Created Mar 4, 2011
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 / git-branch-status
Last active May 5, 2022
show git ahead/behind info for branches
View git-branch-status
moved to github --> https://github.com/bill-auger/git-branch-status/
@jehiah
jehiah / strange_bash_feature.sh
Created May 22, 2012
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 Mar 4, 2011
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 Jul 6, 2021
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%%=*}
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 Sep 28, 2020
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
@jehiah
jehiah / simulate_memcached.py
Created Aug 20, 2011
test script to simulate a partially reachable memcached instance
View simulate_memcached.py
#!/bin/env python
"""
This is a test script to simulate a memcached instance on a server
that has gone south and is accepting connections, but generally not
responding.
The goal of this script is to help test/develop correct client
side settings for timeouts/failure scenarios
@jehiah
jehiah / nsq_testing.go
Last active Jun 30, 2020
NSQ Producer testing abstraction
View nsq_testing.go
package nsqutils
import (
"sync"
"time"
nsq "github.com/nsqio/go-nsq"
)
// Producer is an interface that nsq.Producer fulfills