Skip to content

Instantly share code, notes, and snippets.

View hughrawlinson's full-sized avatar

Hugh Rawlinson hughrawlinson

View GitHub Profile
@hughrawlinson
hughrawlinson / server.js
Last active February 11, 2016 11:46
A Node server for showing temperature from a sensor on a Raspberry Pi
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('<html><body><h1>Welcome to W1-TempServ</h1>\n');
var temp = '';
fs.readFile('/home/simon/temp', 'utf8', function (err, data) {
if (err) throw err;
console.log(data);
res.write("<p>"+data+"</p></body></html>");
res.end();
});
@hughrawlinson
hughrawlinson / crossfade.js
Last active February 11, 2016 11:45
Web Audio Crossfader
var vineVideoElement = document.getElementById('vineVideo');
var instVideoElement = document.getElementById('instVideo');
var instGain;
var vineGain;
window.AudioContext = window.AudioContext||window.webkitAudioContext;
var context = new AudioContext();
function initCrossfade(){
vineVideoElement.play();
instVideoElement.play();
@hughrawlinson
hughrawlinson / logComments.js
Last active December 20, 2015 05:28
A short script to log html comments on a webpage, for use in a bookmarklet.
var content = document.body.innerHTML;;
var comments = content.match(/<!--.*?-->/g);
if(comments!=null|comments!=undefined){
for (var x = 0; x < comments.length;x++){
console.log(comments[x]);
}
}
else{
console.log('No Comments');
}
@hughrawlinson
hughrawlinson / bogo-bruteforce.js
Last active February 11, 2016 11:46
Bogo brute force example
function makepw(){
var text = "";
var len = random(1,15)
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < len; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
@hughrawlinson
hughrawlinson / dogepoem.doge
Last active February 11, 2016 11:44
much dogescript, many error, wow
shh much dogcodez, many errorz, wow
very dog is 'shit zoo'
such woofDog
plz console.loge with dog
wow
while(dog == 'shit zoo'){
rly 0.9 <= Math.random()
@hughrawlinson
hughrawlinson / README.md
Last active March 18, 2016 16:06
New and improved, in Javascript everything's a cat.

Cat.js

Replaces all the images on a webpage with pictures of cats. Now in ES2015!

@hughrawlinson
hughrawlinson / private_functions.js
Last active February 11, 2016 11:43
Private functions in ES5
module.exports = function(){
var self = {};
//constructor stuff here
var private = 1;
self.public = 2;
var privateFunction = function(){
console.log('this is a private function');
@hughrawlinson
hughrawlinson / fuzzylogic.c
Last active November 11, 2021 10:21
A small operation of basic fuzzy logic functions in C++
/**
@file fuzzylogic.c
@ingroup mc2liveAlg
hugh rawlinson - [email protected]
**/
#include <stdio.h>
double fuzzyOR(double a, double b){
@hughrawlinson
hughrawlinson / keybase.md
Last active February 11, 2016 11:44
Keybase Proof

Keybase proof

I hereby claim:

  • I am hughrawlinson on github.
  • I am hugh (https://keybase.io/hugh) on keybase.
  • I have a public key whose fingerprint is 9DF4 5AF7 0122 2683 1AC2 5128 9C1A C9F8 BCFC 89C9

To claim this, I am signing this object:

@hughrawlinson
hughrawlinson / heartbt.ck
Last active February 11, 2016 11:43
Synthesises an approximation of the sound of a hearbeat
int bpm;
// set the beats per minute here
60 => bpm;
// this signal flow approximates the timbre shown at:
// http://www.bsignetics.com/cases/ASD.ht65.gif
Noise n => HPF h => LPF l => ADSR e => dac;
int third;
int twothird;
60000/bpm/3 => third;