Skip to content

Instantly share code, notes, and snippets.

View gabrielstuff's full-sized avatar

Gabriel gabrielstuff

View GitHub Profile
@gabrielstuff
gabrielstuff / sizeof.js
Created December 20, 2016 11:25
Size of Image
function sizeOf(url, callback) {
var image = new Image();
image.src = url;
image.onload = function () {
callback && callback(null, {width: image.width, height: image.height, ratio: image.width/image.height, img: image})
}
image.onerror = function(){
callback && callback('error')
}
}
@gabrielstuff
gabrielstuff / preLoadInCache.js
Created December 15, 2016 17:08
Precache images based on JSON response
'use strict'
var queue = require('async').queue
var cache = require("imgcache")
var _ = require('lodash')
// query the stories
// query content of eachStories
// then findURLInObject
@gabrielstuff
gabrielstuff / globalTool.json
Last active October 15, 2016 11:59
Set of global npm
{
"bistre":"1.0.1",
"budo":"8.3.0",
"cordova":"6.3.1",
"devtool":"2.0.3",
"firebase-tools":"3.0.7",
"generator-babel-boilerplate":"10.0.1",
"gulp":"3.9.1",
"hihat":"2.6.4",
"hotel":"0.5.4",
@gabrielstuff
gabrielstuff / client.js
Last active September 2, 2016 21:16 — forked from sahat/client.js
Calculate client-server latency using socket.io
var socket = require('socket.io-client')('http://spacebro.space:8080');
var startTime;
setInterval(function() {
socket.emit('latency', Date.now(), function(startTime) {
var latency = Date.now() - startTime;
console.log(latency);
})
}, 2000);
@gabrielstuff
gabrielstuff / bodyframe.json
Last active May 2, 2016 16:11
a body frame from kinect
{
"bodies": [
{
"bodyIndex": 0,
"tracked": false
},
{
"bodyIndex": 1,
"tracked": false
},
require('shelljs/global')
var fs = require('fs')
var handlebars = require('handlebars')
var targz = require('tar.gz')
var file = './pm2-auto.json'
cd('test-settings')
rm('-rf', '.build');
var meteorSettingsFile = fs.readFileSync('./test.json', "utf8")
var pm2startTemplate = handlebars.compile(fs.readFileSync('./pm2-start.tpj', "utf8"))
@gabrielstuff
gabrielstuff / get_history.js
Created March 2, 2016 11:09
history from periscope
const request = require('request')
const _ = require('lodash')
const postData = {
access_token:"28h9_iVDARWp5YD8R9_9c4ECK6kcLyXl6cRmc2m28htKORykzgU9w3QkYkUFLc98K61_Ecc9y4-j3bwvW9UpyinCPnf0FfG4bbkwvEwVqPA8ozyXtxd3zJaAo6DMDcVbRqU1XPMnQrk3FIgAwijyGYRft3LvvGd-ALYuI3xg_7R-5yamkd49xgnG6FduR7iuENi5TavP1vCKGaC2Dyia8Z99nWst8-bcwe5Y2beKjB0qcGLJdjFeHEsatox2jBmUuR-CmmPjS57Cz",
cursor:"",
limit:1000,
since:0
}
var url = 'https://chatman-eu-central-1.periscope.tv/k=1ypKdWqyPOgxW/chatapi/v1/history'
{
"access_token":"28h9_iVDARWp5YD8R9_9c4ECK6kcLyXl6cRmc2m28htKORykzgU9w3QkYkUFLc98K61_Ecc9y4-j3bwvW9UpyinCPnf0FfG4bbkwvEwVqPA8ozyXtxd3zJaAo6DMDcVbRqU1XPMnQrk3FIgAwijyGYRft3LvvGd-ALYuI3xg_7R-5yamkd49xgnG6FduR7iuENi5TavP1vCKGaC2Dyia8Z99nWst8-bcwe5Y2beKjB0qcGLJdjFeHEsatox2jBmUuR-CmmPjS57Cz",
"cursor":"",
"limit":1000,
"since":0
}
@gabrielstuff
gabrielstuff / index.js
Created February 16, 2016 08:12
requirebin sketch
var machina = require('machina')
require('blissfuljs')
var vehicleSignal = new machina.Fsm( {
// the initialize method is called right after the FSM
// instance is constructed, giving you a place for any
// setup behavior, etc. It receives the same arguments
// (options) as the constructor function.
initialize: function( options ) {
@gabrielstuff
gabrielstuff / index.js
Created February 1, 2016 11:08
requirebin sketch
var superagent = require('superagent')
require('superagent-cache')()
var uri = 'http://keepcontrol.space/swanmgmt/wp-json/menu/v2/menu?slug=main'
superagent
.get(uri)
.end(function (error, response){
console.log(response.body)
}
)