Skip to content

Instantly share code, notes, and snippets.

@billautomata
billautomata / modular_exponentiation.c
Last active February 5, 2016 04:04
modular multiplicative inverse
#include <msp430.h>
// memory efficient modular exponentiation
//
// calculate c, where - (b^e) mod m = c
// b is the plaintext
// e is the secret key
// m is phi(n) the totient of the public key, a number derived from the public key components
//
@billautomata
billautomata / gist:eda5c5cd98a895493253
Created February 3, 2016 01:57
ttl computer parts list
4-Bit Counter:
74161 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74161&langId=-1&storeId=10001&productId=49664&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView
4-Bit Register (I use two for each 8-bit register):
74LS173 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74LS173&langId=-1&storeId=10001&productId=46922&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView
2-1 Multiplexer:
74LS157 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_46771_-1
16x8 RAM (output needs to be inverted):
@billautomata
billautomata / ssh_tunnels.sh
Last active May 15, 2024 13:22
ssh port forwarding cheatsheet
# local port forwarding
# the target host 192.168.0.100 is running a service on port 8888
# and you want that service available on the localhost port 7777
ssh -L 7777:localhost:8888 user@192.168.0.100
# remote port forwarding
# you are running a service on localhost port 9999
# and you want that service available on the target host 192.168.0.100 port 12340
@billautomata
billautomata / write_iso_to_usb_osx.sh
Last active December 28, 2015 14:08
write file to usb drive and boot it, osx
!#/usr/bin/env bash
sudo diskutil list
sudo diskutil unmountDevice /dev/disk3 # could be disk 2 or disk 4, check the list
sudo dd if=file.iso of=/dev/rdisk3 bs=16m # again, could be disk2 or disk4
@billautomata
billautomata / hrmm.js
Created December 26, 2015 19:46
createDiffieHellman derps
var assert = require('assert')
var crypto = require('crypto')
var fs = require('fs')
var alice = crypto.createDiffieHellman(2048)
alice.setPrivateKey(fs.readFileSync('../alice.private.pem').toString('hex'),'hex')
alice.setPublicKey(fs.readFileSync('../alice.public.pem').toString('hex'),'hex')
var bob = crypto.createDiffieHellman(2048)
bob.setPrivateKey(fs.readFileSync('../bob.private.pem').toString('hex'),'hex')
@billautomata
billautomata / index.html
Created December 19, 2015 01:16 — forked from max-mapper/index.html
play webm video from binary webm data
<body style="width:500px; height:500px;">
<video controls></video>
<script src="index.js"></script>
</body>
@billautomata
billautomata / lib.js
Last active December 11, 2015 20:54
where does this break down?
module.exports = function a(){
var some_variable = 'foo'
function foo(){ console.log(some_variable) }
return {
foo: foo
}
}
a.prototype.__proto__.bar = function(){ console.log('bar') } // the thing standard complains about
@billautomata
billautomata / Secure Sessions Howto
Created December 5, 2015 16:41 — forked from nikmartin/A: Secure Sessions Howto
Secure sessions with Node.js, Connect, and Nginx as an SSL Proxy
Secure sessions are easy, but it's not very well documented, so I'm changing that.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [CLIENT]
To do this, here's what you need to do:
@billautomata
billautomata / mongo_backup.sh
Created November 3, 2015 20:43 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
#!/bin/sh
palette="palette.png"
filters="fps=5,scale=720:-1:flags=lanczos"
# ffmpeg -start_number 33736 -i G00%05d.JPG -r 3 -resize 50% output.gif
ffmpeg -v warning -start_number 33736 -i G00%05d.JPG -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -start_number 33736 -i G00%05d.JPG -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y output.gif