Skip to content

Instantly share code, notes, and snippets.

View lcaballero's full-sized avatar

Lucas Caballero lcaballero

View GitHub Profile
@lcaballero
lcaballero / Example Mapping Parameter Names to Call Values
Last active December 21, 2015 13:08
Example Mapping Parameter Names to Call Values
;(function() {
var slice = Array.prototype.slice
var console = window["console"] || {console:{}};
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
function getParamNames(func) {
var fnStr = func.toString().replace(STRIP_COMMENTS, '')
var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(/([^\s,]+)/g)
if(result === null)
result = []
@lcaballero
lcaballero / Gist form of Eric Meyer's css reset
Last active December 21, 2015 14:29
Gist form of Eric Meyer's css reset.
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@lcaballero
lcaballero / Minimal common helper css
Created August 23, 2013 15:15
Minimal common helper css.
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
.hasLayout, .contain {
*zoom:1;
}
.contain:after {
content:".";
@lcaballero
lcaballero / cssParser
Created August 23, 2013 22:24
CSS Parser in JavaScript. Fork of cssParser (see the lisence and comments).
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
@lcaballero
lcaballero / CSS selector finder
Created August 23, 2013 22:25
CSS rule finder and selector finder given an element.
; (function ($) {
function newSelectorInfo() {
return {
hrefs: [],
selectors: [],
matched: [],
skipped: [],
sortCssText: function () {
this.matched.sort(function (a, b) {
@lcaballero
lcaballero / Css Buttons Less Buttons
Created September 12, 2013 21:20
Css Buttons Less Buttons
.btn-sizing(@color:#fff, @radius: 3px, @padding_top: 4px, @padding_sides: 10px) {
font-weight: bold;
color:@color;
border-radius: @radius;
padding: @padding_top @padding_sides;
}
.btn-colors(@border: #660000, @top: #cb0000, @bottom: #9c0000) {
border: 1px solid @border;
.vertical-gradient(@top, @bottom);
@lcaballero
lcaballero / Create Form
Last active December 23, 2015 22:59
Create a form from input elements and attributes.
;(function($) {
/**
* Creates a form element that can be appended to the body. These
* are the default parameters that can be provided to this function
* via an options object:
*
* Options:
* {
* method: "post" | "get"
@lcaballero
lcaballero / Recursion + Async + Promise + Node
Created October 14, 2013 22:28
Recursive + async traversal of a directory using Promises and Node
Q = require('q')
fs = require('fs')
_ = require("lodash")
isFile = (name) ->
fs.statSync(name).isFile()
isDirectory = (name) ->
fs.statSync(name).isDirectory()
@lcaballero
lcaballero / Event loop halting
Created October 22, 2013 05:28
Example showing the event loop halting because of a `while` loop.
setTimeout(function() {
console.log("after 2sec")
}, 2000)
d = new Date()
while (new Date().getTime() - d.getTime() < 3000);
console.log("after 3sec")
@lcaballero
lcaballero / Alias for Make dir, cd into dir
Created October 25, 2013 03:59
Alias for Make dir, cd into dir
createAndMove() { mkdir $1; cd $1; }
alias md="createAndMove"