This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = 236 # seconds | |
Time.at(t).utc.strftime("%H:%M:%S") | |
=> "00:03:56" | |
# Reference | |
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample implementation of quicksort and mergesort in ruby | |
# Both algorithm sort in O(n * lg(n)) time | |
# Quicksort works inplace, where mergesort works in a new array | |
def quicksort(array, from=0, to=nil) | |
if to == nil | |
# Sort the whole array, by default | |
to = array.count - 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<% @orders.each do |order| %> | |
<li> | |
<!-- Show order stuff --> | |
</li> | |
<% end %> | |
</ul> | |
<%= will_paginate @orders %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install build-essential libxslt1.1 libxslt1-dev libxml2 mysql-server libmysqlclient-dev libmysql-ruby libssl-dev libopenssl-ruby libcurl4-openssl-dev imagemagick libmagickwand-dev git-core redis-server libffi-dev libffi-ruby rubygems libsqlite3-dev libpq-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev libyaml-dev libsqlite3-0 sqlite3 libxml2-dev autoconf libc6-dev ncurses-dev automake libtool bison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..' | |
rails_env = ENV['RAILS_ENV'] || 'development' | |
resque_config = YAML.load_file(rails_root + '/config/resque.yml') | |
Resque.redis = resque_config[rails_env] | |
#secure the admin view of resque | |
Resque::Server.use(Rack::Auth::Basic) do |user, password| | |
password == "secret" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#vim Gemfile | |
source 'http://rubygems.org' | |
gem 'sinatra' | |
gem 'shotgun' | |
gem 'haml' | |
gem 'sass' | |
gem 'unicorn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DownloadsController < ApplicationController | |
DOWNLOAD_EXPIRY = 30.minutes | |
DOWNLOAD_SECRET = "MYSECRET" | |
def show | |
download = Download.find(params[:id]) | |
# download.file_path - get the path to the file, relative to the downloads directory | |
serve_file(download.file_path) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc default-jdk | |
mkdir -p /src/erlang | |
cd /src/erlang | |
wget http://www.erlang.org/download/otp_src_R14B03.tar.gz | |
tar -xvzf otp_src_R14B03.tar.gz | |
chmod -R 777 otp_src_R14B03 | |
cd otp_src_R14B03 | |
./configure | |
make | |
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libreoffice --headless -convert-to pdf fileToConvert.docx -outdir output/path/for/pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem install ruby-debug19 | |
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem | |
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem | |
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include="$rvm_path/src/`rvm tools strings`" | |
# rvm tools strings | |
# gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/home/kir/.rvm/src/ruby-1.9.3-p0/ |
OlderNewer