Skip to content

Instantly share code, notes, and snippets.

View shiplu's full-sized avatar

Shiplu Mokaddim shiplu

View GitHub Profile
shiplu /
Last active May 16, 2020 14:01
A program that compares CSV data between the “before” and the “after” after. Both CSV must have a unique identifier specified in a `key` column. This will output the new rows, updated rows and the deleted rows' keys.
#!/usr/bin/env python3.7
Shows changes in product information from CSV files.
from typing import Dict, List, Tuple, Set, Any, Hashable
import argparse
import csv
import logging
import logging.config
import sys
shiplu /
Last active May 17, 2019 07:02
Sort python log files using date time. Takes datetime regex as input
import argparse
import re
from datetime import datetime
from signal import signal, SIGPIPE, SIG_DFL
from operator import itemgetter
def test_sorted_lines():
shiplu /
Last active April 19, 2022 19:10
Gracefully stop a zerorpc server
Run it with zerorpc. To close press Ctrl+C or send a TERM or INT signal.
import zerorpc
import time
import signal
import sys
import itertools
shiplu / goinside
Created March 16, 2018 11:12
Go inside docker container with same bash column height and width
docker exec -it $1 bash -c "stty cols $COLUMNS rows $LINES && bash";
COMPREPLY=( $(docker ps --format "{{.Names}}" -f name=$2) )
export -f goinside
export -f _goinside
complete -F _goinside goinside
shiplu / ec2-instaces-by-name
Created December 15, 2016 10:21
Lists all the ec2 instance's ip by name. The name can be a glob pattern, means if its '*a' then it'll match any instance that has name ending with letter a. It outputs only the PrivateIpAddress. But if you can also use PublicIpAddress.
aws ec2 describe-instances --output text \
--query 'Reservations[*].Instances[*].{ip:['$IP_SOURCE'],name:Tags[?Key==`Name`].Value}' \
--filter "Name=tag:Name,Values=$1" |
awk '$1 ~ /IP/{ip=$2} $1 ~ /NAME/{printf "%-15s %s\n", ip, $2}' |
sort -k2
shiplu /
Last active December 9, 2016 10:02
Scan for keys with pattern using SCAN
Scan for keys with a pattern in Redis. It uses SCAN command instead of KEYS.
KEYS is dangereros as it locks down the whole server. Hence the need for SCAN
shiplu / i
Last active August 29, 2015 14:06
the great I
echo $(date +"%Y-%m-%d %H:%M:%S") $* | tee -a ~/task.log
shiplu / fterrors.h-not-found
Created August 7, 2014 11:55
OSX "fatal error: 'freetype/fterrors.h' file not found"
Sometimes while compiling you might face this error on OSX. I faced this on Mountain Lion `10.8.5`.
This happens because `freetype` library headers are not found in standard place. To solve this follow the follwing steps.
1. Install `freetype` using [brew](
brew install fretype
2. Now you'll see a `freetype2` directory exists in `/usr/local/include`.
3. But `freetype` is required. So create a symlink
ln -s freetype2 freetype
shiplu / storage_mysql.c
Created July 18, 2012 16:10
Mysql Storage Provider for Bitlbee. main repository
* BitlBee -- An IRC to other IM-networks gateway *
* *
* Copyright 2002-2006 Wilmer van der Gaast and others *
* Storage backend that uses an MySQL.
* Sample schema can be found on /doc/schema_mysql.sql