Skip to content

Instantly share code, notes, and snippets.

@imaginamundo
imaginamundo / Regex telefone Brasil.md
Last active October 9, 2024 12:44
Regex para padrões de telefones brasileiros com explicação e como usar

Regex para telefones do Brasil

(?:(^\+\d{2})?)(?:([1-9]{2})|([0-9]{3})?)(\d{4,5})(\d{4})

Pequena explicação

  • (?:(^\+\d{2})?)

    • Busca por um + seguido por dois números, opcional.
  • (?:([1-9]{2})|([0-9]{3})?)

  • Busca por dois números de 1 à 9, ou três números de 0 à 9, isso faz a diferença entre o DDD com zero e DDD sem zero, lembrando que nenhum código de cidade tem o digito 0. Também opcional.

@jukkatupamaki
jukkatupamaki / 20190417131115_test-setup.ts
Last active November 9, 2024 17:31
How to use Knex.js in a TypeScript project
import { Knex } from 'knex'
export async function up(knex: Knex): Promise<any> {
await knex.schema.createTable('test_setup', (table: Knex.TableBuilder) => {
table.integer('foobar');
});
}
export async function down(knex: Knex): Promise<any> {
await knex.schema.dropTable('test_setup');
@mbejda
mbejda / download.js
Last active March 17, 2024 04:32
Download Private Github Repo with Node.js Request module
var owner = "mbejda";
var repo = "somerepo";
var branch = "master"
var accessToken = "AccessToken";
var options = {
method: "GET",
url: `https://api.github.com/repos/${owner.toLowerCase()}/${repo.toLowerCase()}/tarball/${branch}?access_token=${accessToken}`,
headers: {
'Accept': 'application/vnd.github.v3.raw',
@dhoeric
dhoeric / Ubuntu 16.04
Last active July 18, 2024 17:07
install-docker-aws-ec2-user-data
#!/bin/bash
# Install docker
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
@EvgenyOrekhov
EvgenyOrekhov / A simple Docker and Docker Compose install script for Ubuntu.md
Last active September 26, 2024 10:11
A simple Docker and Docker Compose install script for Ubuntu

A simple Docker and Docker Compose install script for Ubuntu

Usage

  1. sh install-docker.sh
  2. log out
  3. log back in

Links

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE