Code, aimless meanderings and occasional outbursts from an Australian expatriate living in Singapore.
Monday, February 20, 2012
Installing PostgreSQL on Lion with Brew
Basically the configure script is saying that my system version of Python doesn't have 64-bit support.
Warning: Detected a framework Python that does not have 64-bit support in:
/Library/Frameworks/Python.framework/Versions/Current/Python
To fix this issue, you may need to either delete the version of Python shown above, or move it out of the way before brewing PostgreSQL.
I don't like those solutions very much, and I don't need Python support in Postgres anyway. To get around the problem and build Postgres without Python support at all, just...
brew upgrade --no-python postgresql
Muskets at dawn!
Wednesday, January 25, 2012
Bundler invalid byte sequence
ArgumentError: invalid byte sequence in US-ASCII
Normally I use Terminal.app but I recently switched to iTerm as I'm finding it is quite a bit faster, so this little issue caught me out. iTerm doesn't enable UTF-8 by default.
Adding this to ~/.bash_profile will set it no matter what terminal app you're using.
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Thursday, July 8, 2010
Rolling Back iPhone iOS4 to iPhone iOS3
Installing iPhone iOS4 on my iPhone 3G and it was a big mistake for me. My iPhone instantly changed from a lovely, responsive device, to one that was taking 15-20 seconds to start up the SMS or Mail applications.
The list of issues I had with iOS4 was long and uncomfortable enough to force me into deciding to rollback to iOS3.
- Slow to start applications
- Applications are generally slow and unresponsive
- Camera app was slow to start, and slow to take a picture
- 3G network access became unreliable
- Lockups and freezing requiring restarts
It was slow and buggy enough that I hated using my phone at all. I didn't get this phone to become the owner of a useless brick.
Waiting for the first update to iOS4 seemed like a lame idea. Who knows how many of the issues would be addressed anyway?
iTunes won't directly allow you to rollback to a previous OS just by choosing a backup that was on that OS version. It doesn't downgrade the operating system, it only restores the data.
Trying to restore an earlier firmware explicitly in iTunes got close, but also failed.
It turns out there is one more step needed to make the rollback work... RecBoot. @pjammer sent me a link to a YouTube video showing how to rollback to iOS3, which worked a treat.
After restoring the earlier firmware you will receive an error message telling you the OS could not be restored and you should choose one of your backups to restore from. Running RecBoot at this point in time allows you to take you phone out of recovery mode.... to find the firmware of your choice running.
You can then restore your data or setup for a new phone.
Victory!
Guess what? My iPhone 3G is fast again. I'll be researching very cautiously before attempting another upgrade to iOS4.
Wednesday, June 30, 2010
Installing Postgres gem on Snow Leopard
I had to jump through a small hoop to install the postgres gem on Snow Leopard so I'm putting it here to help others out. Hopefully it saves you some time.
Basic System
- Ruby 1.8.7
- Macports
- OSX 10.6 (Snow Leopard)
Install Postgresql
# sudo port install postgresql84-server
Install the Postgres Gem
# sudo env ARCHFLAGS="-arch x86_64" gem install postgres -- --with-pgsql-lib=/opt/local/lib/postgresql84 --with-pgsql-include=/opt/local/include/postgresql84
Monday, April 26, 2010
Mishca's Mothers En Vogue Photoshoot
She went really well considering she was such a shy little girl just a few months ago :)
Well done Mishca!
Sunday, April 25, 2010
Facebook Makes More Of Your Data Available Again
Facebook is once again making more of your data available without your permission.
I was very disappointed to see that I was suddenly opt-ed in to basically sharing everything about me, and allowing my friends to also share this information about me. I never gave my explicit permission to do this. I'm sure it is entirely covered by their Terms and Conditions.
At a minimum, Facebook should have asked users what their preference was, but chose not to do so. This is an extremely deceptive practice, somewhat similar to lying by omission.
Yes, I am aware I can change the settings. I also know most people won't because they don't care, are too lazy, or just do not understand how much they are "sharing".
I also love how giving away your personal information is called "sharing" now. How very, "double-speak" of Facebook. To be fair Facebook aren't the only social networks that shares you information to their partners.
As an individual that still has dreams of privacy I simply do not like where this is going. I was hesitant about joining Facebook to begin with because I could see the depth the data that would allow information seekers to build very detailed profiles on each of us. I even deactivated my Facebook account once before giving in and re-activating it.
So, I'll announce it to the world...
I will be deleting my account on or before 25 May 2010, using Facebook's Delete my Account page.
Deep down I am not at all surprised by the direction Facebook is going with this. My lack of surprise also reminds me that although I was quite sure it would get to this point it was a stupid decision ever choosing to believe it could would have been any different.
Bye bye Facebook. It has been... educational.
Links
Monday, January 18, 2010
Howto Install Ruby 1.8 and RubyGems from source on Debian
In the latest addition to the, "Howto Install stuff from Source on Debian", series, this post shows how to install Ruby 1.8 and RubyGems from source on Debian.
This installation has been tested out successfully on Debian Lenny, and Debian Etch. It should also work on Ubuntu.
Permissions
As noted in my last post, my user has write permissions to /usr/local/src so I don'thave to run everything under sudo. This was accomplished by allowing the staff group to write to /usr/local/src , giving write access to the staff group, and adding my user to the "staff" group.
If you would like to set this up...
# sudo chown root:staff /usr/local/src # sudo chmod 775 /usr/local/src # sudo usermod -a -G staff your_username
If you were not previously a member of the staff group you will need to logout and login again, or just open a new shell, for the changes to take effect.
Install
A browser friendly version of the script can be seen at http://gist.github.com/271029.
Once again, I've leveraged gist as a tool to store my installation scripts.
The script is just a wrapper to install the necessary Debian packages. This script then downloads a second script which actually downloads, configures, and install Ruby 1.8 and RubGems.
Not only is gist a very useful tool, but I've also found GitHub to be an excellent online git repository.
The scripts use the "Raw" versions of the gists.
To install, run these commands...
# wget http://gist.github.com/raw/271029/d16c8acf620047b88e509ccab205959681fd443d/install_ruby18_on_debian.sh # chmod a+x ./install_ruby18_on_debian.sh # ./install_ruby18_on_debian.sh
If all goes well, Ruby and RubyGems will have been installed.
# which ruby /usr/local/bin/ruby # ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux] # which gem /usr/local/bin/gem # gem -v 1.3.5
Enjoy Ruby!
Other Posts in this Series
Friday, January 15, 2010
Install Nginx from source on Debian
I thought it was time to write a followup post to, Install Memcached from source on Debian Lenny.
At this moment, Debian provides Nginx 0.6.39 and I was wanting to run Nginx 0.7. The latest stable version is 0.7.64, so I thought I would put together a script to automate the download and installation for me.
Some devoted Debian users will want to string me up for installing a source package, and some others will no doubt say that I'm hating Debian for not using aptitude. These people are entitled to their opinion of course, but I don't feel that there is anything wrong with installing a source package on Debian.
If you feel like installing a package from source makes Debian cry, leave now :)
Monday, December 14, 2009
Install Memcached from source on Debian Lenny
Debian is quite simply excellent, and I wouldn't even consider running any other distro in production anymore.
Occasionally though, there are packages that become a bit outdated, and a source install is needed.
For me, Memcached is one of those packages. The latest in the Debian Lenny Apt repositories is 1.2.2, but the latest stable build is actually 1.4.4. Good luck seeing that in the stable apt repositories anytime soon :)
So, to make life easy, I've put together a fairly simple bash script that downloads and installs Memcached, and libevent, for you.
The script is a blunt instrument, and assumes...
- You haven't installed memcached from apt repositories on this machine
- You won't be sad when it puts config and startup files at
- /etc/memcached.conf
- /etc/init.d/memcached
- /usr/share/memcached/scripts/start-memcached
Thursday, December 10, 2009
Fix POST for Ruby 1.9.1 and Passenger
How exciting! A new Ruby release to play with.
I figured it was time to migrate this particular app to 1.9.1 on the integration server. We've been developing this app with 1.9 and all looks good.
So I...
- Upgraded Nginx to version 0.7.64
- Installed Ruby 1.9.1-p376
- Installed Passenger 2.2.7
- Configured Nginx to use the new versions of Ruby and Passenger
- ... and restarted Nginx
I hit the home page of the app.... Sweet, it works! Yay!
At this point I did a minor happy dance. Nothing over the top, you know... just a little wiggle :)
Then I tried to login to the app... "500 Internal Server Error"
Oh. :(
I stopped dancing right there.
It turns out that POST requests fail for Ruby 1.9.1 and Passenger.
Fortunately, there is a patch.
Patching tempfile.rb did the trick. On that particular machine, tempfile.rb was located at /usr/local/lib/ruby19/1.9.1/tempfile.rb
Thanks to Ryan Bigg for confirming the fix is good.
Tuesday, November 24, 2009
Remember Which Goals are Important
When Boeing prepared to launch the design of the 727 passenger plain in the 1960s, its managers set a goal that was deliberately concrete: The 727 must seat 181 passengers, fly nonstop from Miami to New York City, and land on Runway 4-22 at La Guardia. (The 4-22 runway was chosen for its length--less than a mile, which was much to short for any of the existing passenger jets.) With a goal this concrete, Boeing effectively coordinated the actions of thousands of experts in various aspects of engineering or manufacturing. Imagine how much harder it would have been to build a 727 whose goal was to be "the best passenger plane in the world."
Tuesday, November 10, 2009
Factory.create(:factory_girl, :fixtures => false)
Friday, March 20, 2009
Australian Website Blacklist. Would you like lies with that?
So it seems the Australian government lied about how many URL's are on their blacklist.
Fair enough I suppose, we weren't meant to ever know what was on the list anyway.
Of course they lied. Whenever power is wielded in the absence of transparency do we ever hear about how it was secretly used for out benefit? No, we don't.
Senator Conroy says that this isn't the list. Now, because the list is supposed to be a secret there is nothing to weigh this statement against, so it must be taken on faith alone.
Ah, faith...
This is where we get to the other part of the problem. Senator Conroy represents a group of Australians that think it is OK to push their religious views onto others. We all know how great religious zealots are at being open and honest. They've scored a 0 out of 10 for that. These guys are as "open and honest" as they need to be to push their agenda, or to escape prosecution. Don't tell me you need examples.
What about my agenda? I don't have one. I'm also a nobody with no power. I just want information to be out on the open where it wants to be. If you or I want information, we should be able to find it. I do not want my Government telling me what information I should or should not see, as it has proven so often in the past to be way too tempting to Governments to use censorship to help keep themselves in power. Again, you don't need examples, I'm sure you can think of many instances of this being reported... eventually.
"But won't someone think of the children?!", some of you cry. Will someone think of the children years from now when they are denied access to information about about other political parties in Australia, or news about the latest bad things the Government has been doing to Australians.? OK, that may not happen, but once a blacklist exists it can happen. You don't need examples provided for this either.
I'm quite sure if the Labour Party had made it known they were planning on introducing web censorship the balance would not have tipped in their favor at the last election. I suppose thats why they want to get the blacklist implemented in the early part of their term. Voters have short memories generally.
Once we've all been conditioned to accept with censorship of the information we can see, your opinion as an individual is worthless. You lost the power to make your vote mean what you intended it to mean, because without all the information available to you, how can you make an informed decision?
As an Australian I'm incredibly disappointed about this whole mess, although the cynic inside me is not at all surprised.
Sunday, March 8, 2009
scottbarr-number_to_text RubyGem
n = Number.new(119) puts n.to_text # => "one-hundred-and-nineteen"I'm not happy with how the implementation came, but it does the job. I'll clean it up to work a bit nicer sometime :) If you need to convert numbers to text in Ruby, take a look at http://github.com/scottbarr/number_to_text/tree/master
Sunday, February 15, 2009
YahooCurrency Gem
exchange_rate = YahooCurrency.get_rate!("JPY", "USD")
exchange_rate.from #=> "JPY"
exchange_rate.to #=> "USD"
exchange_rate.rate #=> 0.0111
exchange_rate.timestamp #=> Wed Feb 11 22:20:00 +0800 2009
Get the source or the gem from http://github.com/scottbarr/yahoo_currency/tree/master
Hopefully this will be the first of many projects that GITC releases as Open Source.
Thursday, February 12, 2009
Horror Movie Code
Monday, September 22, 2008
Rails with NO Fixtures?
norway: code: NO name: NorwayI added a unit test to make sure I could get Norway by it's country code, which is NO
def test_find_by_code
assert_equal countries(:norway), Country.find_by_code('NO')
end
Agreed, I probably don't need a unit test for this, but this should have worked, but it was failing with the following message. Country id: 318845244, code: "1", name: "Norway" expected but was nilApparently NO in the yaml file is interpreted as a 0 (zero). To prove the theory I changed the code of norway to YES. The unit test failed, and indicated that the model it expected should have had code: "1". Changing countries.yml to be...
norway: code: "NO" name: NorwayI personally really like fixtures and the nice features they bring in, but sometimes they can catch you out. I'm sure it's not a bug, I've just never encountered this before. Ever found anything strange in your fixtures?
Sunday, August 31, 2008
View source code for iPhone RSS feed
I tried to view the Slashdot RSS feed on my iPod Touch, but instead of an RSS feed I was redirected to a specially formatted feed for iPhones. Very nice!
The iPhone specific URL is http://reader.mac.com/mobile/v1/http://rss.slashdot.org/Slashdot/slashdot .
I was curious to about the source code of the page, really just to see if there was any interesting markup. So I tried to view the URL in Firefox... no dice. I was shown a page saying, "This Application Is Viewable Only On iPhone".
Hmm... it was time to cheat a little then. I googled around for the User Agent that the iPhone sends, opened a terminal and entered...
Thursday, August 14, 2008
Ruby on Rails doesn't scale you say?
Thursday, August 7, 2008
Stop and start PostgreSQL on OSX
To manually stop or start a PostgreSQL 8.2 server that was installed via macports, use the following commands.
Stop
# sudo launchctl stop org.macports.postgresql82-server
Start
# sudo launchctl start org.macports.postgresql82-server
Obviously this will also work for PostgreSQL 8.3 or 8.4 if you change the commands slightly.
I prefer the approach Linux distros have generally taken for service management, where all services are listed under the /etc/init.d diretory. To me /etc/init.d/postgresql-8.2 is easier, and you can use command completion to type it.






