Skip to content

Instantly share code, notes, and snippets.

@RobDoan
RobDoan / gist:286783
Created January 26, 2010 12:09 — forked from dhh/gist:281420
class Notifier < ActionMailer::Base
delivers_from 'notifications@example.com'
def welcome(user)
@user = user # available to the view
mail(:subject => 'Welcome!', :to => user.email_address)
# auto renders both welcome.text.erb and welcome.html.erb
end
def goodbye(user)
@RobDoan
RobDoan / README
Created September 12, 2011 19:34 — forked from Bertg/README
These are some snips to help you converting video to flash and thumbnails using ruby and paperclip.
Needed: ffmpeg & flvtool, RVideo gem, paperclip
Converting the video is done using outside of paperclip, as this could take quite a while. Paperclip by default does it's conversions during the request, and the last thing you want is a request hanging for 10minutes while ffmpeg does it's thing. It is advised to do this conversion somewhere in the background using Resque or DelayedJob. (make sure not to run to many conversions at one time on your machine)
Most video thumbnailing solutions out there will create all thumbnails from the video. This solution (on paperclip 2.3.0) however will create one large "temp_thumbnail" once and all consequent thumbnails can use this temporary version.
VideoGeometry will make sure that the target dimensions for ffmpeg are always a multiple of 2 and as close as possible to the desired dimensions without breaking the aspect ratio of the original video.
@RobDoan
RobDoan / add_attachment_data_to_wrapper.rb
Created September 26, 2011 20:04 — forked from janv/add_attachment_data_to_wrapper.rb
Small tips for building a polymorphic usage of Paperclip, with video to flv, video thumbnail, mp3 tag extraction, zip file listing processors.
class AddAttachmentsDataToWrapper < ActiveRecord::Migration
def self.up
add_column :wrappers, :data_file_name, :string
add_column :wrappers, :data_content_type, :string
add_column :wrappers, :data_file_size, :integer
add_column :wrappers, :data_updated_at, :datetime
end
def self.down
remove_column :wrappers, :data_file_name
@RobDoan
RobDoan / application.js
Created September 27, 2011 06:10 — forked from fabware/application.js
socket.io application and haproxy configuration
var express = require('express');
var redis = require('redis');
const serverType = process.argv[2];
const serverHost = process.argv[3];
const serverPort = parseInt(process.argv[4]);
const redisPort = 6379;
const redisHost = '127.0.0.1';
@RobDoan
RobDoan / video_information.rb
Created October 12, 2011 21:24
Get video information
module VideoInformation
def get_video_file_information(file_path)
command = "-i #{file_path} 2>&1"
begin
video_info = Paperclip.run('ffmpeg', command, :expected_outcodes => [0, 1, 2, 3])
parse_video_info(video_info)
rescue Cocaine::ExitStatusError => e
Rails.logger.error("There was an error getting the video information from file #{file_path}")
Rails.logger.error(e)
end
@RobDoan
RobDoan / rcov.rake
Created February 11, 2012 21:13 — forked from alexdreher/rcov.rake
rcov raketask for Rails 3, RSpec 2
# Forked to get it working with Rails 3 and RSpec 2
#
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
#
# Use rcov:rspec or rcov:cucumber
# to get non-aggregated coverage reports for rspec or cucumber separately

Customization


  <%= f.input :state, :collection => ['SA', 'WA'] %>
  <%= f.input :state,
              :as => :radio_buttons,
curl -s -XPOST localhost:9200/_bulk?pretty=true --data-binary '
{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" : "store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" : "department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "index" : { "_index" : "parent_child", "_type" : "product", "_id" : "product1", "parent" : "department1", "routing" : "store1" } }
{ "name" : "gun", "trademark" : "tiger", "price" : 9, "store_id" : "store1" }
'
@RobDoan
RobDoan / InstallTeamCity.md
Last active July 28, 2016 00:10
Install TeamCity

Prepare

  • Create teamcity user: adduser -s /bin/bash teamcity
  • Add Group to teamcity: usermod -a -G admin,teamcity teamcity
  • Update aptget sudo apt-get update
  • sudo apt-get install -y openjdk-8-jre-headless
  • sudo apt-get install -y curl

Install Postgresql

  • sudo apt-get install -y postgresql-client postgresql postgresql-contrib
  • sudo -u postgres psql postgres
@RobDoan
RobDoan / install-teamcity.md
Created July 27, 2016 07:16 — forked from sandcastle/install-teamcity.md
Install TeamCity 9.0.3 on Ubuntu with Nginx