January 31, 2014
My keyboard of choice is the Apple Compact keyboard. This is not a great choice for Linux, or any other OS/hardware combination that is not all Apple. For starters the keyboard is missing two really important keys # and del, and secondly the function keys do alot of work on this keyboard with the idea of them being function keys secondary to their main focus which is do other important things. This all makes absolute sense when you are using...
January 31, 2014
On my arch box I have 4 disks the system SSD media (lvm spanning 2 2.5” disks) a spare 3TB volume The system was designed to be very quiet, and it is except when the 3TB drive spins up. This is a Seagate 3.5” drive, and its annoying me. As this drive is rarely used, there is no need for it to be spinning all the time, so how do we tell it to shut up # hdparm -y /dev/sdb...
January 24, 2014
I ‘converted’ to OSX about 7 years ago, and have been happy using it for most of that time. I still love the Mac Air, and, after lots of learning, am pretty productive using OSX to develop software. However a few almost random things have caused me to look seriously into using a Linux distro for my desktop computing. These are, in no particular order, the inability of a Mac Air to play 1440p video without its fan kicking off....
August 22, 2013
Nokogiri has always been erm ‘problematic’ to install on OSX. Currently I have to do this with the following command gem install nokogiri -- --with-xslt-dir=/usr/local/opt/libxslt
September 09, 2012
A common understanding in computing of a specification is A description of how something should work This is fundamentally flawed. At best a specification can be A description of a small subset of the behaviour of something Once this is realised the following mistakes are easier to avoid: Thinking there is nothing left to learn about how something should behave, once the behaviour has been specified. Thinking that if you automate the specification and the specification passes then the subject...
August 18, 2012
Intro I write one of these every couple of years, just to have a reference of things I like to have in a basic rails app. Anyone else reading this should probably look at http://railsapps.github.com/ or something similar. Assumptions git installed rvm installed ruby 1.9.3 installed for rvm numerous alias for git ga git-add gca 'git commit -a you will do Git commits for each action Start with a folder and rvm ➥ mkdir newapp ➥ cd newapp [andy@airy-deux ~/newapp]...
May 07, 2012
Using Cucumber its very easy to increase the cost of change for the software your features are testing. An example will illustrate this. Say we have an ecommerce application that gives free postage if we buy more than $100 of products. We can write a simple feature to exercise this Feature: Free postage Scenario: Get free postage When I buy $110 worth of goods Then I should get free postage Scenario: Pay for postage When I buy $90 worth of...
December 21, 2011
On holiday and finding that my blog was not available makes me think that self hosting on a broadband connection is probably not a good idea blogging on typo is not worth it So I’m looking at simple solutions, using the ‘cloud’ and using my favourite tool (GIT) One thing thats important to me is the ability to publish syntax highlighted code. For example here is a little ruby script I am using to create new posts. #!/usr/bin/env ruby unless...
November 18, 2011
Writing good features is difficult. One way to write better features is to read them critically. Two criteria useful for this are consistency and exclusivity. So a feature should be consistent and exclusive, what does this mean. Consistency For a feature to be consistent the following needs to apply The filename (including path) of the feature should be consistent with the title of the feature inconsistent: features/purchasing.feature and Feature: Writing a blog consistent: features/blog/new_article/ and Feature: New article The narrative...
September 27, 2011
A controversial title which I hope I will be able to amend. I’m new to JRuby, and the following may be due to my ignorance, which I am trying to address. Two identical rails projects with almost identical Gemfile’s. One running under JRuby 1.6.3 and the other on MRI 1.8.7p352. Running exactly the same specs. JRuby is 20x slower!!! JRuby ➥ time rspec spec Person can have pets (FAILED - 1) Pet add some examples to (or delete) /Users/andy/repos/diabolo/jruby/rails-example/spec/models/pet_spec.rb (PENDING:...
September 13, 2011
The following is from a post by Jim Lindley in 2008. This seems to have from the net, so I’m reposting here (with some amendments) so I have a reference. Git-SVN workflow The canonical git-svn workflow that I’ve seen goes like this: git svn clone <svn_repo> git checkout -b <work_branch> ...hack...hack... git commit -a git checkout master git svn rebase git merge <work_branch> #NOTE: no need for --squash anymore git svn dcommit -e # -e will let you enter a...
June 27, 2011
In Eloquent Ruby, Russ Olsen applies the composed method technique to a class. He says "The composed method technique advocates dividing your class up into methods that have three characteristics. First, each method should do a single thing—focus on solving a single aspect of the problem ... Second, each method needs to operate at a single conceptual level: Simply put, don’t mix high-level logic with the nitty-gritty details. A method that implements the business logic around, say, currency conversions, should...
June 27, 2011
Recently I’ve been commenting on the this blog article. I think it would be better to gather my thoughts here. The Problem With Tables I consider tables in features a smell. They are a warning that maybe something is not quite right, and that there is some more work to do. Lets consider the following from the watirmelon article. Feature: Beautiful Tea Shipping Costs - Australian customers pay GST - Overseas customers don’t pay GST - Australian customers get free...
April 13, 2011
For the longest time I’ve been plagued by a chronic inability to play arpeggios on my guitar using my index finger. Playing a simple pim has at times become almost impossible, yet pma is fine and precise. Similarly playing scales with ‘im’ alternation has become very difficult, my speed being less than half that when playing with ma. Things have got so bad that I’ve resorted to hybrid picking, that is holding a plectrum between my thumb and index finger...
February 24, 2011
Its a given in programming that bad habits are hard to get rid off. Its also a given that when you try and go fast, and when you feel pressure bad habits re-surface. Cut and paste programming may be the worst habit of all. Its so enticing, easy to do and so productive! At least that’s how it appears, but really its a cancer, destroying the joy of programming and at the same time destroying your code. Such strong words,...
January 23, 2011
Having had a lot of fun last week doing Uncle Bob’s prime factors kata, I’ve been doing the Codebreaker example from the RSpec book this week. In section 9.2 the number_match_count method is refactored to be def number_match_count total_match_count - exact_match_count end And the problem of implementing total_match_count is discussed. The book starts with def total_match_count count = 0 secret = @secret.split('') @guess.split('').map do |n| if secret.include?(n) secret.delete_at(secret.index(n)) count += 1 end end count end I didn’t like this so...
January 03, 2011
In my attempts to become more proficient with VIM I thought I would try and push some standard editing tasks in its direction. My first choice was blog posting. For this to work I need VIM to: Understand that my blog posts are in markdown Get and retrieve posts from typo like the textmate blogging bundle does. As usual with anything VIM things are not easy. Much of this is down to my ignorance, but the steep learning curve VIM...
December 24, 2010
Currently I use textmate as my main editor, but I find myself often using Vim as a secondary editor for small tasks run from the command prompt. I’m thinking about extending my use of VIM for the following reasons Its available on all the VM’s that I have to use I really like modal editing However textmate still has a number of very attractive features that I will want VIM to emulate including: Excellent markdown support Good cucumber and rspec...
December 24, 2010
I’ve been doing alot of machine setup recently, both VM’s and a new Mac. This has lead me to think about dotfiles once again, and also to consider using VIM much more. One other thing I’ve been thinking about doing for a while is using ZSH. Github has a number of dotfile projects which should make doing this stuff a little bit easier. The idea being that you can clone a repository run a command or two and end up...
December 14, 2010
Been doing alot of this lately, some notes Mounting Shared Workspace Create a shared workspace called ‘workspace’. Mount it by $ mount -t vboxsf workspace /mnt/mountpoint
December 08, 2010
Find this really useful and always forget it. find -type f -exec chmod 666 '{}' \; # change files find -type d -exec chmod 777 '{}' \; # change directories
December 03, 2010
As payment for my many sins, I have been forced to work with Centos and Yum recently. For development this is a fantastically sub-optimal combination with Centos repositories being years out of date and Yum being a slight pain. In addition I’m working in a heavily proxy’d environment. Most of my problems are a result of my ignorance, so I’ll stop moaning and document what I’ve learnt Global Proxies and Yum Yum has a habit of ignoring proxy settings, it...
November 14, 2010
Recently I’ve got into a nice groove using these tools on new ruby projects. I think of the following as a Koan, which I’ve practiced quite alot recently and which gives a nice environment to start working in. The following is the a reasonably verbose version of this Koan. Getting Started Our new project will be called np. ➥ mkdir np ➥ cd np [andy@airy-un ~/Sites/np] note: I have a two line bash prompt generally I’ll leave the first line...
November 13, 2010
Currently I am working on acceptance tests for front end applications that depend on back end services which don’t exist … yet? This means that I have a problem, I need my Cucumber features to create the data that the application will later retrieve. Later I need to test that the UI has retrieved the data and is displaying it. To do this I need to mock each service, how difficult this is depends on how we access the service....
October 13, 2010
One challenge when running a number of rvm rubies and gemsets, is having access to the documentation for the gems in your current gemset. I like to use Hanna for documenting my gems, and have no need for ri, so I have my ~/.gemrc setup as rdoc: -f hanna gem: --no-ri This causes problems with new rubies, and especially with anything that wants to install the latest rdoc (incompatible with the default hanna). What I need to do is install...
October 12, 2010
This is my approach for creating a new rails projects using rvm (and git). What I’m trying to do here is ensure that the repository contains everything required for a developer to work and has minimal environmental pre-conditions. The point of this is that if you get this repository you should only need to do the following to be able to start work on it. cd into the project, trust .rvmrc and do whatever rvm tells you to do to...
May 08, 2010
After manually setting up LVM I forgot to update /etc/fstab. This meant my drives weren’t mounted on rebooting, which caused some worry! Running as root you can get all the information you need to create the fstab entries using lvdisplay This will product something like --- Logical volume --- LV Name /dev/sync/guitar VG Name sync LV UUID vIl1Lb-bVRh-SJPo-KdGd-1wIS-fUfl-J3bgW3 Either the LV Name or LV UUID can be used in fstab e.g. # LVM Volumes -run lvdisplay as root to see...
February 21, 2010
The classic Cockney Rebel song. Best viewed full screen [v1] [chorus] [v2] [chorus] [solo] [v3] [fill] [chorus] {Repeat from Fill to fade} [Verse 1] || [Verse 2] || [Verse 3] || || || || N.C. F C G F || N.C. F C G F || N.C. F C G F || You've done it all, you've broken every code || There's nothing left, all gone and run away || There ain't no more, you've taken everything || || ||...
November 01, 2009
One of the little things that is annoying me at the moment is getting commits in git that are only about whitespace. This is pure noise and makes the commit harder to work with. I’ve looked at a number of ways of fixing this, but have mostly failed. Using textmate Textmate has a text bundle which contains a command to remove trailing whitespace. This can be combined into a save macro, so that every time you save a file it...
October 29, 2009
Just spent several hours pooching around with Chameleon Bootloader on my Hackintosh. I know have working bootloaders on two different disks, which is reassuring. Still got a long way to go. Want to summarise what I’ve learnt so far. Parts of Chameleon To install on a hard disk you have to deal with 3 different loaders. stage0 - disk loader (boot0 - locates active partition & loads the partition booter) stage1 - partition loader (boot1x - partition booter that loads...
August 31, 2009
The Map is Not The Territory I first came across General Semantics in the works of A.E. Van Vogt. His stories from sci-fi’s ‘golden age’ had a common theme about the infinite potential of ‘the human nervous system’ which was very appealing to a brainy weedy kid. Part of the development of human kind, in these stories, involved a rejection of Aristotelian thinking. This Non-Aristotelian thinking is based upon Korzybski’s General Semantics. But wait a minute what has this to...
July 22, 2009
Been meaning to do this for ages! First of all clone rails from git hub into a suitable folder git clone git://github.com/rails/rails.git rails.git I like to give repositories like this a .git extension so can easily differentiate from local things, but you can call the folder whatever you want. After the repository is cloned be sure to checkout the branch you want, in my case git checkout origin/2-3-stable Now you can vendor your rails projects by going into the root...
July 22, 2009
Updating the passenger gem is a bit of a pain. Its dead easy to just to the gem update and forget to do the other stuff you need to do, especially if you update lots of gems at the same time. Anyhow after updating passenger be sure to run passenger-install-apache2-module as root. Follow the instructions and update the passenger config (in/etc/apache2/other/passenger.conf on my work box)
July 21, 2009
Took me far to long to work out how to do this! To find an empty input field we can look for "input[type=text][value='']" e.g. response.body.should have_tag("input[type=text][value='']") This is useful when filling in forms badly to make sure your bad values still remain when you return to the form to edit them.
July 03, 2009
I’ve been struggling alot recently with controllers and with code written by my colleagues. During this period I think I’ve been making quite a few mistakes. One of the rules I generally like to make about things particularly in software is that if its stupid or doesn’t work its probably your fault. This is a really important rule which is real easy to apply to anyone but yourself. So its really easy for me to spot others making mistakes by...
May 29, 2009
Been bitten by this multiple times. I’ve been using Hanna as my default rdoc template following this article. This works fine with rdoc 2.3. Unfortunately rdoc seems to be undergoing some drastic changes at the moment and rdoc 2.4 breaks this lovely stuff. So I probably have to do something like (all with sudo) gem update --no-rdoc --no-ri gem uninstall rdoc # choose 2.4 gem rdoc --all --no-ri That last command can take ages to run so this is a...
April 24, 2009
WORK IN PROGRESS This explains why I need to fork webrat, and why I believe features should rely upon css classes and id’s. I believe that the CSS class is generally the best mechanism for expressing the semantic meaning of a particular piece of html (combined with DOM location and html tags). For example if somehow in viewing an order we want to reorder the order then I would first produce .order .reorder # re-order goes here This clearly establishes...
April 24, 2009
Webrat has become a very important part of my coding toolkit, to the point where its omissions and flaws cause great annoyance. However with the rise of Github we can just fork webrat, fix things and then issue pull requests and hope to get things back into the original. This is what I have done with Webrat. However my pull request has been ignored and now has been rejected ticket ? Here again Git provides a solution, I just keep...
April 07, 2009
Working in Rails and dealing with Rails code and various bits of Ruby in plugins etc. it is easy to forget some OO fundamentals. This is partly due to the power of Ruby and partly due to specialist classes like controllers, models and specs distracting me away from the fact that all these things are still classes. There used to be a rule of thumb used in Java that no method should be more than 10 lines long. Personally I...
April 07, 2009
REST is great, and resources are a great design tool. If we design our rails application around resources we can get alot of things for free. If we apply the same idea to features can we create a standard set of features to give us a quick start for each resource we identify? Resources - Object and Collection With standard rails routing we will get various named routes which we can use either directly in our features or indirectly in...
March 19, 2009
#Composing Features Writing good features is an art-form, a very new art-form that people are just beggining to explore. Of course people have been specifying how things should work throughout history, and people have been trying to specify what software should do (with varying degrees of failure!) since software has been written. You can compare writing features to a new school of art e.g. pontillism. Pontillism built itself on the existing foundations of painting and art - in particular colour...
March 13, 2009
Feeds and shit Feeds could be a strong competitive edge for an ecommerce platform. So we should do them properly and automate the process. If we do this then we can standardise the administration functionality to monitor feeds deal with errors deal with conflicts summarize and report on changes Feed has one source has one supplier has many runs has one last run has one Adaptor Adaptor Consumes run.feed.source produces run.log, run.errors, run.output has many runs Run has one output...
March 08, 2009
Been having some problems with my main OSX86 installation, so looking to fix these by installing IPC final Torrent Software Crashes I’m speculating this is due to my Time Machine fix of applying IONetworkingFamily.kext version 1.6.0. This seems to be confirmed by the fact that my alternate install works fine with Transmission and UTorrent. If I have to choose then Time Machine will go - haven’t really learned how to use it. Voodoo Kernel I’d quite like to try the...
January 22, 2009
First thing I did wrong was Cannot use a symlink for jquery I wanted to have a symlink in my public/javascripts folder that pointed to the current version of jQuery that my project was using rather than specify the version in my layout, or use a copy. However Rails won’t load the library if I do this.
January 17, 2009
FBRP is my rails starter application. When you base an application on it you need another git repository to push the application to. So I have to set up the application in a way that it can get updates from FBRP and yet still be independent. Base and Master Branches Most Git apps have a master branch. When you set up a new application from FBRP your master branch will be tied to FBRP. This is not desirable. So instead...
January 04, 2009
So I’ve been working on new osx86 installations and things are looking good, but are they? Here is a list of tests I need to perform to ensure things really are good GetHostUUIDString: unable to determine UUID for host. Error: 35 Look for these messages using console After installing plist edit pro run the following command in terminal to see if it generates an error 35 pledit /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist USB Hot Plug Plugin USB stick into front USB ports and see...
January 04, 2009
I keep my main user account on a seperate partition. To get it back on a new osx installation I have to do … Before you do any of this make sure you’ve tested the installation Get Account Back In System Preferences Accounts create a new admin account with user name Andrew Premdas right click on account to select ‘advanced options’ change home directory to /Volumes/users/andy disable automatic login, or set it to new account Account Functionality Not enough to...
January 03, 2009
Running a hackintosh as my main desktop involves keeping on top of quite alot of knowledge, which I’m prone to forget. This combined with the rapid development of hackintosh technology and the vastness of the osx86 forums means I need to keep more documentation about what I’m doing. Here I’ll do an overview Multiple Drives, Multiple Installations Ideally you need to have more than one drive and more than one partition on each drive to work with. This is so...
January 03, 2009
Refining installation of ipc has enabled me to make some serious shortcuts. You may need to refer to my other ipc posts to fully understand this procedure. run the ipc diskimage from spare targetting an empty partition and choosing my standard settings use UInstaller to apply AppleYukon2.kext apply ethernet and graphics string apply IONetworkingFamily.kext (1.6.0) apply IOAHCIFamily.kext after these two operations I end up with a new bootable osx installation which takes < 10 mins to create.
January 03, 2009
Once you’ve installed the iPC osx86 distribution, there are a number of system dependent things you will want to do. Here is what I do on my main system System Specs Asus P5B Deluxe, 4GB Ram, SATA Disks using Intel AHCI (ICH8), Marvell 88E8056 Gibabyte Ethernet, USB external sound card Networking Networking doesn’t work after install because distribution is missing kext for the 88E8056. Best thing to do is to add a kext for it using UInstaller. Look for kexts...
January 03, 2009
This is my choice of distribution for osx86 Use Disk Image run from partition Main benefit of this distribution is there is no need to use DVD’s. You can do everything from the disk image. Patching Image Updates for the distribution are distributed as ppf files. You can add these to the diskimage (.iso) using ppf-matic. Then check the result by using md5 Running the Image Open with diskimagemounter (default just double clik) then double click Install Mac OS X...
January 03, 2009
We are now ready to boot our new osx86 installation. Choose the correct drive using you bios then when you get to the boot menu press any key. Select correct partition. IMPORTANT set boot flags to -f -v Boot Flags -f this tells OSX to load all kext files individually (normally OSX caches them to save time). You only really need to do this on first boot -v this tells OSX to show you boot messages, instead of showing default...
January 02, 2009
A Long Awaited Update I’ve put of updating my hackintosh for ages, but having finally got my replacement raptor from Western Digital, I’ve bitten the bullet, and in the processed destroyed my old desktop account!! The osx86 distro I’m using is ipc, see also osx86 forums The best thing about this distribution is you can just run the iso from a hard disk and install directly to a partition. This is very quick. The worst things about the distro is...
January 02, 2009
So I was trying to remove my airport icon from my menu bar after migrating settings from mac-air. After 20 minutes of googling found you can command drag unwanted icons of menubar and poof they’re gone.
December 02, 2008
Reading the Ruby Programming Language which seems excellent so far. So may well do a number of blog posts about bits of it just to reenforce my memory coerce Method used by numeric types. Idea is to force argument into a suitable type so that the calling type can work with it. Method returns array of two values, the first being the converted value. Some irb will illustrate >> require 'rational' >> r = Rational(2,1) >> r.coerce(2) => [Rational(2, 1),...
November 10, 2008
Keywords: Category: What Have I Been Doing Since February 2007 The short answer is lots and lots. For the longer answer After finishing at InView I had alot of money a strong desire to work in a better environment, both with code and with working environment Every programmer should have good control of their fundamental tools, an editor, an environment to compile and run things and a revision control system. In addition we should be able to test every thing...
November 08, 2008
I find it very easy to get paralysed by complexity. This has been happening on my current project with users and customers. You see I want people to be able to buy things without having to be users. However I also want it to be especially easy for users to buy things. Finally I don’t want any particular person to have seperate records in user and customer but a customer can be user. Now this doesn’t really make sense, and...
October 29, 2008
Assert_Select is the main Rails tool for testing HTML output. RSpec wraps this function with its have_tag and with_tag methods. Using these methods effectively is key to writing features. However Assert_Select has some problems which caught me out recently. What I wanted to do is make sure my cart could not be seen when empty Scenario: Cart is hidden if empty Given there are 4 products And I am on the products page And the cart is empty Then I...
October 29, 2008
Been a bit of a dummy in this one. Basically each step definition is a regular expression so if we have When /^I add (\d+) products to the cart$/ do |n| we can improve this to make allow both When I add 1 product to the cart When I add 2 products to the cart by changing our definition to When /^I add (\d+) product[s]? to the cart$/ do |n| In general a good tip is to put step definitions...
October 29, 2008
Had a problem with a feature failing. Was getting an error When I add a product to the cart # features/steps/cart_steps.rb:11 Cannot redirect to nil! (ActionController::ActionControllerError) /Library/Ruby/Gems/1.8/gems/actionpack-2.1.1/lib/action_controller/base.rb:1044:in `redirect_to' The additional huge stack trace led me to my cart controller. Here I was using the rather standard sort of code respond_to do |format| format.html { redirect_to request.env["HTTP_REFERER"]} end Problem is that in the test environment request.env["HTTP_REFERER"] is nil. We have a couple of choices Set HTTP_REFERER in the test environment Program...
October 16, 2008
Been thinking about specifying paths in stories and steps, and the brittleness they can introduce to tests. This was prompted by a bug in rspecs ‘render_template’ matcher. First of all the bug … This is rails testcode that works ok assert_template(“/”) This is the rspec equivalent response.should render_template("/") which throws the exception wrong argument type nil (expected Regexp) (TypeError) /Library/Ruby/Gems/1.8/gems/rspec-rails-1.1.8/lib/spec/rails/matchers/render_template.rb:22:in `match' /Library/Ruby/Gems/1.8/gems/rspec-rails-1.1.8/lib/spec/rails/matchers/render_template.rb:22:in `matches?' Paths Don’t Belong In Stories Feeling more convinced about this the more I think about it. Basically...
October 15, 2008
Depressing how long it took me to find out that the visits method in webrat follows all redirects. This means that having a story like When I visit /products/1 Then I should be redirected to the home page is nonsense as you cannot detect the redirect. In fact all webrats methods follow redirects Of course you can detect that you have gone to the home page so When I visit /products/1 Then I should go to the home page Another...
October 12, 2008
Debugging with Cucumber Simple as putting a debugger statement in any steps file. Note also that you can run just one feature at a time with cucumber using -l. See cucumber -h Needed this when dealing with a problem with Restful Authentication forms. What I wanted to do was run the following story Scenario: Anonymous user can create an account Given I am on the signup page When I fill in "Login" with "My product name" However this kept on...
October 09, 2008
AASM is a/the state machine plugin, which you can now use as a gem. To do this you need to do 2 things Install the GEM Tell your app about AASM Install sudo gem sources -a http://gems.github.com sudo gem install rubyist-aasm note first line only required once per machine for any github gems Configure Application This is relatively new in rails. Idea is that you map a gem to a particular library in environment.rb. This is needed to deal with...
October 08, 2008
Cucumber is the new runner for Rspec plain text stories. It has a number of improvements that make it essential, and it will soon become the default runner for rspec. To get started we need to do a few things Install the gem sudo gem install cucumber Run the generator for each rails project you want to have cucumber in. script/generate cucumber Update my command in ~/.profile that runs rails projects in textmate to include the features folder, and source...
October 08, 2008
If you’ve forgotten something from a commit you can add it to the previous commit using the --amend parameter. This is most useful to keep your GIT repo tidy.
August 26, 2008
Always seem to forget this and take ages finding it again RAILS_ENV=production script/...
August 15, 2008
This one really got me!! Whats wrong with the following class Order < ActiveRecord::Base include AASM aasm_initial_state :customer aasm_column :state aasm_state :address aasm_event :set_user do transitions :from => :customer, :to => :address end end The problem is that you don’t have a :customer state defined. So horrible things happen when you try and transfer using set_user so we should have class Order < ActiveRecord::Base include AASM aasm_column :state aasm_state :customer aasm_state :address aasm_initial_state :customer aasm_event :set_user do transitions :from =>...
August 13, 2008
Slightly spurious title as there is absolutely no need for a winmerge for OSX. Included with the Developer Tools for OSX is filemerge, which is an excellent diff tool. There is also a tool to call it from a terminal called opendiff so you can do opendiff dir1 dir2 opendiff file1 file2 You can also find filemerge using spotlight.
August 13, 2008
God it took me a long time to find this again … If you want to you can disable tabs from the command line. Make sure TextMate isn’t running, and then type: defaults write com.macromates.textmate OakProjectWindowShowTabBarEnabled false into the terminal. To bring tabs back, you’ll have to: defaults delete com.macromates.textmate OakProjectWindowShowTabBarEnabled
July 14, 2008
Answer to my problems with gems being updated at github well before they are updated at rubyforge. Following allows you to install gems from github using standard gem command sudo gem update system gem sources -a http://gems.github.com Unfortunately this doesn’t seem to work for rspec. Perhaps they have not published their plugin as a gem there.
July 12, 2008
Here we discuss getting a simple structure in place for laying out the pages of our application … Using HAML and SASS Our setup is dependent on HAML and SASS. Lets just add this to the HAML branch first of all and see how things go. gch haml We are going to add some SASS stylesheets but first of all we’ll use a reset style sheet. Our SASS stylesheets will separate 3 concerns layout typography appearance Layout Layout comprises of...
July 11, 2008
Now we have a deployed application we can add some plugins to get those extra bits of functionality we want. Missing Directories What we’ve done so far has created a rails project that is to minimal. Applying git and uploading the project has removed any empty directories. If you get errors just create the directories. e.g. mkdir -p vendor/plugins Installing plugins on GIT branches Might be a good idea to install plugins on branches. With sufficient git-fu we should be...
July 11, 2008
A step by step guide to creating a new rails project. The project will be called np. We start with … rails np cd np Setup GIT git init Remove log files We want the log folder to be empty rm -f log/*.log Stop Git From Ignoring Empty Folders We want git to check in all empty folders so we keep the project structure and don’t get missing folder errors later. Unfortunately the only way we can do this is...
July 04, 2008
Often in Rails you will want to use a partial in more than one place. Such partials might add or delete things. Once this is done you will want to return to where you were. The following works without javascript and Ajax … The information we want is called the HTTP_REFERER. This is contained within the request object which is hugely complex. The request contains an env hash and the HTTP_REFERER is in there. request.env["HTTP_REFERER"] Now you can use this...
July 03, 2008
Easy peasy once you know how. start up your server with the -u put debugger in your code where you want the debugger to start run that code e.g. in a web browser The web browser will hang, and a debugging session will be started in the terminal you ran the server. Main things to remember are h get help l list the code where you are reload if debugger doesn’t pick up changes in your code give it a...
June 30, 2008
Rails has a number of helpers which put fairly chunky bits of javascript into your html. This isn’t the purest solution, and is particularly messy for accessibility when javascript is disabled. A number of people have addressed this issue which I’ll discuss here Fundamental Approach We keep css in stylesheets, so lets stop embedding javascript in our html and keep it in separate scripts. The issue is then how do we apply our javascript to our html in an effective...
June 30, 2008
This article was prompted by the problems caused when using a restful design and deleting things with link_to There are several issues to consider here obtrusive javascript supporting browsers where javascript is disabled restful design and current browser limitations restful design and current browser limitations Restful design stipulates that to delete a resource you should call its url using the delete method on it. So with an item foo you would use the same url to delete and show foo...
June 20, 2008
Plain text stories have quite alot of infrastructure that allows you to run the story file. I’m being pretty dumb in understanding this, so I’m going to analyse whats going on in detail so I have a better idea of what is being done and why. I learnt some important lessons from doing this. If you don’t understand a line of code break it down until you do. This will improve your ruby. irb is your friend, use it and...
June 19, 2008
Did 21 minutes at an average heart rate of 158 on Tuesday. This is a personal milestone breaking 20 mins - its a long time since I’ve been able to do that Quite pleased with this run. Decided to try and judge runs on heart rate and time, rather than speed or distance covered. Want to increase time I can run at 160. Milestones will be 25, 30, 35 and 40 mins. Ideally I’d like also to get my heart...
June 04, 2008
Instructions for both Ubuntu and OSX.. Ubuntu Just used apt-get for this sudo apt-get install libfreeimage3 libfreeimage-dev Then to install the image processor sudo gem install image_science OSX Couldn’t get the makefile to compile. Best way of getting this working was to install MacPorts. Downloaded and installed MacPorts using the leopard .dmg After installation ensured that path and manpath were correct which port # gives back a path Used MacPorts to install freeimage sudo port install freeimage n.b. this takes...
June 01, 2008
See this Textmate Blog post
June 01, 2008
Do following cd ~/Library/Application\ Support/TextMate/Bundles/ git clone git://github.com/dchelimsky/rspec-tmbundle.git RSpec.tmbundle Then reload bundles in textmate if its open.
May 30, 2008
Idea behind this is a working environment that spends more time in the editor, rather than switching to the terminal … Autotest Autotest (which is part of ZenTest) is something you run on your Rails project. What it does is detect saved changes and automatically runs test. Growl Growl is a universal notifier for OSX. What it does is pop up messages in temporary windows to tell you about things. RSpec Is the testing framework I am using - blogged...
May 30, 2008
Quick reminder how to do this… Pre-Requisites rails project using git git init . Installation Plugins go in vendor/plugins git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec git submodule add git://github.com/dchelimsky/rspec-rails.git vendor/plugins/rspec-rails Then run script/generate rspec Note: You need to run the following two commands (or at least the last one) every time you clone this repo. git submodule init git submodule update
May 27, 2008
I wanted to make blogging with markdown and textmate as easy as possible. I struggled to do this, though its very easy … Textmate has a number of ways of doing key bindings. The thing I wanted to do was bind the menu item File | New From Template | Blogging | Blog Post Markdown. You cannot do this using System Preferences | Keyboard instead you have to do this in the bundle editor. Here you have to drill into...
May 27, 2008
Looking to manage my projects plugins with GIT, however really struggled (again with something so simple). What I couldn’t understand was why the contents of the sub-modules wasn’t there when I cloned my central repo. Turns out that you have to run a couple of commands when you do this git submodule init git submodule update Now to find out what happens when you add another module, do you have to redo the init or just call the update with...
May 27, 2008
Finally have a good way of working with Capistrano and database.yml. Here’s what I did … Fundamentals Generally a Rails application will be run on at least one server and developed on many machines. The database configuration will not be the same on all the machines. In addition the database configuration on the server should be secure. Remove database.yml from the Repository Added config/database.yml to projects .gitignore file Create database.yml.example This file helps developers connect to there local database. Mine...
May 22, 2008
Been a pain getting my git-server and web-server to communicate via ssh as they are the same box. This is partly to do with the fact that my git user is very restricted I have two users on my server Deploy - who is responsible for deploying applications Git - who is responsible for Git things Using capistrano my deploy user has to get the latest src from the git user. Using ssh to do this kept giving me ssh...
May 21, 2008
Details on how to move new Git project onto my git server so I can use this as a central location for my work. With an existing new project (we will use ‘tc’) which is already under git do the following in the directory above the project ensure the project has no pending work. git status should show nothing outstanding move to folder above the project clone the project (in this case we will clone tc to make tc.git) git...
May 20, 2008
Category: sysadmin Passenger aka mod-rails is an apache module for rails deployment. This documents how I set this up on my Ubuntu server. Get Passenger I used gem to install passenger. Running as root gem install passenger This installed passenger 1.0.5. To then setup passenger I ran passenger-install-apache2-module This runs an installation program that is really very good. The first thing it did was check dependencies. I was missing a couple, and my initial attempt at installing the missing packages...
May 14, 2008
Annoying problem causing syslogd to use 100% cpu and overheat MacBook Air First of all I needed to realise that the problem was not with syslogd, but instead was with a process using syslogd to excess. A couple of interesting things were learnt here. Use of Console Application Located in Applications/Utilities the console app allows you to view all of the key log files on your system. The important thing is to expand the tree on the left hand side...
May 06, 2008
As of now, this is much simpler than many blog posts make out. I downloaded the OSX .dmg from http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg, double clicked on the .dmg and installed mysql package mysql startup mysql preference pane Then went to “system preferences” and started the server using the preference pane. ensured my path included “/usr/local/mysql/bin” checked local installation by running “mysql -u root” from a terminal Installing the MySql Gem This has following pre-requisites Installation of XCode Installation of MySql and ability to...
May 02, 2008
The keyboard layout on the MacAir is a bit of a pain in the arse, mainly because of the absence of a convenient hash key. So I need to put together a custom keyboard layout to sort this out. This is actually really easy to do … once you know how to do it! download Ukelele mount/open the disk image (double click the .dmg file) open the british keyboard layout in the folder “System Keyboards/Roman” in the disk image system...
February 27, 2008
With a fixed IP arriving and the 2 week wait for my Mac Air the time is ripe to work on my public presence on the web. I’ve been meaning to do this for so long, and haven’t. I think its some inherent shyness combined with a generational reticence, which really is obsolete in our brave new world of social networking. The site has to do the following Encourage people to employ me Provide a remote reference site for me...
February 27, 2008
After much tribulation my Mac Air is only a couple of weeks away. Checked out the machine in Trafford Centre yesterday. I was going to buy a budget Mac Book, but the Air is just so much nicer, and a much better fit for me. Much better keyboard. It has the best laptop keyboard I’ve ever used. Its much more precise than the Mac Book keyboard Much better screen. The LED backlit screen can be significantly brighter than the MacBook...
February 27, 2008
So I’m moving to Be and hoping that my new service will have the download speed to get You Tube videos quickly, and the upload speed to support my websites. Running a home server is a little bit daunting, because of security and access issues. Really need to have a careful think about what should be available. One geeky thing about Be is that because its so fast (potentially), there is quite alot of benefit from tweaking your connection. So...
February 25, 2008
I’m a man of many fads. This blog is one of them I guess. My latest fad is traditional wet shaving. As usual it was prompted by some random web trawl that somehow led me to Badger and Blade. There is lots of interesting stuff here including videos, reference articles, product reviews etc. But for me it was an opening to a new world - were the mach3 was scorned! Once again the internet was reviving a lost art through...
February 18, 2008
Running Rails myproj on Cygwin doesn’t work at the moment. This is due to a bug in Ruby that has been fixed, but hasn’t yet made the Cygwin project. At the moment the workaround is to run the Rails command in a windows command prompt. This sux, but only a little bit really. Alternatives focus around patching and rebuilding ruby on cygwin. Don’t really want to do this. See Rails Ticket
February 14, 2008
Followed Dr Nic
February 13, 2008
Terminal App Colors Basic problem is default blue in terminal is very difficult to read. Two approaches to this problem Configure Bash to to use the default blue color Configure your terminal application so the default blue color is rendered more legibly. This SIMBL plugin takes the second approach adding a color picker to terminal so you can change how any ANSI color is rendered
February 13, 2008
Safari Advert Blocker Installed Pith Helmet which is a $10 shareware advert blocker and general bling tool for Safari. Evaluating this at the moment, seems quite promising. Part of this is SIMBL One cool plugin for this thing is the configuration of colors for terminal.
February 13, 2008
Aim is for little-un to be printer server for mac, windows and linux clients. Need to install Cups and Samba to do this. Cups installation sudo apt-get install cupsys cupsys-client documentation in */usr/share/doc/libcupsys2 sudo gunzip /usr/share/doc/libcupsys2/README.txt.gz sudo gunzip /usr/share/doc/libcupsys2/README.Debian.gz ubuntu forums guide Cups configuration Used lynx on localhost:631 to get to web interface of Cups then turned on remote administration. Somehow config file got corrupted. Detected this by Editing /etc/cups/cupsd.conf and setting the LogLevel (on line 1) to debug tail...
February 13, 2008
OSX comes with Cups installed, so you can connect on localhost:631 and add the printer on little-un, using Add Printer. However browsing and discovery of printers doesn’t work, so you have to get the correct address Finding Correct Printer path Log into the CUPS interface on your linux box. (My path was http://192.168.0.2:631/printers/) Right click the “Print test page” button and “Copy Link Location” Use this to create your correct path (remove cruft at end first) Mine ended up being...
February 12, 2008
Writing this in the garden at the front of the house. Its an amazingly beautiful sunny afternoon, incredibly mild for the middle of February. Sitting out here is a delight, but my laptop cannot connect to my router. This is no good at all. Actually maybe my router is no good at all. After all it drops connections all the time under Ubuntu, and seems to do the same (although windows handles it much better) in Windows. Router technology has...
February 12, 2008
Although I already knew that the base joint of the thumb is actually adjacent to the wrist, and not the joint where the thumb and first finger meet, until a couple of hours ago I really hadn’t understood what this means for my guitar playing. All of my current thumb movement comes from my second joint. Because this joint is almost as strong (if not stronger) than the first joints of my fingers, this has felt fine. However making thumb...
February 12, 2008
I have a great need to be more organized in the planning and recording of my activities. My progress in all things is quite eclectic and wide ranging. At the same time it is not very focused and often not appreciated. This results in dissolution and also makes it difficult for me to reach goals. I really am not at all goal orientated except when I’m employed. This doesn’t mean I’m lazy, just not focused on specifics. So whilst I...
February 07, 2008
Been struggling a little with testing Admin::Controllers, mainly because I don’t fully understand the scaffold functional test code. Anyhow just generated Admin::Poop!! so we can see how the nesting affects the tests class Admin::PoopsControllerTest < ActionController::TestCase def test_should_get_index get :index assert_response :success assert_not_nil assigns(:admin_poops) end def test_should_get_new get :new assert_response :success end def test_should_create_poop assert_difference('Admin::Poop.count') do post :create, :poop => { } end assert_redirected_to poop_path(assigns(:poop)) end def test_should_show_poop get :show, :id => admin_poops(:one).id assert_response :success end def test_should_get_edit get :edit,...
January 30, 2008
rake db:fixtures:load loads fixtures data into the current environment. This is an alternative to having data migrations, although whether its a better alternative is something I have to think about. Definitely could use this instead of the data migrations I just committed to the Lemon trunk! Still this gives me an opportunity to do some slightly advanced Git stuff to merge the changes out.
January 28, 2008
Setting up a Rails Project that is kept under svn and uses svn:externals for plugins for use locally with Git Currently git doesn’t support repositories within repositories. This becomes a problem when we are working with Rails projects that use plugins linked externally. If you are just using subversion you’d generally manage plugins using svn:externals or Piston if you’re wise. There is a tool called Giston, which addresses that problem in the Git world. Unfortunately I couldn’t get that to...
January 27, 2008
This failed miserably, will have to stick with localhost and the socket for now.
January 27, 2008
Could it really be that Safari is killing my installation of Typo? preview seems to be working correctly on firefox laptop committed immediately when I did a post on it What will happen here? Well I’ll be … - a really quick post from Firefox, looks like I’m ready to start blogging!!
January 27, 2008
Really need a backlit keyboard for my laptop. I can’t see a bloody thing at the moment. Will this post. My other post from the Mac still hasn’t submitted!
January 27, 2008
Differences between the two editors are quite apparent, with textmate being way ahead at the moment. Some of this is down to environment, some of this down to the usability of OSX (hate to say it as a veteran XP user) and some down to the immaturity of E. No Templates in E This was a bit annoying as I wanted to create this post in E, but couldn’t get the blogging bundle to work correctly. However as Typo’s web...
January 27, 2008
Many others have done this, so thanks to those who provided the info used here. Gem Installation When setting up gems unset the environment variable RUBYOPT RUBYOPT="" Rails Installation Don’t need --include-dependencies switch any more, they’re installed by default. MySQL In Cygwin you’ll want to install the MySQL gem. This needs the MySql libraries/source in order to build, so you need to download the source. Then run ./configure make install This failed at first, trying to resolve by installing g++...
January 27, 2008
Using MySql Most important thing was to have correct database.yml configuration. I was missing the socket option - this would cause typo to just hang, with no indication of what was going wrong - no writes to log files, nothing My database.yml now is login: &login adapter: mysql host: localhost user: typo password: xxxxxxx socket: /var/run/mysqld/mysqld.sock development: database: typo_dev <<: *login production: database: typo <<: *login test: database: typo_test <<: *login The location of mysqld.sock is specific to Debian based...
January 27, 2008
Amazing seems like I’ve finally got my own typo blog and the ability to blog to it from textmate. This really is something else. Now all I need is something worth saying So it seems you can quickly post the blog (need to learn that shortcut pronto), and then textmate will submit it and open the post up (currently in Safari). Really quite spiffy. And of course you can preview locally. Some Things to work out why is the markdown...