Skip to content

Instantly share code, notes, and snippets.

@mahemoff
mahemoff / responsive.css.sass
Created March 26, 2012 11:50
Responsive SASS/Bootstrap
// see http://thesassway.com/intermediate/responsive-web-design-part-2
@media only screen and (max-width: 480px)
@content
@else if $media == desktops
@media only screen and (min-width: 480.1px)
@content
@else if $media == max-screens
@media only screen and (min-width: 1210px + 2*$main-padding + 2*$grid-width + 0.1)
@content
@mahemoff
mahemoff / escape.rb
Created March 30, 2012 11:28
Escape HTML Entities using Ruby 1.9.2 gsub hash syntax
def escape(s)
s.gsub(/[&<>"]/, '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;')
end
@mahemoff
mahemoff / names.txt
Created April 5, 2012 22:24
Reserved username list
###
A meta-compilation of:
https://raw.github.com/gist/1453705/d253733a56632a8d2c29321a75c18b627fa4dda8/reserved_usernames.rb
http://blog.postbit.com/reserved-username-list.html
http://www.quora.com/How-do-sites-prevent-vanity-URLs-from-colliding-with-future-features
(Took out some company-specific terms at the top of the first one (e.g. imulus, stacks), added one term so far - 'edits'.)
NOTE: Does not include profanities. You may or may not want to add a list of those.
(See https://www.google.com/search?q=profanity+list, but don't try to apply regexp's here because Scunthorpe - http://en.wikipedia.org/wiki/Scunthorpe_problem)
<input name='email' type='email' />
<div class='suggestion'>
<span>Did you mean <span class='value'></span>?</span>
</div>
@mahemoff
mahemoff / acronym.rb
Created April 12, 2012 23:10
acronym support in rails 3.1
# "borrowed" from https://github.com/rails/rails/tree/3-2-stable/railties/lib/rails/generators/rails/app/templates/config/initializers
module Irregularities
attr_accessor :acronyms
def acronym(word)
@acronyms[word.downcase] = word
@acronym_regex = /#{@acronyms.values.join("|")}/
end
@mahemoff
mahemoff / episode_sweeper.rb
Created April 18, 2012 02:29
model-based Rails sweeper
class EpisodeSweeper < ActionController::Caching::Sweeper
observe Series, Episode
def after_create(record) expire_series_episodes_cache(record) ; end
def after_update(record) expire_series_episodes_cache(record) ; end
def after_destroy(record) expire_series_episodes_cache(record) ; end
def expire_series_episodes_cache(record)
series = record.is_a?(Series) ? record : record.series
@mahemoff
mahemoff / grunt-wat.js
Created April 25, 2012 00:05 — forked from cowboy/grunt-wat.js
I'm not even joking.
// This was what I got, pasted into an email.
// v0.0.0.2 Robust version with namespacing
module.exports = function(grunt) {
//Grunt Globals
com.wtfjs.constants = new Array();
com.wtfjs.constants.ConcatOutputFileNameAndLocation="c:\\TestOutput.js";
com.wtfjs.constants.JavascriptDirectory = 'C:\\Work\\Patch29\\StaticContent\\RootAssets\\JsLib'
com.wtfjs.constants.MessageTaskStart = "StartingTask_";
com.wtfjs.constants.MessageTaskEnd = "EndingTask_";
@mahemoff
mahemoff / gist:2665452
Created May 12, 2012 09:22
Grunt Quickstart
Install Node
npm install -g grunt
grunt init:jquery
#home(data-role='page')
%div(data-role='header')
%div(data-role='content')
%h2 Select a category
%ul(data-role='listview' data-inset='true')
%li
%a(href='test.html') users
%li
%a(href='test.html') news
%li
$page.page()
$("[data-role='listview']").listview()
$.mobile.changePage($page)