Skip to content

Instantly share code, notes, and snippets.

View phsantiago's full-sized avatar
:shipit:

Pedro H. Santiago phsantiago

:shipit:
View GitHub Profile
<?php
$return = preg_replace( '/\b(\d{2})\D?(\d{3})\D?(\d{3})\D?(\d{4})\D?(\d{2})\b/' , '$1.$2.$3/$4-$5' , $cnpj );
echo $return;
"Ser produtivo não está ligado a quantas horas você tem que trabalhar, e sim a quanto trabalha nas horas que tem."
Eu
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
CREATE EXTERNAL TABLE IF NOT EXISTS Accesslogs(
BucketOwner string,
Bucket string,
RequestDateTime string,
RemoteIP string,
Requester string,
RequestID string,
Operation string,
@phsantiago
phsantiago / es6_mask_cpf_cnpj.js
Created August 22, 2017 15:19
Máscara para CPF e CNPJ em javascript utilizando ES6
const mask = (v) => {
v=v.replace(/\D/g,"")
let len = v.length
if (len < 12) {
v=v.replace(/(\d{3})(\d)/,"$1.$2")
.replace(/(\d{3})(\d)/,"$1.$2")
.replace(/(\d{3})(\d{1,2})$/,"$1-$2")
} else {
v=v.replace(/^(\d{2})(\d)/,"$1.$2")
.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3")
@phsantiago
phsantiago / yt_video_id.js
Created February 13, 2018 05:10
get youtube video id javascript
"https://www.youtube.com/watch?v=lgJOJAmXlBw".match(/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/)[5];
SELECT SUM(funnel_1) as f1_total, SUM(funnel_2) as f2_total FROM (
SELECT
if (event_name = "home_to_info1", 1, 0) AS funnel_1,
if (event_name = "home_to_info1" AND next_event = "app_remove" AND next_timestamp - event_timestamp < 60 * 1000 * 1000, 1, 0) AS funnel_2
FROM (
SELECT event_name, user_pseudo_id , event_timestamp,
LEAD(event_name, 1) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) AS next_event,
LEAD(event_timestamp, 1) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) AS next_timestamp
FROM `mobile-app-production-f37fd.analytics_189954145.events_*`
WHERE event_name = "home_to_info1" OR event_name = "app_remove"
class Gato {
constructor(nome) {
this.nome = nome;
}
falar() {
console.log(`${this.nome}: Meow!`);
}
};
class Gato {
constructor(nome) {
this.nome = nome;
}
falar(paraPessoas) {
paraPessoas.forEach(function(pessoa){
console.log(`${this.nome} para ${pessoa}: Meow!`);
})
}
class Metronomo extends React.Component {
componentDidMount() {
this.primeiroContador = setInterval(
() => this.contagem(),
1000
);
this.segundoContador = setInterval(
() => this.contagem(),
500
);