Skip to content

Instantly share code, notes, and snippets.

View jadaradix's full-sized avatar
🙂
existing

James Garner jadaradix

🙂
existing
View GitHub Profile
@jadaradix
jadaradix / facebook-stalk.js
Last active August 29, 2015 14:12
Stalk people on Facebook. Console this!
var as = ""; var s = false; var t; var f; var c = function() { f = $("#f").contentWindow; var ts = ($(".fbLastActiveTimestamp", f.document).childNodes[0].data == "active now"); if (s != ts) { s = ts; var cd = new Date(); var st = (s ? "online" : "offline") + "," + cd.getHours() + ":" + cd.getMinutes(); console.log(st); as += st + "\n"; } f.location.reload(); }; var stop = function() { clearInterval(t); }; var start = function() { $("body").insertAdjacentHTML('afterbegin', '<iframe id="f" src="https://m.facebook.com/messages/read/?tid=id.289725077795063"></iframe>'); t = setInterval(c, 30 * 1000); }; start();
@jadaradix
jadaradix / facebook-stalk-continuously.js
Created December 30, 2014 03:15
Facebook Stalk continuously. Console this!
var as = ""; var s = false; var t; var c = function() { var f = $("#f").contentWindow; var ts = ($(".fbLastActiveTimestamp", f.document).childNodes[0].data == "active now"); var cd = new Date(); var st = cd.getHours() + ":" + cd.getMinutes() + "," + (s ? "online" : "offline"); console.log(st); as += st + "\n"; f.location.reload(); }; var stop = function() { clearInterval(t); }; var start = function() { $("body").insertAdjacentHTML('afterbegin', '<iframe id="f" src="https://m.facebook.com/messages/read/?tid=id.289725077795063"></iframe>'); t = setInterval(c, 60 * 1000); }; start();
@jadaradix
jadaradix / deploy-aws.sh
Last active August 29, 2015 14:15
"One step" deployment for AWS. As close as it gets.
apt-get update
apt-get install nodejs -y
apt-get install npm -y
ln -s /usr/bin/nodejs /usr/bin/node
npm install
npm install -g grunt-cli
npm install forever -g
apt-get install ruby -y
gem install sass --no-ri --no-rdoc
grunt
@jadaradix
jadaradix / wk-get.sh
Last active September 19, 2015 20:59
Install wkhtmltopdf and wkhtmltoimage on Ubuntu/apt-get tasty flavours.
mkdir tmp
cd tmp
wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb -O x.deb
ar vx x.deb
tar xf data.tar.xz
mv usr/local/bin/* ../
cd ..
rm -rf tmp
@jadaradix
jadaradix / do-ubuntu-node.sh
Last active September 19, 2015 21:00
Make a DigitalOcean Ubuntu Node.js HTTP Server from scratch. Handy.
apt-get update
apt-get install nodejs -y
apt-get install npm -y
npm install http-server -g
ln -s /usr/bin/nodejs /usr/bin/node
echo "Hello, World" > index.html
http-server -p 80
@jadaradix
jadaradix / rename-github-org-remotes.sh
Last active September 23, 2015 11:18
Renaming a GitHub organisation with a folder of repos referencing the old remote.
for i in $(/usr/bin/find $(pwd) -maxdepth 1 -type d); do
if [ $(pwd) != $i ]
then
cd "${i##*/}";
git remote set-url origin "git@github.com:OrganisationName/${i##*/}.git"
git remote -v;
cd ..;
fi
done
<!-- BASED ON https://codepen.io/2ne/pen/osvpj -->
<html>
<head>
<style>
.ios {
font-family: sans-serif;
line-height: 26px;
position: relative;
width: 500px;
@jadaradix
jadaradix / sqlite-bash-list-columns.sh
Created November 14, 2016 19:02
sqlite-bash-list-columns.sh
#!/bin/bash
# output: id, name, age
DATABASE_PATH="database.db";
TABLE_NAME="table";
LIST=$(sqlite3 $DATABASE_PATH "PRAGMA table_info($TABLE_NAME)");
for ROW in $LIST; do
printf $ROW | awk '{split($0,a,"|"); printf "%s, ", a[2]}';
done
@jadaradix
jadaradix / async-await-nodejs.js
Created June 2, 2017 21:24
async-await-nodejs
'use strict';
async function boot () {
async function getName () {
if (false) {
return new Promise(
resolve => {
setTimeout(() => resolve('James'), 1000);
}
@jadaradix
jadaradix / hapi-dynamic-cors.js
Created June 16, 2017 11:12
hapi-dynamic-cors.js
const Hapi = require('hapi');
const allowedOrigins = [];
const middleware = function addCorsHeaders (request, reply) {
// not cors
if (!request.headers.origin) {
return reply.continue()
}