Skip to content

Instantly share code, notes, and snippets.

<FilesMatch "\\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
$(document).ready(function(){
$('.js_resize').each(function(){
var imageParent = $(this).parent();
var myWidth = $(this).width();
var myHeight = $(this).height();
var parentWidth = $(this).parent().width();
var parentHeight = $(this).parent().height();
var offset, ratio, newSide;
if (myWidth>myHeight) {
if ($(this).height()>parentHeight) {
@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>
place = DbObjectCache::fetch("pd-#{params[:permalink]}", 3.days) do
thrift_safe do
Loopt::PlacesClient.new.getPlaceByPermalink(Type::Request.new, params[:permalink])
end
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()=='') {
@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
<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>
$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)
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 "*"
// 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;
});