Skip to content

Instantly share code, notes, and snippets.

@dmitrydanilich
dmitrydanilich / JSKeyCodes
Created September 3, 2018 15:52 — forked from tylerthebuildor/JSKeyCodes
List of JavaScript key codes.
backspace 8
tab 9
enter 13
shift 16
ctrl 17
alt 18
pause/break 19
caps lock 20
escape 27
page up 33
@dmitrydanilich
dmitrydanilich / git tutorials.md
Created October 2, 2017 08:50 — forked from jaseemabid/git tutorials.md
Awesome git tutorials I am finding here and there
@dmitrydanilich
dmitrydanilich / protractor_members.txt
Created November 29, 2016 11:51 — forked from JamieMason/protractor_members.txt
Methods available to you in a Jasmine test using https://github.com/juliemr/protractor/
protractor.wrapDriver
protractor.setInstance
protractor.getInstance
protractor.By
protractor.By.binding
protractor.By.select
protractor.By.selectedOption
protractor.By.input
protractor.By.repeater
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@dmitrydanilich
dmitrydanilich / search-replace.txt
Last active April 5, 2016 16:06
Global recursive search/replace
# Recursively find and replace in files
find . -name "*.txt" -print0 | xargs -0 sed -i '' -e 's/foo/bar/g'
Here's how it works:
find . -name '*.txt' finds, in the current directory (.) and below, all files whose names end in .txt
| passes the output of that command (a list of filenames) to the next command
xargs gathers up those filenames and hands them one by one to sed
sed -i '' -e 's/foo/bar/g' means "edit the file in place, without a backup, and make the following substitution (s/foo/bar) multiple times per line (/g)" (see man sed)
Note that the 'without a backup' part in line 4 is OK for me, because the files I'm changing are under version control anyway, so I can easily undo if there was a mistake.
@dmitrydanilich
dmitrydanilich / ulimit.sh
Last active January 25, 2016 20:00
OSX has a ridiculously low limit on the maximum number of open files. If you use OSX to develop Node applications - or even if you just use Node tools like grunt or gulp - you've no doubt run into this issue.
echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
ulimit -n 65536 65536
sudo chown `whoami` /data/db