Skip to content

Instantly share code, notes, and snippets.

View flpms's full-sized avatar

Filipe M. Silva flpms

View GitHub Profile
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
@flpms
flpms / number
Created January 7, 2015 15:38
Regex para telefones no padrão brasileiro
/^(\([0-9]{2}\))(\s|)([0-9]{4}|[0-9]{5})\-([0-9]{4})$|(^[0-9]{3}|^([0-9]{4})(\s|)([0-9]{3})(\s|)([0-9]{6})|[0-9]{4})$/g
const http = require('http');
const callback = function(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.write('Recebido com sucesso');
response.end();
};
http.createServer(callbackFunction).listen(1337,'127.0.0.1');
//Foi incluido um console.log aqui para saber qual porta e endereço você pode usar
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
@flpms
flpms / form-to-json.js
Created November 28, 2015 21:58
Simple way to parse a form to json with native code
var i, input, obj = {};
var inputs = document.querySelectorAll('form input');
for (i = 0; i < inputs.length; i++) {
input = inputs[i];
obj[input.id] = input.value;
}
console.log(obj);
@flpms
flpms / gist:5344ac4ee45b63ed2d87
Created January 20, 2016 13:37
Several javascripts(ES6) snippets. Generate each <snippet> as different file
//This configure your application for ES6
<snippet>
<content><![CDATA['use strict';]]></content>
<tabTrigger>'us</tabTrigger>
<scope>source.js</scope>
</snippet>
//This create module exports, with you using node
<snippet>
<content><![CDATA[module.exports = ${1};]]></content>
@flpms
flpms / simple-strap.json
Created January 27, 2016 17:40 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
mocha --recursive
var fatorDesq;
var rs = this.getField("rs").value;
var rt = this.getField("rt").value;
var st = this.getField("st").value;
var valores = [rs, rt, st];
valores.sort(function(maior, menor) {
if (maior > menor) return -1;
if (maior < menor) return 1;
if (maior === menor) return 0;
@flpms
flpms / commands.bat
Created May 16, 2016 14:17
this bat file associate linux commands to commands in windows
doskey alias = doskey $*
doskey cat = type $*
doskey clear = cls
doskey cp = copy $*
doskey cpr = xcopy $*
doskey grep = find $*
doskey history = doskey /history
doskey kill = taskkill /PID $*
doskey ls = dir $*
doskey man = help $*