Skip to content

Instantly share code, notes, and snippets.

@joshmvandercom
joshmvandercom / madeofcode.vim
Created August 31, 2011 16:59
Port of Made of Code Theme to VIM
" Port of my favorite theme Made of Code by Mark Dodwell
" For Textmate Theme visit - http://madeofcode.com/posts/29-photo-my-new-textmate-theme-8220-made-of-code-8221-mdash-download-9-feb-2010-update-t
" Vim color file
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
@joshmvandercom
joshmvandercom / rails-template.rb
Created August 31, 2011 03:45
Most of the stuff u needz
## Rails App Template
## Updated for Rails 3.0.7
## Run using $ rails new [appname] -JT -m josh-template.rb
##
## Gems
gem 'mysql'
gem 'sass'
gem 'haml'
gem 'haml-rails'
// obviously this is for alpha
myArray.sort(function(x, y){
var xl = x.toLowerCase();
var yl = y.toLowerCase();
if (xl<yl) return -1;
if (xl>yl) return 1;
return 0;
});
RED="\[\033[1;31m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
BLUE="\[\033[1;36m\]"
# Returns "*" if the current git branch is dirty.
function parse_git_dirty {
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*"
$flap_left = 1
$flap_right = 2
.ribbon-wrapper
position: relative
background-color: $etsy
padding: 10px 30px 10px 55px
margin-bottom: 10px
border: 1px solid #ddd
=ribbon($color, $flap, $flaps=1, $direction=$flap_left)
<div class="users">
<% users.in_groups_of(10, false) do |user_group| %>
<div class="user-row">
<% for user in user_group %>
your user here
<% end %>
</div>
<% end %>
</div>
@joshmvandercom
joshmvandercom / execution_time.rb
Created January 10, 2011 22:55
Calculate Execution time
def execution_time
start = Time.now
yield
puts Time.now - start # Here you would probably log the elapsed time
end
execution_time do
1.upto(10000) do |i|
i * 1 # LIke a for loop
end
jQuery.fn.clearThis = function() {
return this.each(function(){
var initVal = $(this).val();
$(this).click(function(){
if ($(this).val()==initVal) {
$(this).val('');
}
});
$(this).blur(function(){
if ($(this).val()=='') {
place = DbObjectCache::fetch("pd-#{params[:permalink]}", 3.days) do
thrift_safe do
Loopt::PlacesClient.new.getPlaceByPermalink(Type::Request.new, params[:permalink])
end
end
@joshmvandercom
joshmvandercom / .htaccess
Created April 12, 2010 15:34
Simple GZIP compression and ETag removal using .htaccess
<FilesMatch "\\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2011 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>