ruut and me are setting up a new server. This blog is one of the first sites being migrated.
If you can read this, it has worked!
ruut and me are setting up a new server. This blog is one of the first sites being migrated.
If you can read this, it has worked!
I’ve seen myself as a visual person for a long time, but I think I never realized how much this defines me, until now.
It’s almost impossible for me to memorize things just by hearing them. Names, numbers, dates, directions – my mind disposes of them in minutes. But when I read something, when I look at a picture, when I see a map, then I’ll remember it because I understand it. (I’m not talking about photographic memory here; I don’t have that. I’m just much better digesting visually than orally.)
When everybody in my age group started using cell phones, I didn’t have one. I wasn’t interested in talking remotely to other people. Instead, I jumped on the train of modern smartphones at the first station: The week after the original iPhone was available in Germany, I got one. It’s become an extension of my world. Looking at that tiny screen has become an addiction. But I avoid using it as a phone; it’s muted.
I literally cannot understand when somebody is telling me how late it is, or gives me directions to an unknown place. But I can grasp diagrams, tables, structured texts, interfaces, signs, and images instantly. I’m not deaf; I love music, singing, the sounds of nature. But my ears seem to be connected only to my emotions, and not to my brain.
On the other hand, the connection between my eyes and my brain seems to be a fiber optics cable. I live inside my eyes. My job (which is also my hobby) is looking at code, interfaces, diagrams, articles, specifications, emails, search results, icons, wireframes, server logs. Being able to live in a digitized world is a heavenly gift for me. My eyes hunger for text since I learned to read; now I know I can dive into anything I want, whenever I want. I just have to put it on a screen.
When I watch a good movie for the first time, I often don’t get the story. I can’t remember the names of the characters. But I see colors, effects, materials, lights, shadows, signs in the background, textures, dust, skin, hair, tiny little details. I watch it with my eyes and my mind fully focussed on the screen, while the music and voices can stream directly to my heart. I can cry on a well-done emotional scene, but I never look away.
People get frustrated with me for not listening to them, not understanding them, or for having to tell me everything twice. I get frustrated at people for not seeing icons on their screen, not paying attention to spelling or typography, using gadgets that I find ugly, or using buggy syntax highlighting.
I spent years working on a syntax highlighter library. I’m not a designer, but I feel that getting the details of the presentation of source code right is essential. I’m still obsessed with it; I can dream in highlighted code (mostly Ruby) when I close my eyes.
It’s not about aesthetics. I don’t have good visual taste. It is about information. Truth. Seamlessness. Clarity. To me, the only way to make something clear is to visualize it, with text and code and pictures. This preference (or disability) has pushed me into a specific direction since school. It defines what I’m good at and what gives me trouble. It summarizes my strengths and weaknesses as a programmer.
I feel a bit like a penguin: Hearing is waddling on ice. Seeing is swimming in the ocean.
TL;DR If you want to truncate a SQLite table, use DELETE FROM table; VACUUM
.
While cleaning up my blog (backend, frontend and everything) for the new year, I noticed that the SQLite database I use to store its data had become quite huge — 28 MB huge to be exact. Since I could not dream of having written this much text, I had no idea what happened.
Since I despise writing SQL to inspect tables, I first searched for a simple, free graphical SQLite client (for OS X). No success in the Mac App Store. What I found then was a Firefox plugin called “SQLite Manager”. It’s horrible (Windows 3.1 style icons and poor interface design), but it did its job: After it hung up when I tried to look at the “sessions” table (connecting over SFTP wasn’t such a good idea), the culprit was found: ActiveRecord was storing sessions for each visitor without ever cleaning them up.
*sigh*
So, back to SQL:
I totally missed this new Rouge gem which came out in September. It’s a Pygments port in pure Ruby!
Jay Adkisson did a great job in my opinion, and the project is destined to become popular — I guess, in the long run, even more popular than CodeRay. Like Pygments, it has a long list of supported languages, a plethora of compatible stylesheets (even with 256 color terminal output), and the ability to guess the language of a piece of code.
If you’re using CodeRay or one of the Pygments wrappers, you should definitely check out this project.
Rouge also inherits from Pygments the DSL-based lexer definitions, which means it’s much cleaner to maintain, and also slower to execute.
Here’s a very quick benchmark that helped me to get a first impression:
In this article, I merely speculate based on publicly available information. Because it’s fun to speculate :)
Well, CodeRay has had support for Themes for a long time. Seems I need to push that more.
I think these pictures say a lot about why OS X Lion costs $29 and Windows 7 costs $119+:
Since the unit cost of software is minimal1, software companies effectively make up the unit prices.
Apple’s price for Lion is symbolic. Surely the development cost of their OS was less than what Microsoft had to invest in Windows 7; but with $29 per sold copy, and with much less Mac computers than PCs out there, it’s clear that Apple will never match the sales numbers of Windows XP or Windows 7.
Phil Schiller said that there are some 54 million active Mac users out there. Let’s be optimistic and say 30% of them buy Lion in the next quarter. This makes about $470M in revenue, which is less than 2% of their Q3 2011 revenue.
In addition, Apple pre-installs Lion on every new Mac from now on, even giving free upgrades to people who bought a new Mac just before the upgrade came out. But since they update their OS more frequently, more people actually buy the upgrade for their old Macs.
Apple could easily give Lion away for free without making a dent in their revenue graph. But at the same time, they won’t make profit in software department with a price like this; the design, development and testing of such a big software product easily costs billions.
In contrast, Windows 7 made up 27% of Microsoft’s revenue ($4.4B of $16.4B total) according to their last reported quarter. If they price it at, say, 50% of the current price, their overall revenue could go down 10% or more!
Of course, Microsoft doesn’t really sell Windows copies to users directly. They sell OEM licenses and company-wide business licenses. Which means, almost nobody buys a new version of Windows in any store, online or retail. And of course this means that the naming and pricing of all those different Windows versions does only reflect the funny ideas of Microsoft’s marketing department.
Micosoft is very dependent on Windows (and even more so, Office) sales and profits, while Apple is depending on hardware sales. Still, the shop prices of Windows 7 are almost as symbolic as Lion’s $29 price tag.
So, if you ever wondered about the strange difference in pricing of recent version of OS X and Windows: The prices say nothing about development costs, the product’s quality, its value for the customer, or the value it has in the eyes of the company which sells it.
They just make it up.
1 Or almost Zero in Lion’s case. Upload transfer costs might not even add up to $0.01.
You may have noticed that my blog has been down for the last week. We have moved to another server, and I am updating to the latest Camping version, which sadly broke some of the old API.
Expect quirks and 500s for the next days until I’m finished with the port.
Oh, and by the way: I’m in New Zealand! Follow @murphy_nz to find out a lot more about that (with photos!).
Update: It’s fixed, and runs on Passenger now!
When you include this in your ~/.bash_login
file:
# Show current git branch or SVN subfolder in prompt.
GREEN="\[\033[0;32m\]"
LIGHT_GREEN="\[\033[1;32m\]"
GRAY="\[\033[1;30m\]"
LIGHT_BLUE="\[\033[1;34m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_OFF="\[\e[0m\]"
function prompt_func() {
branch_pattern="\* ([^$IFS]*)"
PS1="$LIGHT_GRAY`date +%H:%M:%S`$COLOR_OFF $LIGHT_GREEN\w$COLOR_OFF"
if [[ -d "./.git" && "$(git branch --no-color 2> /dev/null)" =~ $branch_pattern ]]; then
branch="${BASH_REMATCH[1]}"
PS1+=":$LIGHT_BLUE$branch$COLOR_OFF"
elif [[ -d "./.svn" ]]; then
path_pattern="URL: ([^$IFS]*).*Repository Root: ([^$IFS]*).*Revision: ([0-9]*)"
if [[ "$(svn info 2> /dev/null)" =~ ${path_pattern} ]]; then
branch=`/usr/bin/ruby -e 'print ARGV[0][ARGV[1].size + 1..-1] || "/"' ${BASH_REMATCH[1]} ${BASH_REMATCH[2]}`
revision="${BASH_REMATCH[3]}"
PS1+=":$LIGHT_BLUE$branch$GRAY@$revision$COLOR_OFF"
fi
fi
PS1+=" "
}
PROMPT_COMMAND=prompt_func
…it should show you, depending on what kind of folder you’re in, the current git
or svn
branch:
~ cd ruby/coderay
~/ruby/coderay:trunk@644 cd ../coderay-0.9
~/ruby/coderay-0.9:branches/0.9@641 cd ~/studies/ikiwiki/
~/studies/ikiwiki:master
It is quite fast, but needs Ruby (any idea for a bash-only version?)
Update: Fixed a few things.
Update 2: Cleanup, SVN revison number.
Yes. I’m sorry. I’m busy with:
Because of this, I could not find the time yet to write about
You can follow me on @murphy_karasu (manchmal schreibe ich dort auch Deutsch), and/or you can have a completely unrelated “motivational” poster:
I’m sure I’m not the first one to find this, but here’s a working example for a i18n version of Integer#ordinalize.
First, you need to define <locale>.rb
files in you lib/locales
folder for each language. Here are examples for English, German, and French:
# lib/locales/en.rb { :en => { :ordinal => proc { |number| number.ordinalize } } }
This is using the built-in ordinalize
extension, which does the English job.
# lib/locales/de.rb { :de => { :ordinal => proc { |number| "#{number}." } } }
German ordinalization is really easy.
# lib/locales/fr.rb { :fr => { :ordinal => proc { |number| "#{number}#{number == 1 ? 'er/re' : 'e'}" } } }
You’ll have to find out how to apply the correct genus all by yourself if you don’t like the self-service-slash :P
More languages can be added, but it gets really complicated for Spanish or Finnish.
After you restart your server (also in development mode!), I18n.t('ordinal') will return a Proc
object. You can use it in your view like this:
<%= I18n.t('ordinal')[count] + ' ' + I18n.t("article") %>
Notice the use of []
for the object returned by the I18n.t
call: It’s calling the Proc
, passing the number
argument, which is then ordinalized according to the current locale. You could also use .call(count)
, or even .(count)
in Ruby 1.9, but I prefer the brackets.
Edit: Ich glaube, das war eine Zitronenpresse. Mist.
Apple didn’t manage to provide real photos of the iPhone 4’s new display’s quality on their website. 960×640 pixels sure sounds a lot (almost iPad resolution), but I wasn’t convinced, because those digital demos look nothing like a real display.
Thankfully, Engadget has now provided this great comparison photo:
That’s the icon for the Maps app, of course, on iPhone 3GS and 4. Its actual size on the display is 9mm (0.354in), or the width of a typical paperclip, or the height of those arrow keys on a modern Apple keyboard, or the distance between strings on a 6-string guitar, or half the width of my middle finger. It’s really small.
If you have an iPhone or iPod touch (any generation), look at that icon. Can you see the white line between the red and blue parts of the road sign? That’s almost 2 pixels high on an iPhone 4. See the number “280”? The lines are a little more than 2 pixels thick there. See the pin’s head? That’s about 20 pixels in diameter now. The vertical road is about 15 pixels wide.
Apple claims:
It works like this: As you browse the web, Safari detects if you’re on a web page with an article.
Something like Reader might actually turn Safari into my main browser – depending on how well it works.
So, how does this magical “detection”-thingy work? It works on sites like heise, SPIEGEL, or The Wall Street Journal. But it doesn’t work on TUAW or on my blog. Does Safari 5 have a list of well-known mainstream media news sites? Is this what Steve Jobs meant when he said:
I don’t want to see us descend into a nation of bloggers.
I mostly read blog articles nowadays, and Safari Reader is pretty useless to me for now.
Update: Funny thing, it works on Daring Fireball. Maybe this is because John Gruber is considered mainstream now ;)
Update: ars technica claims (Safari Reader enabled):
Safari 5 contains heuristics that will detect if a webpage contains an article and it will present a “Reader button” in the Smart Address field.
Well, how nice for your site. Which heuristics? I couldn’t find any hints in the Safari Dev Center.
Update: It gets funnier :-) With the last update, this article just became a Safari Reader heuristic winner. So it’s about content length?
Update: It looks like it. Yay :-D
Commercial advertising: I hate ads. I hate them. Lipstick commercials, infomercials, placards, Greenpeace booths, Spam. I hate them from the bottom of my heart. They are distracting, stupid, ugly brainwashers, lies and propaganda which reduce my ability to consume information or do work through any media. They are the reason I stopped listening to FM radio. They are turning my mailbox (the real one and the virtual ones) into a wastepaper bin. They make me angry. Like cigarette smoke.
The main reason I switched from TV, magazines, and radio to the computer is, apart from interactivity, that you can actually live pretty ad-free in there. I rarely see ads on my MacBook (mostly MSNBC ones that I simply mute). I installed anti-ad plugins on every browser I use (except one, see below). I uninstall every application that tries to ad me.
(defn <3 [love & loves] (loop [l (str "I love " love) loves loves] (let [[love & loves] loves] (if (nil? love) (str l ".") (if (empty? loves) (str l " and " love ".") (recur (str l ", " love) loves)))))) (<3 "cookies" "cake" "chocolat") ;; => "I love cookies, cake and chocolat."
murphy:
I = Object.new def I.<(three, *args) puts "I love " + args[0..-2].join(', ') + ' and ' + args.last + '.' end I.<3, 'test', 'foo' #~> I love test and foo.
I like the Clojure one better, even without syntax highlighting :)
Update: Licenser complained, so here’s an improved version:
Here’s the ultimate reason why Ruby is better than Python:
Jus ried o clean my keyboard, and now he key is suck. I can no longer run my Pyhon programs, bu I can sill run Ruby scrips. A definiive improvemen.
A gem from Fredrik Lundh, 2003.
See more of her art on her website (sadly, it uses FRAMEs).
Well, Gizmodo spoiled a lot of secrets about the next iPhone in the last week. But I think this won’t hurt Apple, or Gizmodo, or anyone. It’s already internet history.
An interesting side of this is that this might be the first time that we actually see new Apple hardware from inside before we see how it looks to the average user. Apple always focuses on user experience, and never flaunts with tech specs without connecting them to real-world benefits. This is especially true about the iPhone; they don’t even mention the CPU’s speed or the size of the RAM anywhere on their side. Apple doesn’t provide specs for the iPad’s A4 – they just state that it’s fast and efficient. This time, Gizmodo has stripped down their next child before we saw her face. It’s tech porn. I prefer Apple’s reality distortion field.
As Howard Fineman said on Tuesday in Countdown about Barack Obama’s Nuclear Security Summit:
And I think [Obama] also wants to show that in the 21st century, security is about links. It‘s a different paradigm from the Cold War. It‘s almost like the Internet in which you prosper, you profit by the links you make to the other people on the net. He‘s trying to do that in terms of diplomacy globally.
More and more world leaders really get globalization. We share enemies and threads. We are sitting in the same boat. We need to paddle together, and the US wants to be the cox.
I didn’t know where the strange name “Wizengamot” in the Harry Potter books came from (the Supreme Court of the Wizarding world). Now I found out about the Witenagemot: It was a ring of advisors to the Anglo-Saxon kings of the 7th – 11th century.
Interestingly, J.R.R. Tolkien’s term Entmood is also related to the terminology. Thing is another, earlier type of such political institutions and meetings.
I don’t know yet.
According to the first Geekbench results, the Intel i7-620M at 2.66/3.33 GHz in latest flagship MBPs is about 30% faster than the previous Core 2 Duo T9900 at 3.06 GHz. Compared to my early 2008 MacBook (which has a T8300), that’s a 70% speedup. That’s huge, but it’s just a synthetic benchmark. Still, it’s clear that the new MacBooks are speedy, and the new CPUs are not the only reason.
Cupertino finally dumped the crappy NVIDIA chipset in favor of Intel’s integrated graphics. It was a bad deal for MacBook Pros all along: While the MacBook really benefits from a more powerful GPU, especially when some applications use OpenCL, the Pros already have a good graphics chip built-in! All Apple achieved in the late 2008 update was to nullify the speedup that updating to DDR3 would have meant.
Today, Apple corrected their mistake. The i5 and i7 chips seem to be the fastest that Intel makes for the 35W class. I’ll be visiting a Mac shop in the next days to try out some my-world benchmarks. Hopefully, I can get what I have been searching for over a year now: More Speed™.
Update: Geekbench has confirmed my results.
A very minor point in the list of new APIs was this one:
Interesting. They didn’t have this feature before? Apple seems to realize that every weapon they give to developers, even if it’s just an optimized API for something you could also implement on your own, is another selling point against Android. Because Google can’t optimize that deeply: Android is polymorph, and hardware-level fine tuning is a lot of work. Or money, that is. Windows 7 and the other systems will have to fight the same uphill battle.
Having really fast text pattern matching on a mobile device is a feature in itself. Keep in mind that even the iPad is still an order of magnitude behind on raw processing power compared to current laptops. Everything can become a bottleneck in the iPhone OS world.
By the way: CodeRay for iPhone OS, anyone? :D Regular expressions are the core of every good syntax highlighter.
A short story by James Thurber, read by Countdown anchor Keith Olberman.
I’ll be hiding in the middle of nowhere (Rädel, Brandenburg, Germany) for the next 8 days with my Boy Scout Patrol “Berglöwe” (Mountain Lion) on an Easter camp. No computers, no internet, no electricity. Just cooking over the campfire, sleeping in black tents and singing to guitars.
Happy Easter holidays to you all!
(See also my initial thoughts.)
I wondered why the latest Apple devices, including MacBooks (especially the Air), iPhones, and now the iPad all have rounded backs/bottoms. Well, the answer is very simple: Remember the last time you had problems picking up change from a counter? It would be nearly impossible to pick up a 700 gram (1.5 pounds) metal slate lying flat on a table without being able to put a fingertip under it:
It’s so simple that you don’t notice. Like some kind of industrial design typography. Sure, it doesn’t look nice from the back – but who cares? The only important part is the front.
My homepage was about:blank for over a year now. I was sick of slow-loading start pages, and I just don’t have any site I really frequent so much that I want to look at it every time I open a new browser window.
But today, TPUTH became my Home Page in Firefox. It’s a metablog about “tech and design”.
What got me? The whole digital yellow-press newspaper style combined with Socialist party medals of geek gods, a Cyrillic-looking title that you can’t pronounce (try it!)…it’s just cute, and funny, and stylish. It has daily funny pictures, and only features ironic headlines that link straight into the blogosphere.
Ever needed a or a ?
Here’s a nice generator by the French team Country and Kath. It produces animated GIFs for a style and background color you select. You can download them, and they are Public Domain (at least that’s how I understand totally free for use).
I know I’m contradicting myself here:
Seriously, drop animated GIFs. They stink.
AJAX loading indicators may be the only valid excuse for using an animated GIF. And maybe writing a blog post about them.
In January, I wrote about my thoughts on the iPad:
Somehow, I’d like to code on that thing! TextMate 2 for iPad?
Some weeks later, I realized that this might have been a stupid idea. Isn’t the iPad a media viewer, with editing capabilities for visual things like presentations at most?
Well, now Matt Gemmell writes about iPad Application Design. The first line that got me was:
Look like a viewer, and behave like an editor.
Wow, what a statement :) Isn’t that what TextMate is all about?
If something has more than, say, 5 parameters, it should be divided into components that have less.
Less is more. Hierarchies, if sensibly applied, can manage complexity.
Think LEGO.
1 puts
, p
, print
2 require
3 raise
, throw
, warn
4 new
5 to_s
, to_i
, to_f
, to_sym
6 private
, protected
7 class
Why did I name my blog “(almost) murphy.de”? Two reasons:
So, this is my explanation :) What about your blog’s name?
Here’s a good article about the recent discussion about finally allowing gays (and lesbians) to serve openly in the US military. I hope Obama and the Admirals get this through.
And what about you, Turkey? Serbia? Greece? Singapore, Malaysia, Myanmar? North and South Korea? Sri Lanka, India, Pakistan? Western Asia (except Israel)? Venezuela, Chile? Cuba? And, for god’s sake: Jamaica.
Or, the original version:
They do. As do Germans, Spaniards, Californians, Czechs, Polish, Indians, and propably some Japanese. I think that’s cool :)
This has got to be one of the ugliest logo images of a professional project ever:
But it’s used on their official website! This is embarrassing for “The Industry’s Foundation for High Performance Graphics”, as they call themselves. Seriously, drop animated GIFs. They stink.
Website Copyright 1997 – 2010 Khronos Group. A-ha. How about updating it to today’s web standards? At least make it valid!
I hope they make a WebGL website in the future ;)
Well, my prediction was wrong. After all these years, rumors have become reality: The iPad exists.
So, here are my thoughts about it:
All in all, it seems I would still need a laptop to perform day-to-day tasks. In its current form, the iPad is no replacement for a MacBook, not even the Air. It will be compared to the Kindle and other tablets, and the price will surely be a major con.
But as Mel Martin says, I’m sure Apple improves it over the next years.
…defines the following constants:
Two weeks ago, I demonstrated how to draw text on a WebGL texture. Eric Shepherd is even rendering video [warning: with sound]. Today, I’m rendering web content – that’s to say, a HTML page.
Again, I’m using the canvas
2d context to draw the content before using its data for the texture. The example is also based on Giles’ WebGL Lesson 7.
Mozilla’s Firefox has a unique feature called drawWindow. It’s not secure and thus you have to ask the user for explicit permission. So, it’s not ready for general usage, but it’s a nice demonstration.
Note: Before the example works, you have to enable the signed.applets.codebase_principal_support
option in about:config
. Disable it afterwards!
I also use an IFrame. So, this is about as evil as it gets.
You need a WebGL-enabled Firefox to see this.
Here’s the code:
The world expects a “tablet/slate/unicorn/whatever”…as James Higgs puts it.
My prediction, and I go out on a limb with this, is:
There is no f*cking tablet!
Update: Oh wait, now they’re even dismissing a non-existing product!
Apropos…why not posting some more images of unicorns :)
Kirk Haines just stated:
If superior execution time is only achieved by offloading extra work
to an idle core, then that really isn’t a gain.
Agreed. Just because we have multiple cores now, that doesn’t mean we have to spawn threads for everything. In my opinion, achieving great single thread performance with good algorithms and clever optimization is still the best way of programming fast applications.
I compiled a pie graph of times needed for CodeRay scanner tests. More test data for a language means more time to run the tests.
As you can see, I have a lot of tests for Ruby (60,000 lines of code) and C (70,000), and less for Delphi (11,000). The combined “other” languages are C++, the CodeRay debug format, diff, ERB and Nitro HTML templates, Scheme, and XML.
I used the excellent Gruff graph library.
Here’s the code:
WebGL has no text rendering functions. But it’s pretty easy to create a texture with text using canvas
2D context:
You need a WebGL-enabled browser to see this.
The interesting code:
When cp -r
takes a lot of time, I want to have an estimate how long it will take. My first approach was based on checking the size of the copied data repeatedly with du -sh
.
This is obviously now very clean. Marco (a fellow student) told me that cp
reacts to the SIGINFO
signal by printing the progress to stdout. The manpage says:
If cp receives a SIGINFO (see the status argument for stty(1)) signal, the current input and output file and the percentage complete will be written to the standard output.
This is what the output looks like:
$ cp3 large.file large.file.copy
large.file -> large.file.copy 42%
large.file -> large.file.copy 88%
Here’s the code:
I’m trying out a new scanner/encoder concept for CodeRay that would (hopefully) make highlighting even faster while improving the code at the same time.
Basically, it’s about bypassing the Tokens representation altogether.
The tests can be seen at Odd-eyed code.
Here are my results so far:
(1..100).select { |n| p n if ('1' * n) !~ /^1?$|^(11+?)\1+$/ }
Basically, the /^(11+?)\1+$/ part checks if the 1-string can be factorized. See Avinash Meetoo.
I use TextMate for everything that is text. Programming, organizing, shell-foo, writing for studies, protocolling, writing songs or guitar tabs, looking at patches and code, organizing, learning. And I have given up some great editors for it – Delphi, RDE, VIM, Weaverslave…actually, I switched to Mac in 2006 because of this software.
I just found out that I am [one of] the 129th most busy Rails Contributor[s], for my work on 7 patches back in 2006 and 2007.
Actually, I’m even #97 because 3 tickets for murphy where counted separately. Yay! I’m one of the top 100 Rails contributers. Now that’s something to brag about :D [Update: Xavier Noria added the alias. Great!]
Funny: Ezra Zygmuntowicz, Ola Bini, Sam Ruby, _why (the lucky stiff) and Zed Shaw come in last with only 1 commit. Even JEG2 has only worked on 3 tickets.
Also funny: There are currently exactly 1337 contributors listed!
devtail.com, a new site about developers’ lifes and works by Ian Stewart, is using my CodeRay syntax highlighter :) Nice.
Quote from his mail to me:
*Such* a great gem!
But it’s more due to Perl being so unpopular lately. Ruby stagnates; maybe Ruby 1.9.2, Rails 3, JRuby, MacRuby and Gemcutter can make Ruby more interesting in the future.
Update: It seems my prediction was wrong. But I wait another month before I take it back :)
Update: Epic fail. I was totally wrong; instead, Ruby is out of the Top 10 (Delphi took its place again). Every Top 10 language except C and Perl seems to weaken because of the advent of Objective-C and Google Go (the so-called company languages).
A cool feature of JavaScript 1.6 is called E4X:
var xhtml = <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Embedded SVG demo</title> </head> <body> <h1>Embedded SVG demo</h1> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> <circle cx="50" cy="50" r="20" stroke="orange" stroke-width="2px" fill="yellow" /> </svg> </body> </html>;
alert(xhtml.name().localName); // Alerts “html”
alert(xhtml.name().uri); // Alerts “http://www.w3.org/1999/xhtml”
I’m trying to highlight this syntax with CodeRay, but it’s a bit more complicated than I thought.
The last weeks I have been experimenting with WebGL, the upcoming 3D extension to the HTML 5 Canvas element. It is supported by the latest WebKit and Firefox nightly builds (read about getting WebGL to run on your system).
Now, here’s a rotating 500 4000 about 4900 polygon semi-transparent 3D sphere complete with a texture and lightning, animated via OpenGL by your graphics card – no Flash plugin needed (click the image):
If you want to stay updated about this developing technology, you can subscribe to the Planet WebGL meta-blog feed.
I can also recommend Giles’ step-by-step tutorials on learningwebgl.com, which I based my sphere example on.
This is just the beginning :) Some people are already creating games, demoscenes, and Viewers for 3D models with WebGL.
Update: Much faster mesh generation, more polygons. Always use Array.push
instead of Array.concat
.
Update 2: The Mesh library is now a separate file. Fixed some bugs with mesh generation.
In my tests, Ruby 1.8.7 runs simple benchmarks about 3-8% faster than 1.8.6 – that’s nice!
But Ruby 1.9.1 is far more fast, with speedups up to 2x for some real-life cases, and a reliable speedup around 10-20%.
JRuby performs better than 1.8, sometimes even better than 1.9, but only for longer tasks. For short benchmarks and day-to-day tasks, it’s often 2 or 3 times slower than any C-Ruby. The startup time is around 1 second, and thus JRuby is not the right tool for scripting tasks. It runs best on Java 6.
Draw the symbol you want to TeX in a HTML 5 Canvas, and it (mostly) gives you the command. Wow :)
I updated my Ruby 1.8 vs. 1.9 benchmark.
It seems they continue to speed up Ruby in the latest 1.9 trunk, eliminating some slowness and stabilizing the new VM.
For the projects I am programming lately, namely Fukubukuro (a JavaScript interpreter in Ruby) and EPIC/EVIL (a secret project ;), Ruby 1.9 turns out to be about twice as fast as Ruby 1.8.6. I also profit from faster testing, spec-checking and RDoc generation.
uptime
says my MacBook with Leopard (OS X 10.5.7) has been running for over 21 days now without reboot, and with lots of sleep phases:
9:55 up 21 days, 20:55, 3 users, load averages: 0.47 0.36 0.35
A Chess simulation with JavaScript and HTML 5 Canvas.
It is to be played by two human players. I’m planning a computer opponent.
I managed to build a readable QR Code (a 2D barcode) with my Lego blocks:
The encoded content is the URL of this blog, http://murfy.de. As you can see, I had not enough black pieces, and improvised with blue. I had to fill the background with white pieces to make it readable.
I saw this one in my Finder sidebar on Wednesday.
Snow Leopard, the next version of Mac OS X, is scheduled for September, a month before Windows 7. It will be almost completely 64 bit, Intel-only, and cost $29€ for Leopard users. Apple first announced that Snow Leopard would merely include speedups and core improvements, but now they added a lot of new features as well – not all of which get the publicity they deserve.
Ever wanted to know how much longer your cp -r
needs? This little Ruby script might help you.
$ cp2 coderay coderay-0.8
From: 307M coderay
To: 154M coderay-0.8
The second line updates every second while copying. It’s fast enough on OS X, but I’m sure it can be optimized.
Here’s the code:
Today, President Barack Obama released plans to create a new government office dedicated to Cybersecurity. In his announcement, he stated:
Let me also be clear about what we will not do. Our pursuit of cybersecurity will not – I repeat, will not include – monitoring private sector networks or Internet traffic. We will preserve and protect the personal privacy and civil liberties that we cherish as Americans. Indeed, I remain firmly committed to net neutrality so we can keep the Internet as it should be — open and free.
Here’s another experiment with canvas: a simple map editor (click on the image).
You need Firefox, Opera, or Safari to see this; preferably one of the current beta versions (Safari 4 runs fastest, Firefox 3.5 is okay).
TeX is much to complicated for me, especially when it comes to simple text – I prefer the simplicity of Textile. But when it comes to typesetting formulas, there’s no real alternative.
So I’m trying to combine them, with this little Ruby script which runs on Leopard and uses latex2png
:
Another great article about programming is the quite short piece Teach Yourself Programming in Ten Years from Peter Norvig, written 2001. The title should be enough to stir your interest :)
According to this article, I’m some years and a few programming languages away from becoming a “master”. Yay me!
Please don’t vote now.
Actually, I think blog polls are statistically ridiculous.
One of the best articles I’ve read about general programming language topics is Jonathan Amsterdam’s Java’s new Considered Harmful (click on “Print” for a less ad-cluttered version.) He criticizes the use of the new Constructor(...)
statement in Java on a functional level, concluding that “…for statically typed languages, it may not be possible to do better…”.
If you are interested in the never-ending discussion about static versus dynamic typing, I encourage you to read it. If you’re not, well, do something else.
Amsterdam also mentions Ruby’s approach to object creation, stating that it fixes a problematic behaviour of Smalltalk. Still, according to him, one problem remains:
A second drawback with […] Ruby is that initialize, being an ordinary method, does not chain: You must remember to begin your initialize methods with a call to the superclass’s initialize method.
1 Ruby
2 Python
3 JavaScript
4 C
5 QBasic
6 LOLCODE
7 Java
↓ Sarah Palin
↓ Guido Westerwelle
↓ Andrea Ypsilanti
↓ Franz Josef Jung
↓ Hans Joachim Schellnhuber
↓ Hartmut Mehdorn
↓ The Pope
-7 TeX – hate it, can’t find a replacement
-6 MSN Messenger, ICQ Client – I hate ads
-5 TWiki – the ulcer of Web 2.0
-4 coderay
executable – ugly, cryptic, incomplete – needs a rewrite
-3 RDoc – hopelessly bad
-2 chatcity.de – so buggy that it hurts
-1 Internet Explorer 6 – it’s the devil
The Sky Crawlers, the latest movie from Mamuro Oshii, the director of the Ghost in the Shell movies. A quiet, poetic, philosophic, dramatic, sad movie. With lots of silence, CG airfight, cigarettes, children, a mother, a father, and a dog. And to your enjoyment, it’s two hours long.
I’ll just re-post my message to Frostii here:
It’s final. I fell in love with JavaScript.
I still love Ruby, but she can’t do this:
(Essentially the clock from the Mozilla Canvas tutorial, a little tweaked.)
No GIF, no Flash, no Silverlight, no SVG, no ugly hacks – just HTML and JavaScript. As an added bonus, it doesn’t work in Internet Exploder.
…or a meta version of them. Hard stuff.
And someone once wrote my CodeRay website was ugly!
But nothing is as cool as Zombo.com.
Hey, their favicon resembles the CodeRay one o_O
Another variation of Ruby-chan for the CodeRay Website.
(This is an open list, add your ideas in the comments.)
Nobody can solve a big problem. But some people are good at dividing big problems into smaller problems that everybody can solve.
Those people are called programmers; their skill is division.
There’s a form for comments, but if you try to send it, you’re redirected to the login page! If you don’t know how to fight spam, at least don’t let me type my shit into the trash bin. I allow anonymous comments on my blog, and if you don’t, you stink.
Your captchas are so stinkin’ unreadable that I had to try at least a dozen times ! I’m not blind you know? And if you validate my email adress anyway, why bug me with captchas? And then, I couldn’t log in! After trying a dozillion times, I found out that you have to give your email and password, instead of the nickname you had to choose. Try reading some interface guidelines! Finally:
Sorry, your account has been locked due to an excessive number of failed login attempts within a defined period. Your account will automatically be unlocked in 14 minutes
SOB!
Ever wondered where a deep symlink points to? Try tracelink
.
13:59:48 ~ $ tl foo2
foo2 --> foo (relative)
foo --> bla (relative)
bla: empty
14:00:27 ~ $ tl `which tl`
/usr/local/bin/tl --> /usr/local/bin/tracelink (absolute)
/usr/local/bin/tracelink: a ruby script text executable
14:00:34 ~ $ cat `which tl`
Did you know?
Every time you run the Ruby 1.9 test suite, a child dies :(
I wrote a simple version of the UNIX directory disk usage tool du
(disk usage). Its output should be exactly the same as du -sh
. Call it with the name of a file or folder.
Update: This is the second version, using a better method for the bytesize output and guessing the system’s blocksize.
I find this incredible (needs Flash). And this, too (needs Java).
Teaching Rails more languages is now as simple as:
config/locales
folder, andApplicationController
that detects the user’s language:class ApplicationController < ActionController::Base before_filter :set_locale def set_locale I18n.locale = request.env.fetch('HTTP_ACCEPT_LANGUAGE', '')[/(?:,|^)(de|en)\b/, 1] end end
You have to adjust the regexp to allow automatic recognition of more languages; I haven’t found out yet how to get a list of all available locales without using I18n.load_path, but maybe the community helps me out.
It’s cool that changes to the locale files are applied instantly in development mode! A great improvement :D
So far, ever stinking attack from the McCain/Palin campaign against Obama has turned out to be false, misleading, or groundless. But Obama’s connection to ACORN in the past and today (see this McCain Web Ad) could be problematic, since ACORN is a left-wing organization that has tolerated, supported or lead criminal activities, namely voter registration fraud.
Maybe it’s that simple – Gallup finds that John McCain is too old.
Actually, 23/6 were the first to understand this.
(Barack Obama is 47, while John McCain is 72 years old. Michelle Obama is 44, while Cindy McCain is 54. Joe Biden is 65, while Sarah Palin is 44, and younger than Michelle. Together, they are 326 years old.)
My father took that photo in 2004 in Miami:
Well, I’m not sure if this is possible, but then, everything’s possible. Can’t be worse than Palin.
(Thanks to my brother for sending me the picture.)
Question: Right now a recent study says and the polls reflect that Barack Obama is gaining ever since this crisis has landed in everyone’s kitchen table, why is that?
McCain: Because life isn’t fair.
They say they love being underdogs. Well, let them be.
Is Murphy’s Law the way the universe protects itself from destruction?
In addition to delivering such wonderful thoughts, Megan McArdle’s blog reports about things happening in the US and is really worth a read.
(German translation on Ruby-Mine.)
Now, I’m about to write the Java Scanner for CodeRay (ticket #42 btw), and I thought it would be nice to have a list of built-in types highlighted – like String
or IllegalStateException
. I knew that TextMate had quite good highlighting for Java, so I checked the bundle for something to use.
Indeed, some smart guy included a very long regular expression into the token definitions, it looks like this:
support-type-built-ins-java = {
name = 'support.type.built-ins.java';
match = '\b(R(GBImageFilter|MI(S(ocketFactory|e(curity(Manager|Exception)|
rver(SocketFactory|Impl(_Stub)?)?))|C(onnect(ion(Impl(_Stub)?)?|
or(Server)?)|l(ientSocketFactory|assLoader(Spi)?))|IIOPServerImpl|
JRMPServerImpl|FailureHandler)|SA(MultiPrimePrivateCrtKey(Spec)?|
...this goes on for several screens...
Apparently, they converted a long list of types into a minimal regexp, surely using a script for this. But that wasn’t exactly what I had searched for. How could I convert this back into the original plain list?1
Seen the new iPod 4G color lineup?
Well, let me tell you what those colors stand for:
I love Barack Obama’s speeches, and I wish we had such a charismatic politician with such bold ideas of change here in Germany. He’s an attourney, and I assume a great one. But he seems to have some problems with math.
Camping sessions not working lately? Well, it’s a problem with Rails 2.1, to be more precise: ActiveRecord 2.1.0.
This took me at least 5 hours, but I finally got it: the latest version of AR does Dirty tracking and partial SQL updates. This means it only saves a new value when it thinks the attribute has changed. Nice, but it bugs Camping. So, here’s the patch:
I was waiting eagerly for 3rd party apps on my iPhone since I bought it…but I didn’t expect the apps to be this good. Turns out the best game is actually free: “Aurora Feint: The Beginning”. The developers are very active and nice. Give it a try, if you have an iPhone or iPod touch :)
Screw that. Apple has taken it down (Thank you! No sarcasm!) because it actually sends your contact list over to the developers’ server.
I love MacBooks, here’s another reason: LiquidMac!
It works using the internal Sudden Motion Sensor that protects the hard drive from “disk failures if the computer is dropped or undergoes severe vibration” (official info). Nice toy!
Looks like a very old or very futuristic city, don’t you think?
Sorry, I have to do my tax declaration today and it suuuuuucks :/
I got naked!
http://naked.dustindiaz.com/ is celebrating the 3rd CSS Naked Day. Enjoy my blog without CSS :)
MacBooks are closed with two magnets in the top corners of the screen. I wondered how I could put them to further use. This is what I came up with:
I had a short trip to London (business, you know).
A beautiful butterfly took a rest outside of my window for a while and waited for me to make photos of it ^^.
Some pictures of my home city I took a while ago.
This new MacBook looks nice. But it has strange specifications:
Still, I’m thinking about getting one later this year. And I want an SSD (that’s a non-mechanical hard drive – die, HDD!), which is currently just too expensive (900 $ extra!) Am I crazy? Let me explain.