Skip to content

Instantly share code, notes, and snippets.

View weavermedia's full-sized avatar

Dan Weaver weavermedia

View GitHub Profile
class Zencoder
include HTTParty
headers "Accept" => "application/json", "Content-Type" => "application/json"
base_uri 'https://app.zencoder.com/api'
default_params :api_key => "YOUR-API-KEY-GOES-HERE"
format :json
attr_accessor :job_id
attr_reader :errors
attr_reader :output_url
class Video < ActiveRecord::Base
validates_presence_of :title
named_scope :finished, :conditions => { :encoded_state => "finished" }
has_attached_file :video,
:url => ":class/:id/:style/:basename.:extension",
:path => ":class/:id/:style/:basename.:extension",
:storage => :s3
validates_attachment_presence :video
@davist11
davist11 / Fancy File Inputs.js
Created October 25, 2010 21:32
Fancy File Inputs
var SITE = SITE || {};
SITE.fileInputs = function() {
var $this = $(this),
$val = $this.val(),
valArray = $val.split('\\'),
newVal = valArray[valArray.length-1],
$button = $this.siblings('.button'),
$fakeFile = $this.siblings('.file-holder');
if(newVal !== '') {
@bastien
bastien / content.rb
Created July 6, 2012 09:58
Paperclip processor to convert PDF to JPG to go around problems with the old versions of imagemagick and ghostscript available on Heroku. This file is located in [APP_ROOT]/lib/paperclip_processors/ghostscript.rb
# Model using the ghostscript processor
class Content < ActiveRecord::Base
has_attached_file :resource,
:styles => { :preview => ["725x1200>", :jpg], :thumb => ["100x140>", :jpg] },
:processors => [:ghostscript, :thumbnail],
:convert_options => { :all => '-colorspace RGB -flatten -density 300 -quality 100' },
:path => ":page_path/:class/:id/:resource_token/:style/:filename"
end
@iloveitaly
iloveitaly / .gitattributes
Last active May 8, 2019 19:31
Snippets for Spree Commerce Development
# with my git configuration the spree repo was giving me issues with line endings
# this fixed the issue for me: marking a file as binary causes git to ignore it completely
core/vendor/assets/javascripts/jquery.alerts/jquery.alerts.css.erb binary
core/vendor/assets/javascripts/jquery.alerts/jquery.alerts.js binary
core/vendor/assets/javascripts/jquery.jstree/themes/apple/style.css binary
sample/db/sample/spree/line_items.yml binary
sample/db/sample/spree/products.yml binary
@p1nox
p1nox / postgresql_configuration_on_ubuntu_for_rails.md
Last active November 29, 2023 04:38
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev
@glava
glava / Rakefile
Last active August 8, 2020 12:34
Stop, Start, Restart Rake tasks for Rails
desc 'Stop rails server'
task :stop do
 File.new("tmp/pids/server.pid").tap { |f| Process.kill 9, f.read.to_i }.delete
end
desc 'Starts rails server'
task :start do
Process.exec("rails s puma -d")
end
@wetzler
wetzler / gist:6629918
Last active February 23, 2019 21:31
a key with magical powers
d90e5b5598497773de1c57407dd54d65934ba1b5911f6f47311d3c729f510bb5c295284780017a56f17e49234f19c009bfa57f7941413a5dd3c282d7db3692a192b58ea926b637cdcd11377e1e74086641e0672c8b3406aeed49d63ee0a3a3d3751ae7744f08b999df38ca2ccdbb9a2c
@julionc
julionc / 00.howto_install_phantomjs.md
Last active April 26, 2024 09:13
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.