Skip to content

Instantly share code, notes, and snippets.

View victorkurauchi's full-sized avatar
🎯
Focusing

Victor Kurauchi victorkurauchi

🎯
Focusing
View GitHub Profile
var querystring = require('querystring')
, http = require('http');
var data = querystring.stringify({
username: 'yourUsernameValue',
});
var options = {
host: 'http://localhost',
port: 3000,
app.use(express.methodOverride());
// ## CORS middleware
//
// see: http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
/**
* Originalmente escrito por DGmike
* http://code.google.com/p/cidades-estados-js/
*/
/* Dom Ready */
window.onDomReady = function dgDomReady(fn){
if(document.addEventListener) //W3C
document.addEventListener("DOMContentLoaded", fn, false);
else //IE
var str = 'http://www.ultrafarma.com.br/produto/detalhes-21980/noctal_2mg_20_cp__b1_.html'
, word = 'detalhes-'
, reference = ''
, idx = str.indexOf(word);
alert(idx);
if (idx > -1) {
var my = str.substr(idx + word.length);
var limite = my.match(/\//ig);
var ok = my.split(limite);
function snake(string) {
var my = string.replace(/([ ])/g, function($1) {
//alert($1);
return "_";
});
alert(my);
@victorkurauchi
victorkurauchi / install-comodo-ssl-cert-for-nginx.rst
Created September 23, 2015 17:00 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

var $input = $('.datepicker').pickadate();
var picker = $input.pickadate('picker');
picker.on('open', function() {
console.log('Opened.. and here I am!');
})
$('button').on('click', function(event) {
event.stopPropagation();
picker.open();
});
var bonds = [];
var limit = 6;
var leftZeros = limit - bonds[i].idTitulo.length;
var idTituloCompleted = '';
console.log("n", bonds[i].idTitulo);
console.log("leftZeros", leftZeros);
while (leftZeros) {
console.log("oi left zero", idTituloCompleted)
idTituloCompleted += "0";
var items = [1, 2, 3, 4, 5];
var fn = function asyncMultiplyBy2(v){ // sample async action
return new Promise(resolve => setTimeout(() => resolve(v * 2), 100));
};
// map over forEach since it returns
var actions = items.map(fn); // run the function over all items.
// we now have a promises array and we want to wait for it
const cluster = require('cluster');
const PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
//
// You can also of course get a bit fancier about logging, and
// implement whatever custom logic you need to prevent DoS
// attacks and other bad behavior.