Skip to content

Instantly share code, notes, and snippets.

View georgismitev's full-sized avatar

Georgi Mitev georgismitev

  • Zurich, Switzerland
View GitHub Profile
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone https://github.com/rails/rails.git
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
:set nocompatible " Use Vim defaults (much better!)

This is for those having trouble with the 'designmodo-flatuipro-rails' gem in a rails app when using Capistrano for deployment.

This gem required that we use the 'less' gem in conjunction with the 'bootstrap-on-rails' gem. This bootstrap gem is the Less version.

The error we are dealing with is this: couldn't find file 'jquery.ui.touch-punch.min'

All of the work will be done in the 'config/deploy.rb' file

after "deploy:bundle_gems", "deploy:flat_ui"
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
umgi_dir = "/Volumes/OS/interlaced"
files = Dir.glob("#{umgi_dir}/**/*.mp4")
files.each do |f|
ffmpeg_command = "ffmpeg -filter:v idet -frames:v 100 -an -f rawvideo -y /dev/null -i #{f} 2>&1 | awk -F 'detection: ' '/detection/ { print $2 }'"
result_lines = `#{ffmpeg_command}`.split("\n")
puts [f].concat(result_lines).join("\t")
end
/Volumes/OS/interlaced/1/UMG_vidtrk_00602537824199_01_001_20604.mp4 TFF:3 BFF:4 Progressive:12 Undetermined:84 TFF:0 BFF:47 Progressive:45 Undetermined:11
/Volumes/OS/interlaced/2/UMG_vidtrk_00602498883358_01_001_20604.mp4 TFF:90 BFF:2 Progressive:11 Undetermined:0 TFF:86 BFF:0 Progressive:17 Undetermined:0
/Volumes/OS/interlaced/3/UMG_vidtrk_00602498883280_01_001_20604.mp4 TFF:91 BFF:0 Progressive:12 Undetermined:0 TFF:88 BFF:0 Progressive:15 Undetermined:0
/Volumes/OS/interlaced/4/UMG_vidtrk_00602498763469_01_001_20604.mp4 TFF:34 BFF:0 Progressive:69 Undetermined:0 TFF:34 BFF:0 Progressive:69 Undetermined:0
/Volumes/OS/interlaced/5/UMG_vidtrk_00602498644546_01_001_20604.mp4 TFF:50 BFF:4 Progressive:11 Undetermined:38 TFF:67 BFF:12 Progressive:21 Undetermined:3
/Volumes/OS/interlaced/6/ES19X1400059_15320.mp4 TFF:0 BFF:0 Progressive:63 Undetermined:39 TFF:0 BFF:0 Progressive:78 Undetermined:24