Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
Elixir, React, Phoenix, Rust.

Anders Ytterström madr

🤘
Elixir, React, Phoenix, Rust.
View GitHub Profile
@thecocktail
thecocktail / validate.rake
Created Sep 5, 2008
Nanoc rake task to make a w3c validation of your output html/css
View validate.rake
# #Nanoc validation task
#
# To use this validation task you need the w3c_validators gem
# gem install w3c_validators
# and run rake validate on your project root
#
require 'yaml'
require 'w3c_validators'
include W3CValidators
@thecocktail
thecocktail / gist:9281
Created Sep 7, 2008
Rake task to validates massively html files
View gist:9281
# # Massive html validation task
#
# This rake task comes from the nanoc validation task (http://gist.github.com/8961)
# Copy this Rakefile to the root of your htmls or add the task to your existing Rakefile
# and run:
#
# rake validate
#
# and that's all :)
@rpavlik
rpavlik / fix_homebrew.rb
Created Jan 6, 2011 — forked from mxcl/install_homebrew.markdown
Fix permissions on /usr/local for Homebrew
View fix_homebrew.rb
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@chriseppstein
chriseppstein / 0_selector_hacks.scss
Created Sep 14, 2011
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
View 0_selector_hacks.scss
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@rob-ot-dot-be
rob-ot-dot-be / 0_selector_hacks.scss
Created Dec 23, 2011 — forked from chriseppstein/0_selector_hacks.scss
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
View 0_selector_hacks.scss
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@ken-reitz
ken-reitz / mongo.py
Created Mar 13, 2012 — forked from lstoll/mongo.py
MongoHQ w/ pymongo on Heroku
View mongo.py
import os
import pymongo
MONGO_URL = os.environ.get('MONGOHQ_URL')
if MONGO_URL:
# Get a connection
conn = pymongo.Connection(MONGO_URL)
# Get the database
@erikh
erikh / hack.sh
Created Mar 31, 2012 — forked from DAddYE/hack.sh
OSX For Hackers
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@derpston
derpston / button.py
Created May 24, 2012
Python libusb interface for getting key up/down events from USB HIDs like keyboards.
View button.py
import sys
import time
import usb
class Button:
def __init__(self, vendor_id, device_id):
"""
Find and open a USB HID device.
"""
View avoid-jquery-when-possible.md

Avoid jQuery When Possible

jQuery does good jobs when you're dealing with browser compatibility. But we're living in an age that fewer and fewer people use old-school browsers such as IE <= 7. With the growing of DOM APIs in modern browsers (including IE 8), most functions that jQuery provides are built-in natively.

When targeting only modern browsers, it is better to avoid using jQuery's backward-compatible features. Instead, use the native DOM API, which will make your web page run much faster than you might think (native C / C++ implementaion v.s. JavaScript).

If you're making a web page for iOS (e.g. UIWebView), you should use native DOM APIs because mobile Safari is not that old-school web browser; it supports lots of native DOM APIs.

If you're making a Chrome Extension, you should always use native APIs, not only because Chrome has almost the latest DOM APIs available, but this can also avoid performance issue and unnecessary memory occupation (each jQuery-driven extension needs a separate

@madrobby
madrobby / gist:4161897
Created Nov 28, 2012
Retina screen media query
View gist:4161897
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 144dpi),
(min-resolution: 1.5dppx) {
/* Retina rules! */
}
You can’t perform that action at this time.