Skip to content

Instantly share code, notes, and snippets.

View soroushj's full-sized avatar

Soroush Javadi soroushj

View GitHub Profile
#!/usr/bin/env bash
pg_dump \
--data-only \
--inserts \
\
--dbname=DBNAME \
--host=HOST \
--port=PORT \
--username=USERNAME \
#!/usr/bin/env bash
pg_dump \
--schema-only \
--no-owner \
--no-privileges \
--no-publications \
--no-subscriptions \
--no-tablespaces \
\
@soroushj
soroushj / start-react.md
Created December 9, 2018 17:06
Start Font-End Development with React
@soroushj
soroushj / bashrc-prompt-git.sh
Created September 16, 2018 11:19
Show git branch in bash prompt
# ...
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \[\033[01;33m\]$(__git_ps1 "(%s)")\n\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w $(__git_ps1 "(%s)")\n\$ '
fi
# ...
@soroushj
soroushj / addThrottledEventListener.js
Created January 22, 2018 12:56
Add throttled event listener
const addThrottledEventListener = (target, type, listener, delay = 67) => {
let timeoutId;
const throttler = event => {
if (!timeoutId) {
timeoutId = setTimeout(() => {
timeoutId = null;
listener(event);
}, delay);
}
};
@soroushj
soroushj / unsharpmask.py
Created November 12, 2017 15:36
Produce a sharpened version of an image, using an unsharp mask.
import cv2 as cv
import numpy as np
def unsharp_mask(image, kernel_size=(5, 5), sigma=1.0, amount=1.0, threshold=0):
"""Return a sharpened version of the image, using an unsharp mask."""
# For details on unsharp masking, see:
# https://en.wikipedia.org/wiki/Unsharp_masking
# https://homepages.inf.ed.ac.uk/rbf/HIPR2/unsharp.htm
blurred = cv.GaussianBlur(image, kernel_size, sigma)
sharpened = float(amount + 1) * image - float(amount) * blurred
@soroushj
soroushj / ygrayscale.py
Created November 12, 2017 15:34
Produce a grayscale version of an RGB image, using the Y channel of the YCbCr color space.
import cv2 as cv
import numpy as np
def y_grayscale(rgb_image):
"""Return a grayscale version of the RGB image, using the Y channel of the YCbCr color space."""
# For details on the YCbCr color space, see:
# https://en.wikipedia.org/wiki/YCbCr
# https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
return (.299 * rgb_image[:, :, 0] +
.587 * rgb_image[:, :, 1] +