Skip to content

Instantly share code, notes, and snippets.

View shenoudab's full-sized avatar

Shenouda Bertel shenoudab

View GitHub Profile
@mlitwiniuk
mlitwiniuk / video_converter.rb
Created December 4, 2011 11:40
CarrierWave - video encoding with Voyeur - lib/carrierwave_processing/
module CarrierWave
module VideoConverter
extend ActiveSupport::Concern
module ClassMethods
def encode_video(target_format)
process :encode_video => [target_format]
end
end
def encode_video(format='mp4')
@mlitwiniuk
mlitwiniuk / video_uploader.rb
Created December 4, 2011 11:39
CarrierWave - video encoding with Voyeur - app/uploaders/
# encoding: utf-8
class VideoUploader < CarrierWave::Uploader::Base
include CarrierWave::VideoConverter
storage :file
version :mp4 do
process :encode_video => [:mp4]
def full_filename(for_file)
@mlitwiniuk
mlitwiniuk / carrierwave.rb
Created December 4, 2011 11:37
CarrierWave - video encoding with Voyeur - config/initializers/
dir = Rails.root.join('lib', 'carrierwave_processing')
$LOAD_PATH.unshift(dir)
Dir[File.join(dir, "*.rb")].each {|file| require File.basename(file) }
@hernan
hernan / autocomplete.html
Created November 30, 2011 15:39
jquery autocomplete demo with custom render item implementation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Custom data and display</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.6.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
@teeparham
teeparham / devise_resque_mailer.rb
Last active September 28, 2015 03:18
Devise Resque Mailer
module Resque
module Mailer
class MessageDecoy
def deliver
record = @args.first
resque.enqueue @mailer_class, @method_name, record.class.name, record.id
end
end
end
end
@bradly
bradly / deploy.rake
Created July 27, 2011 03:58
Simple Rails Deployments with Net/SSH
require 'net/ssh'
desc "Deploy site to production"
task :deploy => :environment do
host = 'yourhost.com'
user = 'username'
options = {:keys => '~/.ssh/keys/yourserver.pem'}
remote_path = '/path/to/rails_app'
commands = [
@ahamid
ahamid / ImageUploader
Created May 27, 2011 16:51
CarrierWave mixed content upload processing
require 'carrierwave/processing/mini_magick'
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
IMAGE_EXTENSIONS = %w(jpg jpeg gif png)
DOCUMENT_EXTENSIONS = %w(exe pdf doc docm xls)
def store_dir
"files/#{model.id}"
@jraines
jraines / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@dbi
dbi / edit.html.mustache
Created May 4, 2011 09:31
Rails form helper for mustache spike/proof of concept
<!-- A scaffolded edit view converted to mustache -->
<h1>Editing post</h1>
{{#form}}
{{#errors?}}
<div id="error_explanation">
<h2>{{error_header}}</h2>
</div>
<ul>
@marksteve
marksteve / Backbone.View.Autocomplete.js
Created May 3, 2011 10:54
Backbone View for jQuery UI Autocomplete inputs
var Autocomplete = Backbone.View.extend({
render: function() {
var choices = this.options.choices,
selected = this.options.selected,
iterator = this.options.iterator,
label = this.options.label,
allowDupes = this.options.allowDupes,
$el = $(this.el);
$el.autocomplete({
source: function(request, response) {