Skip to content

Instantly share code, notes, and snippets.

@hyzhak
hyzhak / log-leapmotion-websocket.js
Created May 26, 2013 18:26
Short js code to log leapmotion data thought websocket. From article [Leap Motion / Getting started with raw data](http://pressanykeytocreate.blogspot.com/2013/05/leap-motion-getting-started-with-raw.html)
var ws = new WebSocket("ws://localhost:6437/");
ws.onmessage = function(event) {
console.log(event.data);
};
@hyzhak
hyzhak / clear.js
Created June 10, 2013 10:32
Need to clear some cached objects before recreate WebGLRenderer of Pixi.js. To avoid of binding on previous 3D context.
//clear some cached objects in Pixi.js
PIXI._batchs.length = 0;
PIXI.TextureCache = {};
PIXI.BaseTextureCache = {};
@hyzhak
hyzhak / gist:ac6cae5aae10f78aa685
Created May 5, 2014 11:36
How to fail jasmine 2.0 async spec on fail promise (ru)
it('should ....', function(done) {
doAsync().then(function() {
done();
}, function(err) {
//как правильно писать чтобы тест падал в любом случае?
//done(err || 'error') - не работает, т.к. done не обробатывает аргументы;
});
});
@hyzhak
hyzhak / gist:71e9ee218c017f9ce4ef
Created May 5, 2014 11:37
How to fail jasmine 2.0 async spec on fail promise
it('should ....', function(done) {
doAsync().then(function() {
done();
}, function(err) {
//How to fail jasmine 2.0 async spec on fail promise
//done(err || 'error') - doesn't work because 'done' doesn't handle arguments
});
});
@hyzhak
hyzhak / setupLogger.js
Created June 11, 2014 08:17
how to setup Winston logger by nconf
/**
* Setup multiple winston logger:
* https://github.com/flatiron/winston#working-with-multiple-loggers-in-winston
*
* by nconf:
* https://github.com/flatiron/nconf
*/
var winston = require('winston'),
nconf = require('nconf');
@hyzhak
hyzhak / Dockerfile
Created October 25, 2014 11:58
Hello World Test Docker. Try to echo "Hello World!!" to console
# Use phusion/baseimage as base image. To make your builds
# reproducible, make sure you lock down to a specific version, not
# to `latest`! See
# https://github.com/phusion/baseimage-docker/blob/master/Changelog.md
# for a list of version numbers.
FROM phusion/baseimage:0.9.15
MAINTAINER hyzhaka@gmail.com
# Set correct environment variables.
ENV HOME /root
@hyzhak
hyzhak / gist:fb6175e6a0072128b0c1
Last active August 29, 2015 14:08
i18n of MongoDB (Mongoose) - normalization vs de-normalization
// de-normalized
{
"_id": <ObjectId1>,
"name": {
"en": "Eugene",
"uk": "Євген"
}
}
//or normalized
receipt: Oz-Ware Purchase Invoice
date: 2012-08-06
customer:
given: Dorothy
family: Gale
@hyzhak
hyzhak / setup-iss-ustream.sh
Last active February 15, 2017 15:41
Setup live streaming on Raspberry PI v1.0 for International Space Station (http://pressanykeytocreate.blogspot.com/2015/09/live-streaming-of-international-space.html)
#!/bin/bash
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install rtmpdump python-pip
sudo pip install livestreamer
# to get best resolution
sudo apt-get install python-dev
sudo apt-get install libffi-dev
sudo apt-get install librtmp-dev
#!/bin/bash
livestreamer --stream-segment-timeout 100000 --stream-timeout 100000 --http-timeout 100000 ustream.tv/channel/iss-hdev-payload best -np 'omxplayer -o hdmi -live --timeout 100000'