Skip to content

Instantly share code, notes, and snippets.

View djforth's full-sized avatar

Adrian Stainforth djforth

View GitHub Profile
@djforth
djforth / Border-size.css.scss
Created November 7, 2012 11:42
Various Mixins
@mixin background_size($option) {
-webkit-background-size: $option; /* Chrome1.0+, Safari3.0+ */
-moz-background-size: $option; /* Firefox 3.6+ */
-o-background-size: $option; /* Opera 9.5+ */
background-size: $option; /* W3C */
}
@djforth
djforth / body_class.js.coffee
Created November 7, 2012 11:52
Set Body Class on PJAX Request
$.fn.changeBodyClass = () ->
new_class = $("[data-body_class]").attr("data-body_class")
$(this).removeClass()
$(this).addClass(new_class)
new_class
jQuery ->
$(document).pjax("a.pjax", "[data-pjax-container]").on "pjax:end", ->
#sets body class
@djforth
djforth / nav_select.js.coffee
Created November 7, 2012 12:46
PJAX Nav selections
$.fn.set_select_nav = (opt) ->
# Removes highlight class
$(this).removeClass(opt.css)
#Strips out so only root path left e.g. /about, /page, etc
section = opt.path.split("/")
nav_path = ""
#rebuilds root path
for i in [1...2]
@djforth
djforth / application.js
Created November 7, 2012 12:50 — forked from adrianstainforth/pjax_setup.js.coffee
PJAX JavaScript
//= require jquery
//= require jquery_ujs
// Make sure you download latest PJAX code from https://github.com/defunkt/jquery-pjax
//= require jquery.pjax
@djforth
djforth / autoset_height.js.coffee
Created November 7, 2012 15:32
Autosize Box Heights
$.fn.autoset_heights = (opt) ->
h = opt.min || 0
$(this).find(opt.element).each (i) ->
if h < $(this).height()
h = $(this).outerHeight()
# console.log h
$(this).find(opt.element).each (i) ->
if h > $(this).height()
$(this).height(h)
@djforth
djforth / GmapsLoader.js.coffee
Created November 8, 2012 15:15
Setting up Gmaps for PJAX
window.GmapsLoader = {
Initialize: () ->
#Triggers after Maps Load Dynamic
# console.log markers
loadGmaps.markers = markers if markers?
loadGmaps.polylines = polylines if polylines?
loadGmaps.Init()
LoadScript: () ->
#Loads API Dynamically
@djforth
djforth / image_replace.js.coffee
Created November 9, 2012 11:30
Image replace in JS
class ReplaceImage
constructor: () ->
@container = "#container"
@element = ".additional_assets li a"
@main_img = "main_image"
@jq_image = "#"+@main_img
@fig = "figure"
@img
init: ->
@djforth
djforth / controller_shared_example.rb
Created March 1, 2013 09:34
Shared Examples for controllers
shared_examples_for 'check templete return' do |property, path|
it "should set the #{property} variable" do
assigns[property.to_sym].should_not be_nil
end
it "should render template #{path}" do
response.should render_template(path)
end
end
@djforth
djforth / model_shared_examples.rb
Created March 1, 2013 09:35
Shared Examples for models
shared_examples_for 'manditory string' do |property|
it 'should respond' do
# pending
@record.respond_to?(property.to_sym).should be_true
end
it "is valid with valid attributes"do

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt