Skip to content

Instantly share code, notes, and snippets.

View gasp's full-sized avatar
🔧
hacking stuff

Gaspard Beernaert gasp

🔧
hacking stuff
View GitHub Profile
var food = ["kiwi","bananas"],
poo = [],
eat = function(fruit) {
var transformed = (function(fruit) {
return fruit + " shit";
})(fruit);
return transformed;
};
for (var i = food.length - 1; i >= 0; i--) {
@gasp
gasp / slow.js
Created December 31, 2014 09:47
randomly slow server - dev purpose only
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8976,
throttle = 2000; // ms
http.createServer(function(request, response) {
@gasp
gasp / collection.js
Created August 18, 2015 15:22
a prototype-less way to do object with javascript
var Collection = function () {
return {
db: [],
add: function (o) {
if (typeof(o.uid) === 'undefined') {
throw 'error: object has no uid';
}
if (this.get(o.uid) === false) {
this.db.push(o);
}
#include<stdio.h>
main()
{
printf("Hello World");
}
@gasp
gasp / ortc-1.js
Created November 28, 2015 10:41 — forked from kypflug/ortc-1.js
navigator.mediaDevices.getUserMedia ({
"audio": true,
"video": {
width: 640,
height: 360,
facingMode: "user"
}
}).then(
gotStream
).catch(
@gasp
gasp / ortc-7.js
Created November 29, 2015 14:41 — forked from kypflug/ortc-7.js
mySignaller.signalMessage({
"ice": iceGathr.getLocalParameters(),
"dtls": dtlsTr.getLocalParameters(),
"recvAudioCaps": recvAudioCaps,
"recvVideoCaps": recvVideoCaps,
"sendAudioCaps": sendAudioCaps,
"sendVideoCaps": sendVideoCaps
});
Verifying that +gaspard is my blockchain ID. https://onename.com/gaspard
@gasp
gasp / Pilot.ino
Created March 26, 2016 15:27
My first arduino program using HC SRO4, Adafruit Motor Shield 2.3 and an old RC car
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
// these constants won't change:
const int pinTrig = 13; // trigger sound with digital pin 13 (yellow)
const int pinEcho = 12; // green
const int pinLed = 10; // orange
const int threshold = 100; // threshold value to decide when the detected sound is a knock or not
@gasp
gasp / stabilize.js
Created March 31, 2017 13:05
use ms video api to stabilize a video
// doc
// https://westus.dev.cognitive.microsoft.com/docs/services/565d6516778daf15800928d5/operations/565d6517778daf0978c45e35
const fs = require('fs');
const request = require('request'); // use npm i request
const create = (fileUrl) => {
return new Promise(function (resolve, reject) {
request({
method: 'post',
@gasp
gasp / multiple.sh
Created November 27, 2017 11:20
multiple bash processes
#!/usr/bin/env bash
sleep_date() {
echo "starting $1 at $(date)";
sleep $1;
echo "ending $1 at $(date)";
}
echo "starting all $(date)";
sleep_date 10 &