Skip to content

Instantly share code, notes, and snippets.

@nmnp
nmnp / GitMerge.txt
Created April 9, 2015 00:25
git merge dry run
git config --global alias.mergetest '!f(){ git merge --no-commit --no-ff "$1"; git merge --abort; echo "Merge aborted"; };f '
@nmnp
nmnp / ClearOrigFiles.txt
Created April 9, 2015 00:26
Clear all the orig file
git config alias.cleanall "clean -f */*.orig"
@nmnp
nmnp / gist:167089924cc9031ff0aa
Created April 21, 2015 06:14
start and stop selenium server
alias startsel="nohup java -Dwebdriver.chrome.driver=./chromedriver -jar selenium-server-standalone-2.45.0.jar &"
stopsel() {
ps xu | grep selenium | grep -v grep | awk '{ print $2 }' | xargs kill -9
}
@nmnp
nmnp / DefinerRegex
Created May 25, 2015 04:07
mysql definer selector regex
find => DEFINER=`(.*?)`@`(.*?)`
replaceWith => DEFINER=`root`@`localhost`
@nmnp
nmnp / envToJSON.js
Created February 12, 2018 06:00
Generate JSON string of environment variables of a wercker pipeline
var envVar = {};
var tr = Array.from(
document.querySelectorAll("table")[0].querySelectorAll('tbody')[0].querySelectorAll('tr'));
tr.map((el)=>{
var tmp = [];
tmp[el.querySelectorAll('.envvarItem_key')[0].querySelectorAll('input')[0].value] = el.querySelectorAll('td')[1].querySelectorAll('.envvarItem_value')[0].querySelectorAll('.envvarItem_value_container')[0].querySelectorAll('textarea')[0].value;
envVar = Object.assign(envVar, tmp);
}
);
@nmnp
nmnp / envAdder.js
Created February 12, 2018 06:02
Add environment variables to the wercker pipeline
async function getVar(env) {
for (v in env) {
var wait = ms=>new Promise((r,j)=>setTimeout(r, ms));
await wait(500);
var event = new Event('input',{
bubbles: true,
"cancelable": false
});
var click = new Event('click',{
@nmnp
nmnp / pipeline-execute.sh
Last active April 23, 2018 04:29
Execute wercker pipeline in local
#!/bin/bash
wercker --environment ./wercker/.env.wercker.unittest.sample deploy --pipeline unittest
@nmnp
nmnp / pip.sh
Created June 13, 2018 23:22
Freeze PIP requirements
pip freeze -l > requirements.txt
@nmnp
nmnp / aws_cli_commands.sh
Last active February 4, 2021 10:17
aws/awslocal cli commands
# create function
# without environment variables
awslocal --endpoint-url=http://localhost:4574 lambda create-function --function-name=f1 --runtime=python3.6 --role=r1 --handler=coupon.handler --zip-file fileb://deployment_bundle.zip
#with environment varibles
awslocal --endpoint-url=http://localhost:4574 lambda create-function --function-name=f1 --runtime=python3.6 --role=r1 --handler=coupon.handler --zip-file fileb://deployment_bundle.zip --environment Variables='{HOST=localhost, USERNAME=root, PASSWORD=promoms, DATABASE=promoms, PORT=3306, REDIS_HOST=localhost, REDIS_PORT=6379, APP_NAME=promoms, APP_ENV=dev, PROMOTIONS_COUPONS_CACHE_KEY=promoms:coupons}'
# invoke function
awslocal lambda --endpoint-url=http://localhost:4574 invoke --function-name f1 --payload '{"coupon":"default"}' result.log
@nmnp
nmnp / localstack_start.sh
Created June 18, 2018 01:02
start localstack docker with temp dir
TMPDIR=/private$TMPDIR localstack start --docker