Skip to content

Instantly share code, notes, and snippets.

View MikeRuby's full-sized avatar

Michael Vallen MikeRuby

  • Acceleration Ventures
  • San Diego, CA
View GitHub Profile
module ActionView
module Helpers
module AssetTagHelper
def favicon_link_tag(url_options = {}, tag_options = {})
href = url_options.is_a?(Hash) ?
url_for(url_options.merge(
:only_path => false)) : url_options
tag(
"link",
"rel" => tag_options[:rel] || nil,
// Modification from original http://twitter.com/javascripts/blogger.js
// Just a quick fix to clean up the code, make html validate, some ajax to add a loader in case Twitter is slow
// and then apear once it loads.
// It uses Scriptaculous
function twitterCallback2(twitters) {
var statusHTML = [];
for (var i=0; i<twitters.length; i++){
var username = twitters[i].user.screen_name;
var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
return '<a href="'+url+'">'+url+'</a>';
/*
Jquery and Rails powered default application.js
Easy Ajax replacement for remote_functions and ajax_form based on class name
All actions will reply to the .js format
Unostrusive, will only works if Javascript enabled, if not, respond to an HTML as a normal link
respond_to do |format|
format.html
format.js {render :layout => false}
end
*/
#ruby-enterprise-1.8.6-20090610
cd ruby-enterprise-1.8.6-20090610/source/ext/iconv
/opt/ruby-enterprise-1.8.6-20090610/bin/ruby extconf.rb --prefix=/opt/ruby-enterprise-1.8.6-20090610 --with-iconv-dir=/usr/local/
make
cp iconv.so /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/1.8/x86_64-freebsd7.2/
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
class MyUploader < CarrierWave::Uploader::Base
include Thumbkit::Adapters::CarrierWave
# Watermark should always be processed after thumbkit, ensuring that we always
# have a valid image and we don't need to change the extension
def watermark(watermark_image, options = {})
cache_stored_file! if !cached?
Watermarker.new(current_path, watermark_image).watermark!(options)
end
@MikeRuby
MikeRuby / gist:8808873
Created February 4, 2014 17:56
Jcrop + Carrierwave
# https://github.com/gzigzigzeo/carrierwave-meta
# The uploader:
class CropUploader < SobakaUploader
include CarrierWave::Meta
# Crop source is a source image converted from original which could be bigger than source area (left image in the example).
version :crop_source do
process :resize_to_fit => [300, 300]

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@MikeRuby
MikeRuby / Gemfile
Last active August 29, 2015 14:16 — forked from pcreux/Gemfile
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end