Skip to content

Instantly share code, notes, and snippets.

javascript:(function(){popw='';Q='';d=document;w=window;if(d.selection){Q=d.selection.createRange().text;}else if(w.getSelection){Q=w.getSelection();}else if(d.getSelection){Q=d.getSelection();}popw=w.open('http://mail.google.com/mail/s?view=cm&fs=1&tf=1&to=&su='+encodeURIComponent(d.title)+'&body='+encodeURIComponent(Q)+escape('%5Cn%5Cn')+encodeURIComponent(d.location)+'&zx=RANDOMCRAP&shva=1&disablechatbrowsercheck=1&ui=1','gmailForm','scrollbars=yes,width=680,height=575,top=175,left=75,status=no,resizable=yes');if(!d.all)setTimeout(function(){popw.focus();},50);})();
@ohjho
ohjho / git_blob_obj.sh
Last active December 11, 2018 07:10
shell script to show all blob objects in your git repo sorted from smallest to largest. For mac users, please comment out the last line. To run, place this in your git directory and run `sh git_blob_obj.sh`
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
@ohjho
ohjho / imaginemagick_color_convert.sh
Last active March 6, 2019 04:29
-fill is the new color and -opaque is the old color; you can use https://imagecolorpicker.com/ to identify the color in the image
convert original.jpg -fuzz 15% -fill "#84BE6A" -opaque "#d89060" new.jpg
@ohjho
ohjho / imaginemagick_crop.sh
Created March 29, 2019 00:52
how to crop an image with imaginemagick: -crop {w}x{h}+{x}+{y}
convert foo.png -crop 640x480+50+100 out.png
@ohjho
ohjho / imgmagick_batch_resize
Created April 23, 2019 02:50
imgmagick resize batch sub directory (replace . with your dir path)
find . -type f -iname "*.jpg" -exec identify -format '%w %h %i\n' {} \; |
awk '$1 > 1200 || $2 > 1200 {sub(/^[^ ]* [^ ]* /, ""); print}' |
tr '\n' '\0' |
xargs -0 mogrify -resize '1200x1200'
@ohjho
ohjho / grep_string_in_dir.sh
Last active October 15, 2019 03:32
use grep to search for files containing a given string
grep -R --exclude-dir=node_modules 'some pattern' /path/to/search
grep -R --exclude-dir={node_modules,.git} 'some pattern' /path/to/search
@ohjho
ohjho / search_and_kill_pid.md
Last active July 15, 2020 08:27
Search and Kill Process in Linux land

Search for your Process's ID:

ps aux | grep 'your search term'

Kill it gently (assuming our id is 93735):

kill 93735
@ohjho
ohjho / change_docker_image_directory.md
Created January 19, 2021 04:51
How to Change Docker's Image Installation Directory

To remove unused images, docker image prune -a, and containers , docker container prune

1. Stop Docker

sudo service docker stop then make sure docker is stop with ps aux| grep docker

2. Backup current docker directory

sudo cp -r /var/lib/docker /your/storage/dir

3. Update Docker Configs per this post

@ohjho
ohjho / nvidia-smi-hacks.md
Last active February 2, 2021 10:36
hacks using `nvidia-smi` to monitor GPU stats from the terminal

A fake nvtop

watch -n 0.5 nvidia-smi

more specific stats

nvidia-smi --format=csv --query-gpu=power.draw,utilization.gpu,fan.speed,temperature.gpu,memory.used,memory.free
@ohjho
ohjho / efs_mounting.md
Last active March 3, 2021 07:49
EFS mounting on AWS EC2 for Data Scientist

Create EFS

make sure it's in the same reigon in the same VPC as your EC2. Furthermore, your EFS also has to be in the same Security Group (with NFS access)

Mounting the EFS

follow this guide on how to mount your EFS on to a new EC2 instance

you can double check that it's mounted by df -h or mount | grep efs

your newly launched EC2 instance should have the EFS mount instructions in /etc/fstab