Skip to content

Instantly share code, notes, and snippets.

@bytespider
bytespider / boilerplate.coffee
Created July 8, 2011 05:51
jsOAuth boilerplate for PIN based authentication in javascript
openAuthoriseWindow = (url) ->
waitForPin = ->
if wnd.closed
pin = prompt("Please enter your PIN", "")
oauth.setVerifier pin
oauth.fetchAccessToken getSomeData, failureHandler
else
setTimeout waitForPin, 100
wnd = window.open(url, "authorise")
setTimeout waitForPin, 100
@bytespider
bytespider / gateway.ino
Created December 5, 2017 17:13
ESP NOW
/**
*
* Author: Andreas Spiess, 2017
* Author: Rob Griffiths
*
This sketch receives ESP-Now message and sends it as an MQTT messge
It is heavily based on of Anthony's gateway setch sketch
https://github.com/HarringayMakerSpace/ESP-Now
Anthony Elder
@bytespider
bytespider / benchmark.sh
Created October 10, 2012 11:24 — forked from peterjmit/benchmark.sh
Bash Benchmark Script (using time)
#!/bin/bash
# REQUIRES SUDO
# Benchmark runner
repeats=20
output_file='benchmark_results.csv'
command_to_run='echo 1'
run_tests() {
# --------------------------------------------------------------------------
@bytespider
bytespider / imagick_transparency.php
Created November 8, 2016 10:40
Setting the background colour of a transparent PNG when converted to JPEG
<?php
$image = new Imagick('kiwi.png'); // https://s13.postimg.org/hakfstg1j/kiwi.png
$image->setImageBackgroundColor(new ImagickPixel('white')); // set the background color of the image
$image->setImageAlphaChannel(Imagick::ALPHACHANNEL_BACKGROUND); // ALPHACHANNEL_BACKGROUND is undocumented and has a value of 2
// save a JPEG
$image->setImageFormat('jpeg');
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
@bytespider
bytespider / LICENSE.txt
Created June 4, 2011 11:46 — forked from 140bytes/LICENSE.txt
140byt.es -- convert string to array of UTF-8 bytes
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
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage showvminfo debian --machinereadable
name="debian"
groups="/"
ostype="Debian (64 bit)"
UUID="323105ea-d8f6-4898-ae9e-459b3d642b23"
CfgFile="/Users/rgrif/VirtualBox VMs/debian/debian.vbox"
SnapFldr="/Users/rgrif/VirtualBox VMs/debian/Snapshots"
LogFldr="/Users/rgrif/VirtualBox VMs/debian/Logs"
hardwareuuid="323105ea-d8f6-4898-ae9e-459b3d642b23"
@bytespider
bytespider / menu.sh
Created May 29, 2012 17:44
bash menu
#!/bin/sh
# Author: Rob Griffiths
# Based on work from http://www.unix.com/shell-programming-scripting/27099-drop-down-menu-bash-timezone-select.html
# Licence: MIT
# Copyright (c) 2012 Rob Griffiths
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
[
{
"keys": ["enter"],
"command": "run_macro_file",
"args": {
"file": "res://Packages/Default/Add Line in Braces.sublime-macro"
},
"context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
@bytespider
bytespider / gwladys_street_trading_number.txt
Last active December 29, 2015 17:39
Gwladys Street Trading. They spammy mother fuckers need reporting. Collecting all offending numbers owned by them.
07730 217 054
07730 217 064
07730 217 073
07730 217 076
07730 217 080
07730 217 093
07730 217 098
07730 217 100
07730 217 117
07730 217 131
@bytespider
bytespider / auth.js
Last active December 24, 2015 09:39
Authenticating Geddy.js with Passport HTTP Bearer
var passport = require('passport');
var BearerStrategy = require('passport-http-bearer').Strategy;
var Posts = function () {
var strategy = new BearerStrategy({ session: false }, function ( token, done ) {
if (token == '1234567890') {
return done(null, {username: "someuser"});
}
return done(null);