Migrate posts back from harp format to markdown with headers once again

This commit is contained in:
Sami Samhuri 2019-12-04 20:27:27 -08:00
parent 4f384e3e4c
commit 5ed68c45f8
231 changed files with 1418 additions and 1962 deletions

View file

@ -1,6 +1,6 @@
all: compile
all: blog
compile:
blog:
@echo
./bin/compile . www
@ -12,8 +12,12 @@ publish_beta: compile
@echo
./bin/publish --beta --delete
sitegen:
@echo
./bin/build-sitegen
test:
@echo
./bin/test
.PHONY: compile publish publish_beta test
.PHONY: blog publish publish_beta sitegen test

View file

@ -57,7 +57,7 @@ Execution, trying TDD for the first time:
- [x] Decide whether to migrate from [9af9d75][] or the current harp format (probably easier to migrate the new format because posts may have been updated since then)
- [ ] Migrate posts
- [x] Migrate posts
- [x] Migrate year indexes
@ -65,7 +65,9 @@ Execution, trying TDD for the first time:
- [ ] Migrate index / recent posts
- [ ] Migrate archive
- [ ] Migrate archive and put it at /posts/index.html, duh!
- [ ] 301 redirect /archive to /posts, and update the header link
- [ ] Check and delete _data.json filse

View file

@ -18,6 +18,8 @@ public final class Generator {
let plugins: [Plugin]
let renderers: [Renderer]
let ignoredFilenames = [".DS_Store", ".gitkeep"]
public init(sourceURL: URL, plugins: [Plugin], renderers: [Renderer]) throws {
let siteURL = sourceURL.appendingPathComponent("site.json")
let site = try Site.decode(from: siteURL)
@ -47,6 +49,9 @@ public final class Generator {
// Recursively copy or render every file in the given path.
func renderPath(_ path: String, to targetURL: URL) throws {
for filename in try fileManager.contentsOfDirectory(atPath: path) {
guard !ignoredFilenames.contains(filename) else {
continue
}
// Recurse into subdirectories, updating the target directory as well.
let fileURL = URL(fileURLWithPath: path).appendingPathComponent(filename)
@ -60,18 +65,13 @@ public final class Generator {
// Make sure this path exists so we can write to it.
try fileManager.createDirectory(at: targetURL, withIntermediateDirectories: true, attributes: nil)
// Processes the file, transforming it if necessary.
// Process the file, transforming it if necessary.
try renderOrCopyFile(url: fileURL, targetDir: targetURL)
}
}
func renderOrCopyFile(url fileURL: URL, targetDir: URL) throws {
let filename = fileURL.lastPathComponent
guard filename != ".DS_Store", filename != ".gitkeep" else {
print("Ignoring hidden file \(filename)")
return
}
let ext = String(filename.split(separator: ".").last!)
for renderer in renderers {
if renderer.canRenderFile(named: filename, withExtension: ext) {

View file

@ -27,8 +27,8 @@ struct Post {
let month = dateComponents.month!
return "/" + [
"posts",
"\(year)",
"\(month)",
String(format: "%02d", year),
String(format: "%02d", month),
"\(slug)",
].joined(separator: "/")
}
@ -46,16 +46,16 @@ extension Post {
case deficientMetadata(missingKeys: [String])
}
init(bodyMarkdown: String, metadata: [String: String]) throws {
init(slug: String, bodyMarkdown: String, metadata: [String: String]) throws {
self.slug = slug
self.bodyMarkdown = bodyMarkdown
let requiredKeys = ["Slug", "Title", "Author", "Date", "Timestamp", "Tags", "Path_deprecated"]
let requiredKeys = ["Title", "Author", "Date", "Timestamp"]
let missingKeys = requiredKeys.filter { metadata[$0] == nil }
guard missingKeys.isEmpty else {
throw Error.deficientMetadata(missingKeys: missingKeys)
}
slug = metadata["Slug"]!
title = metadata["Title"]!
author = metadata["Author"]!
date = Date(timeIntervalSince1970: TimeInterval(metadata["Timestamp"]!)!)
@ -66,10 +66,12 @@ extension Post {
else {
link = nil
}
tags = metadata["Tags"]!.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }
let handWrittenPath = metadata["Path_deprecated"]!
assert(path == handWrittenPath, "FUCK: Generated path (\(path)) doesn't match the hand-written one \(handWrittenPath)")
if let string = metadata["Tags"] {
tags = string.split(separator: ",").map({ $0.trimmingCharacters(in: .whitespaces) })
}
else {
tags = []
}
}
}

View file

@ -34,7 +34,8 @@ final class PostsPlugin: Plugin {
do {
let markdown = try String(contentsOf: url)
let result = markdownParser.parse(markdown)
return try Post(bodyMarkdown: result.html, metadata: result.metadata)
let slug = url.deletingPathExtension().lastPathComponent
return try Post(slug: slug, bodyMarkdown: result.html, metadata: result.metadata)
}
catch {
print("Cannot create post from markdown file \(url): \(error)")
@ -94,7 +95,11 @@ final class PostsPlugin: Plugin {
let monthDir = yearDir.appendingPathComponent(month.padded)
try fileManager.createDirectory(at: monthDir, withIntermediateDirectories: true, attributes: nil)
let context: [String: Any] = ["posts": renderedPosts.map { $0.dictionary }]
#warning("FIXME: get the site name out of here somehow")
let context: [String: Any] = [
"title": "samhuri.net: \(month.name) \(year)",
"posts": renderedPosts.map { $0.dictionary },
]
let monthHTML = try templateRenderer.renderTemplate(name: "posts-month", context: context)
let monthURL = monthDir.appendingPathComponent("index.html")
try monthHTML.write(to: monthURL, atomically: true, encoding: .utf8)
@ -107,7 +112,9 @@ final class PostsPlugin: Plugin {
dict[month.padded] = renderedPosts.map { $0.dictionary }
}
let monthsPadded = months.map { $0.padded }
#warning("FIXME: get the site name out of here somehow")
let context: [String: Any] = [
"title": "samhuri.net: \(year)",
"path": postsPath,
"year": year,
"months": monthsPadded,
@ -132,7 +139,11 @@ final class PostsPlugin: Plugin {
let postURL = monthDir.appendingPathComponent(filename)
let bodyHTML = markdownParser.html(from: post.bodyMarkdown)
let renderedPost = RenderedPost(post: post, body: bodyHTML)
let postHTML = try templateRenderer.renderTemplate(name: "post", context: ["post": renderedPost.dictionary])
#warning("FIXME: get the site name out of here somehow")
let postHTML = try templateRenderer.renderTemplate(name: "post", context: [
"title": "samhuri.net: \(renderedPost.post.title)",
"post": renderedPost.dictionary,
])
try postHTML.write(to: postURL, atomically: true, encoding: .utf8)
}

View file

@ -46,13 +46,21 @@ final class ProjectsPlugin: Plugin {
let projectsDir = targetURL.appendingPathComponent(path)
try fileManager.createDirectory(at: projectsDir, withIntermediateDirectories: true, attributes: nil)
let projectsURL = projectsDir.appendingPathComponent("index.html")
let projectsHTML = try templateRenderer.renderTemplate(name: "projects", context: ["projects": projects])
#warning("FIXME: get the site name out of here somehow")
let projectsHTML = try templateRenderer.renderTemplate(name: "projects", context: [
"title": "samhuri.net: Projects",
"projects": projects,
])
try projectsHTML.write(to: projectsURL, atomically: true, encoding: .utf8)
for project in projects {
let filename = "\(project.title).html"
let projectURL = projectsDir.appendingPathComponent(filename)
let projectHTML = try templateRenderer.renderTemplate(name: "project", context: ["project": project])
#warning("FIXME: get the site name out of here somehow")
let projectHTML = try templateRenderer.renderTemplate(name: "project", context: [
"title": "samhuri.net: \(project.title)",
"project": project,
])
try projectHTML.write(to: projectURL, atomically: true, encoding: .utf8)
}
}

6
bin/build-sitegen Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
pushd "SiteGenerator" >/dev/null
swift build
cp .build/x86_64-apple-macosx/debug/SiteGenerator ../bin/sitegen
popd >/dev/null

83
bin/harp2swift Executable file
View file

@ -0,0 +1,83 @@
#!/usr/bin/env ruby -w
# encoding: utf-8
require 'rubygems'
require 'time'
require 'bundler/setup'
require 'builder'
require 'json'
require 'rdiscount'
require 'mustache'
class Hash
def compact
h = {}
each_pair do |k, v|
h[k] = v unless v.nil?
end
h
end
end
def main
dir = ARGV.shift.to_s
unless File.directory? dir
puts 'usage: harp2swift <dir>'
exit 1
end
b = Blag.new dir
b.migrate!
end
class Blag
def initialize dir
@dir = dir
end
def migrate!
migrate_posts
end
def migrate_posts
Dir[File.join(@dir, 'posts/*/*')].sort.map do |dir|
next unless File.directory?(dir) && dir =~ /\/\d\d$/
year, month = dir.split('/')[-2..-1]
data_json = File.read File.join(dir, '_data.json') rescue nil
next unless data_json
data = JSON.parse data_json
data.each do |slug, post|
post_path = File.join dir, "#{slug}.md"
plain_md = File.read post_path
if plain_md[0, 3] == '---'
puts ">>>> Skipping #{post_path} which already has metadata"
next
end
author = post['author'] && post['author'] != "" ? post['author'] : 'Sami Samhuri'
headers = {
'Title' => post['title'],
'Author' => author,
'Date' => post['date'],
'Timestamp' => post['timestamp'],
'Tags' => post['tags'].join(', '),
}
if post['link']
headers['Link'] = post['link']
end
header_string = headers.map { |name, value| "#{name}: #{value}" }.join("\n")
fancy_md = <<-EOT
---
#{header_string}
---
#{plain_md}
EOT
File.write post_path, fancy_md
puts ">>>> Migrated #{post_path}"
end
end
end # def migrate_posts
end # class Blag
main if $0 == __FILE__

View file

@ -2,11 +2,6 @@
set -e
pushd "SiteGenerator" >/dev/null
swift build
cp .build/x86_64-apple-macosx/debug/SiteGenerator ../bin/sitegen
popd >/dev/null
for site in Tests/test-*; do
bin/compile "$site/in" "$site/actual" # >/dev/null
diff -ru "$site/expected" "$site/actual"

View file

@ -1,181 +0,0 @@
{
"first-post": {
"title": "First Post!",
"date": "8th February, 2006",
"timestamp": 1139368860,
"tags": [
"life"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/first-post"
},
"touch-screen-on-steroids": {
"title": "Touch Screen on Steroids",
"date": "8th February, 2006",
"timestamp": 1139407560,
"tags": [
"technology",
"touch"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/touch-screen-on-steroids"
},
"urban-extreme-gymnastics": {
"title": "Urban Extreme Gymnastics?",
"date": "15th February, 2006",
"timestamp": 1140028860,
"tags": [
"amusement"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/urban-extreme-gymnastics"
},
"girlfriend-x": {
"title": "Girlfriend X",
"date": "18th February, 2006",
"timestamp": 1140292200,
"tags": [
"crazy",
"funny"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/girlfriend-x"
},
"jump-to-viewcontroller-in-textmate": {
"title": "Jump to view/controller in TextMate",
"date": "18th February, 2006",
"timestamp": 1140303060,
"tags": [
"hacking",
"rails",
"textmate",
"rails",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/jump-to-viewcontroller-in-textmate"
},
"some-textmate-snippets-for-rails-migrations": {
"title": "Some TextMate snippets for Rails Migrations",
"date": "18th February, 2006",
"timestamp": 1140331680,
"tags": [
"textmate",
"rails",
"hacking",
"rails",
"snippets",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/some-textmate-snippets-for-rails-migrations"
},
"obligatory-post-about-ruby-on-rails": {
"title": "Obligatory Post about Ruby on Rails",
"date": "20th February, 2006",
"timestamp": 1140424260,
"tags": [
"rails",
"coding",
"hacking",
"migration",
"rails",
"testing"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/obligatory-post-about-ruby-on-rails",
"styles": [
"/css/typocode.css"
]
},
"textmate-snippets-for-rails-assertions": {
"title": "TextMate Snippets for Rails Assertions",
"date": "20th February, 2006",
"timestamp": 1140508320,
"tags": [
"textmate",
"rails",
"coding",
"rails",
"snippets",
"testing",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/textmate-snippets-for-rails-assertions"
},
"textmate-move-selection-to-self-down": {
"title": "TextMate: Move selection to self.down",
"date": "21st February, 2006",
"timestamp": 1140510360,
"tags": [
"textmate",
"rails",
"hacking",
"hack",
"macro",
"rails",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/textmate-move-selection-to-self-down",
"styles": [
"/css/typocode.css"
]
},
"textmate-insert-text-into-self-down": {
"title": "TextMate: Insert text into self.down",
"date": "21st February, 2006",
"timestamp": 1140562500,
"tags": [
"textmate",
"rails",
"hacking",
"commands",
"macro",
"rails",
"snippets",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/textmate-insert-text-into-self-down",
"styles": [
"/css/typocode.css"
]
},
"intelligent-migration-snippets-0_1-for-textmate": {
"title": "Intelligent Migration Snippets 0.1 for TextMate",
"date": "22nd February, 2006",
"timestamp": 1140607680,
"tags": [
"mac os x",
"textmate",
"rails",
"hacking",
"migrations",
"snippets"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/intelligent-migration-snippets-0_1-for-textmate"
},
"sjs-rails-bundle-0_2-for-textmate": {
"title": "SJ's Rails Bundle 0.2 for TextMate",
"date": "23rd February, 2006",
"timestamp": 1140743880,
"tags": [
"textmate",
"rails",
"coding",
"bundle",
"macros",
"rails",
"snippets",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2006/02/sjs-rails-bundle-0_2-for-textmate",
"styles": [
"/css/typocode.css"
]
}
}

View file

@ -1,3 +1,12 @@
---
Title: First Post!
Author: Sami Samhuri
Date: 8th February, 2006
Timestamp: 1139368860
Tags: life
---
so it's 2am and i should be asleep, but instead i'm setting up a blog. i got a new desk last night and so today i finally got my apartment re-arranged and it's much better now. that's it for now... time to sleep.
(speaking of sleep, this new [sleeping bag](http://www.musuchouse.com/) design makes so much sense. awesome.)

View file

@ -1,5 +1,14 @@
---
Title: Girlfriend X
Author: Sami Samhuri
Date: 18th February, 2006
Timestamp: 1140292200
Tags: crazy, funny
---
This is hilarious! Someone wrote software that manages a "parallel" dating style.
> In addition to storing each woman's contact information and picture, the Girlfriend profiles include a Score Card where you track her sexual preferences, her menstrual cycles and how she styles her pubic hair.
It's called [Girlfriend X](http://www.wired.com/news/columns/0,70231-0.html), but that's a link to an article about it. I didn't go to the actual website. I just thing it's amusing someone went through the trouble to do this. Maybe there's a demand for it. *\*shrug\**

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,11 @@
---
Title: Intelligent Migration Snippets 0.1 for TextMate
Author: Sami Samhuri
Date: 22nd February, 2006
Timestamp: 1140607680
Tags: mac os x, textmate, rails, hacking, migrations, snippets
---
*This should be working now. I've tested it under a new user account here.*
*This does requires the syncPeople bundle to be installed to work. That's ok, because you should get the [syncPeople on Rails bundle][syncPeople] anyways.*
@ -35,3 +43,4 @@ Run **Quick Install.app** to install these commands to your <a [syncPeople on Ra
This is specific to Rails migrations, but there are probably other uses for something like this. You are free to use and distribute this code.
[syncPeople]: http://blog.inquirylabs.com/

View file

@ -1 +1,10 @@
---
Title: Jump to view/controller in TextMate
Author: Sami Samhuri
Date: 18th February, 2006
Timestamp: 1140303060
Tags: hacking, rails, textmate, rails, textmate
---
<a href="http://blog.inquirylabs.com/2006/02/17/controller-to-view-and-back-again-in-textmate/trackback/">Duane</a> came up with a way to jump to the controller method for the view you're editing, or vice versa in TextMate while coding using Rails. This is a huge time-saver, thanks!

View file

@ -1,3 +1,11 @@
---
Title: Obligatory Post about Ruby on Rails
Author: Sami Samhuri
Date: 20th February, 2006
Timestamp: 1140424260
Tags: rails, coding, hacking, migration, rails, testing
---
<p><em>I'm a Rails newbie and eager to learn. I welcome any suggestions or criticism you have. You can direct them to <a href="mailto:sjs@uvic.ca">my inbox</a> or leave me a comment below.</em></p>
<p>I finally set myself up with a blog. I mailed my dad the address and mentioned that it was running <a href="http://www.typosphere.org/">Typo</a>, which is written in <a href="http://www.rubyonrails.com/">Ruby on Rails</a>. The fact that it is written in Rails was a big factor in my decision. I am currently reading <a href="http://www.pragmaticprogrammer.com/titles/rails/">Agile Web Development With Rails</a> and it will be great to use Typo as a learning tool, since I will be modifying my blog anyways regardless of what language it's written in.</p>
@ -205,3 +213,4 @@
<p>I love how I've only been coding in Rails for a week or two and I can do so much already. It's natural, concise and takes care of the inane details. I love how I <em>know</em> that I don't even have to explain that migration example. It's plainly clear what it does to the database. It doesn't take long to get the basics down and once you do it goes <strong>fast</strong>.</p>

View file

@ -1,3 +1,11 @@
---
Title: SJ's Rails Bundle 0.2 for TextMate
Author: Sami Samhuri
Date: 23rd February, 2006
Timestamp: 1140743880
Tags: textmate, rails, coding, bundle, macros, rails, snippets, textmate
---
Everything that you've seen posted on my blog is now available in one bundle. Snippets for Rails database migrations and assertions are all included in this bundle.
There are 2 macros for class-end and def-end blocks, bound to <strong>⌃C</strong> and <strong>⌃D</strong> respectively. Type the class or method definition, except for <code>class</code> or <code>def</code>, and then type the keyboard shortcut and the rest is filled in for you.
@ -21,3 +29,4 @@ Without further ado, here is the bundle:
<p style="text-align: center;"><img src="/images/download.png" title="Download" alt="Download"> <a href="/f/SJRailsBundle-0.2.dmg">Download SJ's Rails Bundle 0.2</a></p>
This is a work in progress, so any feedback you have is very helpful in making the next release better.

View file

@ -1,3 +1,11 @@
---
Title: Some TextMate snippets for Rails Migrations
Author: Sami Samhuri
Date: 18th February, 2006
Timestamp: 1140331680
Tags: textmate, rails, hacking, rails, snippets, textmate
---
My arsenal of snippets and macros in TextMate is building as I read through the rails canon, <a href="http://www.pragmaticprogrammer.com/titles/rails/" title="Agile Web Development With Rails">Agile Web Development...</a> I'm only 150 pages in so I haven't had to add much so far because I started with the bundle found on the <a href="http://wiki.rubyonrails.org/rails/pages/TextMate">rails wiki</a>. The main ones so far are for migrations.
Initially I wrote a snippet for adding a table and one for dropping a table, but I don't want to write it twice every time! If I'm adding a table in **up** then I probably want to drop it in **down**.
@ -83,3 +91,4 @@ I'll be adding more snippets and macros. There should be a central place where t
<p>P.S. I tried several ways to get the combo-snippets to put the pieces inside the right functions but failed. We'll see tomorrow if Allan (creator of TextMate) has any ideas.</p>
</div>
</div>

View file

@ -1,3 +1,11 @@
---
Title: TextMate: Insert text into self.down
Author: Sami Samhuri
Date: 21st February, 2006
Timestamp: 1140562500
Tags: textmate, rails, hacking, commands, macro, rails, snippets, textmate
---
<p><em><strong>UPDATE:</strong> I got everything working and it's all packaged up <a href="/posts/2006/02/intelligent-migration-snippets-0_1-for-textmate">here</a>. There's an installation script this time as well.</em></p>
<p>Thanks to <a href="http://thread.gmane.org/gmane.editors.textmate.general/8520">a helpful thread</a> on the TextMate mailing list I have the beginning of a solution to insert text at 2 (or more) locations in a file.</p>
@ -52,3 +60,4 @@ The macro I'm thinking of to invoke this is tab-triggered and will simply:
<li>Run command "Put in self.down"</li>
</ul>

View file

@ -1,3 +1,11 @@
---
Title: TextMate: Move selection to self.down
Author: Sami Samhuri
Date: 21st February, 2006
Timestamp: 1140510360
Tags: textmate, rails, hacking, hack, macro, rails, textmate
---
<p><strong>UPDATE:</strong> <em>This is obsolete, see <a href="/posts/2006/02/textmate-insert-text-into-self-down">this post</a> for a better solution.</em></p>
<p><a href="/posts/2006/02/some-textmate-snippets-for-rails-migrations.html#comment-3">Duane's comment</a> prompted me to think about how to get the <code>drop_table</code> and <code>remove_column</code> lines inserted in the right place. I don't think TextMate's snippets are built to do this sort of text manipulation. It would be nicer, but a quick hack will suffice for now.</p><p>Use <acronym title="Migration Create and Drop Table">MCDT</acronym> to insert:</p>
@ -20,3 +28,4 @@
<p>The caveat here is that if there is a <code>create_table</code> or <code>add_column</code> between <code>self.down</code> and the table you just added, it will jump back to the wrong spot. It's still faster than doing it all manually, but should be improved. If you use these exclusively, the order they occur in <code>self.down</code> will be opposite of that in <code>self.up</code>. That means either leaving things backwards or doing the re-ordering manually. =/</p>

View file

@ -1,3 +1,11 @@
---
Title: TextMate Snippets for Rails Assertions
Author: Sami Samhuri
Date: 20th February, 2006
Timestamp: 1140508320
Tags: textmate, rails, coding, rails, snippets, testing, textmate
---
This time I've got a few snippets for assertions. Using these to type up your tests quickly, and then hitting **⌘R** to run the tests without leaving TextMate, makes testing your Rails app that much more convenient. Just when you thought it was already too easy! (Don't forget that you can use **⌥⌘↓** to move between your code and the corresponding test case.)
This time I'm posting the .plist files to make it easier for you to add them to TextMate. All you need to do is copy these to **~/Library/Application Support/TextMate/Bundles/Rails.tmbundle/Snippets**.
@ -7,3 +15,4 @@ This time I'm posting the .plist files to make it easier for you to add them to
If anyone would rather I list them all here I can do that as well. Just leave a comment.
*(I wanted to include a droplet in the zip file that will copy the snippets to the right place, but my 3-hour attempt at writing the AppleScript to do so left me feeling quite bitter. Maybe I was just mistaken in thinking it would be easy to pick up AppleScript.)*

View file

@ -1,3 +1,11 @@
---
Title: Touch Screen on Steroids
Author: Sami Samhuri
Date: 8th February, 2006
Timestamp: 1139407560
Tags: technology, touch
---
If you thought the PowerBook's two-finger scrolling was cool check out this touch screen:
<a href="http://mrl.nyu.edu/~jhan/ftirtouch/">Multi-Touch Interaction Research</a>
@ -5,3 +13,4 @@ If you thought the PowerBook's two-finger scrolling was cool check out this touc
> "While touch sensing is commonplace for single points of contact, multi-touch sensing enables a user to interact with a system with more than one finger at a time, as in chording and bi-manual operations. Such sensing devices are inherently also able to accommodate multiple users simultaneously, which is especially useful for larger interaction scenarios such as interactive walls and tabletops."
This is really amazing. Forget traditional tablet PCs... <i>this</i> is revolutionary and useful in so many applications. I hope this kind of technology is mainstream by 2015.

View file

@ -1,3 +1,12 @@
---
Title: Urban Extreme Gymnastics?
Author: Sami Samhuri
Date: 15th February, 2006
Timestamp: 1140028860
Tags: amusement
---
This crazy russian goes all over the place scaling buildings, doing all sorts of flips, bouncing off the walls literally. He'd be impossible to catch.
<a href="http://www.videobomb.com/posts/show/46">Russian parkour (urban extreme gymnastics)</a>

View file

@ -1,46 +0,0 @@
{
"generate-selfdown-in-your-rails-migrations": {
"title": "Generate self.down in your Rails migrations",
"date": "3rd March, 2006",
"timestamp": 1141450680,
"tags": [
"rails",
"textmate",
"migrations",
"rails",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2006/03/generate-selfdown-in-your-rails-migrations"
},
"spore": {
"title": "Spore",
"date": "3rd March, 2006",
"timestamp": 1141450980,
"tags": [
"amusement",
"technology",
"cool",
"fun",
"games"
],
"author": "Sami Samhuri",
"url": "/posts/2006/03/spore"
},
"i-dont-mind-fairplay-either": {
"title": "I don't mind FairPlay either",
"date": "3rd March, 2006",
"timestamp": 1141451760,
"tags": [
"apple",
"mac os x",
"life",
"drm",
"fairplay",
"ipod",
"itunes"
],
"author": "Sami Samhuri",
"url": "/posts/2006/03/i-dont-mind-fairplay-either"
}
}

View file

@ -1 +1,10 @@
---
Title: Generate self.down in your Rails migrations
Author: Sami Samhuri
Date: 3rd March, 2006
Timestamp: 1141450680
Tags: rails, textmate, migrations, rails, textmate
---
<a href="http://lunchboxsoftware.com/">Scott</a> wrote a really <a href="http://lunchroom.lunchboxsoftware.com/articles/2005/11/29/auto-fill-your-reverse-migrations">cool program</a> that will scan `self.up` and then consult db/schema.rb to automatically fill in `self.down` for you. Brilliant!

View file

@ -1,3 +1,11 @@
---
Title: I don't mind FairPlay either
Author: Sami Samhuri
Date: 3rd March, 2006
Timestamp: 1141451760
Tags: apple, mac os x, life, drm, fairplay, ipod, itunes
---
I think that <a href="http://jim.roepcke.com/2006/03/02#item7471">Jim is right</a> about Apple's DRM not being all that evil.
I buy music from the iTunes Music Store *because* I bought an iPod. The fact I can't play them on another device doesn't matter to me. With my purchased songs I can:
@ -13,3 +21,4 @@ I dislike DRM as much as the next guy, but like CSS encryption on DVDs, FairPlay
It reminds me of how here in North America I have to live with the crappy cell phone companies that lock their phones to their networks. If it's something I need or want, sometimes I'll live with restrictions because there are no alternatives yet.
*__Update:__ It's almost settled. The pope <a href="http://www.catholicnews.com/data/stories/cns/0601282.htm">got an iPod</a> so all that's left is to see if he buys any music off of iTunes. If he does, then it can't be evil. heh...*

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,12 @@
---
Title: Spore
Author: Sami Samhuri
Date: 3rd March, 2006
Timestamp: 1141450980
Tags: amusement, technology, cool, fun, games
---
<a href="http://video.google.com/videoplay?docid=8372603330420559198&amp;q=spore">This game</a> that <a href="http://jim.roepcke.com/">Jim</a> <a href="http://jim.roepcke.com/2006/03/01#item7470">blogged about</a> is probably the coolest game I've seen.
You really just have to watch the video, I won't bother explaining it here. I don't really play games much, but this I would play.

View file

@ -1,16 +0,0 @@
{
"zsh-terminal-goodness-on-os-x": {
"title": "zsh terminal goodness on OS X",
"date": "4th April, 2006",
"timestamp": 1144187820,
"tags": [
"mac os x",
"apple",
"osx",
"terminal",
"zsh"
],
"author": "Sami Samhuri",
"url": "/posts/2006/04/zsh-terminal-goodness-on-os-x"
}
}

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,12 @@
---
Title: zsh terminal goodness on OS X
Author: Sami Samhuri
Date: 4th April, 2006
Timestamp: 1144187820
Tags: mac os x, apple, osx, terminal, zsh
---
<a href="http://www.apple.com/">Apple</a> released the <a href="http://docs.info.apple.com/article.html?artnum=303411">OS X 10.4.6 update</a> which fixed a <strong>really</strong> annoying bug for me. Terminal (and <a href="http://iterm.sourceforge.net/">iTerm</a>) would fail to open a new window/tab when your shell is <a href="http://zsh.sourceforge.net/">zsh</a>. iTerm would just open then immediately close the window, while Terminal would display the message: <code>[Command completed]</code> in a now-useless window.
Rebooting twice to get the fix was reminiscent of <a href="http://www.microsoft.com/windows/default.mspx">Windows</a>, but well worth it.

View file

@ -1,34 +0,0 @@
{
"os-x-and-fitts-law": {
"title": "OS X and Fitt's law",
"date": "7th May, 2006",
"timestamp": 1147059780,
"tags": [
"mac os x",
"apple",
"mac",
"os",
"usability",
"x"
],
"author": "Sami Samhuri",
"url": "/posts/2006/05/os-x-and-fitts-law"
},
"wikipediafs-on-linux-in-python": {
"title": "WikipediaFS on Linux, in Python",
"date": "7th May, 2006",
"timestamp": 1147060140,
"tags": [
"hacking",
"python",
"linux",
"fuse",
"linux",
"mediawiki",
"python",
"wikipediafs"
],
"author": "Sami Samhuri",
"url": "/posts/2006/05/wikipediafs-on-linux-in-python"
}
}

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1 +1,10 @@
---
Title: OS X and Fitt's law
Author: Sami Samhuri
Date: 7th May, 2006
Timestamp: 1147059780
Tags: mac os x, apple, mac, os, usability, x
---
I've realized that OS X really does obey Fitt's law in all 4 corners now. Apple menu in the top left, Spotlight top right, and the bottom 2 are always accessible for drag n drop, unless the dock is hidden. I rarely ever use it because I usually have pretty good chunks of the desktop showing, but it is useful.

View file

@ -1,3 +1,12 @@
---
Title: WikipediaFS on Linux, in Python
Author: Sami Samhuri
Date: 7th May, 2006
Timestamp: 1147060140
Tags: hacking, python, linux, fuse, linux, mediawiki, python, wikipediafs
---
Until now I've been using my own version of <a href="http://meta.wikimedia.org/wiki/Pywikipedia">pywikipedia</a> for scripting MediaWiki, and it works well. But I read about <a href="http://wikipediafs.sourceforge.net/">WikipediaFS</a> and had to check it out. It's a user space filesystem for Linux that's built using the <a href="http://fuse.sourceforge.net/wiki/index.php/LanguageBindings">Python bindings</a> for <a href="http://fuse.sourceforge.net/">FUSE</a>. What it does is mounts a filesystem that represents your wiki, with articles as text files. You can use them just like any other files with mv, cp, ls, vim, and so on.
There hasen't been any action on that project for 13 months though, and it doesn't work on my wiki (MediaWiki 1.4.15) so I'm going to try and make it work after I upgrade to MediaWiki 1.6.3 tonight. This will be pretty cool when it works. I haven't looked at the code yet but it's only 650 lines.

View file

@ -1,52 +0,0 @@
{
"ich-bin-auslnder-und-spreche-nicht-gut-deutsch": {
"title": "Ich bin Ausländer und spreche nicht gut Deutsch",
"date": "5th June, 2006",
"timestamp": 1149527460,
"tags": [
"life",
"munich",
"seekport",
"work"
],
"author": "Sami Samhuri",
"url": "/posts/2006/06/ich-bin-auslnder-und-spreche-nicht-gut-deutsch"
},
"never-buy-a-german-keyboard": {
"title": "Never buy a German keyboard!",
"date": "9th June, 2006",
"timestamp": 1149841020,
"tags": [
"apple",
"apple",
"german",
"keyboard"
],
"author": "Sami Samhuri",
"url": "/posts/2006/06/never-buy-a-german-keyboard"
},
"theres-nothing-regular-about-regular-expressions": {
"title": "There's nothing regular about regular expressions",
"date": "10th June, 2006",
"timestamp": 1149928080,
"tags": [
"technology",
"book",
"regex"
],
"author": "Sami Samhuri",
"url": "/posts/2006/06/theres-nothing-regular-about-regular-expressions"
},
"apple-pays-attention-to-detail": {
"title": "Apple pays attention to detail",
"date": "11th June, 2006",
"timestamp": 1150014600,
"tags": [
"technology",
"mac os x",
"apple"
],
"author": "Sami Samhuri",
"url": "/posts/2006/06/apple-pays-attention-to-detail"
}
}

View file

@ -1 +1,10 @@
---
Title: Apple pays attention to detail
Author: Sami Samhuri
Date: 11th June, 2006
Timestamp: 1150014600
Tags: technology, mac os x, apple
---
I think this has to be one of the big reasons why people who love their Mac, love their Mac (or other Apple product). I usually just have cheap PC speakers plugged into my Mac mini, but I didn't bring any with me to Munich and the internal Mac mini speaker isn't very loud, so I'm using headphones to watch movies. My Mac remembers the volume setting when the headphones ore plugged in, and when they're not, so I don't accidentally blow my ears. It's like my iPod pausing when the headphones are unplugged. It's excruciating attention to the smallest, (seemingly) most unimportant detail. I love it, and I'm hooked.

View file

@ -1,3 +1,11 @@
---
Title: Ich bin Ausländer und spreche nicht gut Deutsch
Author: Sami Samhuri
Date: 5th June, 2006
Timestamp: 1149527460
Tags: life, munich, seekport, work
---
How's this for an update: I'm working in Munich for the summer at a European search engine called <a href="http://www.seekport.co.uk/">Seekport</a>. The search engine isn't all they do, as right now I'm programming a desktop widget that shows live scores &amp; news from World Cup matches (in English and Arabic). I'm building it on top of the <a href="http://widgets.yahoo.com/">Yahoo! Widget Engine</a> because it needs to run on Windows. Even though I quite like the Y! Engine, I would still prefer to be coding in straight HTML, CSS & JavaScript like Dashboard programmers get to use. The Y! Engine uses XML (it is somewhat HTML-like) and JavaScript.
The place I'm living in is like a dormitory for younger people. I share a bathroom & kitchen with a German guy named Sebastian who is 21 and an artist; a stonecutter actually. I only met him briefly yesterday, but he seems nice. I'm going to teach him English, and he'll teach me German, though his English is much better than my German. It's a pretty quiet place, and we get breakfast included, dinner can be bought for €2,50, and Internet access is included as well. I brought my Mac Mini with me, and as soon as I find an AC adapter I'll be ready to go with the 'net at home. I probably won't blog again until then, since I'm at work right now.
@ -5,3 +13,4 @@ The place I'm living in is like a dormitory for younger people. I share a bathro
Germany is great so far, and as soon as I get learning some German I'll be a much happier person. I consider it rude of me to expect everyone to converse with me in English, like I have to do right now.
(Oh, and they sell beer by the litre in Germany! They call it a maß.)

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,11 @@
---
Title: Never buy a German keyboard!
Author: Sami Samhuri
Date: 9th June, 2006
Timestamp: 1149841020
Tags: apple, apple, german, keyboard
---
Nothing personal, but the backtick/tilde is located where the rest of the left shift key should be, and the return key is double-height, forcing the backslash/bar to the right of the dash/underscore (that'd be the apostrophe/double quote for pretty much everyone else who types qwerty). Note that I'm talking about using a German keyboard with an English layout. The German layout is flat out impossible for coding.
<a href="/images/keyboard.jpg"><img src="/images/keyboard.jpg" title="German Apple Keyboard" alt="German Apple Keyboard"></a>
@ -5,3 +13,4 @@ Nothing personal, but the backtick/tilde is located where the rest of the left s
For some reason it gets even worse with a German Apple keyboard. Square brackets, where for art though? Through trial and error I found them using Alt/Opt+5/6... non-Apple German keyboards I've seen use Alt Gr+8/9, which is just as bad but at least they were <strong>labeled</strong>. I know why coders here don't use the German layout! I feel uneasy just talking about it.
Here's a <a href="/f/german_keys.txt">text file</a> with each character of the 4 rows in it, normal and then shifted, in qwerty, qwertz, and dvorak. I personally think that some ways the German keys change must be some sick joke (double quote moved up to shift-2, single quote almost staying put, angle brackets being shoved aside only to put the semi-colon and colon on different keys as well). If you ask me lots of that could be avoided by getting rid of the key that replaced the backtick/tilde, and putting the 3 vowels with the umlaut (ü, ö, and ä) on Alt Gr/Opt+[aou]. But hey, I don't type in German so what do I know.

View file

@ -1,3 +1,11 @@
---
Title: There's nothing regular about regular expressions
Author: Sami Samhuri
Date: 10th June, 2006
Timestamp: 1149928080
Tags: technology, book, regex
---
I'm almost half way reading Jeffrey Friedl's book <a href="http://www.oreilly.com/catalog/regex2/">Mastering Regular Expressions</a> and I have to say that for a book on something that could potentially bore you to tears, he really does an excellent job of keeping it interesting. Even though a lot of the examples are contrived (I'm sure out of necessity), he also uses real examples of regexes that he's actually used at <a href="http://www.yahoo.com/">Yahoo!</a>.
As someone who has to know how everything works it's also an excellent lesson in patience, as he frequently says "here, take this knowledge and just accept it for now until I can explain why in the next chapter (or in 3 chapters!)". But it's all with good reason and when he does explain he does it well.
@ -12,3 +20,4 @@ QOTD, p. 329, about matching nested pairs of parens:
Wow, that's ugly.
(Don't worry, there's a much better solution on the next 2 pages after that quote.)

View file

@ -1,72 +0,0 @@
{
"working-with-the-zend-framework": {
"title": "Working with the Zend Framework",
"date": "6th July, 2006",
"timestamp": 1152196560,
"tags": [
"coding",
"technology",
"php",
"framework",
"php",
"seekport",
"zend"
],
"author": "Sami Samhuri",
"url": "/posts/2006/07/working-with-the-zend-framework"
},
"ubuntu-linux-for-linux-users-please": {
"title": "Ubuntu: Linux for Linux users please",
"date": "13th July, 2006",
"timestamp": 1152804840,
"tags": [
"linux",
"linux",
"ubuntu"
],
"author": "Sami Samhuri",
"url": "/posts/2006/07/ubuntu-linux-for-linux-users-please"
},
"ruby-and-rails-have-spoiled-me-rotten": {
"title": "Ruby and Rails have spoiled me rotten",
"date": "17th July, 2006",
"timestamp": 1153140000,
"tags": [
"rails",
"ruby",
"php",
"coding",
"framework",
"php",
"rails",
"ruby",
"zend"
],
"author": "Sami Samhuri",
"url": "/posts/2006/07/ruby-and-rails-have-spoiled-me-rotten"
},
"late-static-binding": {
"title": "Late static binding",
"date": "19th July, 2006",
"timestamp": 1153329780,
"tags": [
"php",
"coding",
"coding",
"php"
],
"author": "Sami Samhuri",
"url": "/posts/2006/07/late-static-binding"
},
"class-method-instance-method-it-doesnt-matter-to-php": {
"title": "Class method? Instance method? It doesn't matter to PHP",
"date": "21st July, 2006",
"timestamp": 1153493760,
"tags": [
"php",
"coding"
],
"author": "Sami Samhuri",
"url": "/posts/2006/07/class-method-instance-method-it-doesnt-matter-to-php"
}
}

View file

@ -1,3 +1,11 @@
---
Title: Class method? Instance method? It doesn't matter to PHP
Author: Sami Samhuri
Date: 21st July, 2006
Timestamp: 1153493760
Tags: php, coding
---
*Update: This has <a href="http://www.php.net/~derick/meeting-notes.html#method-calls">been discussed</a> for PHP6. A little late, but I guess better than never.*
I made a mistake while I was coding, for shame! Anyway this particular mistake was that I invoked a class method on the wrong class. The funny part was that this method was an instance method in the class which I typed by mistake. In the error log I saw something like "Invalid use of $this in class function."
@ -47,3 +55,4 @@ This is an instance method!
</code></pre>
What the fuck?! <a href="http://www.php.net/manual/en/language.oop5.static.php">http://www.php.net/manual/en/language.oop5.static.php</a> is lying to everyone.

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,11 @@
---
Title: Late static binding
Author: Sami Samhuri
Date: 19th July, 2006
Timestamp: 1153329780
Tags: php, coding, coding, php
---
*Update: This has <a href="http://www.php.net/~derick/meeting-notes.html#late-static-binding-using-this-without-or-perhaps-with-a-different-name">been discussed</a> and will be uh, sort of fixed, in PHP6. You'll be able to use static::my_method() to get the real reference to self in class methods. Not optimal, but still a solution I guess.*
As colder on ##php (freenode) told me today, class methods in PHP don't have what they call late static binding. What's that? It means that this code:
@ -38,3 +46,4 @@ class Bar extends Foo
I was told that they had a discussion about this on the internal PHP list, so at least they're thinking about this stuff. Too bad PHP5 doesn't have it. I guess I should just be glad I won't be maintaining this code.
The resident PHP coder said "just make your code simpler", which is what I was trying to do by removing duplication. Too bad that plan sort of backfired. I guess odd things like this are where PHP starts to show that OO was tacked on as an after-thought.

View file

@ -1,3 +1,11 @@
---
Title: Ruby and Rails have spoiled me rotten
Author: Sami Samhuri
Date: 17th July, 2006
Timestamp: 1153140000
Tags: rails, ruby, php, coding, framework, php, rails, ruby, zend
---
It's true. I'm sitting here coding in PHP using the <a href="http://framework.zend.com/">Zend Framework</a> and all I can think about is how much nicer Rails is, or how much easier it is to do [x] in Ruby. It's not that the Zend Framework is bad or anything, it's quite nice, but you just can't match Ruby's expressiveness in a language like PHP. Add the amazing convenience Rails builds on top of Ruby and that's a really hard combo to compete with.
I'd love to be using mixins instead of mucking around with abstract classes and interfaces, neither of which will just let you share a method between different classes. Writing proxy methods in these tiny in-between classes is annoying. (ie. inherit from Zend_class, then my real classes inherit from the middle-man class) I *could* add things to Zend's classes, but then upgrades are a bitch. I miss Ruby. I could use something like <a href="http://www.advogato.org/article/470.html">whytheluckystiff's PHP mixins</a>, which is a clever hack, but still a hack.
@ -7,3 +15,4 @@ I keep looking at Rails code to see how things are done there, and I already cod
It's no wonder <a href="http://www.loudthinking.com/">David H. Hansson</a> wasn't able to write a framework he was happy with in PHP. After using Rails everything seems like a chore. I'm just coding solved problems over again in an inferior language.
But hey, I'm learning things and I still got to use Ruby even if the code won't be used later. I guess this experience will just make me appreciate the richness of Ruby and Rails even more.

View file

@ -1,3 +1,11 @@
---
Title: Ubuntu: Linux for Linux users please
Author: Sami Samhuri
Date: 13th July, 2006
Timestamp: 1152804840
Tags: linux, linux, ubuntu
---
<a href="http://www.ubuntu.com/">Ubuntu</a> is a fine Linux distro, which is why it's popular. I still use <a href="http://www.gentoo.org/">Gentoo</a> on my servers but Ubuntu is fast to set up for a desktop. Linux for humans it certainly is, but dammit sometimes I want Linux like I'm used to.
It should ship with build-essentials (gcc & others) installed. It *shouldn't* ask me if I'm sure I want to restart at the GDM login screen. I have no session open and already clicked twice to choose Restart.
@ -5,3 +13,4 @@ It should ship with build-essentials (gcc & others) installed. It *shouldn't* as
Other things aren't quite ready for humans yet. Network config needs some work. It's very slow to apply changes. Connecting to Windows printers should be easier (ie. let us browse to find them, or just search and present a list). Fonts aren't amazing yet, though Mac OS X has spoiled me as far as fonts are concerned.
Other than these things I think Ubuntu Dapper is a fine release. It installed on my work laptop without a problem and detected the volume keys and wireless network card flawlessly.

View file

@ -1,3 +1,11 @@
---
Title: Working with the Zend Framework
Author: Sami Samhuri
Date: 6th July, 2006
Timestamp: 1152196560
Tags: coding, technology, php, framework, php, seekport, zend
---
At [Seekport](http://translate.google.ca/translate?hl=en&sl=de&u=http://de.wikipedia.org/wiki/Seekport&prev=/search%3Fq%3Dseekport%26client%3Dsafari%26rls%3Den) I'm currently working on an app to handle
the config of their business-to-business search engine. It's web-based and I'm using PHP, since
that's what they're re-doing the front-end in. Right now it's a big mess of Perl, the main
@ -30,3 +38,4 @@ that nothing is coupled.
So I'll probably be writing some notes here about my experience with this framework. I also
hope to throw Adobe's [Spry](http://labs.adobe.com/technologies/spry/) into the mix.
That little JS library is a lot of fun.

View file

@ -1,13 +0,0 @@
{
"where-are-my-headphones": {
"title": "Where are my headphones?",
"date": "22nd August, 2006",
"timestamp": 1156257060,
"tags": [
"life",
"seekport"
],
"author": "Sami Samhuri",
"url": "/posts/2006/08/where-are-my-headphones"
}
}

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1 +1,10 @@
---
Title: Where are my headphones?
Author: Sami Samhuri
Date: 22nd August, 2006
Timestamp: 1156257060
Tags: life, seekport
---
Some people left Seekport this month and 2 of the remaining employees moved into the office Im working in. Thats fine, and Im leaving at the end of the week, but man Im going crazy. This guys pounding on his keyboard like its a fucking whack-a-mole game! I dont know what kind of keyboard he learned to type on but it mustve been horrible. It sounds like he must go through at least 10 of those things in a year. I dont know if Ill make it until Friday without yelling "AGH! STOP THE MADNESS YOU CRAZY BASTARD YOU JUST HAVE TO TOUCH THE KEYS!"

View file

@ -1,26 +0,0 @@
{
"buffalo-buffalo-buffalo-buffalo-buffalo-buffalo-buffalo-buffalo": {
"title": "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo",
"date": "16th September, 2006",
"timestamp": 1158469860,
"tags": [
"amusement",
"buffalo"
],
"author": "Sami Samhuri",
"url": "/posts/2006/09/buffalo-buffalo-buffalo-buffalo-buffalo-buffalo-buffalo-buffalo",
"link": "http://en.wikipedia.org/wiki/Buffalo_buffalo_buffalo_buffalo_buffalo_buffalo_buffalo_buffalo"
},
"some-features-you-might-have-missed-in-itunes-7": {
"title": "Some features you might have missed in iTunes 7",
"date": "22nd September, 2006",
"timestamp": 1158969540,
"tags": [
"apple",
"apple",
"itunes"
],
"author": "Sami Samhuri",
"url": "/posts/2006/09/some-features-you-might-have-missed-in-itunes-7"
}
}

View file

@ -1 +1,11 @@
---
Title: Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo
Author: Sami Samhuri
Date: 16th September, 2006
Timestamp: 1158469860
Tags: amusement, buffalo
Link: http://en.wikipedia.org/wiki/Buffalo_buffalo_buffalo_buffalo_buffalo_buffalo_buffalo_buffalo
---
Wouldn't the sentence 'I want to put a hyphen between the words Fish and And and And and Chips in my Fish-And-Chips sign' have been clearer if quotation marks had been placed before Fish, and between Fish and and, and and and And, and And and and, and and and And, and And and and, and and and Chips, as well as after Chips?

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,14 +1,22 @@
<img src="/images/menu.png" style="float: right; margin: 10px;" title="New menu" alt="New menu">
---
Title: Some features you might have missed in iTunes 7
Author: Sami Samhuri
Date: 22nd September, 2006
Timestamp: 1158969540
Tags: apple, apple, itunes
---
Besides the <a href="http://www.tuaw.com/2006/09/12/walkthrough-itunes-7s-big-new-features/">big changes</a> in <a href="http://www.apple.com/itunes">iTunes 7</a> there have been some minor changes that are still pretty useful.
<p style="text-align: center"><img src="/images/menu.png" title="New menu" alt="New menu"></p>
Here's a quick recap of a few major features:
* <a href="http://sami.samhuri.net/files/coverflow.png">Coverflow</a> built in, new views to flip through album covers and video thumbnails
* iTunes Music Store is now just the iTunes Store
* New look, no more brushed metal
* The menu on the left is more structured and easier to navigate (for me)
* Games support
- <a href="http://sami.samhuri.net/files/coverflow.png">Coverflow</a> built in, new views to flip through album covers and video thumbnails
- iTunes Music Store is now just the iTunes Store
- New look, no more brushed metal
- The menu on the left is more structured and easier to navigate (for me)
- Games support
And now some of the smaller gems are listed below.
@ -41,3 +49,4 @@ For videos you can now set the Show, Season Number, Episode Number, and Episode
I want to be able to change more than one movie's type to Movie, Music Video, or TV Show at once. Manually doing it for more than one season of a show gets old very fast, and I'm reluctant to write a program to let you do just that but I may if I have time.
I'm sure I have other gripes, but honestly iTunes is a full-featured app and while there's room for improvement they do get a lot right with it as well.

View file

@ -1,16 +0,0 @@
{
"coping-with-windows-xp-activiation-on-a-mac": {
"title": "Coping with Windows XP activiation on a Mac",
"date": "17th December, 2006",
"timestamp": 1166427000,
"tags": [
"parallels",
"windows",
"apple",
"mac os x",
"bootcamp"
],
"author": "Sami Samhuri",
"url": "/posts/2006/12/coping-with-windows-xp-activiation-on-a-mac"
}
}

View file

@ -1,8 +1,16 @@
---
Title: Coping with Windows XP activiation on a Mac
Author: Sami Samhuri
Date: 17th December, 2006
Timestamp: 1166427000
Tags: parallels, windows, apple, mac os x, bootcamp
---
**Update:** This needs to be run at system startup, before you log in. I have XP Home and haven't been able to get it to run that way yet.
I can't test my method until I get XP Pro, if I get XP Pro at all. However chack left a <a href="/posts/2006/12/coping-with-windows-xp-activiation-on-a-mac.html#comment-1">comment</a> saying that he got it to work on XP Pro, so it seems we've got a solution here.
<hr>
---
### What is this about? ###
@ -14,7 +22,7 @@ I try and stick to Linux and OS X especially for any shell work, and on Windows
If anyone actually knows how to write batch files I'd like to hear any suggestions you might have.
<hr>
---
### Make sure things will work ###
@ -28,11 +36,11 @@ If you see a line of output like **"Description . . . . : Parallels Network Adap
If you're lazy then you can download <a href="http://sami.samhuri.net/files/parallels/test.bat">this test script</a> and run it in a command window. Run it in both Parallels and Boot Camp to make sure it gets them both right. The output will either be "Boot Camp" or "Parallels", and a line above that which you can just ignore.
<hr>
---
**NOTE:** If you're running Windows in Boot Camp right now then do Step #2 before Step #1.
<hr>
---
## Step #1 ##
@ -43,7 +51,7 @@ Run Windows in Parallels, activate it, then open a command window and run:
Download <a href="http://sami.samhuri.net/files/parallels/backup-parallels-wpa.bat">backup-parallels-wpa.bat</a>
<hr>
---
## Step #2 ##
@ -54,7 +62,7 @@ Run Windows using Boot Camp, activate it, then run:
Download <a href="http://sami.samhuri.net/files/parallels/backup-bootcamp-wpa.bat">backup-bootcamp-wpa.bat</a>
<hr>
---
## Step #3: Running the script at startup ##
@ -80,7 +88,7 @@ If you have XP Pro then you can get it to run using the Group Policy editor. Sav
Download <a href="http://sami.samhuri.net/files/parallels/activate.bat">activate.bat</a>
<hr>
---
### You're done! ###
@ -90,10 +98,11 @@ If MS doesn't get their act together with this activation bullshit then maybe th
This method worked for me and hopefully it will work for you as well. I'm interested to know if it does or doesn't so please leave a comment or e-mail me.
<hr>
---
#### Off-topic rant ####
I finally bought Windows XP this week and I'm starting to regret it because of all the hoops they make you jump through to use it. I only use it to fix sites in IE because it can't render a web page properl and I didn't want to buy it just for that. I thought that it would be good to finally get a legit copy since I was using a pirated version and was sick of working around validation bullshit for updates. Now I have to work around MS's activation bullshit and it's just as bad! Screw Microsoft for putting their customers through this sort of thing. Things like this and the annoying balloons near the system tray just fuel my contempt for Windows and reinforce my love of Linux and Mac OS X.
I finally bought Windows XP this week and I'm starting to regret it because of all the hoops they make you jump through to use it. I only use it to fix sites in IE because it can't render a web page properly and I didn't want to buy it just for that. I thought that it would be good to finally get a legit copy since I was using a pirated version and was sick of working around validation bullshit for updates. Now I have to work around MS's activation bullshit and it's just as bad! Screw Microsoft for putting their customers through this sort of thing. Things like this and the annoying balloons near the system tray just fuel my contempt for Windows and reinforce my love of Linux and Mac OS X.
I don't make money off any of my sites, which is why I didn't want to have to buy stupid Windows. I hate MS so much for making shitty IE the standard browser.

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1 +0,0 @@
<%- partial('../_year') %>

View file

@ -1,40 +0,0 @@
{
"full-screen-cover-flow": {
"title": "Full-screen Cover Flow",
"date": "6th March, 2007",
"timestamp": 1173217860,
"tags": [
"apple",
"coverflow",
"itunes"
],
"author": "Sami Samhuri",
"url": "/posts/2007/03/full-screen-cover-flow"
},
"digg-v4-reply-to-replies-greasemonkey-script": {
"title": "Digg v4: Reply to replies (Greasemonkey script)",
"date": "8th March, 2007",
"timestamp": 1173424740,
"tags": [
"coding",
"digg",
"firefox",
"userscript"
],
"author": "Sami Samhuri",
"url": "/posts/2007/03/digg-v4-reply-to-replies-greasemonkey-script"
},
"diggscuss-0_9": {
"title": "Diggscuss 0.9",
"date": "25th March, 2007",
"timestamp": 1174834980,
"tags": [
"coding",
"digg",
"firefox",
"userscript"
],
"author": "Sami Samhuri",
"url": "/posts/2007/03/diggscuss-0_9"
}
}

View file

@ -1,3 +1,11 @@
---
Title: Digg v4: Reply to replies (Greasemonkey script)
Author: Sami Samhuri
Date: 8th March, 2007
Timestamp: 1173424740
Tags: coding, digg, firefox, userscript
---
It's nearly identical to <a href="http://userscripts.org/scripts/show/4664">the previous one</a> but works with Digg v4 and should be slightly more efficient. I'm working on making it faster because I believe it is quite inefficient as it is. It was David Bendit's (the original author) first script though so kudos to him for starting this thing because I love it. I just hate a slow greasemonkey script on pages with hundreds of comments.
Please leave me some comments if you appreciate this, or have any feedback on the code.
@ -5,3 +13,4 @@ Please leave me some comments if you appreciate this, or have any feedback on th
Happy Digging!
<a href="http://www.digg.com/software/Reply_to_reply_Greasemonkey_script_Updated_for_Digg_v4">Digg this script!</a>

View file

@ -1,3 +1,11 @@
---
Title: Diggscuss 0.9
Author: Sami Samhuri
Date: 25th March, 2007
Timestamp: 1174834980
Tags: coding, digg, firefox, userscript
---
The biggest change is that it uses XPath for the dirty work, which makes it quite a bit more readable. It's 100 lines longer than the previous version, but it does twice as much.
Now both a [reply] and a [quote] link are added to each comment. Replying to parent comments now adds @username: to the comment field as well as the links added by the script.
@ -7,3 +15,4 @@ Regression: The link to the parent comment is no longer displayed. If you miss t
Any comments, criticism or feature requests are welcome just leave me a comment here or on userscripts.org.
Happy Digging!

View file

@ -1,5 +1,14 @@
---
Title: Full-screen Cover Flow
Author: Sami Samhuri
Date: 6th March, 2007
Timestamp: 1173217860
Tags: apple, coverflow, itunes
---
<a href="http://www.apple.com/itunes/jukebox/coverflow.html">Cover Flow</a> now comes in a full-screen flavour. It's pretty sweet, but unfortunately the remote controls iTunes exactly the same so you need a mouse to flick through the covers.
That made me wonder if Front Row used this full-screen Cover Flow view for albums now, but it doesn't. I hope Apple gets on this and adds it to Front Row and the Apple TV. I'm sure it's already on their list.
I would love to be able to flick through my albums with the remote right now, but I'm not going to install one of those 3rd-party remote config tools. Guess I have to wait for Apple to do it.

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,58 +0,0 @@
{
"a-triple-booting-schizophrenic-macbook": {
"title": "A triple-booting, schizophrenic MacBook",
"date": "4th April, 2007",
"timestamp": 1175754600,
"tags": [
"linux",
"mac os x",
"windows"
],
"author": "Sami Samhuri",
"url": "/posts/2007/04/a-triple-booting-schizophrenic-macbook"
},
"activerecord-base_find_or_create-and-find_or_initialize": {
"title": "ActiveRecord::Base.find_or_create and find_or_initialize",
"date": "11th April, 2007",
"timestamp": 1176287040,
"tags": [
"activerecord",
"coding",
"rails",
"ruby"
],
"author": "Sami Samhuri",
"url": "/posts/2007/04/activerecord-base_find_or_create-and-find_or_initialize"
},
"getting-to-know-vista": {
"title": "Getting to know Vista",
"date": "16th April, 2007",
"timestamp": 1176746940,
"tags": [
"windows"
],
"author": "Sami Samhuri",
"url": "/posts/2007/04/getting-to-know-vista"
},
"quickly-inserting-millions-of-rows-with-mysql-innodb": {
"title": "Quickly inserting millions of rows with MySQL/InnoDB",
"date": "26th April, 2007",
"timestamp": 1177596360,
"tags": [
"linux",
"mysql"
],
"author": "Sami Samhuri",
"url": "/posts/2007/04/quickly-inserting-millions-of-rows-with-mysql-innodb"
},
"funny-how-code-can-be-beautiful": {
"title": "Funny how code can be beautiful",
"date": "30th April, 2007",
"timestamp": 1177942020,
"tags": [
"haskell"
],
"author": "Sami Samhuri",
"url": "/posts/2007/04/funny-how-code-can-be-beautiful"
}
}

View file

@ -1,3 +1,11 @@
---
Title: A triple-booting, schizophrenic MacBook
Author: Sami Samhuri
Date: 4th April, 2007
Timestamp: 1175754600
Tags: linux, mac os x, windows
---
The steps are well documented so I wont get into detail here but if you have a backup and can wipe your disk all you do is:
* Install OS X to a single partition filling your disk (optionally use your existing OS X intall)
@ -25,3 +33,4 @@ Oh yeah, I also have a Parallels VM for Windows 3.11. It boots in about second t
* and/or going through a screwed up mode with a black & white scrambled screen for a seconds before getting to the houndstooth.
Like I said the X.org boys are doing amazing work. Hopefully soon after the current eye-candy craze is over theyll get to more important work that needs to be done.

View file

@ -1,3 +1,11 @@
---
Title: ActiveRecord::Base.find_or_create and find_or_initialize
Author: Sami Samhuri
Date: 11th April, 2007
Timestamp: 1176287040
Tags: activerecord, coding, rails, ruby
---
I've extended ActiveRecord with `find_or_create(params)` and `find_or_initialize(params)`. Those are actually just wrappers around `find_or_do(action, params)` which does the heavy lifting.
They work exactly as you'd expect them to work with possibly one gotcha. If you pass in an `id` attribute then it will just find that record directly. If it fails it will try and find the record using the other params as it would have done normally.
@ -98,3 +106,4 @@ Enough chat, here's the self-explanatory code:
<span class="r">end</span>
<span class="r">end</span>
<span class="r">end</span></code></pre>

View file

@ -1,3 +1,11 @@
---
Title: Funny how code can be beautiful
Author: Sami Samhuri
Date: 30th April, 2007
Timestamp: 1177942020
Tags: haskell
---
While reading a <a href="http://www.haskell.org/tutorial/index.html">Haskell tutorial</a> I came across the following code for defining the <a href="http://en.wikipedia.org/wiki/Fibonacci_number">Fibonacci numbers</a>:
fib = 1 : 1 : [ a + b | (a, b) <- zip fib (tail fib) ]
@ -16,3 +24,4 @@ Going deeper down the functional rabbit-hole youll find things like <a href="
* <a href="http://web.cecs.pdx.edu/~antoy/Courses/TPFLP/lectures/MONADS/Noel/research/monads.html">What the hell are Monads?</a>
* <a href="http://en.wikibooks.org/wiki/Programming:Haskell_monads">Monads on WikiBooks</a>
* <a href="http://www.engr.mun.ca/~theo/Misc/haskell_and_monads.htm">Monads for the Working Haskell Programmer</a>

View file

@ -1,3 +1,11 @@
---
Title: Getting to know Vista
Author: Sami Samhuri
Date: 16th April, 2007
Timestamp: 1176746940
Tags: windows
---
### It looks pretty good! ###
After figuring out how to minimise the translucency of the window decorations I think Aero looks ok. Window titles, on both windows and the taskbar, can be difficult to read at a glance which is really stupid if you ask me. But its better than Luna! They really lay the effects on thick but overall I find it pretty pleasant and it runs well on my MacBooks Intel 945 video chip.
@ -55,3 +63,4 @@ The bad:
### My conclusion ###
Perhaps the scores of talented developers at Microsoft *can* save them despite their obvious shortcomings in management. .NET seems like a decent platform, but well have to see how I like it once I actually use it. So far I dont hate Vista and considering the previous versions of Windows thats a pretty good review coming from me. Im still recommending Macs to my family and friends, but who knows what the future holds. I dont hate Vista and by the end of the summer I may even [gasp] like it, and/or .NET. I havent used an IDE since VB6 and MS has always had a decent IDE (albeit with a crummy text editor). Im expecting to enjoy it. If theres one thing MS knows its the value of good dev tools and <a href="http://www.youtube.com/watch?v=d_AP3SGMxxM">developers</a>.

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,11 @@
---
Title: Quickly inserting millions of rows with MySQL/InnoDB
Author: Sami Samhuri
Date: 26th April, 2007
Timestamp: 1177596360
Tags: linux, mysql
---
The absolute first thing you should do is check your MySQL configuration to make sure its sane for the system youre using. I kept getting a The table is too large error on my Gentoo box after inserting several million rows because the default config limits the InnoDB tablespace size to 128M. It was also tuned for a box with as little as 64M of RAM. Thats cool for a small VPS or your old Pentium in the corner collecting dust. For a modern server, workstation, or even notebook with gigs of RAM youll likely want to make some changes.
### Tweaking my.cnf ###
@ -43,3 +51,4 @@ Now you should be able to insert dozens and indeed hundreds of millions of rows
The solution now is to execute <code>SET AUTOCOMMIT=0</code> before inserting the data, and then issuing a <code>COMMIT</code> when youre done. With all that in place Im inserting 14,000,000 rows into both MyISAM and InnoDB tables in 30 minutes. MyISAM is still ~ 2 min faster, but as I said earlier this is adequate for now. Prior to all this it took several <b>hours</b> to insert 14,000,000 rows so I am happy.
Now you can enjoy the speed MyISAM is known for with your InnoDB tables. Consider the data integrity a bonus! ;-)

View file

@ -1,152 +0,0 @@
{
"typo-and-i-are-friends-again": {
"title": "Typo and I are friends again",
"date": "1st May, 2007",
"timestamp": 1178081497,
"tags": [
"typo"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/typo-and-i-are-friends-again"
},
"a-scheme-parser-in-haskell-part-1": {
"title": "A Scheme parser in Haskell: Part 1",
"date": "3rd May, 2007",
"timestamp": 1178178470,
"tags": [
"coding",
"haskell"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/a-scheme-parser-in-haskell-part-1"
},
"gotta-love-the-ferry-ride": {
"title": "Gotta Love the Ferry Ride",
"date": "5th May, 2007",
"timestamp": 1178364300,
"tags": [
"life",
"photo",
"bc",
"victoria"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/gotta-love-the-ferry-ride"
},
"a-new-way-to-look-at-networking": {
"title": "A New Way to Look at Networking",
"date": "5th May, 2007",
"timestamp": 1178406600,
"tags": [
"technology",
"networking"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/a-new-way-to-look-at-networking"
},
"dtrace-ruby-goodness-for-sun": {
"title": "dtrace + Ruby = Goodness for Sun",
"date": "9th May, 2007",
"timestamp": 1178725500,
"tags": [
"ruby",
"dtrace",
"sun"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/dtrace-ruby-goodness-for-sun"
},
"i-cant-wait-to-see-what-matt-stone-trey-parker-do-with-this": {
"title": "I Can't Wait to See What Trey Parker & Matt Stone Do With This",
"date": "9th May, 2007",
"timestamp": 1178746440,
"tags": [
"crazy"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/i-cant-wait-to-see-what-matt-stone-trey-parker-do-with-this"
},
"rails-plugins-link-dump": {
"title": "Rails Plugins (link dump)",
"date": "10th May, 2007",
"timestamp": 1178756520,
"tags": [
"rails"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/rails-plugins-link-dump"
},
"enumerable-pluck-and-string-to_proc-for-ruby": {
"title": "Enumurable#pluck and String#to_proc for Ruby",
"date": "10th May, 2007",
"timestamp": 1178838840,
"tags": [
"ruby",
"extensions"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/enumerable-pluck-and-string-to_proc-for-ruby",
"styles": [
"/css/typocode.css"
]
},
"dumping-objects-to-the-browser-in-rails": {
"title": "Dumping Objects to the Browser in Rails",
"date": "15th May, 2007",
"timestamp": 1179261480,
"tags": [
"rails"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/dumping-objects-to-the-browser-in-rails",
"styles": [
"/css/typocode.css"
]
},
"cheating-at-life-in-general": {
"title": "Cheating at Life in General",
"date": "16th May, 2007",
"timestamp": 1179308760,
"tags": [
"cheat",
"vim",
"emacs",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/cheating-at-life-in-general"
},
"iphone-humour": {
"title": "iPhone Humour",
"date": "18th May, 2007",
"timestamp": 1179513240,
"tags": [
"apple",
"funny",
"iphone"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/iphone-humour"
},
"inspirado": {
"title": "Inspirado",
"date": "22nd May, 2007",
"timestamp": 1179865380,
"tags": [
"rails",
"inspirado"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/inspirado"
},
"finnish-court-rules-css-ineffective-at-protecting-dvds": {
"title": "Finnish court rules CSS ineffective at protecting DVDs",
"date": "26th May, 2007",
"timestamp": 1180175040,
"tags": [
"drm"
],
"author": "Sami Samhuri",
"url": "/posts/2007/05/finnish-court-rules-css-ineffective-at-protecting-dvds"
}
}

View file

@ -1,3 +1,11 @@
---
Title: A New Way to Look at Networking
Author: Sami Samhuri
Date: 5th May, 2007
Timestamp: 1178406600
Tags: technology, networking
---
<a href="http://en.wikipedia.org/wiki/Van_Jacobson">Van Jacobson</a> gave a <a href="https://www.youtube.com/watch?v=gqGEMQveoqg">Google Tech Talk</a> on some of his ideas of how a modern, global network could work more effectively, and with more trust in the data which changes many hands on its journey to its final destination.
<p style="width:100%;text-align:center;">
@ -9,3 +17,4 @@ The man is very smart and his ideas are fascinating. He has the experience and k
He explains the problems that were faced while using the phone networks for data, and how they were solved by realizing that a new problem had risen and needed a new, different solution. He then goes to explain how the Internet has changed significantly from the time it started off in research centres, schools, and government offices into what it is today (lots of identical bytes being redundantly pushed to many consumers, where broadcast would be more appropriate and efficient).
If you have some time I really suggest watching this talk. I would love to research some of the things he spoke about if I ever got the chance. I'm sure they'll be on my mind anyway and inevitably I'll end up playing around with layering crap onto IPV6 and what not. Deep down I love coding in C and I think developing a protocol would be pretty fun. I'd learn a lot in any case.

View file

@ -1,3 +1,11 @@
---
Title: A Scheme parser in Haskell: Part 1
Author: Sami Samhuri
Date: 3rd May, 2007
Timestamp: 1178178470
Tags: coding, haskell
---
From <a href="http://halogen.note.amherst.edu/~jdtang/scheme_in_48/tutorial/firststeps.html">Write Yourself a Scheme in 48 hours</a>:
<blockquote>
@ -58,3 +66,4 @@ When I first read about Haskell I was overwhelmed by not knowing anything, and n
I'm currently working on ex. 3.3.4, which is parsing <a href="http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_sec_6.3.5">R5RS compliant numbers</a> <em>(e.g. #o12345670, #xff, #d987)</em>. I'll probably write something about that once I figure it out, but in the meantime if you have any hints I'm all ears.
*Update #1: I should do more proof-reading if I'm going to try and explain things. I made some changes in wording.*

View file

@ -1,3 +1,11 @@
---
Title: Cheating at Life in General
Author: Sami Samhuri
Date: 16th May, 2007
Timestamp: 1179308760
Tags: cheat, vim, emacs, textmate
---
*NB: My definition of life is slightly skewed by my being somewhat of a geek*
Luckily no one in the real world cares if you cheat. Most of life is open-book, but for the times when you just need to find something quick the answer, of course, is to [cheat](http://cheat.errtheblog.com/) profusely.
@ -8,3 +16,4 @@ I've only checked out a few of the cheat sheets but they are of high quality and
They certainly know the way to my heart! Ruby, Rails, TextMate*, vim*, zsh, screen. That'll do snake. That'll do.
*\* There are cheats for emacs, jEdit, and [e](http://www.e-texteditor.com/) too if TextMate and/or vim don't tickle your fancy.*

View file

@ -1,3 +1,12 @@
---
Title: dtrace + Ruby = Goodness for Sun
Author: Sami Samhuri
Date: 9th May, 2007
Timestamp: 1178725500
Tags: ruby, dtrace, sun
---
Suddenly I feel the urge to try out Solaris for i386 again. Last time I gave it a shot was when it was first released, and all I ever got out of the CD was a white screen. It's been 2-3 years since then and it should be well-tested. I'll try to install it into a VM first using the ISO and potentially save myself a CD. (I don't even think I have blank CDs lying around anymore, only DVDs.)
<a href="http://joyeur.com/2007/05/07/dtrace-for-ruby-is-available">The culprit.</a>

View file

@ -1,3 +1,11 @@
---
Title: Dumping Objects to the Browser in Rails
Author: Sami Samhuri
Date: 15th May, 2007
Timestamp: 1179261480
Tags: rails
---
Here's an easy way to solve a problem that may have nagged you as it did me. Simply using <code>foo.inspect</code> to dump out some object to the browser dumps one long string which is barely useful except for short strings and the like. The ideal output is already available using the <a href="http://www.ruby-doc.org/stdlib/libdoc/prettyprint/rdoc/index.html"><code>PrettyPrint</code></a> module so we just need to use it.
@ -23,3 +31,4 @@ Alternatively you could do as the extensions folks do and actually define <code>
<span class="ident">pps</span><span class="punct">.</span><span class="ident">string</span>
<span class="keyword">end</span>
<span class="keyword">end</span></code></pre></div>

View file

@ -1,3 +1,11 @@
---
Title: Enumurable#pluck and String#to_proc for Ruby
Author: Sami Samhuri
Date: 10th May, 2007
Timestamp: 1178838840
Tags: ruby, extensions
---
I wanted a method analogous to Prototype's <a href="http://prototypejs.org/api/enumerable/pluck">pluck</a> and <a href="http://prototypejs.org/api/enumerable/invoke">invoke</a> in Rails for building lists for <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000510">options_for_select</a>. Yes, I know about <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000511">options_from_collection_for_select</a>.
I wanted something more general that I can use anywhere - not just in Rails - so I wrote one. In a second I'll introduce <code>Enumerable#pluck</code>, but first we need some other methods to help implement it nicely.
@ -116,3 +124,4 @@ I wrote another version without using the various <code>#to_proc</code> methods
It's just icing on the cake considering Ruby's convenient block syntax, but there it is. Do with it what you will. You can change or extend any of these to support drilling down into hashes quite easily too.
*<strong>Update #1:</strong> Fixed a potential performance issue in <code>Enumerable#to_proc</code> by saving the results of <code>to_proc</code> in <code>@procs</code>.*

View file

@ -1 +1,10 @@
---
Title: Finnish court rules CSS ineffective at protecting DVDs
Author: Sami Samhuri
Date: 26th May, 2007
Timestamp: 1180175040
Tags: drm
---
It's nice to see people making sane calls on issues like this. <a href="http://arstechnica.com/index.ars">Ars</a> has a nice <a href="http://arstechnica.com/news.ars/post/20070525-finland-court-breaking-ineffective-copy-protection-is-permissible.html">summary</a> and there's also a <a href="http://www.turre.com/blog/?p=102">press release</a>.

View file

@ -1,3 +1,12 @@
---
Title: Gotta Love the Ferry Ride
Author: Sami Samhuri
Date: 5th May, 2007
Timestamp: 1178364300
Tags: life, photo, bc, victoria
---
I lived in <a href="http://en.wikipedia.org/wiki/Victoria%2C_British_Columbia">Victoria</a> for over a year before I ever rode the <a href="http://www.bcferries.com/">ferry</a> between <a href="http://en.wikipedia.org/wiki/Vancouver_Island">Vancouver Island</a> and <a href="http://en.wikipedia.org/wiki/Tsawwassen">Tsawwassen</a> (ignoring the time I was in BC with my family about 16 years ago, that is). I always just flew in and out of Victoria directly. The ferry is awesome and the view is incredible, navigating through all those little islands. Last time I rode the ferry I snapped this shot. It's possibly the best picture I've taken on that trip.
<img src="https://samhuri.net/images/sunset-lol.jpg" title="Sunset" alt="Sunset">

View file

@ -1,3 +1,11 @@
---
Title: I Can't Wait to See What Trey Parker & Matt Stone Do With This
Author: Sami Samhuri
Date: 9th May, 2007
Timestamp: 1178746440
Tags: crazy
---
I'd just like to say, <a href="http://news.com.com/8301-10784_3-9717828-7.html">bwa ha ha ha!</a>
Summary: Paris Hilton drove with a suspended license and is facing 45 days in jail. Now she's reaching out to lord knows who on her MySpace page to petition The Governator to pardon her. I might cry if I weren't pissing myself laughing.
@ -9,3 +17,4 @@ Paris Hilton is out of her mind, living in some fantasy world separate from Eart
I take this as a learning experience. For example, I learned that the US is no longer part of the world.
Flat out crazy, insane, not of sound mind. She is not any sort of hope, inspiration or role model for anyone.

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,11 @@
---
Title: Inspirado
Author: Sami Samhuri
Date: 22nd May, 2007
Timestamp: 1179865380
Tags: rails, inspirado
---
<a href="http://spyderous.livejournal.com/">spyderous</a> is a Gentoo dev and I read his posts via the <a href="http://planet.gentoo.org/">Gentoo planet</a> (and again on the <a href="http://planet.freedesktop.org/">freedesktop.org planet</a>).
He recently mentioned <a href="http://spyderous.livejournal.com/88463.html">an idea</a> to foster participation in Gentoo (or any other project) by aggregating personal project plans for people to browse. I thought it sounded cool so I started coding and came up with what I call <a href="http://http://rubyforge.org/projects/inspirado/">inspirado</a>.
@ -9,3 +17,4 @@ Note that everything you see there is purely for testing purposes and any change
There are several features on my TODO list but I'd love to hear about any you might have. Write to sami.samhuri@gmail.com if you have suggestions or anything else to say.
(Inspirado is, of course, a Rails app.)

View file

@ -1,3 +1,11 @@
---
Title: iPhone Humour
Author: Sami Samhuri
Date: 18th May, 2007
Timestamp: 1179513240
Tags: apple, funny, iphone
---
Love it or hate it - even though it's not even out yet - the iPhone has spawned at least 2 good jokes.
[The other iPhone lawsuit](http://www.geekculture.com/joyoftech/joyarchives/910.html) (GeekCulture.com)
@ -5,3 +13,4 @@ Love it or hate it - even though it's not even out yet - the iPhone has spawned
[A comment on slashdot](http://apple.slashdot.org/comments.pl?sid=235163&cid=19174829):
> "I'm waiting for the iPhone-shuffle, no display, just a button to call a random person on your contacts list."

View file

@ -1,3 +1,11 @@
---
Title: Rails Plugins (link dump)
Author: Sami Samhuri
Date: 10th May, 2007
Timestamp: 1178756520
Tags: rails
---
Some Rails plugins I find useful:
* <a href="http://matthewman.net/articles/2006/09/04/new-rails-feature-simply_helpful">Simply Helpful</a>
@ -6,3 +14,4 @@ Some Rails plugins I find useful:
* <a href="http://blog.inquirylabs.com/2006/09/28/textmate-footnotes-v16-released/">TextMate Footnotes</a> (just awesome)
* <a href="http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroids">acts\_as\_taggable\_on\_steroids</a>
* <a href="http://errtheblog.com/post/14">acts\_as\_textiled</a>

View file

@ -1,3 +1,11 @@
---
Title: Typo and I are friends again
Author: Sami Samhuri
Date: 1st May, 2007
Timestamp: 1178081497
Tags: typo
---
<p>I've been really frustrated with <a href="http://www.typosphere.org/">Typo</a> recently. For some reason changing my <a href="/posts/2007/04/funny-how-code-can-be-beautiful">last post</a> would cause MySQL to timeout and I'd have to kill the rogue ruby process manually before any other changes to the DB would work, instead of hanging for a minute or two then timing out. Luckily I was able to disable the post using the command line client, the bug only manifested itself when issuing an UPDATE with all the fields present. Presumably the body was tripping things up because most other fields are simple booleans, numbers, or very short strings.
Add to that the random HTTP 500 errors which were very noticeable while I was trying to fix that post and I was about to write my own blog or switch to WordPress.
@ -5,3 +13,4 @@ Add to that the random HTTP 500 errors which were very noticeable while I was tr
I don't love WP so I decided to just upgrade Typo instead. I was using Typo 2.6, and the current stable version is 4.1. They skipped version 3 to preclude any confusion that may have ensued between Typo v3 and the CMS <a href="http://typo3.com/">Typo3</a>. So it really isn't a big upgrade and it went perfectly. I checked out a new copy of the repo because I had some difficulty getting <code>svn switch --relocate</code> to work, configured the database settings and issued a <code>rake db:migrate</code>, copied my theme over and it all just worked. Bravo Typo team, that's how an upgrade should work.
No more random 500 errors, things seem faster (better caching perhaps), and that troublesome post is troublesome no more. I am happy with Typo again.

View file

@ -1 +1,10 @@
---
Title: 301 moved permanently
Author: Sami Samhuri
Date: 8th June, 2007
Timestamp: 1181350800
Tags: life
---
Last weekend I moved out of the apartment I lived in for the last 3 1/2 years. Moving was a cinch thanks to a friend's garage, conveniently placed smack between my old place and the new one. Google maps tells me that I moved just under 3.4 km, which is 2.1 mi for the metric impaired, so it wasn't much of a move at all! My roommate and I live in the basement of a house split into 3 apartments. Our upstairs neighbours are friendly and seem pretty cool, except one lady upstairs seems a bit strange. It's a great place though and in the winter the wood stove fireplace is going to be awesome.

View file

@ -1,179 +0,0 @@
{
"301-moved-permanently": {
"title": "301 moved permanently",
"date": "8th June, 2007",
"timestamp": 1181350800,
"tags": [
"life"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/301-moved-permanently"
},
"so-long-typo-and-thanks-for-all-the-timeouts": {
"title": "so long typo (and thanks for all the timeouts)",
"date": "8th June, 2007",
"timestamp": 1181350860,
"tags": [
"mephisto",
"typo"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/so-long-typo-and-thanks-for-all-the-timeouts"
},
"more-scheming-with-haskell": {
"title": "More Scheming with Haskell",
"date": "14th June, 2007",
"timestamp": 1181783340,
"tags": [
"coding",
"haskell",
"scheme"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/more-scheming-with-haskell"
},
"testspec-on-rails-declared-awesome-just-one-catch": {
"title": "test/spec on rails declared awesome, just one catch",
"date": "14th June, 2007",
"timestamp": 1181830860,
"tags": [
"bdd",
"rails",
"test/spec"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/testspec-on-rails-declared-awesome-just-one-catch"
},
"begging-the-question": {
"title": "Begging the question",
"date": "15th June, 2007",
"timestamp": 1181933340,
"tags": [
"english",
"life",
"pedantry"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/begging-the-question"
},
"back-on-gentoo-trying-new-things": {
"title": "Back on Gentoo, trying new things",
"date": "18th June, 2007",
"timestamp": 1182215100,
"tags": [
"emacs",
"gentoo",
"linux",
"vim"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/back-on-gentoo-trying-new-things"
},
"reinventing-the-wheel": {
"title": "Reinventing the wheel",
"date": "20th June, 2007",
"timestamp": 1182356820,
"tags": [
"emacs",
"snippets"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/reinventing-the-wheel"
},
"embrace-the-database": {
"title": "Embrace the database",
"date": "22nd June, 2007",
"timestamp": 1182507240,
"tags": [
"activerecord",
"rails",
"ruby"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/embrace-the-database"
},
"emacs-for-textmate-junkies": {
"title": "Emacs for TextMate junkies",
"date": "23rd June, 2007",
"timestamp": 1182565020,
"tags": [
"emacs",
"textmate"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/emacs-for-textmate-junkies"
},
"floating-point-in-elschemo": {
"title": "Floating point in ElSchemo",
"date": "24th June, 2007",
"timestamp": 1182711180,
"tags": [
"elschemo",
"haskell",
"scheme"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/floating-point-in-elschemo"
},
"propaganda-makes-me-sick": {
"title": "Propaganda makes me sick",
"date": "25th June, 2007",
"timestamp": 1182768900,
"tags": [
"propaganda"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/propaganda-makes-me-sick"
},
"rtfm": {
"title": "RTFM!",
"date": "26th June, 2007",
"timestamp": 1182806340,
"tags": [
"emacs",
"rtfm"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/rtfm"
},
"emacs-tagify-region-or-insert-tag": {
"title": "Emacs: tagify-region-or-insert-tag",
"date": "25th June, 2007",
"timestamp": 1182809580,
"tags": [
"emacs",
"tagify"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/emacs-tagify-region-or-insert-tag"
},
"recent-ruby-and-rails-regales": {
"title": "Recent Ruby and Rails Regales",
"date": "28th June, 2007",
"timestamp": 1183058580,
"tags": [
"rails",
"rails on rules",
"regular expressions",
"ruby",
"sake",
"secure associations",
"regex"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/recent-ruby-and-rails-regales"
},
"controlling-volume-via-the-keyboard-on-linux": {
"title": "Controlling volume via the keyboard on Linux",
"date": "30th June, 2007",
"timestamp": 1183245180,
"tags": [
"alsa",
"linux",
"ruby",
"volume"
],
"author": "Sami Samhuri",
"url": "/posts/2007/06/controlling-volume-via-the-keyboard-on-linux"
}
}

View file

@ -1,3 +1,11 @@
---
Title: Back on Gentoo, trying new things
Author: Sami Samhuri
Date: 18th June, 2007
Timestamp: 1182215100
Tags: emacs, gentoo, linux, vim
---
I started using my Gentoo box for development again and there are a few things about Linux I didn't realize I had been missing.
### Shell completion is awesome out of the box ###
@ -17,3 +25,4 @@ In the spirit of switching things up I'm going to forgo my usual routine of usin
I'm just waiting for a bunch of crap to compile because I use Gentoo and soon I'll have a Gtk-enabled Emacs to work in. If I can paste to and from Firefox then I'll be happy. I'll have to open this in vim or gedit to paste it into Firefox, funny!
I'm also going to try replacing a couple of desktop apps with web alternatives. I'm starting with 2 no-brainers: mail and feeds with Gmail and Google Reader. I never got into the Gmail craze and never really even used Gmail very much. After looking at the shortcuts I think I can get used to it. Seeing j/k for up/down is always nice. Thunderbird is ok but there isn't a mail client on Linux that I really like, except mutt. That played a part in my Gmail choice. I hadn't used G-Reader before either and it seems alright, but it'll be hard to beat NetNewsWire.

View file

@ -1,3 +1,11 @@
---
Title: Begging the question
Author: Sami Samhuri
Date: 15th June, 2007
Timestamp: 1181933340
Tags: english, life, pedantry
---
I'm currently reading <a href="http://mitpress.mit.edu/sicp/full-text/book/book.html">SICP</a> since it's highly recommended by many people, available for free, and interesting. The fact that I have a little <a href="/posts/2007/06/more-scheming-with-haskell">Scheme interpreter</a> to play with makes it much more fun since I can add missing functionality to it as I progress through the book, thereby learning more Haskell in the process. Yay!
Anyway I was very pleased to see the only correct usage of the phrase "begs the question" I have seen in a while. It's a pet peeve of mine, but I have submitted myself to the fact that the phrase is so oft used to mean "begs for the following question to be asked..." that it may as well be re-defined. In its correct usage the sentence seems to hang there if you try to apply the commonly mistaken meaning to it. That's all very hazy so here's the usage in SICP (emphasis my own):
@ -14,3 +22,4 @@ This describes a perfectly legitimate mathematical function. We could use it to
</blockquote>
Begging the question is to assume what one is trying to prove (or here, define) and use that as the basis for a conclusion. Read the <a href="http://en.wikipedia.org/wiki/Begging_the_question">Wikipedia article</a> for a better definition and some nice examples.

View file

@ -1,5 +1,14 @@
---
Title: Controlling volume via the keyboard on Linux
Author: Sami Samhuri
Date: 30th June, 2007
Timestamp: 1183245180
Tags: alsa, linux, ruby, volume
---
I was using Amarok's global keyboard shortcuts to control the volume of my music via the <a href="http://pfuca-store.stores.yahoo.net/haphackeylit1.html">keyboard</a> but I wanted to control the system volume as well. A quick script later and now I can control both, and thanks to libnotify I get some feedback on what happened. It's not as pretty as OS X's volume control or <a href="http://growl.info/">Growl</a> but it'll certainly do.
<a href="/f/volume.rb">&darr; Download volume.rb</a>
I save this as <strong>~/bin/volume</strong> and call it thusly: <code>volume +</code> and <code>volume -</code>. I bind Alt-+ and Alt—to those in my fluxbox config. If you don't have a preferred key binding program I recommend trying <a href="http://hocwp.free.fr/xbindkeys/xbindkeys.html">xbindkeys</a>. apt-get install, emerge, paludis -i, or rpm -i as needed.

View file

@ -1,3 +1,11 @@
---
Title: Emacs for TextMate junkies
Author: Sami Samhuri
Date: 23rd June, 2007
Timestamp: 1182565020
Tags: emacs, textmate
---
*Update #1: What I first posted will take out your < key by mistake (it's available via `C-q <`), it has since been revised to Do The Right Thing.*
*Update #2: Thanks to an anonymouse[sic] commenter this code is a little cleaner.*
@ -126,3 +134,4 @@ attributes are specified then they are only included in the opening tag."
&darr; <a href="/f/wrap-region.el" alt="wrap-region.el">Download wrap-region.el</a>
That more or less sums up why I like Emacs so much. I wanted that functionality so I implemented it (barely! It was basically done for me), debugged it by immediately evaluating sexps and then trying it out, and then once it worked I reloaded my config and used the wanted feature. That's just awesome, and shows one strength of open source.

View file

@ -1,5 +1,14 @@
---
Title: Emacs: tagify-region-or-insert-tag
Author: Sami Samhuri
Date: 25th June, 2007
Timestamp: 1182809580
Tags: emacs, tagify
---
After <a href="/posts/2007/06/rtfm">axing</a> half of <a href="/posts/2007/06/emacs-for-textmate-junkies">wrap-region.el</a> I renamed it to <a href="/f/tagify.el">tagify.el</a> and improved it ever so slightly. It's leaner, and does more!
<code>tagify-region-or-insert-tag</code> does the same thing as <code>wrap-region-with-tag</code> except if there is no region it now inserts the opening and closing tags and sets point in between them. I have this bound to <code>C-z t</code>, as I use <code>C-z</code> as my personal command prefix.
<code>&lt;</code> is bound to <code>tagify-region-or-insert-self</code> which really doesn't warrant an explanation.

View file

@ -1,3 +1,11 @@
---
Title: Embrace the database
Author: Sami Samhuri
Date: 22nd June, 2007
Timestamp: 1182507240
Tags: activerecord, rails, ruby
---
If you drink the Rails koolaid you may have read the notorious <a href="http://www.loudthinking.com/arc/2005_09.html">single layer of cleverness</a> post by <a href="http://www.loudthinking.com/">DHH</a>. <em>[5th post on the archive page]</em> In a nutshell he states that it's better to have a single point of cleverness when it comes to business logic. The reasons for this include staying agile, staying in Ruby all the time, and being able to switch the back-end DB at any time. Put the logic in ActiveRecord and use the DB as a dumb data store, that is the Rails way. It's simple. It works. You don't need to be a DBA to be a Rails developer.
<a href="http://www.stephenbartholomew.co.uk/">Stephen</a> created a Rails plugin called <a href="http://www.stephenbartholomew.co.uk/2007/6/22/dependent-raise">dependent-raise</a> which imitates a foreign key constraint inside of Rails. I want to try this out because I believe that data integrity is fairly important, but it's really starting to make me think about this single point of cleverness idea.
@ -25,3 +33,4 @@ Using the DB from within Ruby is a solved problem. I don't see why this couldn'
Many relationships could be derived from constraints as people have pointed out before. There are benefits to using the features of a decent RDBMS, and in some cases I think that we might be losing by not making use of them. I am not saying we should move everything to the DB, I am saying that we should exploit the implemented and debugged capabilities of our RDBMSs the best we can while practicing the agile methods we know and love, all from within Ruby.
[1] I make liberal use of <a href="http://agilewebdevelopment.com/plugins/annotate_models">annotate_models</a> as it is.

View file

@ -1,3 +1,11 @@
---
Title: Floating point in ElSchemo
Author: Sami Samhuri
Date: 24th June, 2007
Timestamp: 1182711180
Tags: elschemo, haskell, scheme
---
### Parsing floating point numbers ###
The first task is extending the <code>LispVal</code> type to grok floats.
@ -421,3 +429,4 @@ That was a bit of work but now ElSchemo supports floating point numbers, and if
Next time I'll go over some of the special forms I have added, including short-circuiting <code>and</code> and <code>or</code> forms and the full repetoire of <code>let</code>, <code>let*</code>, and <code>letrec</code>. Stay tuned!

View file

@ -1 +0,0 @@
<%- partial('../../_month') %>

View file

@ -1,3 +1,11 @@
---
Title: More Scheming with Haskell
Author: Sami Samhuri
Date: 14th June, 2007
Timestamp: 1181783340
Tags: coding, haskell, scheme
---
It's been a little while since I wrote about Haskell and the <a href="/posts/2007/05/a-scheme-parser-in-haskell-part-1">Scheme interpreter</a> I've been using to learn and play with both Haskell and Scheme. I finished the tutorial and got myself a working Scheme interpreter and indeed it has been fun to use it for trying out little things now and then. (Normally I would use Emacs or Dr. Scheme for that sort of thing.) There certainly are <a href="http://www.lshift.net/blog/2007/06/11/folds-and-continuation-passing-style">interesting things</a> to try floating around da intranet. And also things to read and learn from, such as <a href="http://cubiclemuses.com/cm/blog/tags/Misp">misp</a> (via <a href="http://moonbase.rydia.net/mental/blog/programming/misp-is-a-lisp">Moonbase</a>).
*I'm going to describe two new features of my Scheme in this post. The second one is more interesting and was more fun to implement (cond).*
@ -85,3 +93,4 @@ eval env (List (Atom "cond" : List (pred : conseq) : rest)) =
* __Line 9:__ Anything other than <code>#f</code> is considered true and causes <code>conseq</code> to be evaluated and returned. Like <code>else</code>, <code>conseq</code> can be a sequence of expressions.
So far my Scheme weighs in at 621 lines, 200 more than the tutorial's final code listing. Hopefully I'll keep adding things on my TODO list and it will grow a little bit more. Now that I have <code>cond</code> it will be more fun to expand my stdlib.scm as well.

View file

@ -1,30 +1,39 @@
---
Title: Propaganda makes me sick
Author: Sami Samhuri
Date: 25th June, 2007
Timestamp: 1182768900
Tags: propaganda
---
Things <a href="http://arstechnica.com/news.ars/post/20070625-spying-on-campus-fbi-warns-mit-harvard.html">like this</a> in modern times are surprising. Can't people spot this phony crap for what it is?
<code>First they put away the dealers, keep our kids safe and off the streets<br>
Then they put away the prostitutes, keep married men cloistered at home<br>
Then they shooed away the bums, and they beat and bashed the queers<br>
Turned away asylum-seekers, fed us suspicions and fears<br>
We didn't raise our voice, we didn't make a fuss<br>
It´s funny there was no one left to notice, when they came for us<br>
<br>
<strong>Looks like witches are in season, you better fly your flag and be aware<br>
Of anyone who might fit the description, diversity is now our biggest fear<br>
Now with our conversations tapped, and our differences exposed<br>
<code>First they put away the dealers, keep our kids safe and off the streets<br/>
Then they put away the prostitutes, keep married men cloistered at home<br/>
Then they shooed away the bums, and they beat and bashed the queers<br/>
Turned away asylum-seekers, fed us suspicions and fears<br/>
We didn't raise our voice, we didn't make a fuss<br/>
It´s funny there was no one left to notice, when they came for us<br/>
<br/>
<strong>Looks like witches are in season, you better fly your flag and be aware<br/>
Of anyone who might fit the description, diversity is now our biggest fear<br/>
Now with our conversations tapped, and our differences exposed<br/>
How ya supposed to love your neighbour, with our minds and curtains
closed?<br>
We used to worry 'bout big brother<br>
Now we got a big father and an even bigger mother</strong><br>
<br>
And still you believe, this aristocracy gives a fuck about you<br>
They put the mock in democracy, and you swallowed every hook<br>
The sad truth is, you'd rather follow the school into the net<br>
closed?<br/>
We used to worry 'bout big brother<br/>
Now we got a big father and an even bigger mother</strong><br/>
<br/>
And still you believe, this aristocracy gives a fuck about you<br/>
They put the mock in democracy, and you swallowed every hook<br/>
The sad truth is, you'd rather follow the school into the net<br/>
'Cause swimming alone at sea, is not the kind of freedom that you
actually want<br>
So go back to your crib, and suck on a tit<br>
Bask in the warmth of your diaper, you're sitting in shit<br>
And piss, while sucking on a giant pacifier<br>
A country of adult infants, a legion of mental midgets<br>
A country of adult infants, a country of adult infants<br>
All regaining their unconsciousness<br>
actually want<br/>
So go back to your crib, and suck on a tit<br/>
Bask in the warmth of your diaper, you're sitting in shit<br/>
And piss, while sucking on a giant pacifier<br/>
A country of adult infants, a legion of mental midgets<br/>
A country of adult infants, a country of adult infants<br/>
All regaining their unconsciousness<br/>
</code>
—from the song <a href="http://www.nofxwiki.net/w/Lyrics:Regaining_Unconsciousness_%28song%29">Regaining Unconsciousness</a>, by <a href="http://www.nofx.org/">NOFX</a>

View file

@ -1,3 +1,11 @@
---
Title: Recent Ruby and Rails Regales
Author: Sami Samhuri
Date: 28th June, 2007
Timestamp: 1183058580
Tags: rails, rails on rules, regular expressions, ruby, sake, secure associations, regex
---
Some cool Ruby and [the former on] Rails things are springing up and I haven't written much about the two Rs lately, though I work with them daily.
### Rails on Rules ###
@ -17,3 +25,4 @@ I've noticed a trend among some <a href="http://www.railsenvy.com/2007/6/11/ruby
<a href="http://t-a-w.blogspot.com/">taw</a> taught me a <a href="http://t-a-w.blogspot.com/2007/06/regular-expressions-and-strings-with.html">new technique for simplifying regular expressions</a> by transforming the text in a reversible manner. In one example he replaced literal strings in SQL - which are easily parsed via a regex - with what he calls embedded objects. They're just tokens to identify the temporarily removed strings, but the important thing is that they don't interfere with the regexes that operate on the other parts of the SQL, which would have been very difficult to get right with the strings inside it. If I made it sound complicated just read the post, he explains it well.
If you believe anything <a href="http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html">Steve Yegge</a> says then that last regex trick may come in handy for Q&#38;D parsing in any language, be it Ruby, NBL, or whataver.

View file

@ -1,3 +1,11 @@
---
Title: Reinventing the wheel
Author: Sami Samhuri
Date: 20th June, 2007
Timestamp: 1182356820
Tags: emacs, snippets
---
Emacs is very impressive. I only felt lost and unproductive for minutes and now it seems natural to use and get around in. I've got <a href="/posts/2007/06/more-scheming-with-haskell">ElSchemo</a> set as the default scheme, and running inferior processes interactively is an absolute dream. My scheme doesn't have readline support (which bothers me to the point where I've thought about adding it just so I can use the thing) but when running it under Emacs there's absoutely no need for anything like that since I have the power of my editor when interacting with any program.
There has been a considerable amount of work done to aide in Rails development which makes Emacs especially comfortable for me. I now know why people have Emacs windows maximized on their screens. Because of its age Emacs is a handy window manager that basically eliminates the need for anything like <a href="http://en.wikipedia.org/wiki/GNU_Screen">GNU screen</a> or a window manager such as <a href="http://www.nongnu.org/ratpoison/">Rat poison</a> (which is great if you like screen), just maximize that Emacs "frame" or open one for each display and get to it. If you need a shell you just split the window and run your shell, when you're done you can easily switch back to your editing and your shell will wait in the background until you need it again. With rails-mode on I can run script/console (or switch back to it) with <code>C-c C-c s c</code>. My zsh alias for script/console is <code>sc</code> and I have other similarly succint ones for other stuff, so I took right to the shortcuts for all the handy things that I no longer have to switch applications to do:
@ -10,3 +18,4 @@ There has been a considerable amount of work done to aide in Rails development w
The Rails integration is simply stunning and I could go on all day about the mature indentation support, the Speedbar and what not, but I won't. I'm fairly sure that Emacs has taken the place of TextMate as my weapon of choice now, on all platforms. And after only 2 days!
Anyway, the point of all this was to mention the one thing that's missing: support for <a href="/posts/2006/02/intelligent-migration-snippets-0_1-for-textmate">intelligent snippets</a> which insert text at more than one point in the document (well, they appear to do so). I don't have any E-Lisp-fu to break out and solve the deficiency but if it ever bugs me enough I might try implementing it for Emacs one day. If they were useful to me outside of writing migrations I might have more incentive to do so, but I guess they aren't useful in normal editing situations (maybe I just haven't recognised the need).

Some files were not shown because too many files have changed in this diff Show more