Archive for the 'random' Category
Monday, September 28th, 2009
Stumbled upon this. If you’re going to make a URI (domain or sub domain) with an underscore, think twice. IE7 and IE8 do not support these URI’s when dealing with cookies.
For more details, see this blog post, detailing the symptoms.
http://blog.patrick-morgan.net/2008/09/problems-with-ie7-sessions-not-saved-in.html
Posted in random | No Comments »
Friday, September 4th, 2009
When I started on a new Ruby on Rails project at Katipo Communications, I evaluated a range of testing libraries, and decided on Cucumber. It’s simple and has a flexible style of feature testing. For more info about it, see the Cucumber Wiki Documentation. In this post, I’ll detail some of my experiences with it for other developers who are considering using it.
(more…)
Posted in random | No Comments »
Friday, August 21st, 2009
These are some preparation notes for a panel discussion with the NZ Industry Training Federation – ITOs Marketing and Communications Network. We were asked to respond to three questions:
- My website is a dog’s breakfast, my boss wants it fixed, what do I need to do/think about mys elf before I contact a company?
- What are the most common mistakes you see being made on organisation’s website?
- How do you measure value for money on your website?
(more…)
Posted in random | No Comments »
Saturday, January 24th, 2009
Here’s a quick one. Say you are debugging a bit of code in a plugin that doesn’t fall under the Rails app you are working on’s ActiveSupport context and thus “logger.debug” is not available to you.
You could write up your own logging mechanism, with or without using the Logger gem. However, if what you are working on is run by the Rails app and thus has the apps global constants available, you could simply tie it into the existing logger object in the Rails app like so in your file:
logger = RAILS_DEFAULT_LOGGER
Then you can use logger.debug, logger.info, etc. to your heart’s content. One caveat, if you are working on a gem or a something more general that won’t necessarily always be run in the context of Rails, then you will want to pull your use of logger out before distributing your code. Otherwise you add a dependency on Rails that you may not intend.
Posted in open source, random, ruby on rails | No Comments »
Thursday, January 15th, 2009
You have to give Logical Awesome credit for how much work they do to integrate GitHub’s services with tools that developers use.
The Gist service is a good example. First they added command line support for it, then they simultaneously added in-editor support in Textmate, vim, and my own personal favorite emacs. The blog post announcing gist support in emacs and vim is here.
So how do you add the gist support to emacs?
First, you’ll need an account on github.com and have set up your ~/.gitconfig as outlined in here.
Then download or clone the gist.el file from http://github.com/defunkt/gist.el, copy only the gist.el file from that repository to someplace in your emacs load path (in my case /Users/walter/Library/Preferences/Aquamacs Emacs/ because I use Aquamacs on a Mac), and add a line to your ~/.emacs file or in my case /Users/walter/Library/Preferences/Aquamacs Emacs/Preferences.el that looks like this:
(require ‘gist)
Then you have to either restart your emacs program or do M-x load-library and answer prompt with gist for the new gist commands to be available.
Now you have M-x commands like these:
- gist-view-gist
- view gists after they’re posted
- gist-region
- Post the current region as a new paste at gist.github.com
Copies the URL into the kill ring.
- gist-region-private
- Post the current region as a new private paste at gist.github.com
Copies the URL into the kill ring.
- gist-buffer
- Post the current buffer as a new paste at gist.github.com.
Copies the URL into the kill ring.
- gist-buffer-private
- Post the current buffer as a new private paste at gist.github.com.
Copies the URL into the kill ring.
- gist-region-or-buffer
- Post either the current region, or if mark is not set, the current buffer as a new paste at gist.github.com
Copies the URL into the kill ring.
- gist-region-or-buffer-private
- you can probably guess…
- gist-fetch
- Given an gist id, fetches a Gist and inserts it into a new buffer
If the Gist already exists in a buffer, switches to it.
Very useful stuff for collaboration, but without leaving your editor.
Enjoy,
Walter
Posted in open source, random, ruby on rails | No Comments »
Friday, October 3rd, 2008
One commonly overlooked aspect of website accessibility is the contrast ratio between foreground and background colours.
White poor contrast can cause readability issues for well-sighted visitors, it can be even more of a problem for those visitors with a visual impairment.
Because of this, The New Zealand Government Web Standards and Requirements v 1.0 and W3C’s Techniques for Web Content Accessibility Guidelines v 1.0 both contain standards requiring content have sufficient contrast between foreground and background colours.
For example, The New Zealand Government Standards state:
“Ensure that foreground and background colour combinations provide sufficient contrast for navigation, text and informational elements when viewed by someone having colour deficits or when viewed on a black and white screen.”
Continue below for details on how to test for adequate colour contrast in your design or web pages.
(more…)
Posted in random | 1 Comment »
Thursday, September 11th, 2008
In MySQL, there is an easy way to get all index of a particular table.
SHOW INDEX FROM table_name;
But what if you want to list all index’s from all tables in a database so you can find out what you have and where you’re missing some? If you have 20 or more tables it’ll get tiring after a while running the SHOW INDEX command on each.
Thankfully, the information is stored in another table MySQL uses called information_schema. You can get a list of all the index’s, along with the table name and field names, by running the following (change “your_database”).
SELECT table_name, column_name, index_name FROM information_schema.statistics WHERE index_name != ‘primary’ and table_schema = ‘your_database’;
That’s it. A list of what table, what field, and the name that each index applied to. Happy indexing.
Posted in random | No Comments »
Monday, September 1st, 2008
Sometimes it’s useful to merge in a single commit from another branch. For instance, you may want to merge a single, important bug fix from your Git master branch into a stable release branch.
You can do this using Git’s cherry-pick command.
# Merge in a single commit.
#The -n option tells Git to not commit when it’s finished the merge.
# This allows us to review and commit the changes with our own message later.
# The default commit message is very ambiguous.
$ git cherry-pick -n [The commit's SHA-1 Hash]
# Review the changes
$ git diff –cached
# Commit the changes after reviewed them
# ..with a nice, human written commit message that makes sense.
$ git commit -a -m “Your commit message (some SHA-1 Hash as a reference)”
All done! You can then push your changes to your remote repository.
Posted in random | No Comments »
Friday, August 29th, 2008
I just had to resolve my first conflict in git. It’s a little more convoluted than with subversion, but slicker overall.
So you run into a conflict during a merge (implied by this git pull command):
$ git pull kete_master master
…
Auto-merged app/helpers/application_helper.rb
Auto-merged app/views/layouts/application.rhtml
CONFLICT (content): Merge conflict in app/views/layouts/application.rhtml
…
Automatic merge failed; fix conflicts and then commit the result.
First up, you need to have your git config point at opendiff on Mac OS X. Do the following if you haven’t already (you only have to do this once and it will be set permanently):
git config –global merge.tool opendiff
Then from the shell run this:
$ git mergetool
And then you should see output something like this:
Merging the files: app/views/layouts/application.rhtml
Normal merge conflict for ‘app/views/layouts/application.rhtml’:
{local}: modified
{remote}: modified
Hit return to start merge resolution tool (opendiff):
Hit return and the OpenDiff application should startup with the conflicted file. It will have side by side comparisons of local version of the file and the remote version of the file with nifty highlighted areas where things are different. Select the first highlighted region, go down to the bottom right and choose the appropriate side in the “Action” menu, then proceed on to the next one, and so on until you have taken care of all differences. Then click File > Save Merge.
Back on the shell you are ready to do commit your resolved file. Do “git commit” and you enter an editor to put in your commit message.
Move on to other tasks, you’re done.
Posted in random | No Comments »
Thursday, July 31st, 2008
When you want to use git on Debian its as easy as “apt-get install git-core”…… or is it? The version on the stable debian repositories (1.4.4) is very old. It lacks many of the features git users use on a regular basis. So how do you upgrade git? Well the simplest approach for getting the most recent version, for those that know how, is to wget the source, unpack, cd, configure, make, and make install. Takes about 5 minutes, and you’re up and running. But what if you don’t know how to compile, or you want to maintain package only install for your system, so upgrading and uninstalling will be easy? Where do you find a newer package?
(more…)
Posted in random | 1 Comment »
|