Archive for March, 2011
I don’t like buying Intel CPU’s
by specialj on Mar.28, 2011, under Hardware
I speculated earlier that I might buy a sandy bridge CPU and motherboard and that it would represent a break from 16 years of buying AMD. I have always bought at the low end of price where AMD has always offered superior competition. But I am not blind to how well sandy bridge systems perform and I am looking for more performance from my next system. I was strongly considering buying the i5-2500K and an H67 chipset motherboard. But today I learned about yet another limitation to this configuration (above the 2500K not supporting VT-d and TXT, though I’m sure no TXT is actually a loss) and that is that you cannot overclock it. So as usual Intel has a lineup which is complicated to make a choice because of all the various options in play. I much prefer AMD’s simple setup: all features on every chip and you just pick the speed and cache. Not to mention that I’d really prefer to buy ECC RAM which you can do on a consumer AMD motherboard but not on any consumer Intel board.
Git: Untracked working tree file would be overwritten by merge
by specialj on Mar.23, 2011, under Development
I ran into a merge conflict when a branch had changed a file and I was merging in another branch where the file had been deleted and placed in gitignore. Some suggestions on handling this here:
I used:
- git checkout <your-branch> -f
I then need to “git rm” the file in the branch where it had been modified. I’m not sure what exactly happened to the file since I didn’t care much about it.
Determining if a string is a float
by specialj on Mar.19, 2011, under Ruby On Rails
Using to_f has the problem of returning 0.0 for invalid strings. So for a project I needed to know if a string was a valid float or not and came across this helpful page: ruby on rails – Determine if a string is a valid float value – Stack Overflow. My favorite option was this:
class String
def valid_float?
# The double negation turns this into an actual boolean true - if you're
# okay with "truthy" values (like 0.0), you can remove it.
!!Float(self) rescue false
end
end
Accessing MS SQL Server from Rails without ODBC
by specialj on Mar.18, 2011, under Ruby On Rails
I found myself looking through the code for activerecord-sqlserver-adapter and noticed a new mode called “dblib”. It turns out this mode can be used when using the tiny_tds gem along with FreeTDS to avoid using ODBC altogether. I decided to try it out on a project and have found it to work very well so far. The update_sql call no longer has to make a call to get the number of affected rows, something which was slowing down the code significantly. I don’t have many benchmarks yet but it looks like performance is up or has remained constant across the board. I’m not sure if there are any problems that might come up, certainly TinyTDS is a relatively new project. But for now I’m enjoying not having to use ODBC and hopefully this will continue to work well moving forward.
Ruby regexp surprise: \w is not equivalent to [0-9A-Za-z_]
by specialj on Mar.17, 2011, under Ruby On Rails
Despite ample documentation to the contrary I was surprised to learn that by default ruby matches \w to all unicode characters. This lead to some strange results in one of my apps where unicode quotes were present and matching \w. I found the solution is to use /\w+/n to specify the n kcode rather than the u kcode. But this was still distressing to find as the default in 1.8.7 and 1.9.2. It was further complicated by trying to get information. The following websites all report that \w is equivalent to [0-9A-Za-z_]:
- Regular expressions (Ruby User’s Guide)
- Rubular: a Ruby regular expression editor and tester
- Ruby Regular Expressions
According to these links, this behavior is spec but not documented anywhere:
Rails marshal data too short
by specialj on Mar.15, 2011, under Ruby On Rails
I ran into an error when trying to save an object in flash between Rails actions. I’m still not sure why marshal data too short happened as the session storage is mysql using the text type which should be 64kb. I can’t imagine the object taking more size than that but it would be worth checking. I resolved the issue by not storing the object but other options would be figuring out why the object is so large (Marshal.dump(object) maybe) or switching to mediumtext type which has a limit of 16MB. To do this via a migration can be found here:
Resetting postfixadmin password
by specialj on Mar.15, 2011, under Sysadmin
I had a client using postfixadmin but no one knew the password. Simple enough to go into the db to reset:
dovecotpw -s MD5-CRYPT -p password | sed ‘s/{MD5-CRYPT}//’
Then in the database:
update admin set password=’CRYPTED PASSWORD” where username=’USERNAME’;
I found how to do this here:
SourceForge.net: Postfix Admin: Topic: Postfixadmin mysql password storage method
Getting Xen 4.0.1 working in Debian 6.0
by specialj on Mar.12, 2011, under Sysadmin, virtualization
I’ve decided to expand this post a bit as I’ve run into a lot more problems. I think I will try evaluating XCP 1.0. Hard to imagine it being worse than Xen on Debian.
Encoding webm with ffmpeg
by specialj on Mar.11, 2011, under Uncategorized
It was pretty easy. At it’s most basic:
ffpeg -i infile -f webm outfile.webm
Some resources to get fancier:
Will I end up having to write my own Linux twitter client?
by specialj on Mar.01, 2011, under Linux
I am not at all happy with the state of GNU/Linux twitter clients. It seems this is all too common in the open source world, too many people working on different products, none of which end up being very good. I’ve counted 10 native GNU/Linux clients (not counting Adobe Air) and not one of them suits my needs (Gnome, multiple account support, decent interface, works). Here are some thoughts on each of them: