Skip to content

Instantly share code, notes, and snippets.

@mscalora
mscalora / base64-min.js
Created July 22, 2017 14:04
ncerminara lost Base64 gist - javascript base64 encode decode minified, semicolon added, unneeded escaping removed.
/** ncerminara lost Base64 gist javascript base64 encode decode **/
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n
@mscalora
mscalora / mac-lookup.sh
Created July 10, 2017 23:47
Lookup MAC vendor
curl "http://www.whatsmyip.org/mac-address-lookup/maclookup.php" --data 'q=00%3A18%3A61%3A18%3Ac6%3A91' -H 'Referer: http://www.whatsmyip.org/mac-address-lookup/'
@mscalora
mscalora / pi-sync.sh
Created July 4, 2017 22:14
download files to raspberry pi slideshow system
#! /usr/bin/env bash
echo Syncing $(date) >>/var/log/show.log
ls -1R data/?/*.jp*g >before.txt
rsync -av --include="/?/" --include="/?/*" --exclude="*" --include=1 h4g:"www/cdpf-sites/kitchen/data/" /home/pi/data
ls -1R data/?/*.jp*g >after.txt
if diff before.txt before.txt | egrep '\.jp.?g' >diff.txt ; then
@mscalora
mscalora / pi-run.sh
Created July 4, 2017 22:13
display slideshow on raspberry pi
#! /usr/bin/env bash
COUNT=$(ls -1 data/ | wc -l)
NUM=$(python -c 'import time; print (int(time.time())/600%'${COUNT}'+1)')
NUM2=$(expr $(date "+%s") / 600 % \( $COUNT + 1 \) )
echo -n "Run what=$NUM when=$(date) pi=$NUM vs sh=$NUM2 $NUM:$NUM2"
HOME=${HOME-:/home/pi}
DELAY=8
@mscalora
mscalora / latest-nano-instructions.md
Last active July 24, 2017 21:40
Install the latest nano on debian or ubuntu quickly from debian unstable with apt apt-get, works great on raspbian too

I've found this to be the easiest and quickest way when I setup a lean VM with a debian based distro (like debian-cloud, Ubuntu server, Lubuntu, etc) and/or Raspberry Pi (raspbian):

Edit apt sources list with:

sudo nano /etc/apt/sources.list

Add the following lines at the bottom:

deb http://ftp.debian.org/debian unstable main

deb-src http://ftp.debian.org/debian unstable main

# pipe filter
python -c 'import json,sys; d = json.load(sys.stdin); print(json.dumps(d,separators=(",", ":")))'
# Simple "jump box" scenario
# For any user with the same userid on all three systems
# jump from source.example.com to dest.example.com via jump.example.com
# using default ports
# using local keys (e.g. ~/.ssh/id_rsa on source.example.com)
#
# English: ssh from source.example.com to dest.example.com when dest.example.com is not
# using a ssh
Host jump-to-dest
#!/usr/bin/env bash
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "" ]] ; then
printf "Usage:\n\tonsubnet [ --not ] partial-ip-address\n\n"
printf "Example:\n\tonsubnet 10.10.\n\tonsubnet --not 192.168.0.\n\n"
printf "Note:\n\tThe partial-ip-address must match starting at the first\n"
printf "\tcharacter of the ip-address, therefore the first example\n"
printf "\tabove will match 10.10.10.1 but not 110.10.10.1\n"
printf "\tSee: http://stackoverflow.com/questions/40746463/how-to-automatically-switch-ssh-config-based-on-local-subnet\n"
exit 0
@mscalora
mscalora / HOWTO.md
Last active November 21, 2016 04:43
Setup to hack motioneye on macOS

Assuming pip is running clean without sudu

Note: it's a good idea to create your own fork on github, if you do, use your github id in place of 'ccrisan' on the second line

`cd ~/dev git clone https://github.com/ccrisan/motioneye.git cd motioneye mkdir -p /usr/local/etc/motioneye mkdir -p /usr/local/var/motioneye mkdir -p /usr/local/var/lib/motioneye

jQuery('.holdingsGrid > .dataRow').each(function(){
var t = $('.ticker',this).clone(); t.find('small').text('');
console.log((t.text().trim()||'n/a')+'|'+$('.ticker small',this).text()+'|'+$('.quantity p',this).text()+'|'+$('.price p',this).text()+'|'+$('.value p',this).text());
}); 0