Skip to content

Instantly share code, notes, and snippets.

View phsantiago's full-sized avatar
:shipit:

Pedro H. Santiago phsantiago

:shipit:
View GitHub Profile
@phsantiago
phsantiago / command_enter.ts
Last active August 14, 2022 13:13
command or control enter for react, working on mac and windows
const controlEnter = (e: React.KeyboardEvent) =>
(e.metaKey || e.ctrlKey) && e.which === 13;
@phsantiago
phsantiago / opticalDensitySample-matplotlib.py
Last active May 11, 2022 03:51
Python charts with numpy
import numpy as np
from matplotlib import pyplot as plt
concentrationCurve = [100,50,25,12.5,6.25,3.125,0]
opticalDensityCurve = [0.7755,0.3205,0.1325,0.061,0.038,0.029,0.026]
concentrationSamples = [19.1,28.05,44.44,59.38,68.67,74.27,91.33]
opticalDensitySample = [0.1065,0.1585,0.268,0.384,0.464,0.515,0.684]
const [, token] = bearer.match(/Bearer (.*)/);
@phsantiago
phsantiago / countries.jsx
Last active June 3, 2019 11:42
country selector in react using antd
import React from 'react';
import { Select } from 'antd';
const { Option } = Select;
const SelectPaises = props => (
<Select name="paises" style={{width: 150, height: 40}} placeholder="Selecione um país" {...props}>
<Option value="África do Sul">África do Sul</Option>
<Option value="Albânia">Albânia</Option>
<Option value="Alemanha">Alemanha</Option>
import { useState } from 'react';
function Gato() {
const [idade, setIdade] = useState(3);
return (
<div>
<p>Este gato tem {idade} anos</p>
<button onClick={() => setIdade(count + 1)}>
Clique aqui para envelhecer o bixano
class Metronomo extends React.Component {
componentDidMount() {
this.primeiroContador = setInterval(
() => this.contagem(),
1000
);
this.segundoContador = setInterval(
() => this.contagem(),
500
);
class Gato {
constructor(nome) {
this.nome = nome;
}
falar(paraPessoas) {
paraPessoas.forEach(function(pessoa){
console.log(`${this.nome} para ${pessoa}: Meow!`);
})
}
class Gato {
constructor(nome) {
this.nome = nome;
}
falar() {
console.log(`${this.nome}: Meow!`);
}
};
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"
@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];