Skip to content

Instantly share code, notes, and snippets.

@karlbright
karlbright / page_classes.rb
Created July 13, 2012 11:15
Page Classes for ApplicationHelper
def page_classes
classes = []
# Get our path along with action name
path = controller.controller_path.split('/') << controller.action_name
# Add appropriate class based on namespace
if path[0] != 'admin'
classes << 'public'
end
# Add class based on whether or not sidebar content is provided
if content_for?(:sidebar) || content_for?(:contextual_sidebar_nav)
@karlbright
karlbright / build.js
Created June 7, 2012 23:02 — forked from millermedeiros/build.js
sample node.js build script including RequireJS optimizer (r.js) and copy/delete/filter files
var _cli = require('commander'),
_glob = require('glob'),
_minimatch = require('minimatch'),
_wrench = require('wrench'),
_fs = require('fs'),
_path = require('path'),
_requirejs = require('requirejs');
class Diablo3
def self.pick_my_class(option1,option2)
options = []
18.times do
options.push(option1)
options.push(option2)
end
options.push('QUIT LIFE')
options.shuffle!
# puts options.sample
@karlbright
karlbright / border.css
Created May 2, 2012 23:47 — forked from nrrrdcore/border.css
Faded/Gradient Borders in Pure CSS
.border-container {
width: 28%; /* border will be on the left on this container */
float: right;
overflow: hidden; /* only needed if floating container */
min-height: 600px; /* static height if you want your container to be taller than its content */
-moz-box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF;
-webkit-box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF;
box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF;
border-width: 0 0 0 1px;
-webkit-border-image:
$(function(){
REGEX = /^\/thefrontiergroup\//;
if(window.location.pathname.match(REGEX)){
var actions, tip, button, commentForm, comment;
discussion = $('#discussion_bucket');
actions = discussion.find('div.form-actions');
@karlbright
karlbright / key down case vs if.coffee
Created March 16, 2012 00:10
Which one looks nicer?
keyDown: (event) ->
switch event.keyCode
# Backspace
when 8
if @el.val() is ''
token = @tokens.pop()
token.remove()
# Enter
when 13 then Houston.nextStep() if @el.autocomplete 'option', 'disabled'
# @
@karlbright
karlbright / gist:2020188
Created March 12, 2012 06:10 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p0
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1333785)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p0 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
@karlbright
karlbright / gist:1558768
Created January 4, 2012 06:18 — forked from sj26/gist:1558727
Sorting and merging a set of numbers and ranges
We couldn’t find that file to show.
@karlbright
karlbright / modalize.js
Created October 27, 2011 00:03
Fixing some of Jesse's code. Example of using jquery extend functionality.
$.fn.modalize = function(){
$(this).each(function(i,v){ // Iterate over each of the elements
var el = $(v), popup = el.prev('.popup');
el.bind('input', function(){ // When the user types within input...
if(popup.is(':hidden')) el.prev('.popup').fadeIn(100); // Grab previous sibling with class of 'popup'
});
el.bind('focusout', function(){ // When focus leaves this element...
$('.popup').fadeOut(300); // Fade all popups out
});
})
var http = require('http')
http.createServer(function (req,res) {
res.writeHead(200, {'Content-Type':'text/plain'});
res.end('Hello World! \n');
}).listen(1337,"127.0.0.1");
console.log('Server running at http://127.0.0.1:1337//');