Skip to content

Instantly share code, notes, and snippets.

View dchapkine's full-sized avatar

Dmitri Chapkine dchapkine

View GitHub Profile
@dchapkine
dchapkine / TweetDeck Account Switch Bookmarklet
Last active December 18, 2015 05:29
Do you use TweetDeck to manage multiple twitter accounts ? Do you want a simple tool to ONLY show columns for 1 specific account, and hide other columns ? This bookmarklet, will replace items in left side bar with account buttons. When you click on one of these buttons, only the columns for this account will be shown. Keep in mind that if TweetD…
/**
* Do you use TweetDeck to manage multiple twitter accounts ?
*
* Do you want a simple tool to ONLY show columns for 1 specific account, and hide other columns ?
*
* This bookmarklet, will replace items in left side bar with account buttons. When you click on one of these buttons,
* only the columns for this account will be shown.
*
* Keep in mind that if TweetDeck update their code, this bookmark will probably brake, but atm it works great !
*/
@dchapkine
dchapkine / makeHtml5SnippetLink.js
Created October 1, 2013 06:52
Turns a json object with snipet content into a simple link that let you edit the snippet in the html5snippet.net editor This is useful if you host js/css/html5 snippets in your tutorials and want users to be able to play with it without leaving the browser, and without saving snippets at html5snippet.net server. Another example is: If your app …
@dchapkine
dchapkine / gist:6909493
Last active December 25, 2015 03:28
getRandomColorString & getRandomColor
var getRandomColor = function() {
return {
r: Math.floor(Math.random()*255),
g: Math.floor(Math.random()*255),
b: Math.floor(Math.random()*255),
a: parseFloat(Math.random().toFixed(2))
}
};
var getRandomColorString = function(alpha) {
@dchapkine
dchapkine / gist:8410054
Last active January 3, 2016 04:39
read input
read -s -p "Enter password: " password && echo $password
@dchapkine
dchapkine / Docker Snippets
Last active June 7, 2022 12:57
Docker Snippets
# Build
IMAGEID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1) && sudo docker build -t $IMAGEID .
# Run new container
CONTAINER_ID=$(sudo docker run -t -d -p 0.0.0.0:81:80 $IMAGEID)
# Login into running containe. REQUIRES DOCKER >= 1.3
sudo docker exec -it $CONTAINER_ID bash
# !!! DEPRECATED !!! Login into running container. REQUIRES DOCKER < 0.9
var replaceVarsUnsafe = function(vars, str, sep) {
sep = sep||'%';
for (var i in vars) str = str.replace(new RegExp('('+sep+i+sep+')+', 'g'), vars[i]);
return str;
};
var s = "/home/%user%/somedir/%dir1%/foo/%dir2%/%dir1%/file.%ext%";
r = replaceVarsUnsafe({
user: "alice",
@dchapkine
dchapkine / install_wifi_sniffer_deps.sh
Last active August 29, 2015 13:57
install wifi sniffer deps
#!/bin/sh
echo "installing scapy"
sudo apt-get install tcpdump python-scapy -y
echo "installing aircrack ng"
cd ~ && rm -rf aircrack && mkdir -p aircrack && cd aircrack
sudo apt-get install libnl1 libnl-dev libssl-dev subversion -y
svn co http://svn.aircrack-ng.org/trunk && cd trunk
make
@dchapkine
dchapkine / laravel4 tips
Last active August 29, 2015 14:01
laravel4 tips
// Tip #1
//
// Symptom: environment hell
// Here is how i handle environments
// In bootstrap/start.php, replace "$env = $app->detectEnvironment(..." by this:
$env = $app->detectEnvironment(function(){
$SERVER_ENV = strtolower(strval(isset($_SERVER["ENV"])?$_SERVER["ENV"]:''));
$DOCKER_ENV = strtolower(strval(getenv("ENV")));
@dchapkine
dchapkine / smtp.sh
Last active August 29, 2015 14:04
Local SMTP catch all
#/bin/bash
python -m smtpd -n -c DebuggingServer localhost:25
1/ Resize to X width, keep aspect ratio
#!/bin/bash
mogrify -resize 2000x *.jpg
2/ Resize to Y height, keep aspect ratio