One of Ruby's better-kept secrets: how to get temporary directory →
Here’s how
require 'tmpdir'
puts Dir.tmpdir
How to add working directory to $LOAD_PATH
Simply
$:.unshift File.dirname(__FILE__)
How to completely reset a remote repository
Delete the .git directory locally
Recreate the git repostory
git init
touch .gitignore
git add .gitignore
git commit -m 'Initial commit'
Push to remote server, overwriting
git remote add origin <url>
git push --force
How to create a new empty branch
Create a new empty branch named “your-new-branch”, clean up, add .gitignore and commit.
git symbolic-ref HEAD refs/heads/your-new-branch
rm .git/index
git clean -fdx
touch .gitignore
git add .gitignore
git commit -m 'Initial commit'
How to install rmagick gem on Ubuntu 10.04? →
Why can’t I remember this?
$ sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
$ gem install rmagick
How to merge branch back into trunk
$ cd /path/to/trunk
$ svn merge --reintegrate http://example.com/path/to/branch
How to install Firefox 4 on Kubuntu 10.10
I’m a Kubuntu 10.10 user who want to use Firefox 4. Here’s what I did
Add the Firefox Stable PPA to the system source
sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get install firefox
Remove the Ubuntu modification add-on
sudo apt-get purge ubufox xul-ext-ubufox
Remove the old Firefox 3.6 language pack
sudo rm -rf /usr/lib/firefox-addons/extensions/langpack-en*
Done. Now you have Firefox 4 on your Kubuntu.
When you use after_sign_in_path_for, make sure your root controller is publicly accessible.
My Ruby on Rails on Windows setup
I am not a Windows fanboy but sometime I have to use it. Here is my current Ruby on Rails environment setup on Windows 7.
Since I dealing with console (Command Prompt) a lot, so before I setup Ruby and Rails, I install these 2 nifty tools first.
Console
Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles.
Get it here.
ANSICON
I like colored console output mainly because I often dealing with log files. ANSICON is a tool that provide those colors.
Here is how I install it
- Extract ansi140.zip to C:\bin so you have C:\bin\ansi140
- Add C:\bin\ansi140\x86 to Path
- Fire the Command Prompt, type and enter: ansicon -i
The last command you run will install ansicon permanently. To uninstall ansicon,
simply close any programs that currently using it and run ansicon -u from the Command Prompt.
Now the Ruby part. In summary, I install the 1.8.7 version first, then pik the Ruby version manager and then the Ruby Development Kit.
Ruby 1.8.7
Download and run rubyinstaller-1.8.7-p334.exe, install Ruby in their default folder C:\Ruby187 and don’t forget to check ‘Add Ruby executables to your PATH’.
Open up a Console and execute
ruby -v
and you should get
ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
pik
First, you want to update your gem
gem update --system
I usually don’t need ri and rdoc from the installed gems so I disabled it by default. Create a file named .gemrc in your home directory
C:\Users\YourUserName
with the following content
gem: --no-ri --no-rdoc
Now install pik
gem install pik
Read the rest of the installation manual here
Development Kit
Installing native gem has never been easy for Windows people, until DevKit came in into the scene. Follow the detailed instruction here.
Download DevKit and extract to C:\DevKit then from a Console
cd C:\DevKit
ruby dk.rb init
Test your installation by installing rdiscount gem
gem install rdiscount --platform=ruby
rdiscount should installed correctly
ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html
you should see
<p><strong>Hello RubyInstaller</strong></p>
XAMPP (for the MySQL)
No suprise that you will also need MySQL on your Windows setup. I use XAMPP. To connect your Rails app to MySQL you will need mysql2 gem. This is how to install mysql2 on Windows 7 using XAMPP
gem install mysql2 -- --with-mysql-include=C:\xampp\mysql\include --with-mysql-lib=C:\xampp\mysql\lib\opt
Done!
Now you are ready to build the next big thing in web application industry using Rails right from your Windows box.
Link dump for November 2010
A bit late though..here we go.
being agile: Creating and publishing your first ruby gem
Don’t Know Metaprogramming In Ruby?
jQuery 1.4.3 Offline Learning Kit - jQuery 1.4.3 Offline Learning Kit
Securing your SSH Server | Rackspace Cloud Computing & Hosting
Focus: My new book on simplicity in the age of distractions | zen habits
8 Ways to Speed Up the Performance of CakePHP Apps | PseudoCoder.com
Ruby on Rails web development services: Applicake
Howto: SSH into VirtualBox 3 Linux Guests by Stuart Colville