Skip to content

Instantly share code, notes, and snippets.

View komuw's full-sized avatar

Komu Wairagu komuw

View GitHub Profile
@komuw
komuw / create_vpn.sh
Last active November 15, 2023 09:12
create vpn
#https://www.zeitgeist.se/2013/11/22/strongswan-howto-create-your-own-vpn/
#https://www.gypthecat.com/ipsec-vpn-host-to-host-on-ubuntu-14-04-with-strongswan
#Example of simple pre-shared keys vpn setup: https://www.strongswan.org/uml/testresults/ikev2/rw-psk-ipv4/
$ sudo apt-get -y install strongswan
$ ipsec version
Linux strongSwan U5.1.2/K3.13.0-55-generic
Institute for Internet Technologies and Applications
University of Applied Sciences Rapperswil, Switzerland
See 'ipsec --copyright' for copyright information.
@komuw
komuw / install_nginx_and_override.yml
Created December 25, 2015 16:16
install nginx and override old config
- name: install newer nginx and ovveride old config file
shell: sudo apt-get -y -o Dpkg::Options::=--force-confnew install nginx
notify: restart nginx
@komuw
komuw / pycrypto_DES3.py
Last active March 28, 2023 06:35
python DES3(triple DES encryption)
`pip install pycrypto`
from Crypto.Cipher import DES3
from Crypto import Random
key = 'Sixteen byte key'
iv = Random.new().read(DES3.block_size) #DES3.block_size==8
cipher_encrypt = DES3.new(key, DES3.MODE_OFB, iv)
plaintext = 'sona si latine loqueri ' #padded with spaces so than len(plaintext) is multiple of 8
encrypted_text = cipher_encrypt.encrypt(plaintext)
@komuw
komuw / pycrypto_AES.py
Created February 15, 2016 14:19
python AES with CBC/PKCS5Padding
from Crypto.Cipher import AES
from Crypto import Random
import base64
block_size = AES.block_size
#unpad = lambda s : s[0:-ord(s[-1])]
def pad(plain_text):
@komuw
komuw / delete_old_git_branches.sh
Last active September 1, 2016 17:06
delete branches that are older than x days
# delete branches that are older than x days
# this will delete branches that havent received any commits that are newer than Aug 10, 2016
# see this answer for a bit more detail: http://stackoverflow.com/questions/10325599/delete-all-branches-that-are-more-than-x-days-weeks-old/39277210#39277210
for k in $(git branch -r | sed /\*/d); do
if [ -z "$(git log -1 --since='Aug 10, 2016' -s $k)" ]; then
branchnew=$(echo $k | sed -e "s/origin\///")
echo deleting branch: $branchnew
git push origin --delete $branchnew
fi
@komuw
komuw / openvpn_client.confs
Last active December 14, 2016 13:51
client config for openvpn
$ sudo apt -y install openvpn
## cat /etc/openvpn/client.conf
remote <PUBLI_IP> 1194
proto udp
ns-cert-type server
client
dev tun
resolv-retry infinite
@komuw
komuw / pritunl_client.confs
Last active February 14, 2017 13:00
configure pritunl vpn client
$ cat /etc/apt/sources.list.d/pritunl.list
deb https://repo.pritunl.com/stable/apt xenial main
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 7568D9BB55FF9E5287D586017AE645C0CF8E292A
sudo apt-get update
sudo apt-get install pritunl-client-gtk
# download profile(vpn config)
# start pritunl client from apps
@komuw
komuw / paypal_express.js
Last active December 24, 2019 05:17
create paypal express checkout app
// create a paypal express checkout app
1. create a sandbox paypal app: https://developer.paypal.com/developer/applications (under REST API apps)
2. copy the app email([email protected]), client_id(Ac3vNqODzxe40U2kczQd92e4CGDor1SVM7GBfHzimCflhTaS6CtHW-jHMwys1RAKFzfLM-vX7xFPfCzo
)
3. use the client_id from above and replace it in the html_snippet below
4. configure webhooks for any events that occur: https://developer.paypal.com/docs/integration/direct/webhooks/rest-webhooks/
example of events that can occur-> https://developer.paypal.com/docs/integration/direct/webhooks/event-names/
5. setup a Return URL - Target URL where users will be redirected after test transactions. Please allow up to 3 hours for the change to go into effect.
6. You will go through the same steps later on when you want to create the proper LIVE prod paypal. app