Skip to content

Instantly share code, notes, and snippets.

View manrueda's full-sized avatar

Manuel Rueda manrueda

View GitHub Profile
@manrueda
manrueda / interceptor.js
Created April 14, 2016 17:00
Intercept angular.module function before his creation
window.angular = {};
window.angular.modules = {};
var originalModuleFunc;
var customFunction = function(){
if (arguments.length > 1) {
angular.modules[arguments[0]] = originalModuleFunc.apply(null, arguments);
return angular.modules[arguments[0]];
}else{
return originalModuleFunc.apply(null, arguments);
@manrueda
manrueda / mouse.js
Created December 6, 2015 01:51 — forked from bfncs/mouse.js
Read Linux mouse(s) in node.js
/**
* Read Linux mouse(s) in node.js
* Author: Marc Loehe (marcloehe@gmail.com)
*
* Adapted from Tim Caswell's nice solution to read a linux joystick
* http://nodebits.org/linux-joystick
* https://github.com/nodebits/linux-joystick
*/
var fs = require('fs'),
@manrueda
manrueda / example.js
Last active October 10, 2015 20:58
New line parse in environment variables
// set the TEST environment variable with TEST=first line\\n\\nsecond line\\n
// you need to duplicate the \ to scape it
function parseEnvVarible(envVar){
return new Buffer(envVar.split('\\n').join(require('os').EOL), 'UTF-8').toString('UTF-8');
}
console.log('Wrong: ' + process.env.TEST);
console.log('Right: ' + parseEnvVarible(process.env.TEST));
@manrueda
manrueda / HeavyWork.js
Created September 11, 2015 02:58
Async a function with WebWorkers
function HeavyWork(func, param, cb){
if (window.Worker){
var strFunc = 'onmessage = function(event) {' +
' postMessage((' + func.toString() + ')(event.data));' +
'}';
var blob = new Blob([strFunc], {type: 'application/javascript'});
var work = new Worker(URL.createObjectURL(blob))
@manrueda
manrueda / Example.cs
Last active August 29, 2015 14:26
Request Piper
using System;
using System.Collections.Generic;
using System.Net;
using System.Web.Mvc;
namespace MySite.Controllers
{
public class ServersController : Controller
{
@manrueda
manrueda / ClientInfo.js
Last active August 29, 2015 14:25
OS and Browser detector
function ClientInfo(){
this.windows = false;
this.linux = false;
this.osx = false;
this.osArch = {
x86: false,
x64: false,
PowerPC: false
};
this.osVersion = {
@manrueda
manrueda / index.js
Created February 11, 2015 22:41
Segmentation fault (core dumped) - Node 0.12.0
var sql = require('mssql');
sql.connect({
user: 'XXXX',
password: 'XXXXX',
database: 'XXXXX',
server: 'XXXXX'
}, function(err){
});