Skip to content

Instantly share code, notes, and snippets.

@gitawego
gitawego / queue.js
Last active August 29, 2015 14:04
task buffer method
function queue(tasks, scope) {
var slice = Array.prototype.slice,task, on ={}, error;
function next() {
if (task = tasks.shift()) {
task.apply(scope, [next].concat(slice.call(arguments, 0)));
}else{
on.done && on.done();
}
}
next.error = function(err){
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
var socketIO = require('socket.io'),
io;
// hapi plugin registration
exports.register = function(plugin, options, next) {
// this is the hapi specific binding
io = socketIO.listen(plugin.servers[0].listener);
io.sockets.on('connection', function(socket) {
socket.emit({msg: 'welcome'});
@gitawego
gitawego / generator-test.js
Last active August 29, 2015 14:10
generator example
var commonJs = function(src,callback){
setTimeout(function(){
callback(null,{
src:src,
style:"commonJs"
});
},100);
}
var commonJsError = function(src,err,callback){
setTimeout(function(){
var os = require('os');
var ifaces = os.networkInterfaces();
Object.keys(ifaces).forEach(function (ifname) {
var alias = 0
;
ifaces[ifname].forEach(function (iface) {
if ('IPv4' !== iface.family || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
/*
Plugin: jQuery Parallax
Version 1.1.3
Author: Ian Lunn
Twitter: @IanLunn
Author URL: http://www.ianlunn.co.uk/
Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/
Dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php
/**
* media streaming
* @method streamMedia
* @param {String} path file path
* @param {Object} ioArgs a http connection
* @param {Object} ioArgs.req request object of a http connection
* @param {Object} ioArgs.res response object of a http connection
* @param {Object} ioArgs.next passe to not found
*/
function streamMedia(path, ioArgs) {
@gitawego
gitawego / websocket.conf
Created June 4, 2015 10:34
nginx config for websocket
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 192.168.100.10:8010;
}
server {
@gitawego
gitawego / captcha.js
Created July 31, 2015 12:51
simple captcha in angular
angular.module('myApp.directives', [])
.directive('captcha', function () {
return {
scope: { ngData: '@', ngClick: '@' },
restrict: 'A',
link: function (scope, el, attrs) {
var canvas = el[0];
var context = canvas.getContext("2d");
var fontsize = 14;
@gitawego
gitawego / .eslintrc.json
Last active March 3, 2016 12:35
eslint setting
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": "airbnb/base",
"rules": {
"semi": 2,