Blog names ..

Choosing a blog name is the most annoying part of setting up a blog. I think most people don’t care to have a blog name. In all honesty, the only name that makes sense for most blogs is the blogger’s own name (or alias/nickname).

Things that need fixing in Ubuntu’s package system

Debian’s APT system is great for installing and updating system tools.

It’s not so great for installing and updating “apps”.

Most of the user-centric “apps” don’t do anything that requires root permissions. Why does it require root privileges to install them? Because APT packages get installed to system directories.

Solution? It shouldn’t be too complicated. Make some sort of a standard way for applications to install themselves to user-specific locations (or maybe some location that’s accessible to all users but doesn’t require root permissions to write to).

There’s also a problem with PPAs. The idea of PPAs is great: provide a channel for application developers that integrates with the built-in “system update” system (i.e. APT).

It takes 3 steps to install something from a ppa:

  • add the ppa
  • update apt (most annoying step)
  • install the application

Additionally, the ppa may provide different versions of some system libraries — not a good thing. I once had a ppa install its own version of the kernel, and one of those updates killed wireless for me (fixing the issue caused a lot of un-needed headache). The worst part is the user doesn’t realize that some ppa’s are overriding part of his system.

Why not instead, just have one command to install “app” from “ppa”, such that:

  • The installation doesn’t require root permissions (see above).
  • The ppa is not added to APT’s sources.
  • Only the installed application knows about the ppa and can somehow update itself through it.

Why Unity is a win

The introduction of Unity as a desktop environment is a great win for Ubuntu and the Linux Desktop.

Unlike gnome, which is designed by a committe of techies, Unity is designed by a small group of designers and techies. And unlike gnome, the goal is not to just offer a “free” desktop (that may or may not offer a good user experience); the goal of unity is to offer a great user experience (that happens to be free).

So even if 10.04 unity sucks (I think it will rock, but hypothetically speaking ….) in the long it can only get better, and therefor Unity will be awesome.

IBM and its minions …

From a tech talk about the history of JSON

http://developer.yahoo.com/yui/theater/video.php?v=crockford-json

(Note: Douglas Crockford put the following clause in the JSON license “The Software should be used for Good, not Evil.”)

About once a year, I get a letter from a lawyer, every year a different lawyer, at a company – I don’t want to embarrass the company by saying their name, so I’ll just say their initials – IBM…

[laughter]

…saying that they want to use something I wrote. Because I put this on everything I write, now. They want to use something that I wrote in something that they wrote, and they were pretty sure they weren’t going to use it for evil, but they couldn’t say for sure about their customers. So could I give them a special license for that?

Of course. So I wrote back – this happened literally two weeks ago – “I give permission for IBM, its customers, partners, and minions, to use JSLint for evil.”

[laughter and applause]

And the attorney wrote back and said: “Thanks very much, Douglas!”

تخطيط العود

الطريقة مأخوذة من هذا المنتدى: http://www.saudimusicians.com/vb/showthread.php?t=5475

لتخطيط العود نأخذ اولا طول العود و نقسمه على الرسم السحري 1.059463094 و هو جذر 2 للقوة 12

>>> pow(2, 1/12.0)
1.0594630943592953

انظر: http://en.wikipedia.org/wiki/Twelfth_root_of_two

نتيجة القسمة هي مكان الخط الاول.

ناخذ النتيجة و نقسمها على نفس الرقم .. و نحصل على الخط الثاني.

و لتسهيل العملية لا داعي لان نقوم بهذه الحسابات .. يكفي تشغيل كود يقوم برسم الخطوط بالابعاد الصحيحة، و من ثم نطبع الصورة الناتجة و نستخدمها كمقياس للتخطيط، و لا اسهل من فعل ذلك بصفحة html تحتوي على سكربت صغير يقوم بالعمليات الحسابية، مع اعتبار طول الوتر 60 سانتيمتر.

<p>تخطيط العود</p>
<style type="text/css">
    p { direction: rtl; text-align: center; font: 24pt normal serif; width: 400px; }
    div { float: left; height: 100px; border: solid 1px gray; border-right: none; }
</style>
<script type="text/javascript">
// <div style="width: 3.3cm;">&nbsp;</div>
    var m = 1.059463094; //magic number
    var a = 60;
    var b = a;
    for(var i = 0; i < 8; i++) {
        b = a/m;
        var w = a - b;
        document.write("<div style='width:" + w + "cm;'>&nbsp</div>\n");
        a = b;
    }
</script>

قمت بوضع الكود على github https://gist.github.com/813039

تعديل

قمت بوضع الصفحة على النت و اضفت عليها بعض التطويرات: http://misc.hasenj.org/oud-lines.html

يمكن اختيار طول الوتر و عدد الخطوط اللتي تحتاجها

How I hack on node apps

splitw

First, there’s my ‘splitw’ command, which I use to run long-running process in a split screen.

Code on github

XRefresh

Then, there’s the XRefresh extension for Firefox. It requires a separate server. Check it out from github: https://github.com/YouWoTMA/xrefresh-server then create a symlink to the xrefresh-server (an executable python script).

I run it like this:

xrefresh-server -e ".git/" .

Supervisor

And also, there’s ‘supervisor’ node package; it runs js (or coffee) files and watches them automatically; when they change, it restarts the server.

Install it from npm:

npm install supervisor

Assumptions

I assume the app’s starting is always server.js (this is actually because of the webbynode hosting). And I assume there’s a git repo that I want to constantly work with as I hack.

I can still write the app in coffee-script, just have to make server.js look kinda like this:

require("coffee-script")
require('./app.coffee')

And then I have to pass -e "coffee|js" to supervisor so that it also watches .coffee files for changes (by default it only watches files with .js or .node extensions).

Putting them together

So here’s a simple command:

splitw 'supervisor -e "coffee|node|js" server.js' 'xrefresh-server -e ".git/" .' 'bash'

This splits the terminal to 3 horizontal panes, the first running the ‘supervisor’ node reloader, the second running xrefresh-server, and the last one just a normal shell so I can create git commits.

hack hack hack

I save that command to ~/bin/gonode and so when ever I want to hack on some node app,

~$ cd code/<app>
~/code/<app>$ vim server.js

Then hit ctrl-shift-t to open a new tab (it inherits the current working directory), and in it:

~/code/<app>$ gonode

And it will fire the server, the firefox refresher, and leave a pane for the shell.

The screen split kinda looks like this:

A brief explanation of what lisp macros are

A lisp program looks something like this:

(a b c d)
(m o (p k))
(a b c (d e f g (h i j k) l m) 
       n 
       (o p q (r s t (u v) (w x y)) 
           z))

The only form of syntax in lisp is the (a b c ..) form.

The if statement looks like this:

(if a b)

A function call also looks like this:

(foo a b)

A function definition looks sorta like this:

(def foo (a b) body)

Contrast this with python, where the if statement is of the form:

if a: b

And if ‘b’ is multiple lines:

if a:
    b

And the function call is of the form:

foo(a, b)

And the function definition is like:

def foo(a, b):
     body

Without delving too deep into “how”, you can now know what macros do.

Macros are a way of defining new forms of statements.

(bar a b c)

It looks exactly like all other forms of statements.

Why would you define a new form of statements? To abstract the syntax away. To get rid of repetitive code that you can’t get rid of using functions or even higher order functions.

For example:

if some_expression(a, b, c):
      do_something_with( some_expression(a, b, c), d, e, f)
      another_thing(some_expression(a, b, c))

Notice we’re repeating the expression some_expression(a, b, c) and not only that, but we’re calling the function twice.

It’s better to:

x = some_expression(a, b, c)
if x:
    do_something(x, d, e, f)
    another_thing(x)

This is a pattern that can repeat itself in many places.

Some languages allow you to:

if x = some_expression(a, b, c):
   use(x)
   again(x)

But if the language doesn’t provide such a syntax, you can’t define it yourself.

Lisp macros basically allow you to define a new type of statement that 1) look like the rest of the language 2) doesn’t have to wait for the language makers to implement them.

Another good example, the pattern:

try:
    statement block
catch:
    do nothing

In lisp, you can define a macro for that:

(errsafe expression)

Note that an expression can be a statement block.

This is actually the name of an Arc macro, but there’s nothing special about how arc defines it, it’s just like how you can define a function in C; if the standard library doesn’t come with it, you can just write it yourself.