Skip to content

Instantly share code, notes, and snippets.

View weslleyaraujo's full-sized avatar
💤

Weslley Araujo weslleyaraujo

💤
View GitHub Profile
@weslleyaraujo
weslleyaraujo / extend.js
Created October 4, 2014 18:46
Merge objects
Object.defineProperty(Object.prototype, 'extend', {
enumerable: false,
value: function (from) {
var props = Object.getOwnPropertyNames(from),
dest = this;
props.forEach(function(name) {
var destination;
if (name in dest) {
@weslleyaraujo
weslleyaraujo / git-lg.sh
Created October 15, 2014 22:46
Pretty beauty git lg
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
/**
* @method: PubSub
* */
;(function(global) {
'use strict';
function PubSub () {
this.topics = {};
};
@weslleyaraujo
weslleyaraujo / ArrayUnique.js
Created November 10, 2014 16:03
Unique method for Array in Javascript
Array.prototype.unique = function () {
var cached = [];
return this.filter(function (index) {
if (cached.indexOf(index) === -1) {
cached.push(index);
return index;
}
}.bind(this));
};
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
{
"private": true,
"scripts": {
"build:js": "browserify -e source/scripts/index.js -t [ babelify --optional es7 ] -o public/bundle.js",
"build:css": "cssnext source/styles/index.css public/bundle.css",
"build": "npm run js && npm run css",
"watch:js": "watchy -w source/scripts -- npm run build:js",
"watch:css": "watchy -w source/styles -- npm run build:css"
},
"dependencies": {},
@weslleyaraujo
weslleyaraujo / login.php
Last active December 19, 2015 07:59
Login library for CI
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter Login Class
* This class enables you to have a simple login route and permission levels
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author Weslley Araujo (http://weslleydeveloper.com)
def date_to_unix(time)
Time.parse(time).to_i
end
def in_progress(start_time, end_time, time_now = (Time.new.strftime '%d/%m/%Y'))
now = date_to_unix(time_now)
if date_to_unix(start_time) <= now
date_to_unix(end_time) < now ? false : true
else
false
@weslleyaraujo
weslleyaraujo / gist:8268509
Created January 5, 2014 13:54
Simple function to padding your number
function padding(str, len, char) {
return (Array(len).join(char)+str).substr(-len);
}
padding(1, 2, 0) // 01
padding(1, 2, 0) // 02
padding(1, 2, 0) // 27