Skip to content

Instantly share code, notes, and snippets.

View amfg's full-sized avatar

Adam Kecer amfg

  • Košice, Slovakia
View GitHub Profile
@amfg
amfg / clean_wap.sh
Created March 14, 2017 17:12
Linux AP
#!/bin/bash
export DEV_IN=wlan0;
ifconfig $DEV_IN down;
/etc/init.d/hostapd stop
/etc/init.d/dnsmasq stop
iptables -Z
iptables -F
iptables -X
ifconfig $DEV_IN up;
@amfg
amfg / handle.sh
Last active July 8, 2021 10:17
Simple GitLab webhook using netcat & bash
#!/bin/bash
read request
TOKEN='secret token from gitlab' # from https://gitlab.com/{user}/{project}/settings/integrations
HAS_TOKEN=0
while /bin/true; do
read header
[[ "$header" =~ 'X-Gitlab-Token' ]] && [[ "$header" =~ $TOKEN ]] && HAS_TOKEN=1;
[[ "$header" == $'\r' ]] && break;
done
@amfg
amfg / encryption.py
Created June 29, 2016 22:43
PGPy usage
#!/usr/bin/python3.4
# requires pgpy >=0.4.0 (latest, as of 06/30/2016)
import pgpy
from pgpy.constants import PubKeyAlgorithm, KeyFlags, HashAlgorithm, SymmetricKeyAlgorithm, CompressionAlgorithm
class Encryption:
@staticmethod
def get_key(name, plain=False):
try:
key = pgpy.PGPKey.from_file('{}.asc'.format(name))[0]
@amfg
amfg / random.js
Created February 7, 2016 13:30
Generate random unicode string
random = function(length) {
var array = new Uint16Array(length);
window.crypto.getRandomValues(array);
var str = '';
for (var i = 0; i < array.length; i++) {
str += String.fromCharCode(array[i]);
};
return str;
}
@amfg
amfg / random.js
Created February 7, 2016 13:08
Generate random base62 string the right way using window.crypto
random = function(length) {
var base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.split('');
var array = new Uint8Array(length);
window.crypto.getRandomValues(array);
var str = '';
for (var i = 0; i < array.length; i++) {
str += base[array[i]%base.length];
};
return str;
}