Skip to content

Instantly share code, notes, and snippets.

View rafaelrinaldi's full-sized avatar

Rafael Rinaldi rafaelrinaldi

View GitHub Profile
@remy
remy / query.js
Created August 11, 2011 23:05
Get location.search as object
function getQuery(s) {
var query = {};
s.replace(/\b([^&=]*)=([^&=]*)\b/g, function (m, a, d) {
if (typeof query[a] != 'undefined') {
query[a] += ',' + d;
} else {
query[a] = d;
}
});
@jonathantneal
jonathantneal / EventListener.js
Created August 29, 2012 18:31
EventListener // envisions an event listener object
(function (global) {
function EventListener(parameters) {
var self = Object.defineProperties(this, {
dispatch: {
enumerable: true,
value: function (event) { return listener.call(self, event), self; }
},
listener: {
enumerable: true,
get: function () { return listener; },
@rafaelrinaldi
rafaelrinaldi / gist:3922074
Created October 20, 2012 05:01
OSX keyboard icons in unicode

Backspace

Caps lock

Clear

 ⌘ Command

Control

String.prototype.linkify = function()
{
var str = this.toString();
str = str.replace(/(https?:\/\/[^\s]+)/gim, '<a href="$1">$1</a>', str);
str = str.replace(/([#|@][^\s]+)/gim, '<a href="http://twitter.com/$1">$1</a>', str);
return str;
}
@millermedeiros
millermedeiros / gist:1189235
Created September 2, 2011 17:29
Explain difference between revealing module pattern and using a constructor as namespace
//create our "FOO" namespace
window.FOO = window.FOO || {};
FOO.app1 = {
bar : 'foo',
init : function(){
//this wont work as expected since timeout changes scope
@vitaLee
vitaLee / Default (OSX).sublime-keymap
Created December 19, 2012 18:14
Reworked version of Sublime Text 2 default Add Line command. Allows expanding selection at the same column even on shorter lines (as if there is virtual space). Works with multi selections and solves problem Sublime has with expanding non-empty selection regions.
[
{"keys":["ctrl+shift+up"], "command":"super_add_line", "args":{ "forward": false } },
{"keys":["ctrl+shift+down"], "command":"super_add_line", "args":{ "forward": true } }
]
/*****************************************************************************
* __ __ _ _ ___ _
* \ \/ _\ /\/\ (_)_ __ | |_ _ _ / __\ __ ___ ___| |__
* \ \ \ / \| | '_ \| __| | | | / _\| '__/ _ \/ __| '_ \
* /\_/ /\ \ / /\/\ \ | | | | |_| |_| | / / | | | __/\__ \ | | |
* \___/\__/ \/ \/_|_| |_|\__|\__, | \/ |_| \___||___/_| |_|
* |___/
*
* Identifying and Eliminating Code Smells
*
@luiz
luiz / menu-example.html
Last active February 1, 2016 23:04
Example of menu tag usage
<article>
<h1>Using the correct tags in HTML</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In et iaculis
risus. Quisque quis magna diam. Suspendisse aliquet urna eu erat pretium, et
scelerisque odio pulvinar. Nullam fermentum diam nibh, vel eleifend ipsum
tempus ut. Nunc accumsan ligula eget tellus vestibulum, sit amet euismod quam
molestie. Integer feugiat urna sed enim hendrerit vestibulum. Suspendisse
ullamcorper, nisi non mollis eleifend, est nunc sagittis augue, nec convallis
eros est ultrices sem. Curabitur pretium condimentum nulla. Sed convallis augue
vitae metus interdum commodo nec in nulla. Vivamus vulputate eleifend semper.
@gabriel-laet
gabriel-laet / _webpack-example.md
Last active February 7, 2016 15:24
webpack setup example

Just an example of how you can make your webpack config more declarative an re-usable.

You can have a generic webpack.config.js that includes most of your common setup (loaders, plugins and all that) and an attribute in your project's package.json (or anywhere you think it makes sense) containing your project's entries or any other setup you might want to change.

  • npm start - live reload, http://localhost:8000
  • npm run build - build to dist folder
  • npm run build -- -p - production build to folder
  • npm run watch - watch to dist folder
@millermedeiros
millermedeiros / example.html
Created August 28, 2012 13:52
node.js script to inline static includes
<!DOCTYPE html>
<!-- #include "inc_header.html" title="Example" header="Sample Title" -->
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<h1>Sample Title</h1>