Skip to content

Instantly share code, notes, and snippets.

View afucher's full-sized avatar

Arthur Fücher afucher

View GitHub Profile
@afucher
afucher / iniFileParser.js
Created February 4, 2016 00:25
Grammar from PEGjs for ini file
IniFile
= first: Section (BlankLine* others: Section*) {others.unshift(first); return others; }
Section
= section: SectionHeader "\n" values: KeyValues* {return {section:values}}
SectionHeader
= "[" section_name: word "]" {return section_name}
KeyValues
= a: word "=" value: word "\n"? {var o = {}; o[a]=value; return o;}
var async = require('async');
function copyFileToStructure(filename, done){
async.parallel([
async.apply(teste, filename , 'param'),
async.apply(teste, filename , 'param')
], function(result) {
console.log("poa");
console.log(done);
done();
@afucher
afucher / app.js
Last active August 29, 2015 14:28
Echo from bat file
(function() {
var childProcess = require("child_process");
var oldSpawn = childProcess.spawn;
function mySpawn() {
console.log('spawn called');
console.log(arguments);
var result = oldSpawn.apply(this, arguments);
return result;
}
childProcess.spawn = mySpawn;
@afucher
afucher / gist:1b59c976aa41a1af6621
Created March 5, 2015 14:11
Retorna response de http.get no lugar do response da minha rota
express.get('/', function(req, res){
http.get('www.outrolugar.com.br/api/', function(response){
//Posso fazer isso???
//Ou como faço algo parecido
res = response;
res.end();
})
})
"use strict";
var path = require("path");
var fs = require("fs");
var Twit = require('twit');
var rateLimiter = {};
var luckyNumber = Math.round(Math.random()*60);
var re = /\d+/;
var oauth = JSON.parse(fs.readFileSync("./config/twitter_credentials.js", "UTF8"));