Skip to content

Instantly share code, notes, and snippets.

View jcypret's full-sized avatar

Justin Cypret jcypret

View GitHub Profile
@jcypret
jcypret / current-page.coffee
Last active October 6, 2015 16:18
Nav Current Page
$('nav li a').each =>
this.addClass('current') if this.text() == $('h1').text()
@jcypret
jcypret / clickable-tr.coffee
Created July 27, 2012 03:29
Clickable Tablerow
$('tr.clickable').on 'click', ->
document.location.href = $(this).data('url')
@jcypret
jcypret / twitalinkahashifyer.js
Last active January 22, 2018 16:25
JS: Twitalinkahashifyer!
/**
* The Twitalinkahashifyer!
* http://www.dustindiaz.com/basement/ify.html
* Eg:
* Ify.clean('your tweet text');
*/
Ify = {
link: function(tweet) {
return tweet.replace(/\b(((https*\:\/\/)|www\.)[^\"\']+?)(([!?,.\)]+)?(\s|$))/g, function(link, m1, m2, m3, m4) {
var http = m2.match(/w/) ? 'http://' : '';
@jcypret
jcypret / application_helper.rb
Created June 20, 2013 04:58
IE Conditional Comments HAML
# Implements the Paul Irish IE conditional comments HTML tag--in HAML.
# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
# http://ricostacruz.com/2010/haml_and_ie_compatibility.html
def cc_html(options={}, &blk)
attrs = options.map { |(k, v)| " #{h k}='#{h v}'" }.join('')
[ "<!--[if lt IE 7 ]> <html#{attrs} class='ie6'> <![endif]-->",
"<!--[if IE 7 ]> <html#{attrs} class='ie7'> <![endif]-->",
"<!--[if IE 8 ]> <html#{attrs} class='ie8'> <![endif]-->",
"<!--[if IE 9 ]> <html#{attrs} class='ie9'> <![endif]-->",
"<!--[if (gt IE 9)|!(IE)]><!--> <html#{attrs}> <!--<![endif]-->",
@jcypret
jcypret / main.js.coffee
Created June 22, 2013 01:14
Google Analytics Turbolinks
$(document).on 'page:change', ->
if window._gaq?
_gaq.push ['_trackPageview']
else if window.pageTracker?
pageTracker._trackPageview()
@jcypret
jcypret / wufoo_regex
Created July 2, 2013 03:15
Wufoo Shortcode Regex
/\[wufoo username="(\S+)" formhash="(\S+)" autoresize="(\S+)" height="(\S+)" header="(\S+)" ssl="(\S+)"\]/
@jcypret
jcypret / wercker.yml
Created April 12, 2014 00:35
Wercker Middleman
box: wercker/ruby
build:
steps:
# Execute the bundle install step, a step provided by wercker
- bundle-install
# Execute a custom script step.
- script:
name: middleman build
code: bundle exec middleman build --verbose
deploy:
@jcypret
jcypret / Gemfile
Created July 10, 2014 02:58
WordPress Rack Config
source 'https://rubygems.org'
gem 'rack'
gem 'rack-legacy'
@jcypret
jcypret / service.rb
Created February 3, 2015 04:23
Module for creating service objects
module Service
extend ActiveSupport::Concern
included do
def self.call(*args)
new(*args).call
end
end
end
@jcypret
jcypret / hashids.rb
Created February 10, 2015 07:40
Initializer to enable Hashids in a Rails app
module HashidsSupport
extend ActiveSupport::Concern
class_methods do
def hashids
Hashids.new(table_name, 6)
end
def encode_id(id)
hashids.encode(id)