Mozaik.

31 Jul, 2011

Skip Trash in Lion

Posted by: Urban In: english

One of the things that bothers me in Mac OS X is that you cannot delete files without skipping the trash (apart from using the console). This means that to free the disk space of, say, a 2GB file, you have to empty the trash; if you delete large files often, your trash either grows very large or you empty it so often, that it defeats the very purpose of having one.

Until now I’ve used a handy script/droplet Permanently shred, but it broke in Lion. So here’s how you make your own “Skip Trash” dock app using Automator.

1. Start Automator
2. Choose “Application”

 

3. Search for “Ask for confirmation” and drag it to the right pane
4. Enter a confirmation message, e.g. “Are you sure?”

5. Search for “Run shell script” and drag it to the right pane
6. Select “Pass input: as arguments”
7. Replace “echo” with “rm -rf”

8. Save application (e.g. as SkipTrash.app)
9. drag it to the dock and select “Options -> keep in dock”

If you want the app to play a Poof sound when finished, add “afplay /Library/poof.aif” at the end of the shell script and unzip and copy this file to your /Library/ (or any other location you want, but update the path accordingly): poof.aif.zip

So now whenever you want to skip the trash, drop files or folders onto the newly created SkipTrash.app instead of the regular Trash icon.

19 Jul, 2011

O knjigarnah

Posted by: Urban In: misc

Ko smo se potikali po ZDA, sem večkrat zataval v knjigarno Borders, ki je s svojim umirjenim ambientom, bolj podobnim knjižnici, kot pa knjigarni, predstavljala oazo sredi hektičnega mesta. Klima, zastonj internet in vse knjige, ki jih je poželelo srce, tako da sploh nisem vedel kaj bi prej vzel v roke; večkrat sem se zalotil pri tuhtanju, kako bi domov odvlekel večji kup knjig, pa sem se hitro streznil, češ da take kupe doma že imam, pa jih sploh še nisem prebral.

Borders je že februarja oznanil bankrot, ker pa do zdaj niso našli kupca, dokončno zapirajo vrata. In ne morem reči, da nisem tudi sam pomagal pri njihovem propadu. Par dobrih knjig sem našel tam, pa sem jih kar sproti kupil v Amazonovem Kindle Storu, preko iPhona in Bordersovega brezplačnega WiFi-ja. Pa še malo počíl in se lahkih rok podal naprej. Dvomim da sem bil edini.

Čeprav vem, da se pol tisočletja stari tehnologiji tiska počasi bliža konec, ter so mi znane prednosti prenosne knjižnice, pa se mi takih kotičkov vseeno zdi škoda. Pasovna širina interakcije™ je v knjigarni mnogo večja kot na spletu. Uporabiš lahko roke, noge, ter se prebiješ čez celo knjigarno v nekaj minutah. Najdeš zanimiv oddelek, kjer se lahko ustaviš, pri tem pa s pogledom oplaziš na stotine knjig1.

Na spletu smo še vedno v kameni dobi. Page 1 of 145. Next.

Seveda knjigarne iz opeke in malte ne bodo odšle čez noč. Borders ni bila niti največja ameriška veriga (Barnes&Noble je še večji). Ampak posel ne bo iz dneva v dan lažji, občutki pa ne povsem različni od čakanja pred strelskim vodom.

  1. Pri nas recimo mi je izredno všeč ValeNovak, kjer lahko najdeš tudi tako sodobne naslove kot so XKCD, Dilbert in zbrane objave z blogov Setha Godina. []

11 Jul, 2011

Server status via SMS

Posted by: Urban In: english|programming|projects

Stormy weather makes me worried about my electronic equipment, especially servers. A summer storm can take out power, corrupt a HDD in the process, or in the worst case, fry absolutely everything by a strategically placed lightning strike.

But even on a quiet winter day, hard disk can quietly fill with logs, one byte at a time, finally causing a bunch of services to die (I’m looking at you, Mysql).

The point is, anything can happen and you have to check often to prevent an unplanned downtime, which can sometimes extend significantly because no-one checked1. And checking gets more tedious the more stuff you have. So this post describes a quick&dirty method, tailored to my needs, on the cheap.

A quick disclaimer: I do know about Pingdom and similar services, as well as Nagios. However, I wanted a simple lightweight script, which runs on my home server behind a firewall, and queries my public servers over HTTP. Then it sends me a text, once daily.

This is how it works:

  • my home server acts as an agent and tries to contact all the public servers
  • each server performs a quick and dirty on-demand self-test, responding with a message that reports the available disk space, mysql status, etc.
  • python script on the home server aggregates all the responses into a concise form, suitable for texting
  • and sends it, once a day.

To test the public servers, I created a simple PHP script which performs some basic tasks a healthy server should be able to do, and returns a response. This is the version 1:


A<?php
    /*A stands for Apache.
      If only "A" gets served,
      the web server is alive, but PHP doesn't work. */

    /*print P (short for PHP OK),
      followed by GBs of free disk space */
    echo "P[" . floor(disk_free_space("/") / 1024 / 1024 / 1024) . "G]";

    /*try connecting to MySQL */
    mysql_connect("server", "user", "pass")
        or die("db_down");
    mysql_select_db("mysql")
        or die("db_err");

    /*Print a short string ("My") through the
      database to prove it works.*/
    $res = mysql_query("select 'My' as my from user");
    $row = mysql_fetch_assoc($res);
    echo $row["my"];

    /*if everything works ok, this should
      return something like AP[10G]My
      which simply means apache works ok,
      php interpreter is fine,
      there's 10G of free disk
      and mysql is fine. */
?>

I wanted to get this summary delivered as a SMS notification. Twillio looked promising, but in the end wouldn’t take my CC, so I used this awesome hack to send free text in the form of a Google Calendar reminder.

I extended the provided Python script to also get the free disk space of my home server and wrap everything up as a single SMS. The result looks something like this:

Reminder: srv1_ok! c:1018M d:709054M srv2:AP[10G]My srv3:AP[2G]My

This was at first meant to be just a form of “infrastructure unit test”, returning true if everything checks out OK, and false otherwise. But since there was room for additional info, I added more to fill the message.

I’ve been somewhat reluctant to set up different notifications in the past, because that basically means more spam. But since I did it once at work (via e-mail), it’s been quite satisfying. An e-mail with the subject “Everything ok!” makes my day, and that’s what I get most of the time anyway.

  1. It’s just recently happened to me :) []

20 May, 2011

Dr. Strangelove endorses our app

Posted by: Urban In: english

It appears that Dr. Strangelove in the movie with the same title1 also uses the Nuclear Bomb Effects Computer slide rule in a scene or two. I just spotted it (and I have proof: see two screen grabs below, around 01h25 in the movie).

So now I can add a tagline to Nuke Effects: As seen in Dr. Strangelove.

 

  1. that is, Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb, 1964 []

14 May, 2011

Nuke Effects for iPad

Posted by: Urban In: english|projects

Nuke Effects, an iPad version of the once famous Nuclear Bomb Effects Computer just hit the App Store.

From the Nuke Effects description:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In 1960s, when the Cold War was at its peak and the world’s two superpowers were locked in a nuclear arms race, the U.S. Government Printing Office published a handy slide rule for estimating the effects of nuclear weapon explosions. It was available for $1.00 to anyone interested in “the study of effects data derived from nuclear weapons tests and from experiments designed to duplicate various characteristics of nuclear weapons”.

Since then, many things have changed and this slide rule remains a relic of the past. Having become a collector’s item, it is only available for a handy sum on auction sites and as a rather impractical web-based version. Until now.

This app is a faithful (although—for greater ease of reading—somewhat oversized) digital replica of the real thing. By responding to your touch much like the original plastic version, it brings this museum piece back to life.

With it you can evaluate 28 different effects of nuclear weapons, of which 13 relate to blast, 5 to thermal radiation, 1 to initial nuclear radiation, 2 to early fallout, 6 to crater dimensions, and 1 to fireball dimensions. Most of the parameters are presented as functions of range and yield.

The original slide rule was based on a book “The effects of nuclear weapons”. This hefty 700+ page publication (which is in public domain, as well as the slide rule itself) is available at the support site of this app, together with links to the resources used to create this app.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This app is free (as in free beer). It was inspired by the Trigonir iPad App of my good colleague Dragan and by the web version of the slide rule at Fourmilab. The app was created using the materials, generously provided on the Fourmilab website, which you can also use to build your own paper&plastic version.


About


Researcher at FE, LTFE,
founder at Obelisk, programmer, photographer,
technology enthusiast, etc.

See what I share on Google Reader, and elsewhere.

Recently added pictures

Footsteps Brooklyn Bridge Ceiling Fan Rebuilding WTC In God We Trust Shadows