Change default ssh port number on Ubuntu
Login as the root user or as a user that can execute sudo commands.
#open this file for editing...
vim /etc/ssh/sshd_config
Find the line that reads
Port 22
Change this to an different and an available port number...
Port 8000
Next reload ssh
/etc/...
Written by Sean Behan on 06/17/2012
Roll Your Own Full Page Caching in Sinatra
It's as simple as this.
# app.rb
get '/:slug' do
@slug = File.basename("#{params[:slug]}")
@cache = "public/cache/#{@slug}.html"
if File.exists?(@cache)
File.read(@cache)
else
@post = Post.find_by(page: params[:slug])
...
Written by Sean Behan on 08/23/2013
How to Use RVM and POW with Ruby 2.0.0
In your project's root directory add a .ruby-version file and add the ruby version to the file
ruby-2.0.0-p247
Next source RVM in the .powrc file, also in your project's root directory.
source "$rvm_path/scripts/rvm"
rvm use `cat .ruby-versio...
Written by Sean Behan on 10/19/2013
Override to_param method in model to get pseudo permalinks without any work
There are a number of permalink plugins for Rails, http://www.seoonrails.com/even-better-looking-urls-with-permalink_fu, is a good one that I've used before. However, this involves informing the model class (has_permalink :title), adding a route, using t...
Written by Sean Behan on 06/17/2012
Ruby Strftime Day Without the Leading Zero
%e # rather than %d
Time.now.strftime("%e")
Written by Sean Behan on 06/17/2012