Skip to content

Instantly share code, notes, and snippets.

View jamlfy's full-sized avatar
🏡
Working from home

Jamlfy jamlfy

🏡
Working from home
View GitHub Profile
@jamlfy
jamlfy / dabblet.css
Created March 9, 2013 08:23 — forked from anonymous/dabblet.css
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@jamlfy
jamlfy / tria
Last active April 7, 2018 01:21
Creación de triangulos por less. Esto ayuda a crear triángulos, al lado de una etiqueta.
#arrow {
.left ( @color : blue, @size: 20px, @position : center, @alt : 150px ){
content: "";
position: absolute;
right: 100%;
border-top: @size solid transparent;
border-bottom: @size solid transparent;
border-right: @size solid @color;
z-index : 200;
top: @position;
@jamlfy
jamlfy / gist:5889188
Created June 29, 2013 00:57
Using all machine or pc
var cluster = require('cluster');
var http = require('http');
var free = 250000000;
var sizeWoker = 157286400;
var NumberWorkers = Math.round( ( os.freemem() - free ) / sizeWoker );
if (cluster.isMaster) {
for (var i = 0; i < NumberWorkers; i++) {
cluster.fork();
}
@jamlfy
jamlfy / query.ramdom.js
Last active December 20, 2015 11:29
Random con Query en mongoose Nodejs
module.exports = exports = function (mongo){
var mng = mongo || require('mongoose');
var Query = mng.Query;
Query.prototype.random = function ( query, func ){
var q = typeof query === 'object' ? query : this.query;
var f = typeof query === 'function' ? query : func;
if(!( typeof f === 'function' )) retrun new Error("Is not a function");
this.count(q, function (err, count) {
@jamlfy
jamlfy / see.js
Last active December 24, 2015 08:18
Document watch!!!
/*
var see = require('mongose-watch');
var Player = new Schema({ });
var Game = new Schema({ });
Player.plugin(watch() );
var watchingPlayer = Plaver.findById( MyID ).watch( "_id" );
watchingPlayer.start( function (err, doc){
@jamlfy
jamlfy / pool.js
Last active December 26, 2015 04:29
This program reads a folder or file, and tests, and screen prints only Emails. It is built for large amounts of data.
var fs = require('fs')
var events = require('events')
var util = require('util')
var path = require('path')
var FsPool = function (dir) {
events.EventEmitter.call(this)
this.dir = dir;
this.files = [];
this.active = [];
@jamlfy
jamlfy / balance.js
Last active December 26, 2015 13:29
To balance clustered nodejs actually generates greater stability
const cluster = require('cluster');
const http = require('http');
const httpProxy = require('http-proxy');
const _ = require('underscore');
var numCPUs = 10;
var isPort = 8080;
function estimatePi() {
var n = 10000000, inside = 0, i, x, y;
@jamlfy
jamlfy / file_1.js
Last active December 30, 2015 22:49
Exportación
var connect = function ( config ){
this.db = mongo.createConnection( config.url );
};
// Mis metodos..
// y mas funciones necesarias
exports.Connect = connect;
+ Proyectos/Mis Proyectos
+ node_modules
| + express
| + mongodb
| ....
|
+ Parte/Proyecto A
| + index.js
| ...
+ Parte/Proyecto B
@jamlfy
jamlfy / gist:7939182
Created December 13, 2013 02:52
Exportacion amplia
/// Cuando solo carpetas
var z = fs.readdirSync(__dirname);
for (var i = 0; i < z.length; i++)
if( z[i] != 'index.js' )
exports[ z[i] ] = require(path.join( __dirname, z[i] ) );
// Cuando solo archivos
var z = fs.readdirSync(__dirname);