Skip to content

Instantly share code, notes, and snippets.

View blake-simpson's full-sized avatar

Blake Simpson blake-simpson

View GitHub Profile
@blake-simpson
blake-simpson / gist:1422895
Created December 2, 2011 11:24
Alen Grakalic's Pure CSS3 tags in SASS/Compass
//Thank you to Alen Grakalic: http://cssglobe.com/lab/css3_tags/01.html
$_tag_color: #006DDC
.tags
list-style: none
margin: 10px 0 0 0
.tags li, .tags a
float: left
height: 20px
line-height: 20px
@blake-simpson
blake-simpson / module.params.js
Created July 19, 2012 13:18
Javascript module that returns current URL params ($.params)
(function(){
findURLParams = function() {
var params = {};
location.search.replace(
/([^?=&]+)(=([^&]*))?/g,
function (match, key, full, value) {
params[key] = decodeURIComponent(value);
}
);
return params;
@blake-simpson
blake-simpson / gist:3164344
Created July 23, 2012 15:50
unless_blank Handlerbars JS helper
// Uses same syntax as #if helper but initially returns false for falsey or empty string values.
Handlebars.registerHelper('unless_blank', function(item, block) {
return (item && item.replace(/\s/g,"").length) ? block.fn(this) : block.inverse(this);
});
// Only the first 2 rows will be displayed.
data = {
rows: [
'user_name': 'Blake',
'user_name': 'Joe',
@blake-simpson
blake-simpson / setup.rake
Created August 6, 2012 10:55
Rake Setup task
task :devenv_check do
raise "You can only run this task in development mode!" unless Rails.env == 'development'
end
task :setup do
puts "Preparing to build databases. Running Rake tasks...."
#Remove all existing photo uploads and caches. TextMate users will appreciate this!
system "rm -rf public/uploads/*"
system "rm -rf tmp/cache/*"
@blake-simpson
blake-simpson / .tm_properties
Created August 10, 2012 15:28
TM Properties: Rails setup
tabSize = 2
softTabs = true
showInvisibles = true
include = "{.rvmrc,.rspec,.gitignore,.tm_properties,.htaccess}"
excludeInFileChooser = "{$excludeInFileChooser,log,vendor,tmp,.sass-cache,uploads}"
excludeInBrowser = "{$excludeInBrowser,log,vendor,tmp,.sass-cache,uploads}"
excludeInFolderSearch = "{$excludeInFolderSearch,log,vendor,tmp,.sass-cache,uploads}"
@blake-simpson
blake-simpson / .vimrc
Last active October 9, 2022 17:12
Macvim Config
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-rails'
@blake-simpson
blake-simpson / gist:3654276
Last active January 6, 2019 22:48
Convert all ERB templates to HAML templates

Prerequisites

You must have the following gems installed:

  • haml (or haml-rails)
  • html2haml
  • hpricot
  • ruby_parser

Create HAML files

@blake-simpson
blake-simpson / .bash_profile
Last active October 10, 2015 21:38
bash_profile
alias ls='ls -G'
alias lsa='ls -la'
alias g='git'
alias gp="git pull"
alias gpu="git push"
alias gpt="git push --tags"
alias gpp="git pull && git push"
alias gc="git checkout"
alias gs="git status"
@blake-simpson
blake-simpson / gist:5115461
Created March 8, 2013 10:02
A JavaScript function that checks the size of the scrollbar for the current browser and adds a class to the body allowing CSS styling. Useful when designing cross-browser for OSX where some browsers have an overlaid 0 width scrollbar and other use 15px+. The function could be modified to add a data attribute with the exact width, if you need mor…
// Discovered here then refactored: http://davidwalsh.name/detect-scrollbar-width
var checkScrollbarWidth = function() {
var $body = $("body"),
$div = $('<div class="scrollbar-measure">'),
scrollbarWidth;
$div.appendTo( $body );
scrollbarWidth = $div[0].offsetWidth - $div[0].clientWidth;
$div.remove();
@blake-simpson
blake-simpson / .jshintrc
Created September 1, 2013 16:02
JS hint config dotfile
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope