Skip to content

Instantly share code, notes, and snippets.

View paulgreg's full-sized avatar

Grégory Paul paulgreg

View GitHub Profile
@paulgreg
paulgreg / https-self-signed
Created November 9, 2022 15:52
Quickly serve a local directory with TLS using http-server (node) & with self signed certificates
#!/bin/bash -v
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -subj '/CN=localhost' -nodes
npx http-server -S .
@paulgreg
paulgreg / totp.sh
Created February 26, 2020 21:07
A simple oathtool wrapper to generate second factor TOTP token stored in a gpg encrypted file
#!/usr/bin/env bash
if [ -z $1 ]; then
echo
echo "Usage:"
echo " ./totp.sh service"
echo
echo "Configuration: $HOME/.totpkeys.gpg"
echo "File encoded with gpg"
echo "Format: service=key"
exit
@paulgreg
paulgreg / unicorn.py
Last active March 18, 2016 15:33
mitmproxy script to insert unicorns
from netlib.http import decoded
import pprint
def response(context, flow):
if flow.response.headers.get('Content-Type','').startswith("text/html"):
with decoded(flow.response):
flow.response.content = flow.response.content.replace(
"</body>",
"<script>var cornify_count=0,cornify_add=function(){cornify_count+=1;var e=\"http://www.cornify.com/\",t=document.createElement(\"div\");t.style.position=\"fixed\";var n=\"px\",o=.75*Math.random(),r=768,i=1024,c=0,a=document.documentElement;\"number\"==typeof window.innerHeight?(r=window.innerHeight,i=window.innerWidth):a&&a.clientHeight?(r=a.clientHeight,i=a.clientWidth):(n=\"%\",c=Math.round(100*c)+\"%\"),t.onclick=cornify_add,t.style.zIndex=10,t.style.outline=0,15==cornify_count?(t.style.top=Math.max(0,Math.round((r-530)/2))+\"px\",t.style.left=Math.round((i-530)/2)+\"px\",t.style.zIndex=1e3):(\"px\"==n?t.style.top=Math.round(r*o)+n:t.style.top=c,t.style.left=Math.round(90*Math.random())+\"%\");var l=document.createElement(\"img\"),d=new
@paulgreg
paulgreg / pi-gpio-switch
Created March 5, 2016 15:59
Utility to switch Raspberry-Pi GPIO pin functions by Tim Giles 01/04/2013
/*
Utility to switch Raspberry-Pi GPIO pin functions
Tim Giles 01/04/2013
Usage:
$ gpio_alt -p PIN_NUMBER -f ALT_NUMBER
Based on RPi code from Dom and Gert, 15-Feb-2013, <http://elinux.org/RPi_Low-level_peripherals#C_2>
and Gnu getopt() example <http://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html#Example-of-Getopt>
*/
@paulgreg
paulgreg / bookmarklet-sms-free
Created November 21, 2014 21:35
Bookmarklet : send SMS via free mobile
javascript:var u='USERNAME', p='PASSWORD', m = prompt('Message ?'); if (m) {var r = new XMLHttpRequest();r.open('GET', 'https://smsapi.free-mobile.fr/sendmsg?user='+u+'&pass='+p+'&msg='+encodeURIComponent(m), true);r.send(null);}
@paulgreg
paulgreg / rsstodolist.coffee
Created May 15, 2014 07:04
rsstodolist Hubot script
# Description:
# Allows you to send or fetch links to/from the rsstodolist service (https://rsstodolist.appspot.com)
#
# Dependencies:
# jsdom
#
# Configuration:
# None
#
# Commands:
@paulgreg
paulgreg / parallelized-casperjs
Created November 29, 2012 15:57
Parallelized caspers
ls tests/suites/ | /usr/local/bin/parallel "casperjs test tests/suites/{}"
@paulgreg
paulgreg / future
Created July 16, 2012 15:24
Future
var future = function(expectedCalls, action) {
var counter = 0;
return function() {
counter++;
if (counter === expectedCalls) action();
}
}
var products = [ {id:1}, {id:2}, {id:3}, {id:4}, {id:5} ];
@paulgreg
paulgreg / LICENSE.txt
Created November 23, 2011 17:25 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE