Skip to content

Instantly share code, notes, and snippets.

View daviferreira's full-sized avatar

Davi Ferreira daviferreira

View GitHub Profile
@daviferreira
daviferreira / .jshintrc
Created August 15, 2014 14:33
my jshintrc
{
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": true,
@daviferreira
daviferreira / SassMeister-input.scss
Created September 18, 2014 21:48
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
$settings: ("offset": 'margin-left',
"push": 'left',
"pull": 'right',
"center": 'margin-left');
@daviferreira
daviferreira / react-phantom-bind.js
Created October 14, 2014 19:40
react with phantomjs
if (!Function.prototype.bind) {
var Empty = function(){};
Function.prototype.bind = function bind(that) { // .length is 1
var target = this;
if (typeof target != "function") {
throw new TypeError("Function.prototype.bind called on incompatible " + target);
}
var args = Array.prototype.slice.call(arguments, 1); // for normal call
var binder = function () {
if (this instanceof bound) {
@daviferreira
daviferreira / gist:892717
Created March 29, 2011 16:46
Seletor personalizado jQuery
$.expr[':'].seletor = function(objNode, intStackIndex, arrProperties, arrNodeStack){
// código que deve retornar true para incluir o objeto ou false
};
@daviferreira
daviferreira / minifier.py
Created September 1, 2011 13:12
Python minifier using Reducisaurus
import httplib, urllib
origin = 'file.js'
destination = 'file.min.js'
params = urllib.urlencode({'file1': open(origin).read()})
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
conn = httplib.HTTPConnection('reducisaurus.appspot.com')
conn.request('POST', '/js', params, headers)
response = conn.getresponse()
@daviferreira
daviferreira / sanitize_preserving_code.rb
Created September 8, 2011 17:26
Sanitize preserving tags inside a code block
require 'nokogiri'
def sanitize_preserving_code(content)
doc = Nokogiri::HTML::DocumentFragment.parse content
doc.css('code').each do |code|
code.inner_html = h code.inner_html
end
sanitize doc.to_html, :tags => %w(strong em code br a)
end
@daviferreira
daviferreira / git_aliases
Created December 12, 2011 15:01
Git aliases
[alias]
co = checkout
st = status
cm = commit
hist = log --pretty=format:'%Cred%h%Creset %C(bold blue)<%an>%Creset%C(yellow)%d%Creset %Cgreen(%cr)%Creset%n%w(80,8,8)%s' --graph
histfull = log --pretty=format:'%Cred%h%Creset %C(bold blue)<%an>%Creset%C(yellow)%d%Creset %Cgreen(%cr)%Creset%n%w(80,8,8)%s%n' --graph --name-status
@daviferreira
daviferreira / article.css
Created January 24, 2012 17:56
Basic CSS for articles.
body { color: #222; font: normal normal 400 100%/1.5em georgia,serif; margin: 3em auto; width: 40em }
a:link { color: #3366CC }
a:visited { color: #224488 }
blockquote,ol,p,ul { display: block; margin: 0 0 1.5em }
blockquote { border-left: solid .1em #E4E4E4; color: #919191; padding: 0 1.5em 0 1.4em }
code { font: normal normal 87.5%/1.71428571em monospace,sans-serif }
img { display: block; margin: 1.5em auto }
pre { display: block; font: normal normal 87.5%/1.71428571em monospace,sans-serif; margin: 1.71428571em }
h1,h2,h3,h4,h5,h6 { font-weight: 400 }
h1 { font-size: 225%; line-height: 1.3334em; margin: 0 0 .1666em }
@daviferreira
daviferreira / gem-virtualenv.sh
Created January 29, 2012 12:38
Gems and virtualenvs
# add this to your virtualenv activate script
export GEM_HOME="$VIRTUAL_ENV/gems"
export GEM_PATH=""
@daviferreira
daviferreira / html5-css3.md
Created February 13, 2012 16:34
HTML5/CSS3 workshop links