categories: design
web
dev
near life experience

ttf fonts repository

June 11th, 2009

I had a bunch of interesting fonts.. So I uploaded them to move them to another machine later.
I thought I’d hack a script to show them to me also..
It spits out this kind of content..

04b24.ttf download
04b_03Regular.ttf download
04b_03bRegular.ttf download
04b_08Regular.ttf download
04b_09Regular.ttf download

The trick is, it uses image magick to write the text to a image file.
Also, the other trick is that if a font is missing a preview, it makes it. But only 5 at a time!
So, if I want to add fonts, I simply upload them to the directory and forget about them.
You do want to set a limit to how many previews you generate at a time.
This is a relatively expensive operation, and you don’t want to piss off your sysadmin.

bash grab bag

June 11th, 2009

Some posix utilities can be a mindfuck. They can also be incredibly useful.

  • I have a directory with txt files. I want to move all files which filename is a number to another directory.
    $ for var in $(ls ./ | grep "^[0-9]\+\.txt$”); do mv $var ./; done;
  • If you have a text file, each line is an argument for another program.
    For example, I recently had to get md5 sums for a ton of pdf files.
    This turns out to be an expensive operation, so I did it in steps.

    1. I save where the files are to a text file.
      find ~/ -type f -iname "*.pdf" >> /tmp/found_pdfs
    2. Next.. I need to feed the paths as arguments to md5sum..
      xargs --delimiter=\\n --arg-file=/tmp/found_pdfs md5sum >> /tmp/found_pdfs_md5sums

    Now, this oculd have been done with find’s -exec, but I’m concerned this would take longer..
    find ~/ -type f -iname "*.pdf" --exec md5sum '{}' >> /tmp/fond_pdfs_md5sums

  • You have a large text file and you need to see the end or beggining..
    Beggining..
    head ~/file.txt
    End..
    tail ~/file.txt
    But but.. I need to see more! Maybe 2000 lines?
    tail -n 2000 ~/file.txt

How to Solve your Windows Problems

June 3rd, 2009

Introduction

I came to work to see this message today on my chat box.

(18:57:05) Coworker A: If you get a chance, could you look at my son’s computer down here?
Coworker B got it a little acceptable a few months ago.
He is a sophomore at School A and will be starting summer school soon.
The computer has that stupid Vista which blue screens all the time.
Coworker B said for him to list down the codes when it blue screens. He did.
Can you check it out and see if it can be fixed or if I need to buy him a new computer?

DO YOU NEED WINDOWS?

The comfort zone

I was a windows user for ten years.
I went to work at an IT firm, I was doing graphic design and some web stuff at the time.
The shop had some real coding going on as well, none that I was a part of.
The coders were all using posix machines- linux, solaris, etc.

I noticed their s**t didn’t stink. That is, the machines did not crash.
I wanted that in my life. I knew windows and I knew it well. Well enough to know there is no
such thing as a stable windows box.

Moving to linux meant no more adobe photoshop. No more ms office stuite, no more video games-
not really. No more macromedia flash development. (No more guis really.. But at the time I had
no idea.. Simply suggesting to me that I have to ‘click’ on something tells me the software
is a piece of s**t)
It meant my box was going to stop being a cesspool of viruses, cracked video games, illegal
martian ballpoint sex porn. It meant my machine wwas going to be used for one thing and one
thing only: work.

I bit the fucking bullet. It took me a year to get comfy, and it worked.
I have no more problems with my operating system. I don’t lose data anymore.
I don’t have crashes.

Why the comfort zone is not comfortable

As I said, it took me a year to get used to linux, to another operating system.
But what I can do today, my ability as a worker- man and machines- is an order of magnitude
deeper than anything it could have been otherwise.
I would still be stuck picking my nose and wondering where my excel spreadsheet went.
Hoping that the ms word file I got sent via email will open up in my computer.

Windows is an evolutionary dead end

The operating systems are getting worse. It’s costing more and more- for software, for
maintenance, for repairs that shoudn’t even need to be made.

Linux used to be harder to use than windows. To learn, to install. Yes.
Maybe two years ago that started changing.
Today, it is harder to use windows than to learn and use linux or mac os.

If you continue to use windows computers, you will have more and more problems.
Your old data will not be accessible in a few years.
You will lose your children.
You will be raped.
You will die.

Windows alternatives

Mac

This will cost money. This will work. Mac is a great machine.
Mac will work well, there is a learning curve associated.
This is a safe choice. It’s expensive.

Linux

This is what I use.
Now, if you go online and search for download linux, you will be overwhelmed with
the choices.
There’s fifty different names like Fedora, Ubuntu, Debian, Suse, etc etc etc.
These are all what we call ‘distributions’.
That means that it’s linux, plus some stuff such as a gui (the mouse, the icons, the things
you think are the computer). They all run linux.
Try Ubuntu, I hear people are very happy with it.

time: 12 horus
You will need to read up on intalling linux.
Don’t install over your old hard drive, buy a new one.
Download your distribution of choice, burn to cd or dvd..
time: 15 minutes
Install.

IF YOU STILL NEED WINDOWS

Use a secondary drive to store all your base

If you have a workstation (a box you can open, without a screen, a monitor and keyboard plug in ),
keep all your personal data in a secodary hard drive.
This is good practice in general.

This will allow you to simply throw the primary drive in the trash in case your system becomes
unusable. And using windows, it will.

time: 15 minutes
Go to BestBuy or whatever black market hardware source you have and dish out the
$60 for a new hard drive.
Ebay is a good choice also, Amazon.com as well.
Don’t buy the largest drive you can afford, or the cheapest.
Buy a known brand, Seagate, Western Digital.
Don’t buy a strange drive, such as a solid state “ssd” drive.
time: 60 minutes
Become educated acquainted about hard drives.
time: 35 minutes
Open your machine, install a secondary drive, also known as a slave drive.
You will have to refernce back to google to read up on
‘installing a slave drive into my workstation’.
time: 20 minutes
Boot up, go to ‘your computer’, find where the ‘c’ drive is, you should see another hard drive
icon with another letter. This drive will likely need to be formatted.
time: 40 minutes
Read up on ‘formatting a slave drive on windows’.
Format the drive.
Move your data. Stop saving any data to the old drive (c drive, ‘your’ desktop, etc).

Now, next time you get the blue screen, next time your windows software blows up and eats your
baby, all your data is “safe”.

You can simply buy a new hard drive, and install windows into ‘it’, keeping the slave drive
with all your stuff where it is.

searching through the linux man pages

March 20th, 2009

UNDERSTANDING WHAT YOU HAVE

Every fucking thing on your linux machine is documented.
And all of this documentation- is in that machine right now- for your free access.

Let me explain this another way- because I was a windows user for many years- so I think you need to get this.
Using linux for a while now, you must have heard of grep, sed, awk, find, all this other weird shit.
And it’s all … weird.. You see some posix hacker sit at your machine and roll out one liners that make your car start up in the driveway- check your and your momma’s email yahoo and gmail accounts remotely.. and..
Well- but you try it and it’s freaky.
Linux command line tools, (cli) The Command Line.. MR COMMAND LINE to you.. cli tools will do a lot with little pushing around.
If you want to turn your fucking computer off.. we just type poweroff, hit enter- and by god, motherfucker– you can walk away without looking - the shit will actually go down and shut off.
There’s no if about it.

EVERYTHING IN THE COMMAND LINE IS DOCUMENTED

People bitch a lot about the linux man pages.
I think the linux documenation is actually really fucking good.
It takes time to get used to it and understand why it seems to cryptic.

The documentation is very specific- if you want to know the options for a command, you look that up and you get what the options are. Period.

If you want to see example usage, chances are that there is a document about example usage.

This is not the windows way- in shitty documentation land- we have everything in one place. You have a manual for using your mouse, and you have everything from plugging it in and what is ‘usb’- to ergonomics of grabbing your mouse.

In linux, this would be looked down upon.
Here we do shit different- we do shit right.
You do NOT cover ergonomics and usb in a mouse manual.
You leave that to the ergonomics team, and to the usb team.
You reference to the ergonomics manual, and the usb manual. Period. Stop.

As a result of this, linux documentation is perfect. It’s vast, it’s huge and detailed- and if you find the document about the mouse, guess what- the only thing that document is about- is the mouse. Every fucking thing about it. More than you want to know- but about the mouse. Just the mouse. No cats.

ENTER MY CONCERN

Looking up information in the man pages is not so easy, when you don’t know what you’re looking for- exactly.

For example.
I am using imagemagick convert.
I want to colorize an image. I want to look up imagemagick color names.
What are they? I know there’s an imagemagick color name table..
I know it’s in my linux man pages somewhere.

How do you find this?
Now.. I hope you get that my question here is somewhat rhetorical.

I know someone who uses imagemagick all the time or who knows where the man pages will say something STUPID like “well, just look inside /usr/lib/do…… ” - I don’t want the ANSWER you bumblefuck.
I want to know how to find the answer. And googling it is ok- but why on earth would I when it’s all inside my machine.
(Fuck, ok.. yeah.. I fucking google it.. but let’s forge that for a minute here.. cause it’s so damn fine when I don’t)
So, let’s find somw ways.. how to search for documentation in your linux box..

SEARCHING THROUGH THE LINUX MAN PAGES

My first gut feeling here was maybe two cups of find, two teaspoons of grep and if it got bland- maybe a dash of perl regex.

But I resisted this.. I went to ‘man –help’ and ‘man man’, to see what we have about searching.
It seems you can look up keywords.. so I tried imagemagick colors

man -K imagemagick colors

Sure enough, it slowed my 64bit girl down some.

The first result shows up, I’m prompted to either see it or continue searching…

group elements by similarity

March 18th, 2009

I wrote some awesome useful subs and put them in String::Similarity::Group, it lets you provide a list of strings, and groups or isolates by similarity.
You can also provide a list of strings, and it tells you which is the closest match to a control string.

There’s also a cli interface called gbs, you could group files by similarity for example.

$ ls ./ | gbs

Basic API usage is..

To group elements by similarity

use String::Similarity::Group 'groups';
use Smart::Comments '###';

my @groups = groups( 0.8, qw/james joe jimmy vanessa carla vanesa kuiper MAarchus archus/ );

### @groups

To find most similar element in group

use String::Similarity::Group 'similarest';
use Smart::Comments '###';

my ($closest, $score) = similarest( qw/james joe jimmy vanessa carla vanesa kuiper MAarchus archus/, 'James' );

### $closest
### $score