Skip to content

Instantly share code, notes, and snippets.

View lgarciasbr's full-sized avatar

Leandro Garcia lgarciasbr

View GitHub Profile
@lgarciasbr
lgarciasbr / estados-cidades.json
Created May 29, 2018 19:51 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@lgarciasbr
lgarciasbr / Sort Array with Objects
Created May 12, 2018 03:01
TypeScript - Sort Array with Objects
array.sort(function(a, b){
if(a.name < b.name) return -1;
if(a.name > b.name) return 1;
return 0;
})
@lgarciasbr
lgarciasbr / Remover Acento
Created May 10, 2018 15:05
Função em TypeScript que remove acentos.
removerAcentos(s) {
var map = { "â": "a", "Â": "A", "à": "a", "À": "A", "á": "a", "Á": "A", "ã": "a", "Ã": "A", "ê": "e", "Ê": "E", "è": "e", "È": "E", "é": "e", "É": "E", "î": "i", "Î": "I", "ì": "i", "Ì": "I", "í": "i", "Í": "I", "õ": "o", "Õ": "O", "ô": "o", "Ô": "O", "ò": "o", "Ò": "O", "ó": "o", "Ó": "O", "ü": "u", "Ü": "U", "û": "u", "Û": "U", "ú": "u", "Ú": "U", "ù": "u", "Ù": "U", "ç": "c", "Ç": "C" };
return s.replace(/[\W\[\] ]/g, function (a) { return map[a] || a }).toLowerCase()
};
# The "timeit" module lets you measure the execution
# time of small bits of Python code
import timeit
timeit.timeit('"-".join(str(n) for n in range(100))',
number=10000)
@lgarciasbr
lgarciasbr / README.md
Created March 22, 2017 22:17 — forked from nicerobot/README.md
Mac OS X uninstall script for packaged install of node.js

To run this, you can try:

curl -ks https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh | bash

I haven't tested this script doing it this way but i run a lot of my Gists like this so maybe this one'll work too.

Alternatively,

curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh

chmod +x ./uninstall-node.sh

@lgarciasbr
lgarciasbr / latency.txt
Created January 11, 2016 23:56 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@lgarciasbr
lgarciasbr / setup.sh
Created December 21, 2015 02:35 — forked from rg3915/setup.sh
Shell script to create a simple Django project.
# Shell script for create a simple Django project.
# wget --output-document=setup.sh https://goo.gl/3j87iT
# Type the following command, you can change the project name.
# source setup.sh myproject
# Colors
red=`tput setaf 1`
green=`tput setaf 2`