2010-05-26

Packing files together, then splitting them: tar

The tar program is so useful for packing files together for transport.  With all the talk of cloud storage and all, especially now with Ubuntu One, there's still sometimes a place for good ol' email it to yourself storage.  Except that email servers typically won't let you upload files larger than 10 or 20 MB.

The solution is to archive the files into one, then split it into say 10 MB segments.

Say all the files are in a directory src-code.  Then do tar -czf src-code.tgz src-code.  That'll pack the whole directory into one zipped and archive file.

Then to split it into approximately 10 MB segments, do tar -ML 10240 -cf src-code.part1.tgz src-code.tgz. This will return an interactive session, where it'll ask you for the name of the next segment to save as, at which point you'll want to do n src-code.part2.tgz for the second segment, and so on (do ? and return-key for help).

To reverse the process, do tar -Mxf src-code.part1.tgz and then n src-code.part2.tgz and so on at the interactive prompt.  Then tar -xzf src-code.tgz to get back the src-code directory.

2010-05-25

Ubuntu Lucid: Restarting X Server

Strangely, on my desktop computer, sometimes the Nvidia driver doesn't get used properly on startup or restart, resulting in an ultra low display resolution.  This sometimes occur, and sometimes doesn't.  Very frustrating.

Fortunately, a one-shot solution is just to restart the X Server.  Go to a terminal, eg, by keying Ctrl-Alt-F7 to go to a tty after reaching the log-in screen at startup.  Then do sudo restart gdm.

This requires that you can use sudo of course.  At least with Ubuntu, that's the same as doing sudo /etc/init.d/gdm restart.

On startup, Ubuntu does detect the problem and offers a choice to restart the X server, but that somehow doesn't work.  Doing this manually at a terminal does though.  Weird.

2010-05-18

Raising children without discomfort

Take a look at the article, Weaponizing Mozart. It's incredible the ingenuity put into thinking up devices like the Mosquito, techniques like shining bright halogen lights from helicopters, or forcing children in detention to listening to classical music, in order to influence or modify the children's behaviour.

Essentially it's putting all this time and effort into modifying children's behaviour without subjecting adults to the discomfort experienced in confronting and personally working with the children to change.

It's as if for some parents, teachers, and adults, they don't mind at all spending more money, time, and resources on the problem. Whatever it takes, so long as they don't have to actually face a child, build a relationship with the child, and work with the child constantly over time to internalize better and more effective behaviours.

2010-05-16

Dear Grade 9s: What algebraic equations are for

A friend of mine was making an algebra test for his junior high math class recently and asked me what I thought equations are for.  What he meant is that the students are required to write out an equation for a given word problem before solving the equation, but students are bound to ask what the point of writing an equation is if they can solve it without it.

For assessment purposes, of course teachers need to see students write out an equation to know that they can.  But for students, the problems are probably easy enough that they don't really need to write out an equation to solve the problem, and so they see no point in doing the extra algebraic work!  Of course, they have also been trained over the years to recognize nice, round numbers as "The Answer" to all types of questions, so it's hard for them to understand how an equation can be part of "The Answer."

So here's a simple reason that I might give to a hypothetical grade 9 class: the point of writing an equation is to communicate an argument, and to tell the reader what the writer thinks is in fact true reality.

2010-05-15

Few reminders to the very 1st steps to application development in Clojure

Just a few reminders for myself for now...

Get lein.
Get emacs with elpa; use it to get swank-clojure into emacs.

Do lein new project_name
Modify project.clj to use Incanter and Swank, so it should include something like this:

:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
              [org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
              [incanter "1.2.3-SNAPSHOT"]]
:dev-dependencies [[swank-clojure "1.2.1"]
                   [jline "0.9.94"]]

(edit: turns out incanter will use/import the right clojure libraries for you, but you still should specify which version of clojure and contrib you want to use.  Also note leiningen/lein-swank "1.1.0" is being replaced by swank-clojure)

Do lein deps
Do lein swank
From emacs, do M-x slime-connect

Write your code in files in src/project_name
From the repl in emacs, do (load-file "path/to/code_file.clj") to load the code so you can run it manually to inspect it.  Do (remove-ns 'main-ns-in-code-file) to start over and re-load the file for further inspection (say after you'd done some edits).

(edit: unfortunately, it looks like Java doesn't allow dynamically changing the classpath, so if you write a new file new_file.clj then you'll have to restart the repl or the swank server)

Oh, make sure file names do not include the "-" character even if the namespace you use has a "-" character in it; replace it with a "_" instead in the file name (the namespace can continue to use the "-" though).

You'll need a -main function and an addition to the project.clj file, but that's all I want to note down for now.

(edit: also check out this intro for more readable info from the Incanter web site. My stuff above was more like a brain-dump of mental notes.)