Skip to content

Instantly share code, notes, and snippets.

View lleitep3's full-sized avatar
🏠
Working from home

Leandro (Hey Man) lleitep3

🏠
Working from home
View GitHub Profile
@lleitep3
lleitep3 / display-date.js
Last active May 2, 2018 13:26
exemplo attachShadow
(function() {
const style = `
:host {
display: inline-block;
margin: 0 5px;
contain: content;
}
`
// usage <display-date format="DD/MM/YYYY"></display-date>
<div class="lista-pessoas"></div>
<style>
</style>
<script>
var listaDeFuncionarios = [
{
@lleitep3
lleitep3 / webServer.php
Created December 28, 2015 19:26
script de web server quebra galho com rewrite para meu ambiente de dev
<?php
/**
* To run PHP server just paste the code bellow in root path :
* $ php -S 0.0.0.0:8080 -t ./public -f webServer.php
**/
if (preg_match('/\.css|\.js|\.jpg|\.png|\.map$/', $_SERVER['REQUEST_URI'], $match)) {
$mimeTypes = [
'.css' => 'text/css',
'.js' => 'application/javascript',
'.jpg' => 'image/jpg',
@lleitep3
lleitep3 / Preferences.sublime-settings.json
Created October 21, 2015 11:00
Minhas configurações de usuário no sublime text
{
"color_scheme": "Packages/1337 Color Scheme/1337.tmTheme",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",
"*.o",
Element.prototype.addClass = function (className) {
if (this.className.indexOf(className) === -1)
this.className = this.className + ' '+className;
};
Element.prototype.hasClass = function (className) {
return (this.className.indexOf(className) > -1);
}
Element.prototype.removeClass = function (className) {
@lleitep3
lleitep3 / localStorageAPI.js
Created July 20, 2015 19:34
serviço de acesso ao localStorage
angular.module('starter.services', [])
.service('$storage', function () {
this.get = function (key) {
var arrK = key.split('.'),
first = arrK.shift(),
result = JSON.parse(localStorage.getItem(first));
if (arrK.length === 0) {
return result;
<?php
class User implements IEntity
{
public $id = null;
public $name = '';
public $email = '';
public $pass = '';
public function hasId()

a simple git branching model

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

The gist

@lleitep3
lleitep3 / deleteDir.php
Created October 9, 2012 13:42
delete some folder recursive
<?php
function deleteDir($source)
{
if(!is_dir($source))
return false;
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source),
\RecursiveIteratorIterator::SELF_FIRST);
$it->next();
@lleitep3
lleitep3 / ascii2entities.php
Created March 17, 2012 16:09
ascii2entities
<?php
// encontrada nesse link
// http://www.php.net/manual/en/function.htmlentities.php
function ascii2entities($string){
for($i=128;$i<=255;$i++){
$entity = htmlentities(chr($i), ENT_QUOTES, 'cp1252');
$temp = substr($entity, 0, 1);
$temp .= substr($entity, -1, 1);