Skip to content

Instantly share code, notes, and snippets.

View danvitoriano's full-sized avatar
💭
probably coding

Dan Vitoriano 🌈 danvitoriano

💭
probably coding
View GitHub Profile
var messages = [
"message1",
"message2"
];
var message_time_ms = 1000;
var index = 0;
document.title = messages[index];
window.setInterval(function(){
document.title = messages[index++ % messages.length];
@danvitoriano
danvitoriano / asyncloops.js
Created July 27, 2016 14:24 — forked from lukehoban/asyncloops.js
Async/await and parallel loops
// ES6 w/ Promises
// Note: From a React starter template - see https://t.co/wkStq8y3I5
function fetchData(routes, params) {
let data = {};
return Promise.all(routes
.filter(route => route.handler.fetchData)
.map(route => {
return route.handler.fetchData(params).then(resp => {
data[route.name] = resp;
@danvitoriano
danvitoriano / const.js
Last active November 12, 2016 18:59
ES6 JavaScript Examples
/*
// const scope cannot be update
*/
const key = 'abc123';
/*
// const object properties and values can change
*/
const person = {
name: 'Wes',
@danvitoriano
danvitoriano / nginx.conf
Created November 22, 2016 16:05
NGINX config file to http (80) and https (443) server
user root;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
@danvitoriano
danvitoriano / OAuthPost.js
Created November 22, 2016 16:50
OAuth Post Request Authorize Implicit Grant Token
var req = {
method: 'POST',
url: 'https://myendpoint.com:3000/api/oauth/authorize?client_id=web-client&response_type=token&redirect_uri=https://myawesomesite.com:3000/token/',
data: {
login: $scope.user,
password: $scope.password,
type: 'LOGIN_CPF_PASSWORD',
service: 'SERVICE'
},
headers: {
@danvitoriano
danvitoriano / phoneValidate_BR.php
Created January 8, 2017 17:52 — forked from boliveirasilva/phoneValidate_BR.php
Regex para validação de telefones (celular ou fixo) no Brasil. A expressão leva em conta o formato internacional/nacional, com ou sem o DDD, de telefones fixos e celulares.
<?php
// A função abaixo demonstra o uso de uma expressão regular que identifica, de forma simples, telefones válidos no Brasil.
// Nenhum DDD iniciado por 0 é aceito, e nenhum número de telefone pode iniciar com 0 ou 1.
// Exemplos válidos: +55 (11) 98888-8888 / 9999-9999 / 21 98888-8888 / 5511988888888
function phoneValidate($phone)
{
$regex = '/^(?:(?:\+|00)?(55)\s?)?(?:\(?([1-9][0-9])\)?\s?)?(?:((?:9\d|[2-9])\d{3})\-?(\d{4}))$/';
if (preg_match($regex, $phone) == false) {
@danvitoriano
danvitoriano / gisttools.js
Last active June 1, 2018 00:42
JavaScript Reference
Whereas HTML defines a webpage's structure and content and CSS sets the formatting and appearance, JavaScript adds interactivity to a webpage and creates rich web applications.
The DOM is an API that allows access to and modification of the current document. It allows manipulation of document Node and Element. HTML, XML and SVG have extended it to manipulate their specific elements.
@danvitoriano
danvitoriano / docker.md
Last active July 16, 2017 13:54
Introdução ao Docker

Docker

O docker serve para prepararmos ambientes de execução (ubuntu,mysql,wordpress) de forma rápida e prática, a grande vantagem disso é que em uma máquina física podemos simular diversos ambientes isolados que ficam isolados no que chamamos de containers, que compartilham o mesmo sistema operacional.

docker run ubuntu /bin/echo “hello docker”
docker pull mysql (puxa a imagem)
docker images
docker ps -a
docker run — name database -e MYSQL_ROOT_PASSWORD=teste123 -d mysql
@danvitoriano
danvitoriano / ReactDefaultProps.md
Created November 7, 2017 15:53
defaultProps just needs to be a static property on the component class. How you want to do this is up to you.

Static property:

class C1 extends React.Component {
  static defaultProps = {
    prop: 'hello',
  };
}