Skip to content

Instantly share code, notes, and snippets.

View lightyrs's full-sized avatar
🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)

Harris Novick lightyrs

🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)
View GitHub Profile
@lightyrs
lightyrs / .gitignore
Created February 23, 2012 03:48
Rails .gitignore
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
/.bundle
/vendor/bundle
/log/*
/tmp/*
/db/*.sqlite3
@lightyrs
lightyrs / black_glass.css
Created January 12, 2012 03:01
Black Glass CSS3
http://dev.opera.com/articles/view/beautiful-ui-styling-with-css3-text-shadow-box-shadow-and-border-radius/
Here I’ve applied rgba colours to the shadows, so most of this box is semi-transparent. I have added a second div around the first one with a repeating background pattern image applied to it, so you can appreciate the full extent of this effect.
div {
width: 100px;
height: 100px;
margin: 10px;
padding: 0;
border: 1px solid rgba(0,0,0,0.5);
@lightyrs
lightyrs / app--helpers--application_helper.rb
Created January 9, 2012 02:43 — forked from nickhoffman/app--helpers--application_helper.rb
pjax is awesome, but causes code within #content_for not to be rendered. Here's a solution.
module ApplicationHelper
def content_for_or_pjax(name, &block)
request.headers['X-PJAX'] ? capture(&block) : content_for(name, &block)
end
end
@lightyrs
lightyrs / Loadingdotdot.mod.js
Created January 8, 2012 02:53
Loadingdotdot.js (modified)
(function($) {
$.Loadingdotdotdot = function(el, options) {
var base = this;
base.$el = $(el);
base.$el.data("Loadingdotdotdot", base);
@lightyrs
lightyrs / backbone_router_helper.rb
Created January 2, 2012 21:01
Rails Backbone Router Helper
# application_helper.rb
def backbone_router(resource, collection)
<<-eos
$(function() {
window.router = new #{APP_NAME.capitalize}.Routers.#{resource.capitalize}Router({#{resource.downcase}:#{collection.to_json.html_safe}});
Backbone.history.start();
});
eos
end
@lightyrs
lightyrs / wanstrath.txt
Created December 30, 2011 22:52 — forked from defunkt/gist:6443
Chris Wanstrath Open Source Talk
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
@lightyrs
lightyrs / list_rails_models.rb
Created December 8, 2011 21:36
Rails List All Models
ActiveRecord::Base.connection.tables.map do |model|
model.capitalize.singularize.camelize
end
# returns ["Activity", "Article", "User", "Video", "Vote"]
@lightyrs
lightyrs / apple_browser_detect.js
Created October 16, 2011 19:05
How Apple does browser detection
SC._detectBrowser = function(userAgent, language) {
var version, webkitVersion, browser = {};
userAgent = (userAgent || navigator.userAgent).toLowerCase();
language = language || navigator.language || navigator.browserLanguage;
version = browser.version = (userAgent.match(/.*(?:rv|chrome|webkit|opera|ie)[\/: ](.+?)([ \);]|$)/) || [])[1];
webkitVersion = (userAgent.match(/webkit\/(.+?) /) || [])[1];
browser.windows = browser.isWindows = !! /windows/.test(userAgent);
browser.mac = browser.isMac = !! /macintosh/.test(userAgent) || (/mac os x/.test(userAgent) && !/like mac os x/.test(userAgent));
browser.lion = browser.isLion = !! (/mac os x 10_7/.test(userAgent) && !/like mac os x 10_7/.test(userAgent));
browser.iPhone = browser.isiPhone = !! /iphone/.test(userAgent);
@lightyrs
lightyrs / canvas_color_fade.js
Created October 15, 2011 09:19
Transition canvas img from grayscale to color
(function() {
var supportsCanvas = !!document.createElement('canvas').getContext;
supportsCanvas && (window.onload = greyImages);
function greyImages() {
var ctx = document.getElementsByTagName('canvas')[0].getContext('2d'),
img = document.getElementById('cvs-src'),
imageData, px, length, i = 0,
red, green, blue, grey;
require 'action_controller/test_process'
# Paperclip attachments in factories, made easy based on technicalpickles
Factory.class_eval do
def attach(name, path, content_type = nil)
if content_type
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}", content_type)
else
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}")
end