Skip to content

Instantly share code, notes, and snippets.

View qzaidi's full-sized avatar
💭
smiling

Qasim Zaidi qzaidi

💭
smiling
View GitHub Profile
@qzaidi
qzaidi / jq-cheat.md
Last active August 19, 2022 07:23
jq cheat sheet

Convert json to csv

cat json | jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv'

Alternative method, handles nested objects

Create a file named filter.jq

@qzaidi
qzaidi / quarantine-mac
Created June 26, 2022 07:17
remove quarantine
xattr -d com.apple.quarantine /path/to/file
@qzaidi
qzaidi / gist:f2a8ebf51daa8479f62788db753e2b81
Created May 25, 2022 08:55 — forked from danielestevez/gist:2044589
GIT Commit to an existing Tag
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
@qzaidi
qzaidi / unicode.txt
Created December 22, 2020 08:54
unicode - farsi
Various unicode utilities
https://www.online-toolz.com/tools/text-unicode-entities-convertor.php
@qzaidi
qzaidi / openssl
Created May 31, 2020 15:49
SSL Certs verification
## To fetch a cert chain and make server.crt ##
openssl s_client -showcerts -verify 5 -servername aaacertificateservices.test.certificatetest.com -connect aaacertificateservices.test.certificatetest.com:443
## To view validity
echo | openssl s_client -servername api.snapp.site -connect api.snapp.site:443 2>/dev/null | openssl x509 -noout -dates
@qzaidi
qzaidi / vpn.sh
Created March 31, 2020 12:43
Openfortivpn bitbar script
#!/bin/bash
# Run sudo visudo and whitelist your user, eg
#qasim ALL=(ALL) NOPASSWD: /usr/local/bin/openfortivpn
#qasim ALL=(ALL) NOPASSWD: /usr/bin/killall -2 openfortivpn
VPN_EXECUTABLE=/usr/local/bin/openfortivpn
VPN_EXECUTABLE_PARAMS="-c $HOME/vpn" # Optional
VPN_INTERFACE=ppp0
# Command to determine if VPN is connected or disconnected
VPN_CONNECTED="/sbin/ifconfig | egrep -A1 $VPN_INTERFACE | grep inet"

echo "show errors" | socat unix-connect:/var/lib/haproxy/run/haproxy.sock stdio | more

AnyConnect VPN

Get a entry level burstable instance with alicloud with ubuntu 18.04 on it.

  1. Install ocserv, easy-rsa and firewalld
    apt-get update
    apt install ocserv git firewalld
    git clone https://github.com/OpenVPN/easy-rsa
# First, setup the vpn on your pi-zero. For me, this entails
openfortinet -c vpn
# This will create a ppp0 interface, via which we want to allow tunneling to the whole network.
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE