Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Stamatiou stammy

View GitHub Profile
@niftylettuce
niftylettuce / getscript.js
Last active Nov 17, 2017
getScript() - load scripts asynchronously w/375 bytes of code - e.g. `getScript(src, cb)`
View getscript.js
// # getScript()
// more or less stolen from jquery core and adapted by paul irish
function getScript(url,success) {
var head = document.getElementsByTagName("head")[0], done = false;
var script = document.createElement("script");
script.src = url;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
@alanhogan
alanhogan / compass-retina-sprites.scss
Created Jun 5, 2012 — forked from thulstrup/compass-retina-sprites.scss
Using Compass to generate normal and retina sprite maps
View compass-retina-sprites.scss
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@addyosmani
addyosmani / pubsub.md
Created Oct 28, 2011
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)
View pubsub.md

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@troyk
troyk / whyme.js
Created Oct 12, 2011
Get a list of email addresses from your gmail sent folder using node
View whyme.js
// Based off an example from node-imap, will output a list of email addresses from your
// gmail sent folder (so you can copy/paste to the BCC field and let people know your
// sorry for using the same password all over the internet resulting in your buddies
// getting a lame spam message)
var ImapConnection = require('imap').ImapConnection,
imap = new ImapConnection({
username: '{{replace}}@gmail.com',
password: '{{replace}}',
host: 'imap.gmail.com',
@sulf
sulf / gist:1157909
Created Aug 19, 2011
Rails helper time_ago_in_words() and distance_of_time_in_words() translated into JavaScript
View gist:1157909
var distance_of_time_in_words, time_ago_in_words;
time_ago_in_words = function(from_time, include_seconds) {
if (include_seconds != null) {
include_seconds;
} else {
include_seconds = false;
};
return App.distance_of_time_in_words(from_time, Date.now(), include_seconds);
};
distance_of_time_in_words = function(from_time, to_time, include_seconds) {
@mikegehard
mikegehard / 0_README.md
Created May 5, 2011 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine
View 0_README.md

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@janlelis
janlelis / .railsrc
Created Mar 31, 2011
13 Rails-specific hints for your rails 3 console.
View .railsrc
# .railsrc for Rails 3, encoding: utf-8
# see http://rbjl.net/49-railsrc-rails-console-snippets
if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else
# # #
def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end
# # #
# loggers
@igrigorik
igrigorik / ruby-1.9-tips.rb
Created Feb 3, 2011
Ruby 1.9 features, tips & tricks you may not know about...
View ruby-1.9-tips.rb
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@aliang
aliang / application_controller.rb
Created Feb 1, 2011
Force SSL on Devise routes only, then redirect back
View application_controller.rb
class ApplicationController < ActionController::Base
# Tell Devise to redirect after sign_in
def after_sign_in_path_for(resource_or_scope)
some_url(:protocol => 'http')
end
# Tell Devise to redirect after sign_out
def after_sign_out_path_for(resource_or_scope)
some_url(:protocol => 'http')
end
@harperreed
harperreed / create_custom_origin.py
Created Jan 14, 2011
creates a custom origin for cloudfront. EASY CDN!
View create_custom_origin.py
import boto
# requires cf_customorigin branch
# https://github.com/boto/boto/tree/cf_customorigin
origin_domain = 'www.example.org'
cdn_cname = ['media.example.org']
caller_reference = 'exmaple Distribution'
c = boto.connect_cloudfront()
d = c.create_custom_distribution(
You can’t perform that action at this time.