triptico.com

Un naufragio personal

Why the iPod interface is crap

  • You cannot delete songs from the device. So everytime that fucking song starts again, you can do nothing but hope never forgetting to delete it on next sync time.
  • When you browse your songs by artist, only those with an album tag will be shown. Delete all album tags but one for all songs of a given artist for enhanced hilarity.
  • There is no way to play randomly any set, only the full one. So, if you're in the mood to listen those music from the chillout genre, you better fuck yourself and enjoy them in alphabetical order (again).
  • It's too easy to let it playing alone, so next time you pick it from the table, the battery is probably gone.
  • There is no way to enhance their storage capacity with external memory cards or so. Yes, this is on purpose. And yes, this is not an interface issue but a design one. My ass.

Fuck you, Apple. Your interface is shit no matter what your fanboys say.

All this is for the touch wheel ones, never used one of these new touch thingies. Yes, I'm an old fart.

Related

Note to Facebook web programmers

When you talk about Entering an URL, you are implying that it's a real URL, that is, a string prefixed by an URL schema (the http+colon+slash+slash funny gibberish). By fixing this in your 'Import blog' option in your Notes application you can save several minutes of time to insignificant morons like me.

Or may be this is just a problem in the spanish translation.

Related

How to enter spanish quotes (« and ») under MS Windows

The crappy way: Alt-174 for « and Alt-175 for ».

The more definitive, but not at all not cumbersome way: download a thing called Microsoft Keyboard Layout Creator from http://www.microsoft.com/downloads/details.aspx?familyid=FB7B3DCD-D4C1-4943-9C74... and create your own keyboard layout, probably using a standard one as template. This program will prepare a .msi installer for you. After executing it go to Control Panel and set your layout as the default one.

You most probably want to set « to AltGr-Z and » to AltGr-X, as any Linux user know and love.

Or take my spanish keyboard layout: keybspao.msi with source keybspao.klc.

Update: If you use Windows Vista or 7, you'll need at least Microsoft Keyboard Layout Creator 1.4. My keyboard layout source file is still functional, but you need one of this installers instead:

Related

Overriding mod_rewrite if a file exists

I use mod_rewrite intensively on this site, mainly to make the transition from the old static files layout to this new, dynamic one based on my Gruta CMS. Following the premise that URLs must be eternal, I've used mod_rewrite magic to make old URLs like

http://triptico.com/software/mp.html

still be accesible, but be interally redirected to

http://triptico.com/?t=STORY;topic=software;id=mp

Anyway, it may prove useful to only do this redirection if a file with that path and name does not already exist in the filesystem. This can be used, for example, to serve special, manually crafted HTML pages, statistics made by other software, or to 'freeze' a special page to avoid too much server load.

So these are the magic words:

 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}      -f
 RewriteRule ^ %{DOCUMENT_ROOT}%{REQUEST_URI}    [L]

They must be entered before any other rewriting directives.

What they mean is, if a file exists (-f) with a path formed by the site's document root plus the requested uri, rewrite the query to it and stop rewriting ([L]).

Related

File locking in Perl

File locking in Perl is done with the flock() function. It's portable among architectures, is advisory-only and locks full files.

It accepts two arguments: a file handle and an operation id. As expected, it allows only one writer or many simultaneous readers, with no wait. Locks are automatically released on closing. The usage is simple:

  1. Open the file (for reading or writing).
  2. Call flock() with the file handle, and a second argument of 1 (if reading) or 2 (if writing).
  3. Do whatever operations you do to the file.
  4. Close it.

And that's it. The magic numbers 1 and 2 can also be used as LOCK_* constants imported from the Flock module. The perldoc documentation is comprehensive, take a look at it.

Example reader:

 open F, 'index.db'; # open for reading
 
 # lock file. If a writer has it locked, it will
 # wait until released. Many readers will read the
 # file simultaneously without blocking.
 flock F, 1;
 
 while (<F>) {
    # do things...
 }
 
 # lock is released
 close F;

And a writer:

 open F, '>index.db'; # open for writing
 
 # lock file for writing. If there is another reader
 # or writer using the lock, it will block until
 # released.
 flock F, 2;
 
 # file is now locked
 # write stuff to the file...
 
 # lock is released; any readers or writers waiting
 # will unblock and go on with its business
 close F;

As these locking semantics are advisory-only, anyone can screw everything by writing without locking, so take care.

Related

Showing an intermixed short log of a bunch of git repositories

I store all my git repositories under the same directory, unsurprisingly called ~/git. I needed a way to have a quick list of what I have done in all of them in a given time, so I wrote a script named (probably incorrectly) my-git-metachangelog.sh. This script iterates all subdirectories, finds all that are git repositories, takes a shortlog for all of them, and sorts by date. The fields shown are: date, time, project and the first line of the commit message.

By default, shows the short log for the last 6 months. It accepts an optional unique argument with the number of months to summarize.

This is an example of its output:

 2008-12-11 18:25:29 gruta: Changed all POD docum. in templates to head2.
 2008-12-11 17:04:37 gruta: New templates 'main_top' and 'main_bottom'.
 2008-12-11 10:57:19 grutatxt: The option 'no-pure-verbatim' has been docum.
 2008-12-11 10:25:26 grutatxt: Don't move to 'blockquote' if in 'pre' mode.
 2008-12-11 10:19:44 grutatxt: Strip bold form head2 documentation.
 2008-12-11 10:17:11 grutatxt: 'pod2grutatxt' creates 'NAME' (Closes: #1016).
 2008-12-11 10:08:07 grutatxt: Improved header generation in pod2grutatxt.
 2008-12-11 09:49:30 grutatxt: New '--no-pure-verbatim' mode (Closes: #1015).
 2008-12-10 14:24:06 mp-5.x: Updated TODO.
 2008-12-10 07:25:44 gruta: New field 'description' (Closes:  #1050).
 2008-12-09 20:20:52 mp-5.x: Small documentation tweaks.
 2008-12-09 13:47:48 gruta: More comments in templates.
 2008-12-07 19:58:33 mp-5.x: New syntax color for special doc. blocks.
 2008-12-07 08:42:38 mp-5.x: Version 5.1.1 RELEASED.
 ...

And the script:

 #!/bin/sh
 # my-git-metachangelog.sh
 # Angel Ortega <angel@triptico.com> - public domain
 
 MONTHS=$1
 
 [ -z "$MONTHS" ] && MONTHS=6
 
 for r in *
 	do ([ -d $r ] && cd $r &&
 		git rev-parse HEAD > /dev/null 2>&1 &&
 		git log --no-merges \
 		--since="$MONTHS months ago" \
 		--pretty="format:%ai $r: %s%n")
 	done | \
 grep -v '^$' | sed -e 's/+[0-9][0-9][0-9][0-9] //' | \
 sort -r | less

2010-12-08 update: Fixed to also work on bare repositories.

Related

Calculated columns in PostgreSQL using triggers

Sometimes is useful to have columns that are automatically created using operations with other ones. Certainly this violates the Relational Model, but sometimes you don't have a choice if the database schema was given to you by a legacy system.

In my case, I found a living system with a table like this:

 CREATE TABLE users (
 	first_name VARCHAR,
 	family_name VARCHAR,
 	full_name VARCHAR PRIMARY KEY
 );

It's certainly aberrant; the full_name column is just a concatenation of the other two. For additional fun, it's the primary key.

PostgreSQL makes maintaining this monster easier by using triggers.

First, create the following function (this is in plpgsql, but it could be done in any programming language linked to the PostgreSQL engine):

 CREATE FUNCTION build_user_full_name_func () RETURNS trigger AS '
 BEGIN
 	NEW.full_name = NEW.first_name || '' '' || NEW.family_name;
 	RETURN NEW;
 END;
 ' LANGUAGE plpgsql;

What this function does should be obvious: update full_name concatenating the other two columns with a space in between.

The magic is done creating this trigger:

 CREATE TRIGGER build_user_full_name_trg BEFORE INSERT OR UPDATE
     ON users FOR EACH ROW
     EXECUTE PROCEDURE build_user_full_name_func ();

Whenever users is affected by an INSERT or UPDATE, the trigger is called, and full_name (re)built.

Disallow connections from an IP, in one line

If you are having an attack from an IP and want to ban it right now, use this ban_ip script:

 ban_ip() { iptables -A INPUT -s $1 -j DROP; }

Mouse cursor jumps like crazy under QEMU

Just set the following environment variable:

 export SDL_VIDEO_X11_DGAMOUSE=0

Cálculo de la letra del NIF español, en una línea de shell script

 nif() { echo $1$(expr substr TRWAGMYFPDXBNJZSQVHLCKET $(($1 % 23 + 1)) 1) ; }

Acepta como primer argumento el número de NIF (sin ceros por delante, si los llevara). Útil para añadir a ~/.bashrc.

How To Verify CD-R Data Retention Over Time?

http://hardware.slashdot.org/article.pl?sid=08/11/06/1549256

The following two interesting tools are referred there:

par2 - PAR 2.0 compatible file verification and repair tool

"par2 is a program for creating and using PAR2 files to detect damage in data files and repair them if necessary. It can be used with any kind of file."

dvdisaster - data loss/scratch/aging protection for CD/DVD media

"dvdisaster provides a margin of safety against data loss on CD and DVD media caused by scratches or aging media. It creates error correction data which is used to recover unreadable sectors if the disc becomes damaged at a later time."

Dvdisaster approach is specially interesting, as it can append its error correction information to an existing .iso file, using as much space as available to fill the smallest medium size (CD, DVD or DVD9). That information seems to be invisible, so it does not interfere with the media content.

 dvdisaster -i cd.iso -mRS02 -c

Related

More on Apache's mod_rewrite

Links:

What I use here to emulate static pages:

 RewriteEngine On
 RewriteRule /(img|download)/.* - [L]
 RewriteRule ^/(.+)/index\.html$ /?t=TOPIC&topic=$1       [PT]
 RewriteRule ^/(.+)/(.+)\.html$  /?t=STORY&topic=$1&id=$2 [PT]
 RewriteRule ^/(.+)/$            /?t=TOPIC&topic=$1       [PT]
 RewriteRule ^/rss\.xml$         /?t=RSS                  [PT]
 RewriteRule ^/sitemap\.xml$     /?t=SITEMAP              [PT]

Related

Sharing code via email with git

In a clone of a remote repository, start a branch to hold your code:

 git-checkout -b my-changes

Do your work and commit changes as you like.

When you are happy with your work, create a temporary directory:

 mkdir /tmp/patches

Then change back to the master branch and build a set of patches from your branch with git-format-patch:

 git-checkout master
 git-format-patch -n master..my-changes -o /tmp/patches

A bunch of files, one per changeset, have been created in /tmp/patches. Now, use the git-send-email to send them, one per email, to the original author.

 git-send-email --no-thread --from me@here --to author@remote /tmp/patches

If author@remote acknowledges your changes, you can just merge your changes to the current master head and delete your temporary branch:

 git-merge my-changes
 git-branch -d my-changes

On the remote machine

If author@remote uses mutt, he can move to his working copy, call it and type |git-am on each message.

Related

Matching git-svn strange authors to useful email addresses

Git-svn is a useful tool to communicate with a Subversion repository from git. You usually clone a repository with a command like:

 git-svn clone svn+ssh://angel@svn.example.com/path/to/prj/trunk prj

And a prj directory is created with a full git repository. Then, you get another people changes with git-svn rebase and commit yours with git-svn dcommit.

It has one drawback, though; authors are mangled to something like

 Author: angel <angel@2e99d34b-3c1d-0410-9ca7-923d03b5684e>

which is not only ugly but completely useless.

To map this monstrosity to real user email addresses and names, use the following steps:

First, create the file ~/.gitusers with content like this:

 angel = Ángel Ortega <angel@triptico.com>
 otheruser = Other User <ouser@example.net>

If you converted your SVN repository from CVS with something like cvs2svn you'll also find entries like this:

 Author: (no author) <(no author)@2e99d34b-3c1d-0410-9ca7-923d03b5684e>

Those ones can be converted with another line in ~/.gitusers.

 (no author) = Really Me <email@example.org>

And now, instead of the usual git-svn clone command, use the following ones:

 mkdir prj
 cd prj
 git-svn init svn+ssh://angel@svn.example.com/path/to/prj/trunk
 git config svn.authorsfile ~/.gitusers
 git-svn fetch

Always maximized X11 terminal emulators

Add this to your ~/.bashrc:

 [ -z "$DISPLAY" ] || wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz

Desactivación de servicios telefónicos molestos

Telefónica (fijo)

Contestador
Llamar al #10#

Movistar

Buzón
Llamar al 537
Avísame
Llamar al 579

My preferred way of C code formatting

They mean: Kerninghan & Ritchie indentation, 4 spaces, no cuddled else, no tabs.

 indent -kr -i4 -nce -nut *.c

I previously used:

 indent -kr -i8 -nce *.c

Related

Setting global git variables

 git config --global user.name "Angel Ortega"
 git config --global user.email angel@triptico.com

Related

Building a point-to-point VPN (SSH tunnel) in one line

 pppd noauth 192.168.33.1:192.168.33.2 \
     pty 'ssh root@REMOTE_HOST pppd notty noauth'

The remote host needs a passwordless authorized key.

Redirecting a full site to https

 <Location />
        RewriteEngine on
        RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1
 </Location>

Related