Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joshuapaling
joshuapaling / rename_css_scss.rake
Created March 31, 2015 23:45
Rake task to rename .css.scss files to just .scss (the long extension is deprecated)
task :rename_css_scss do
files = Rake::FileList["app/assets/stylesheets/**/*.css.scss"]
files.each do |f|
new_name = f.gsub(/\.css\.scss/, '.scss')
sh "mv #{f} #{new_name}"
end
end
@joshuapaling
joshuapaling / capistrano log
Last active August 29, 2015 14:08
BIG Vault Capistrano Deployment
joshuapaling: /Applications/MAMP/htdocs/BIG/Employee_Management_Website/www
->cap staging deploy
INFO[516fb1c3] Running /usr/bin/env mkdir -p /tmp/the_big_vault_staging/ on XXX.XXX.XXX.XXX
DEBUG[516fb1c3] Command: /usr/bin/env mkdir -p /tmp/the_big_vault_staging/
INFO[516fb1c3] Finished in 0.501 seconds with exit status 0 (successful).
DEBUGUploading /tmp/the_big_vault_staging/git-ssh.sh 0.0%
INFOUploading /tmp/the_big_vault_staging/git-ssh.sh 100.0%
INFO[7f2c25f1] Running /usr/bin/env chmod +x /tmp/the_big_vault_staging/git-ssh.sh on XXX.XXX.XXX.XXX
DEBUG[7f2c25f1] Command: /usr/bin/env chmod +x /tmp/the_big_vault_staging/git-ssh.sh
INFO[7f2c25f1] Finished in 0.069 seconds with exit status 0 (successful).
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
staging 1709 0.0 0.0 10772 1404 ? S 10:14 0:00 bash -c cd '/home/staging/public_html/releases/20141013231355/app/Vendor/kamisama/php-resque-ex/'; VERBOSE=true QUEUE='default' PIDFILE='/home/staging/public_html/releases/20141013231355/app/Plugin/CakeResque/t
staging 1710 0.0 0.7 161472 15492 ? S 10:14 0:00 php ./bin/resque
staging 3437 0.0 0.0 10772 1404 ? S 10:17 0:00 bash -c cd '/home/staging/public_html/releases/20141013231718/app/Vendor/kamisama/php-resque-ex/'; VERBOSE=true QUEUE='default' PIDFILE='/home/staging/public_html/releases/20141013231718/app/Plugin/CakeResque/t
staging 3438 0.0 0.7 161496 15468 ? S 10:17 0:00 php ./bin/resque
staging 4803 0.0 0.0 10772 1404 ? S 10:19 0:00 bash -c cd '/home/staging/public_html/releases/20141013231903/app/Vendor/kamisama/php-resque-ex/'; VERBOSE=true QUEUE='default' PIDFILE='/home/staging/p
@joshuapaling
joshuapaling / gist:cb683d8ec6ecab077c19
Last active August 29, 2015 14:03
htaccess caching, gzip compression, and blocking bots / scrapers
<IfModule mod_deflate.c>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
<?php
// put this code in app/View/Layouts/ajax.ctp
echo $this->fetch('content');
?>
@joshuapaling
joshuapaling / gist:6879193
Created October 8, 2013 03:49
Using: gem 'spree', github: 'radar/spree', branch: '2-1-stable'
Bundler could not find compatible versions for gem "nokogiri":
In Gemfile:
spree (>= 0) ruby depends on
nokogiri (< 1.6.0, >= 1.4.4) ruby
spree (>= 0) ruby depends on
nokogiri (1.6.0)
@joshuapaling
joshuapaling / Cap deploy errors
Last active December 24, 2015 23:09
Spree upgrade errors - rake aborted! Invalid route name, already in use: 'root'
* executing "cd -- /var/www/vhosts/sneakerology.com.au/staging/releases/20131008015449 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile"
servers: ["sneakerology.com.au"]
[sneakerology.com.au] executing command
** [out :: sneakerology.com.au] rake aborted!
** [out :: sneakerology.com.au] Invalid route name, already in use: 'root'
** [out :: sneakerology.com.au] You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
** [out :: sneakerology.com.au] http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
** [out :: sneakerology.com.au] /var/www/vhosts/sneakerology.com.au/staging/shared/bundle/ruby/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:409:in `add_route'
** [out :: sneakerology.com.au] /var/www/vhosts/sneakerology.com.au/staging/sh
@joshuapaling
joshuapaling / gist:6712817
Created September 26, 2013 11:19
ruby warrior beginner level 6
class Player
def initialize
@max_health = 20
@prev_health = @max_health
@rescued_behind = false
@half_health = @max_health / 2
end
def play_turn(warrior)
@joshuapaling
joshuapaling / deploy.rb
Last active December 20, 2015 22:48
capistrano output - failing to install pg gem
require "bundler/capistrano"
require "rvm/capistrano"
#set :rvm_ruby_string, :local # from https://github.com/wayneeseguin/rvm-capistrano
set :rvm_type, :system # from http://stackoverflow.com/questions/5253153/rvm-error-with-deploying-rails-app-via-capistrano
default_run_options[:shell] = '/bin/bash --login'
set :application, "sneakerology_spree"
set :repository, "ssh://git@bitbucket.org/bbldigital/sneakerology-ecom.git"
@joshuapaling
joshuapaling / jquery-tabs
Created July 15, 2013 04:02
Super Simple JQuery Tabs
function setUpTabs($tabContainer){
$('.tab_links a', $tabContainer).click(function(){
$('.tab_content', $tabContainer).hide();
$('.tab_links a', $tabContainer).removeClass('current');
$(this).addClass('current');
var tabId = $(this).attr('href');
//tabId = tabId.substr(1); // stip of the # from the front
window.location.hash = tabId;
$(tabId).show();