Skip to content

Instantly share code, notes, and snippets.

def pf(path)
picturefill(path, "AltText") do
b = path.scan(/(^.*)\.(jpg|png|gif)/).flatten
sizes = {
:small => "#{b[0]}_small.#{b[1]}",
:medium => "#{b[0]}_medium.#{b[1]}",
:medium_high_dpi => "#{b[0]}_medium_high_dpi.#{b[1]}",
:large => "#{b[0]}_large.#{b[1]}",
:large_high_dpi => "#{b[0]}_large_high_dpi.#{b[1]}"
}
@twetzel
twetzel / deploy.rb
Last active February 22, 2018 09:37 — forked from Jesus/deploy.rb
compile assets local with capistrano 3.2.1 and rails 4.1.1 (fully integrated)
# Clear existing task so we can replace it rather than "add" to it.
Rake::Task["deploy:compile_assets"].clear
namespace :deploy do
desc 'Compile assets'
task :compile_assets => [:set_rails_env] do
# invoke 'deploy:assets:precompile'
invoke 'deploy:assets:precompile_local'
invoke 'deploy:assets:backup_manifest'
@Jesus
Jesus / deploy.rb
Last active June 2, 2016 23:31 — forked from buntine/deploy.rb
# Clear existing task so we can replace it rather than "add" to it.
Rake::Task["deploy:compile_assets"].clear
desc "Precompile assets locally and then rsync to web servers"
task :compile_assets do
# compile assets locally
run_locally do
with rails_env: fetch(:stage) do
execute :bundle, "exec rake assets:precompile"
end
@staltz
staltz / introrx.md
Last active May 6, 2024 01:44
The introduction to Reactive Programming you've been missing
defmodule ApplicationRouter do
use Dynamo.Router
prepare do
# Pick which parts of the request you want to fetch
# You can comment the line below if you don't need
# any of them or move them to a forwarded router
conn.fetch([:cookies, :params])
end
@kimjoar
kimjoar / 1_fakeResponse.js
Created May 10, 2013 08:14
High-level helpers for Sinon.js
define(function(require) {
var sinon = require('sinon');
var _ = require('underscore');
// fakeResponse
// ------------
//
// High-level helper for responding equally to all Ajax requests.
//
@imonyse
imonyse / jasmine_config.rb
Created September 5, 2011 05:25 — forked from rsim/jasmine_config.rb
Adds CoffeeScript support for jasmine gem (rake jasmine task), uses barista gem to compile CoffeScript files to JavaScript before running Jasmine tests.
# put this file in spec/javascripts/support directory
require 'barista'
require 'logger'
require File.join(Rails.root, 'config/initializers/barista_config')
Barista.configure do |c|
c.env = 'test'
c.logger = Logger.new(STDOUT)
@viola
viola / gist:1070410
Created July 7, 2011 20:00
Example of fetching Hash (key,value) to the simple_form collection.
-- model
some sort of constant hash:
HASH_NAME = {
0 => "Choose:",
1 => "On-Campus Recruiting - CSO",·
2 => "CSO Staff Referral",
3 => "Faculty Contact",·
4 => "Career Day",·
5 => "CSO Summer Job Listing",·
6 => "Alumni Contact",·
@yortz
yortz / post-receive
Created June 26, 2011 00:28 — forked from carlosantoniodasilva/post-receive
Basic git post-receive hook file to deploy a Rails app.
#!/bin/bash
APP_NAME="your-app-name-goes-here"
APP_PATH=/home/deploy/${APP_NAME}
# Production environment
export RAILS_ENV="production"
# This loads RVM into a shell session. Uncomment if you're using RVM system wide.
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
" Switch wrap off for everything
set nowrap
if has("autocmd")
" This is probably in your .vimrc already. No need to duplicate!
filetype plugin indent on
" Set File type to 'text' for files ending in .txt
autocmd BufNewFile,BufRead *.txt setfiletype text