Skip to content

Instantly share code, notes, and snippets.

View gpedro's full-sized avatar

Gabriel Pedro gpedro

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / context.xml
Created September 14, 2018 02:46
Configuração do Projeto - context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- aqui você coloca aquelas credenciais de desenvolvimento que estavam em persistence.xml -->
<Resource name="jdbc/xablau" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/xablau"
username="postgres" password="postgres" />
</Context>
@gpedro
gpedro / persistence.xml
Last active September 14, 2018 02:48
Configuração do Projeto - persistence.xml (depois)
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="Xablau">
<!-- adicionar esta referencia ao jndi -->
<non-jta-data-source>java:comp/env/jdbc/xablau</non-jta-data-source>
<properties>
<!-- pode comentar ou excluir
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
@gpedro
gpedro / persistence.xml
Created September 14, 2018 02:47
Configuração do Projeto - persistence.xml (antes)
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="Xablau">
<properties>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/xablau" />
<property name="hibernate.connection.username" value="postgres" />
<property name="hibernate.connection.password" value="postgres" />
@gpedro
gpedro / context.xml
Created September 14, 2018 02:58
Configuração do Tomcat - context.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software