Skip to content

Instantly share code, notes, and snippets.

View gpedro's full-sized avatar

Gabriel Pedro gpedro

View GitHub Profile
@gpedro
gpedro / README.md
Created June 20, 2017 04:12
regex-benchmark
RegExp#newInstance x 3,181,722 ops/sec ±1.59% (79 runs sampled)
RegExp#storedInstance x 13,501,235 ops/sec ±1.20% (84 runs sampled)
inline#jit x 7,129,021 ops/sec ±1.07% (82 runs sampled)
inline#stored x 13,703,416 ops/sec ±0.90% (84 runs sampled)
Fastest is inline#stored,RegExp#storedInstance

package.json

@gpedro
gpedro / INSTALL.md
Created October 27, 2016 15:44
shortcut to open godoc from github repository

Minified Version

javascript:(function(t,o){if("github.com"===o.hostname){var n=o.pathname,i=n.split("/")[1],a=n.split("/")[2],c=function(){return/^\/[^\/]+\/[^\/]+/.test(o.pathname)};c()&&t.open("https://godoc.org/github.com/"+i+"/"+a)}})(window,location);

Full Version

javascript:(function(w, l){
  // functions & variables
 // powered by sindresorhus@refined-github
@gpedro
gpedro / my-vertx-application
Created August 1, 2016 13:54 — forked from cescoffier/my-vertx-application
Vert.x init.d service script
#!/bin/bash
###
# chkconfig: 345 20 80
# description: Vert.x application service script
# processname: java
#
# Installation (CentOS):
# copy file to /etc/init.d
# chmod +x /etc/init.d/my-vertx-application
@gpedro
gpedro / create-swap.sh
Created May 27, 2016 19:39
AWS EC2 micro instances don't have swap
#!/bin/bash
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
@gpedro
gpedro / postgresql-json-eloquent.php
Last active April 12, 2016 16:25
Allowing Eloquent execute search in json data-types (pgsql) (Laravel 4x)
<?ṕhp
// /vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
protected $unwrappedTypes = array(
'->>', '->', '#>', '#>>'
);
/**
* Compile a basic where clause.
*
* @param \Illuminate\Database\Query\Builder $query
@gpedro
gpedro / dojo_date.php
Created June 29, 2015 19:13
Algoritmo em PHP que pega o início e fim da semana em um intervalo de data
<?php
function toDateString(DateTime $date) {
return $date->format("d-m-Y");
}
class Semana {
private $inicio;
private $fim;
@gpedro
gpedro / Gulpfile.js
Last active August 29, 2015 14:19
Awesome TaskRunner for Harmonic Theme Development.
var gulp = require('gulp');
var exec = require('child_process').exec;
var path = require('path');
var harmonic = require('./harmonic.json');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var config = {
outDir: 'public'
@gpedro
gpedro / template.ejs
Created January 9, 2015 12:42
jade > ejs
<% if (paginate.hasPreviousPages || paginate.hasNextPages(pageCount)) { %>
<ul class="pager">
<% if (paginate.hasPreviousPages) {%>
<li class="previous">
<a href="<%- paginate.href(true) %>" class="prev"><i class="fa fa-arrow-circle-left"></i> Previous</a>
</li>
<% } %>
<% if (paginate.hasNextPages(pageCount)) { %>
<li class="next">
@gpedro
gpedro / pucpr.py
Last active August 29, 2015 14:08
Resultado PUCPR 2014
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re,requests,os,time
while(1):
ping = requests.get('http://resultado2015.pucpr.br/')
p = re.compile(ur'Em breve, resultado do Vestibular 2015', re.IGNORECASE)
if ping.status_code == 200:
if not re.search(p, ping.text):
from random import randint
import unittest
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
self.animals = ['dog', 'cat', 'bird', 'mouse', 'cow', 'frog', 'elephant', 'duck', 'fox']
self.says = ['woof', 'meow', 'tweet', 'squeek', 'moo', 'croak', 'toot', 'quack']
self.fox = ['Ring-ding-ding-ding-dingeringeding!', 'Gering-ding-ding-ding-dingeringeding!', 'Wa-pa-pa-pa-pa-pa-pow!', 'Hatee-hatee-hatee-ho!', 'Joff-tchoff-tchoffo-tchoffo-tchoff!', 'Tchoff-tchoff-tchoffo-tchoffo-tchoff!', 'Jacha-chacha-chacha-chow!', 'Chacha-chacha-chacha-chow!', 'Fraka-kaka-kaka-kaka-kow!', 'A-hee-ahee ha-hee!']