Skip to content

Instantly share code, notes, and snippets.

View kaiquewdev's full-sized avatar

Kaique Silva kaiquewdev

View GitHub Profile
var userComponent = {
fullName: function () { return this.firstName + ' ' + this.lastName; },
get: function (key, value) { return this[key] || (value || ''); },
};
var evandro = Object.create(userComponent, {
'firstName': { value: 'Evandro', enumerable: false },
'lastName': { value: 'Ribeiro', enumerable: false }
});
var ether = require('ether');
var meta = null;
meta = ether({
tree: [
'modules',
'models',
'middlewares',
'controllers',
'fixtures',
{
"name": "{{name}}",
"version": "{{version}}",
"author": "{{author}}",
"public": {{public}},
"main": "{{entryPoint}}"
}
Hello from {{name}}
var gulp = require('gulp');
var spawn = require('child_process').spawn;
var gutil = require('gulp-util');
var gmocha = require('gulp-mocha');
var gwatch = require('gulp-watch');
var gbatch = require('gulp-batch');
function testsTaskHandler ( callback ) {
var paths = [
'./test/**/*.test.js',
@kaiquewdev
kaiquewdev / yeoman-generator.out
Created February 4, 2014 03:26
All tests pass, but this error appears after choose the options 1 in the select menu
/home/sigmund/war/fth-ship/yo/node_modules/yeoman-generator/lib/base.js:341
Object.getPrototypeOf(self)[method].apply(self, args);
^
TypeError: Cannot call method 'apply' of undefined
at /home/sigmund/war/fth-ship/yo/node_modules/yeoman-generator/lib/base.js:341:43
at /home/sigmund/war/fth-ship/yo/node_modules/async/lib/async.js:551:21
at /home/sigmund/war/fth-ship/yo/node_modules/async/lib/async.js:227:13
at iterate (/home/sigmund/war/fth-ship/yo/node_modules/async/lib/async.js:134:13)
at /home/sigmund/war/fth-ship/yo/node_modules/async/lib/async.js:145:25
at /home/sigmund/war/fth-ship/yo/node_modules/async/lib/async.js:229:17
@kaiquewdev
kaiquewdev / watch.js
Created January 11, 2014 15:27
Exemplo de uma ferramenta para debug.
var spawn = require('child_process').spawn;
var fs = require('fs');
var args = process.argv.slice(2);
var program = null;
var filename = args[ 0 ];
function execHandler ( err, stdout, stderr ) {
if ( err ) console.log( 'error: %s', err );
if ( stdout ) console.log( 'stdout: ', stdout );
if ( stderr ) console.log( 'stderr: %s', stderr );
@kaiquewdev
kaiquewdev / jogo-dos-numeros.js
Last active February 27, 2017 22:54
Um dos primeiros exemplos do fth-cast.
#!/usr/bin/env node
// As regras do jogo são simples,
// Você vai jogar contra a maquina e
// Quem formar o numero 15 ganha.
// Mas para formar o numero 15,
// Você só pode adicionar 1, 2, 3
// Até somar 15. Passando disso é empate.
var placar = 0;
var maquinaComeca = !!( Math.max( 0, Math.round( Math.random() * 1 ) ) );
var maquinaJogando = false;

why ./task.js?

One word: task automation. It's basically zero effort and you can use the ./task.js package manager to handle any repetitive tasks. You can use ./task.js to automate everything with minimum effort.

./task.js provides the structure, order, and authority that you as a developer so desperately crave. ./task.js will also take responsibility for your actions if you need it to. It's what everybody is using now. ./task.js is the new hotness. It's all about ./task.js now, just like that.

This is compared to npm run/bash scripts, which are:

@kaiquewdev
kaiquewdev / hell.js
Last active January 2, 2016 00:09
Callback hell? Let me show you a trick.
// Promessas podem resolver a sua vida.
// Mas se o Javascript foi pensado desta forma, com a possibilidade
// de funções dentro de funções, então existiria algum recurso para resolver este problema?
// Bom, não tem um recurso especifico que vai fazer a sua vida mudar, mas com algum conhecimento
// sobre a linguagem, você acaba descobrindo que isso pode acontecer.
// Primeiro exemplo - #1
function sayHello () {