Skip to content

Instantly share code, notes, and snippets.

@khapota
khapota / letencrypt_creator.sh
Last active March 30, 2016 09:13
Letencrypt create with current web server
# need to setup dns of your domain first
# cert will be stored in /etc/letencrypt
# renew command without --force-renew will not get new certificate if old certificate has long live til expired
./letsencrypt-auto certonly --webroot -w /usr/share/nginx/www -d domain.com --email phankhanh@gmail.com --agree-tos
@khapota
khapota / self_sign.sh
Created April 12, 2016 08:00
ssl self sign
openssl req -newkey rsa:2048 -sha256 -nodes -keyout khapota.key -x509 -days 365 -out khapota.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=khapota.info"
@khapota
khapota / upload.py
Created April 13, 2016 02:16
upload files python request
import requests
files = {"upload_file": open('path/to/file.txt', 'rb')}
data = {"content": "test upload"}
requests.post(url, files=files, data=data)
@khapota
khapota / linnworksUpdatePrice.php
Last active December 27, 2016 15:06
linnworks update price
function updatePrice($itemId, $price, $title) {
$header = array('Host' => 'eu1.linnworks.net',
'Connection' => 'keep-alive',
'Accept' => 'application/json, text/javascript, */*; q=0.01',
'Origin' => 'https://www.linnworks.net',
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36',
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer' => 'https://www.linnworks.net/',
'Authorization' => '6f004779-0784-45bd-86b5-7bec6bc475',
'Accept-Encoding' => 'gzip, deflate');
@khapota
khapota / pf.conf
Created February 13, 2015 02:17
pf conf mac os 10.10
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "forwarding"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "forwarding" from "/etc/pf.anchors/mitm"
@khapota
khapota / mitmproxy pf
Created February 13, 2015 02:17
/etc/pf.anchors/mitm
rdr pass on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr pass on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
# status bar
set-option -g status-utf8 on
set -g set-titles on
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
set-option -g status-bg colour235 #base02
@khapota
khapota / bash-setup.sh
Created August 18, 2017 04:23
Bash it
#!/bin/bash
git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
~/.bash_it/install.sh
@khapota
khapota / vundle.sh
Created August 18, 2017 07:57
Install vundle
#!/bin/bash
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
@khapota
khapota / mongokill.js
Created August 21, 2017 14:18
Kill long query
db.currentOp().inprog.forEach(
function(op) {
if(op.secs_running > 5 && op.op == 'query') printjson(op);
}
)