Skip to content

Instantly share code, notes, and snippets.

View postpostmodern's full-sized avatar

Jason T Johnson postpostmodern

View GitHub Profile
@postpostmodern
postpostmodern / gist:1343748
Created November 6, 2011 23:03
Pow Aliases
# Pow
alias startpow='curl get.pow.cx | sh'
alias stoppow='curl get.pow.cx/uninstall.sh | sh'
@postpostmodern
postpostmodern / post.rb
Created January 8, 2012 23:37
posts scoped by subdomain
class PostsController < ApplicationController
inherit_resources
protected
def begin_of_association_chain
Agency.find_by_code request.subdomains.first
end
end
@postpostmodern
postpostmodern / width_classes.js
Created January 12, 2012 21:59
Add classes to <html> for responsive layouts
// Add classes to <html> for responsive layouts -
// e.g. <html class="over320 over480 under768 under960">
jQuery(function() {
var widths = [ 320, 480, 768, 960 ];
var setWidthClasses = function() {
var w = $(window).width();
for(var i=0; i<widths.length; i++) {
$('html').removeClass('under' + widths[i]).removeClass('over' + widths[i]);
}
@postpostmodern
postpostmodern / rails_bootstrap_delete_confirmation_modal.md
Created February 19, 2012 07:38 — forked from trey/rails_bootstrap_delete_confirmation_modal.md
A nice delete confirmation modal in Rails courtesy of Bootstrap

Here's what you get.

Some CoffeeScript (verbosely commented for clarity)

# Override Rails handling of confirmation

$.rails.allowAction = (element) ->
  # The message is something like "Are you sure?"
  message = element.data('confirm')
@postpostmodern
postpostmodern / seeds.rb
Created March 20, 2012 14:38
Example seeds.rb file which creates records and imports records from CSV files
Language.create!(name: 'English (US)', code: 'en', locale: 'en-US') if Language.count == 0
if Administrator.count == 0
admin = Administrator.new(
first_name: 'Super',
last_name: 'Admin',
email: '[email protected]',
password: 'adminpass',
password_confirmation: 'adminpass'
)
function longestCommonPrefix(arr) {
var prefix = '';
var firstWord = arr[0];
function inAll(letter, idx) {
for(var j=0; j<arr.length; j++) {
if(arr[j][idx] != letter) return false;
}
return true;
}
@postpostmodern
postpostmodern / PIE.htc
Created July 4, 2012 19:37
Sass Mixins for CSS3 with CSS3PIE support
<!--
PIE: CSS3 rendering for IE
Version 1.0.0
http://css3pie.com
Dual-licensed for use under the Apache License Version 2.0 or the General Public License (GPL) Version 2.
-->
<PUBLIC:COMPONENT lightWeight="true">
<!-- saved from url=(0014)about:internet -->
<PUBLIC:ATTACH EVENT="oncontentready" FOR="element" ONEVENT="init()" />
<PUBLIC:ATTACH EVENT="ondocumentready" FOR="element" ONEVENT="init()" />
@postpostmodern
postpostmodern / sanitize_for_dom_id.coffee
Created August 20, 2012 21:40
Cleans up a string for suitability as a css id or class
sanitizeForDomID = (str) ->
chars =
"ä": "ae"
"ö": "oe"
"ß": "ss"
"ü": "ue"
"æ": "ae"
"ø": "oe"
"å": "aa"
"é": "e"
@postpostmodern
postpostmodern / plan.js
Created September 21, 2012 14:22 — forked from wyattdanger/plan.js
js demo
var Plan = (function() {
// protected
var records = [];
// the Plan constructor
function Plan(key, id, price) {
this.id = id;
this.price = price;
var more = key.split('||');
#!/usr/bin/env ruby
require 'fog'
require 'open-uri'
class BrandsmithDNS
def initialize
@dns = Fog::DNS.new(:provider => 'rackspace', :rackspace_api_key => 'xxxxxxxxxxxxxxxxxx', :rackspace_username => 'yyyyyyyyyyyyyyyyyy')
@record = @dns.zones.get('11111111').records.get('A-222222222')
end