Category Archives: dev

command line wordpress via WordPress::CLI

Ok- Just released a beta version of WordPress::CLI, this is a command line set of tools to interact with wordpress.
This is pretty awesome and useful. It really speeds up posting tons of stuff to wordpress instead of using the icky gui.

  • upload a post to wordpress to one or more categories
  • set a date for a post, make it appear 5 years back
  • upload images to your wordpress blog via the command line
  • experimental (wors for me, see caveats in docs): set titles, set description, set date- for media files you upload

I thought thigs may be of interest to other people- since I’ve put out a little stuff on this before- and I get asked about this a lot.
This distro has fewer dependencies. It’s very simple. It’s mainly an interface to WordPress::XMLRPC, with some added hacks.
It does some cool useful things, like upload a text file content as post, lets you set date- you can upload media- etc etc.
All via the command line, remotely.
It’s extremely useful to me when I have to set up a site for a client, for example.

Ever wanted to say something like ..

   wordpress-upload-post ./content

Now you can. Yes.
Wait wait.. .. what aobut..

   wordpress-upload-media ./files*jpg

Yes.

It gets better too.
You can set category, date..
You can browse latest posts with

   wordpress-info

Seriously- check this distro out, please send me feedback via rt.cpan.org !!

I had a previous wordpress cli set of tools that did some awesome things, as mentioned- but these were too complicated. This in turn is easy- these commands just interact with WordPress::XMLRPC.

Please try this out, and enjoy- and feedback, please tell me what’s wrong- what
to improve. All of this is under cvs, so feel free to submit diff patchest etc.
Everyone gets credit for any contributions.
This is gpl software.

And yes, this post was uploaded with wordpress-upload-post !

Getting rid of flash

Flash rules

I love flash.
However- flash is not web content. Flash is a system to present animated media
to users who want to see it.

Spam is any email received which you did not request. By this definition I
hold dear to my heart- learned from those who know better than I do- anything
on a website that blinks or makes noise, is spam.

If you own a website, flash makes sense to use if you’re into the media
business. If I visit a website for a movie- and the entire site is flash- I
can accept. If I go to youtube- ok, makes sense. If you have a website, and
you explicitly state the following link is to something that contains flash
that you want me to see, ok.

I love flash.
Flash rules.

Flash usage on the web sucks

Overall, this blanket statement is one that does not leave me wanting for
allies.

What I do to block flash

I use the adblock filter for firefox.

I ad a custom blocking rule, for anything matching *.swf. It’s
effective. Almost brutal.
To allow flash on youtube, I go to youtube, and opt to “disable adblock for
this site only”. Note, I don’t disable adblock, I select the option to disable
on this site only.
Do this for other sites you do wish to view flash on. I can’t think of where
else that would be, though.
This makes it so automatically, the only sites you see flash in, are the sites
you decide.

automatically setting version in code with cvs


Introduction

I maintain a lot of code/scripts/packages/modules with version control.
It”s really useful to have automatic versioning of something.

What am I talking about?

There are certain things a command line interface program (a command) should do.
One is, there has to ve a -h or –help flag to get basic help.

Another thing- is that somehow it should be able to tell you what the version is.
This may be inside the help output, or it may be triggered by the -h or –help option.

CVS

If you”re using some kind of version control system ( which you should- and if you don”t,
then stop reading and go figure out basic cvs usage. ), there are several special
strings that you put in your code that will automatically be updated It can recover hard drive recovery service lost due to all types of problems, from simple accidental file deletions to full system crashes and reformatted drives. by cvs.

One of them is “$Revision:$”, this gets automatically updated every time you commit a change
to such file in cvs.

This way, you never have to change the version number in your code by hand. You can have cvs
automatically do this.
This is useful if you want to keep up to date the date and version of last changes – in your pod
documentation, in a perl script.. shell script.. etc.

setting VERSION in a perl script

code

 our $VERSION = sprintf "%d.d", q$Revision: 1.4 $ =~ /(\d )/g;
vim abbreviation


 iab plv- our $VERSION = sprintf "%d.d", q$Revision: 1.0 $ =~ /(\d )/g;

setting VERSION in a bash script

code


 VERSION=$(printf "%d.d" $(echo "$Revision: 1.6 $" | sed "s/\$\|Revision:\|\./ /g"))
vim abbreviation

 iab shv- VERSION=$(printf "%d.d" $(echo "$Revision: 1.6 $" <bar> sed "s/\$\<bar>Revision:\<bar>\./ /g"))

Using the vim abbreviations provided

I hate trying to remember the code lines shown. It sucks. That”s not what people were made to do.
Computers were made to do these things- so .. The abbreviations.
You can have the abbreviations available to you by putting these lines in your .vimrc file..

 iab shv- VERSION=$(printf "%d.d" $(echo "$Revision: 1.6 $" <bar> sed "s/\$\<bar>Revision:\<bar>\./ /g"))
 iab plv- our $VERSION = sprintf "%d.d", q$Revision: 1.0 $ =~ /(\d )/g;

So when you type out plv- and a whitespace character (space, tab, return (newline) etc.. ) You”ll
get the expansion you want. You may want to read more about vim abbreviations, I wrote a small program to help in creating them from text blurbs.

Setting LS_COLORS colors of directory listings in bash terminal

This one I underestimated the importance of. But no more.

If you really use vim/perl/unix as I do- you are in bed with the command line. You”re looking through a lot of file listings, regularly.

Using most guis, such as kde/gnome on ubuntu/fedora/suse/debian.. You”ll notice when you do an ls on a directory- you most likely, by default, get some funny ephemera manifestations. What I mean is, directories may be listed in a different color. Maybe they are bold. And regular files are normal text. And some of them are in different colors!

What”s up with that? Do we really give a shit if every jpg is red and every gif is blue, pdfs are purple and then notice also- JPG is not detected as a file ext to highlight and jpg *is*. Try it, change the ext of a JPG file to jpg, the color changes.

What is up with that? Well- I had been pleasantly ignoring that since- forever. I never cared to meddle or alter the settings, or even to look if there was a setting to affect that.

But recently I”ve been really curious to learn not just more code- more programming- but more of *how to work* more efficiently. I looked up how to affect these color and text formatted listings of directories- hoping that it may be helpful when looking through distros, through filesystems.. And you know what.. it is. Do you remember using vim and then one day actually taking the time to search and replace, properly, with capture.. And.. Wasn”t it really fucking useful?

Ok, this one I know you”re gonna roll your eyes at. And I did too, for years. But I would like you to take ten minutes of your life to give this a ride and see for yourself that it does help out a little. And the life of the code… These little things add up- using find xargs grep, using cv, perl one liners- and I”m gonna have to vouch for this one too. Directory listing text formatting.

  1. Ok, the thing you are looking to alter is a shell environment variable- on bash it”s LS_COLOR.
  2. What is it set at currently? Run set and grep out for LS_COLOR:
    $ set | grep LS_COLOR
    LS_COLORS="no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;35:*.cmd=00;32:*.exe=00;32:*.sh=00;32:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.t=93:*.pm=00;36:*.pod=00;96:*.conf=00;33:*.off=00;9:*.jpg=00;94:*.png=00;94:*.xcf=00;94:*.JPG=00;94:*.gif=00;94:*.pdf=00;91"
    
  3. Alright, wtf just happened. This string tells ls that when ls –color is called, these are the colors/text formatting to use.

    Now, ls –color? When have you run that flag?
    This is set as an alias in some bashrc file somewhere. Likely not your ~/.bashrc. But in some /etc/$BASHRC?? file. If you want to find out in which exact place you”re defaulting to use ls –color …

    $ find /etc/ 2>/dev/null | xargs grep -s "alias ls"
    /etc/profile.d/colorls.sh: alias ls="ls --color=tty" 2>/dev/null
    /etc/profile.d/colorls.csh:alias ls "ls --color=tty"
    

    Now, how the heck is this being called??? Look at your ~/.bashrc, it may have an entry to include /etc/bashrc if it exists, and then.. well.. there”s some other default profile voodoo and such I”m not versed in.

  4. How it works..

    The string value of the LS_COLOR environment variable is parsed as a hash, internally.
    The stream of garble is understood as.. The delimiter is the color (:) symbol. The first part is what the element of the directory listing is, then assignment (=), and a style code. More than one style code can be assigned.

    For the following chunk of string: di=00;1:fi=00:*.php=00;34, it means:

    di(directory) =(assignment) 00(normal text) ;(and) 1(bold)
    :(delimiter, next entry..)
    fi(file) =(assignment) 00(normal text)
    :(delimiter, next entry..)
    *.php(everything matching *.php) =(assignment) 00(normal text) ;(and) 34(blue)
    
  5. How to change it!

  6. All you need to do to see it change before your eyes, is to go to a command line prompt, and type in:

    $ LS_COLOR="di=00:fi=00;1:*.php=00;34"
    $ ls
    

    You”ll notice that makes all regular files appear bold, all directories in “normal text weight” and default color (black on white, white on black)- and php files are blue (or whatever color is mapped to that slot).

    Now, if you wanted to make that change permanent (instead of only to that one terminal session you just opened)- you would enter that into your ~/.bashrc file .. as:

    export LS_COLOR="di=00:fi=00;1:*.php=00;34"
    
  7. Knowing the codes:

    Please do note.. that”s a pretty lousy string to use. It”s just an example. You need to play around with it and figure out what you really want.
    For that, you need to know what the codes are.. for the filesystem elements (no,li,di.fi.. etc), for setting up regexes (*.pm)- and what the codes mean (1 bold, 00 normal, 9 Please note that high end free healthcare plans will be subject to a 40% excise tax come 2017. strikethrough).
    I picked up a good list from Bartman.

    Here”s that same list with some extras added- these work properly on GNU bash 3.0.

    0 = default colour
    1 = bold
    4 = underlined
    5 = flashing text
    6 = no change
    7 = reverse field
    8 = black
    9 = strikethrough (cool!)
    10 - 29= no change
    30 = light green
    31 = red
    32 = green
    33 = orange
    34 = blue
    35 = purple
    36 = cyan
    37 = grey
    38 = underline
    39 = no change
    40 = black background
    41 = red background
    42 = green background
    43 = orange background
    44 = blue background
    45 = purple background
    46 = cyan background
    47 = grey background
    90 = dark grey
    91 = light red
    92 = light green
    93 = yellow
    94 = light blue
    95 = light purple
    96 = turquoise
    100 = dark grey background
    101 = light red background
    102 = light green background
    103 = yellow background
    104 = light blue background
    105 = light purple background
    106 = turquoise background
    
  8. One way of managing colorschemes..

    Yup. You can have colorschemes for dir listings. Crazy, huh?

    All you would need to do is to save your colorschemes in files.

    For example in ~/.ls_color-joe

    export LS_COLORS="no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:ex=00;35"
    

    If you want to import that via the current shell, just use the “.” operator, the command would be:

    . ~/.ls_color-joe
    

    And now when you do a listing, it will use those colors. My god, though, why would you want to do that? What if you don”t have the same ~/.bashrc in every system? You really want to copy and paste that string amongst various machines?

    What could be convenient is to store them as files, and call them into your current shell with the dot operator.
    Or.. You can do this in your ~/.bashrc as..

    if [ -f "~/.ls_color-joe"]; then . ~/.ls_color-joe; fi
    
  9. Making it easier to edit the color string

    Now.. I hate to edit a string like that.. “no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:ex=00;35″.. Yuck!
    So, what I”ve done for myself is my colorscheme file let”s me enter things like:

    # images
    *.jpg 35
    *.gif 35
    *.xcf 33
    
    # code
    *.sh 91
    *.pl 91
    

    The file is still called the same way as explained above, it”s just a bash file.. But.. it has a little magic. It allows human formatted LS_COLORS strings to automatically be turned into the proper bash environment variable string.

    Or you could save the human readable format in a flat text file, for example ~/.mylscolors

    # HUMAN_FORMATTED_DATA
    # list one per line
    
    # these are basic filesystem items
    no 00 # normal
    fi 00 # file
    di 00 34 # directory
    ln 00 36 # link
    pi 40 33 # pipe
    so 00 35 #
    bd 40 33 01
    cd 40 33 01
    or 01 05 37 41
    mi 01 05 37 41
    ex 00 91 # executable
    *.ai 00 91 # adobe ill
    *.doc 00 91 # msword shit
    
    # data, such as .db, .csv
    *.csv 95
    *.dsv 95
    *.db 95
    *.sql 95
    *.meta 95
    # CONFS
    *.xml 95
    *.yaml 95
    *.yml 95
    *.conf 95
    # [a-z0-9]*rc
    
    # by now you should really know that everything after the # pound sign is a comment.. use vim, nice syntax highlighting
    

    And then use this command to turn it into the LS_COLORS string:

    $ cat ~/.mylscolors | grep "\w" | grep -v "^#" | sed "s/#.\ //" | perl -lane "printf "%s=%s:", shift @F, join ";", @F;"
    

    What if you wanted to save that output to your ~/.bashrc ? Yes, you could copy and paste the output into your ~/.bashrc. But that is not the unix way…

  10. Doing it via the command line instead of cutting and pasting..

    What we do is redirect the output into the ~/.bashrc.
    First let”s make sure we don”t havbe a LS_COLORS string in there.. We can look inside via:

    $ cat ~/.bashrc | grep LS_COLORS
    

    If we do, let”s just rip that right out..

    $ perl -p -i -e "s/^export LS_COLORS=.*$//" ~/bashrc
    

    Is perl too weird for you? We can use bash..

    $ cp ~/.bashrc ~/.bashrc.bak; cat ~/.bashrc.bak | grep -v LS_COLORS > ~/.bashrc
    

    The -v flag is match reverse, so no lines containing LS_COLORS will be spat out. Backing up the file is good, and also.. if you tried to to this to the file itself.. You”re end up with a blank file:

    # THIS IS WRONG and will delete your file:
    cat ~/.bashrc | grep -v LS_COLORS > ~/.bashrc
    

    Ok, now we can turn the string into the variable, the source being human readable content.. and save it to the ~/.bashrc..

    $ echo "export LS_COLORS=""$(cat ~/tmp/testlscolor | grep "\w" | grep -v "^#" | sed "s/#.\ //" | perl -lane "printf "%s=%s:", shift @F, join ";", @F;")"" # source was ~/tmp/testlscolor" >> ~/.bashrc
    

    Make sure you redirect the output as append “>>” and not overrite “>”.

    Great. What if we wanted to make this into a command? So we can use the source, the human legible format of a LS_COLORS string anytime?

    For that.. we need to more or less script all of our example…

  11. Making it all into commands

    The first thing we should do here, is separate this into two commands, one should be a unix filter, and the other.. should be the procedure we want .

    Now, a unix filter is the most important and useful kind of command you can write in unix. It simply takes standard input and spits to standard output. Read The Rule of Composition, it explains the idea behind filters.

    1. Making this a simple filter..

      Will make it so the process can be used for anything else.

      The cheap and simple way to do this, is do one of..

      a) Make it an alias in your ~/.bashrc
      This is a cheap and simple way to add commands to your environment. Aliases can be cool.

      In your ~/.bashrc, enter this line:

      alias string2lscolors="grep "\w" | grep -v "^#" | sed "s/#.\ //" | perl -lane "printf \"%s=%s:\", shift @F, join \";\", @F;""
      

      Now reload your config file “$ . ~/.bashrc”

      And let”s see what aliases we have, you should see your newly created alias, run the command “$ alias” to see a listing.

      We can now use that as a filter on the command line.

      b) Save it to a bash script
      Edit a file in your ~/bin directory.. make sure it”s got execute permissions..

      $ vim ~/bin/string2lscolors
      $ cat ~/bin/string2lscolors
      #!/bin/sh
      grep "\w" | grep -v "^#" | sed "s/#.\ //" | perl -lane "printf "%s=%s:", shift @F, join ";", @F;"
      $ chmod 0755 ~/bin/string2lscolors
      

      Awesome, now you can call the command “string2lscolors” anywhere you want.

      To try it out, do the above steps, and you can download my example human legible format file, and try it out..

      $ wget http://leocharre.com/docs/lscolorscheme.txt -O /tmp/lscolorscheme.txt
      $ cat /tmp/lscolorscheme.txt | string2lscolors
      no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;91:*.cmd=00;32:*.exe=00;32:*.gz=00;90:*.bz2=00;90:*.bz=00;90:*.tz=00;90:*.rpm=00;90:*.rar=00;90:*.zip=00;90:*.iso=00;90:*.cpio=00;31:*.c=33:*.h=33:*.sh=33:*.t=33:*.pm=33:*.pl=33:*.cgi=33:*.pod=33:*.PL=33:*.js=33:*.php=33:*.off=00;9:*.bak=00;9:*.old=00;9:*.htm=94:*.html=94:*.txt=94:*.text=94:*.css=94:*.avi=96:*.wmv=96:*.mpeg=96:*.mpg=96:*.mov=96:*.AVI=96:*.WMV=96:*.mkv=96:*.jpg=96:*.jpeg=96:*.png=96:*.xcf=96:*.JPG=96:*.gif=96:*.svg=96:*.eps=00;96:*.pdf=00;96:*.PDF=00;96:*.ps=00;96:*.ai=00;91:*.doc=00;91:*.csv=95:*.dsv=95:*.db=95:*.sql=95:*.meta=95:*.xml=95:*.yaml=95:*.yml=95:*.conf=95:
      
      c) You can make sure the thing is presented kind of decent, writing a minimal program..
      This means a few things.. One for damn sure, that if I ask for –help, I get help. There are no conditions about this. It simply has to be there. If you can”t assure your programs at least have the appropriate help docs- you should not be writing software, unless you”re using microsoft type environments, then- knock yourself out- You won”t be heard from again.

      The reason is that in any sort of interface- you must present your users with what they are already familiar with. This is explained in The Rule of Least Surprise. And by the way- those rules there, the basics of the unix philosophy.. Those are not little poems- those the FUCKING RULES, maggot! It”s what separates the women from the little girls. You don”t have to always abide by all of them- but you must aspire to at *least* make note of most of them.

      If you”re having any doubts about the supremacy of unix philosophy- please, read those rules, carefully, slowly. If you”re still in doubt, consider that programs written in unix shell ten or twenty years ago, still work today.

      This is how you would write the same one liner up there, as a more useful program.. Again, this is minimal, but you can see that instead of two lines we have 117.. See string2LS_COLORS.sh.

    2. Using the filter to automatically edit your ~/.bashrc..

      Soon…

My personal LS_COLOR environment variable for perl development- I have refined mine to be:

LS_COLORS="no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;35:*.cmd=00;32:*.exe=00;32:*.sh=00;32:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.t=93:*.pm=00;36:*.pod=00;96:*.conf=00;33:*.off=00;9:*.jpg=00;94:*.png=00;94:*.xcf=00;94:*.JPG=00;94:*.gif=00;94:*.pdf=00;91"

This helps me detect some things that are important to me, such as tests.t to stand out from other junk in t/, a different color for pod and pm files.. etc. very cool.

I”ve been using this across my servers. And it does help. It”s a very small thing to do, to improve your development environment. I suggest you try it out.

pan 0.133 crashes as soon as it starts up

I’ve had this happen to me a couple of times.
Pan crashes like it was written to do so.

# dmesg | grep pan
 domain 0: span 00000001
pan0: Dropping NETIF_F_UFO since no NETIF_F_HW_CSUM feature.
pan[3632]: segfault at b ip 00c15426 sp b7062098 error 4 in libc-2.7.so[bac000+153000]
pan[3752]: segfault at b ip 00c15426 sp b7a1c098 error 4 in libc-2.7.so[bac000+153000]

What I have experienced is that the tasks list is messed up.
Because I erase it, and restart pan, and voila.

I found this out beause pan was starting and crashing immediately.
Then I ran it as root, and it worked fine. Obviously- the problem was in the config stuff particular to the user.

So if you get funny pan crashes as soon as it starts up,..
Look for and delete: /home/myself/.pan2/tasks.nzb

Another error I had seen.. I had tried also running straight and seeing the output and I would get this:

$ pan
*** glibc detected *** pan: corrupted double-linked list: 0x0920db88 ***
======= Backtrace: =========
/lib/libc.so.6[0xc159aa]
/lib/libc.so.6(cfree+0x90)[0xc190f0]
pan(UUCleanUp+0x1da)[0x81a3b6a]
pan(_ZN3pan7Decoder7do_workEv+0x60c)[0x8175a8c]
pan(_ZN3pan10WorkerPool6Worker18worker_thread_funcEPvS2_+0x12)[0x81a2c02]
/lib/libglib-2.0.so.0[0x743a788]
/lib/libglib-2.0.so.0[0x7438bff]
/lib/libpthread.so.0[0xd3e50b]
/lib/libc.so.6(clone+0x5e)[0xc7fb2e]
======= Memory map: ========
00110000-00111000 r-xp 00110000 00:00 0          [vdso]
00111000-00209000 r-xp 00000000 fd:00 10198488   /usr/lib/libX11.so.6.2.0
00209000-0020d000 rw-p 000f7000 fd:00 10198488   /usr/lib/libX11.so.6.2.0
0020d000-00217000 r-xp 00000000 fd:00 26214508   /lib/libnss_files-2.7.so
00217000-00218000 r--p 00009000 fd:00 26214508   /lib/libnss_files-2.7.so
00218000-00219000 rw-p 0000a000 fd:00 26214508   /lib/libnss_files-2.7.so
00219000-0021d000 r-xp 00000000 fd:00 26214506   /lib/libnss_dns-2.7.so
0021d000-0021e000 r--p 00003000 fd:00 26214506   /lib/libnss_dns-2.7.so
0021e000-0021f000 rw-p 00004000 fd:00 26214506   /lib/libnss_dns-2.7.so
0021f000-0022a000 r-xp 00000000 fd:00 10422436   /usr/lib/gtk-2.0/2.10.0/engines/libmist.so
0022a000-0022b000 rw-p 0000a000 fd:00 10422436   /usr/lib/gtk-2.0/2.10.0/engines/libmist.so
0027a000-002a1000 r-xp 00000000 fd:00 20218265   /lib/libpcre.so.0.0.1
002a1000-002a2000 rw-p 00026000 fd:00 20218265   /lib/libpcre.so.0.0.1
002aa000-002ae000 r-xp 00000000 fd:00 10219054   /usr/lib/libXfixes.so.3.1.0
002ae000-002af000 rw-p 00003000 fd:00 10219054   /usr/lib/libXfixes.so.3.1.0
002b2000-002b9000 r-xp 00000000 fd:00 26214471   /lib/librt-2.7.so
002b9000-002ba000 r--p 00007000 fd:00 26214471   /lib/librt-2.7.so
002ba000-002bb000 rw-p 00008000 fd:00 26214471   /lib/librt-2.7.so
002bd000-002c3000 r-xp 00000000 fd:00 10219053   /usr/lib/libXrandr.so.2.1.0
002c3000-002c4000 rw-p 00005000 fd:00 10219053   /usr/lib/libXrandr.so.2.1.0
002c6000-0034e000 r-xp 00000000 fd:00 10194128   /usr/lib/libfreetype.so.6.3.16
0034e000-00352000 rw-p 00087000 fd:00 10194128   /usr/lib/libfreetype.so.6.3.16
00358000-00377000 r-xp 00000000 fd:00 26215938   /lib/libexpat.so.1.5.2
00377000-00379000 rw-p 0001f000 fd:00 26215938   /lib/libexpat.so.1.5.2
0037b000-003a2000 r-xp 00000000 fd:00 10194191   /usr/lib/libfontconfig.so.1.2.0
003a2000-003aa000 rw-p 00027000 fd:00 10194191   /usr/lib/libfontconfig.so.1.2.0
003ac000-003b1000 r-xp 00000000 fd:00 10219969   /usr/lib/libgtkspell.so.0.0.0
003b1000-003b2000 rw-p 00004000 fd:00 10219969   /usr/lib/libgtkspell.so.0.0.0
003e2000-003ea000 r-xp 00000000 fd:00 10218085   /usr/lib/libXrender.so.1.3.0
003ea000-003eb000 rw-p 00007000 fd:00 10218085   /usr/lib/libXrender.so.1.3.0
003ed000-003f5000 r-xp 00000000 fd:00 10219052   /usr/lib/libXi.so.6.0.0
003f5000-003f6000 rw-p 00007000 fd:00 10219052   /usr/lib/libXi.so.6.0.0
00409000-00412000 r-xp 00000000 fd:00 10219055   /usr/lib/libXcursor.so.1.0.2
00412000-00413000 rw-p 00008000 fd:00 10219055   /usr/lib/libXcursor.so.1.0.2
00415000-00445000 r-xp 00000000 fd:00 10194291   /usr/lib/libpangoft2-1.0.so.0.1800.4
00445000-00446000 rw-p 0002f000 fd:00 10194291   /usr/lib/libpangoft2-1.0.so.0.1800.4
00895000-0089e000 r-xp 00000000 fd:00 10194341   /usr/lib/libpangocairo-1.0.so.0.1800.4
0089e000-0089f000 rw-p 00008000 fd:00 10194341   /usr/lib/libpangocairo-1.0.so.0.1800.4
008a7000-008aa000 r-xp 00000000 fd:00 20218360   /lib/libgmodule-2.0.so.0.1400.6
008aa000-008ab000 rw-p 00002000 fd:00 20218360   /lib/libgmodule-2.0.so.0.1400.6
008ce000-008f4000 r-xp 00000000 fd:00 10192707   /usr/lib/libpng12.so.0.33.0
008f4000-008f5000 rw-p 00025000 fd:00 10192707   /usr/lib/libpng12.so.0.33.0
009bf000-009c1000 r-xp 00000000 fd:00 10219056   /usr/lib/libXcomposite.so.1.0.0
009c1000-009c2000 rw-p 00001000 fd:00 10219056   /usr/lib/libXcomposite.so.1.0.0
00aa8000-00abd000 r-xp 00000000 fd:00 26215943   /lib/libnsl-2.7.so
00abd000-00abe000 r--p 00014000 fd:00 26215943   /lib/libnsl-2.7.so
00abe000-00abf000 rw-p 00015000 fd:00 26215943   /lib/libnsl-2.7.so
00abf000-00ac1000 rw-p 00abf000 00:00 0
00ac3000-00ad3000 r-xp 00000000 fd:00 26215945   /lib/libresolv-2.7.so
00ad3000-00ad4000 r--p 00010000 fd:00 26215945   /lib/libresolv-2.7.so
00ad4000-00ad5000 rw-p 00011000 fd:00 26215945   /lib/libresolv-2.7.so
00ad5000-00ad7000 rw-p 00ad5000 00:00 0
00ae1000-00b24000 r-xp 00000000 fd:00 10194161   /usr/lib/libgmime-2.0.so.2.2.10
00b24000-00b37000 rw-p 00043000 fd:00 10194161   /usr/lib/libgmime-2.0.so.2.2.10
00b8d000-00ba8000 r-xp 00000000 fd:00 26215929   /lib/ld-2.7.so
00ba8000-00ba9000 r--p 0001a000 fd:00 26215929   /lib/ld-2.7.so
00ba9000-00baa000 rw-p 0001b000 fd:00 26215929   /lib/ld-2.7.so
00bac000-00cff000 r-xp 00000000 fd:00 26215930   /lib/libc-2.7.so
00cff000-00d01000 r--p 00153000 fd:00 26215930   /lib/libc-2.7.so
00d01000-00d02000 rw-p 00155000 fd:00 26215930   /lib/libc-2.7.so
00d02000-00d05000 rw-p 00d02000 00:00 0
00d07000-00d2e000 r-xp 00000000 fd:00 26215934   /lib/libm-2.7.so
00d2e000-00d2f000 r--p 00026000 fd:00 26215934   /lib/libm-2.7.so
00d2f000-00d30000 rw-p 00027000 fd:00 26215934   /lib/libm-2.7.so
00d32000-00d35000 r-xp 00000000 fd:00 26215931   /lib/libdl-2.7.so
00d35000-00d36000 r--p 00002000 fd:00 26215931   /lib/libdl-2.7.so
00d36000-00d37000 rw-p 00003000 fd:00 26215931   /lib/libdl-2.7.so
00d39000-00d4e000 r-xp 00000000 fd:00 26215932   /lib/libpthread-2.7.so
00d4e000-00d4f000 r--p 00014000 fd:00 26215932   /lib/libpthread-2.7.so
00d4f000-00d50000 rw-p 00015000 fd:00 26215932   /lib/libpthread-2.7.so
00d50000-00d52000 rw-p 00d50000 00:00 0
00d54000-00d66000 r-xp 00000000 fd:00 26215933   /lib/libz.so.1.2.3
00d66000-00d67000 rw-p 00011000 fd:00 26215933   /lib/libz.so.1.2.3
00d69000-00d84000 r-xp 00000000 fd:00 10205425   /usr/lib/libxcb.so.1.0.0
00d84000-00d85000 rw-p 0001a000 fd:00 10205425   /usr/lib/libxcb.so.1.0.0
00d87000-00d88000 r-xp 00000000 fd:00 10198498   /usr/lib/libxcb-xlib.so.0.0.0
00d88000-00d89000 rw-p 00000000 fd:00 10198498   /usr/lib/libxcb-xlib.so.0.0.0
00d8b000-00d90000 r-xp 00000000 fd:00 10213345   /usr/lib/libXdmcp.so.6.0.0
00d90000-00d91000 rw-p 00004000 fd:00 10213345   /usr/lib/libXdmcp.so.6.0.0
00d93000-00d95000 r-xp 00000000 fd:00 10213344   /usr/lib/libXau.so.6.0.0
00d95000-00d96000 rw-p 00001000 fd:00 10213344   /usr/lib/libXau.so.6.0.0
00da2000-00db1000 r-xp 00000000 fd:00 10219050   /usr/lib/libXext.so.6.4.0
00db1000-00db2000 rw-p 0000e000 fd:00 10219050   /usr/lib/libXext.so.6.4.0
00dfa000-00dfc000 r-xp 00000000 fd:00 10219051   /usr/lib/libXAborted

retrieving tv channel listings

Are you looking for tv listings ? I would like to suggest http://titantv.com

Letter to titantv.com


I’ve looked over your content and services off and on over the last (3?) years. I think there are some serious improvements.
I’m a unix hacker- I like tv listings. I’ve considered off and on to code a gpl cli to retrieve tvlistings from the net.
At this point, I can say that the service you provide is good enough that I have no need of such thing.
I can honestly refer anybody in need of tv listings to titantv.com.
I especially like the nice interface to add and remove channel lineup elements and simplify the color scheme.
Congratulations.

I’m learning unix philosophy.
I think that this one need- tv listings- is satisfied by this provider.

text to html

I’ve been trying out text2html. It’s pretty cool.
You point it to a text file (or stdin), and it spits out html.
There are some fucked up things about it though..

For one, by default, it does nothing.
Nah, I’m not kidding. It does nothing- spits out same shit that came in. Can you imagine if you ate an apple and shat and apple out, unchanged? That would not be cool. Ok ok.. so it does html entities.. fuck me..
Second- there’s no help option.
Every unix command must have a -h or –help option. Because it’s expected. The empirical *I* fucking expect it.
Instead you have to use $ man ‘text2html’. Oh- but.. wait.. what’s this? Not the complete manual? You have to read $ man HTML::FromText for the full options.
Shit.
This is enough to piss me the fuck off.

It does cool shit, but you have to wine and dine it before it’ll suck your dick. It won’t just take your fifty bucks to do it. And you know the unix way.. By default, this program should suck your dick, no surprises, and shut up.
It should eat my apple and shit out a shit.

Workaround..

Create an alias in your ~/.bashrc file. Add this line:

alias text2html='text2html --blockcode --bold --bullets --email --numbers --paras --tables --underline --urls'

Note that it won’t work until you start another shell session.

Now all options are on, and the thing behaves closer to what is expected.

To install this fine mess of a program… Well.. the application is awesome- the api is a fucking cracked out microsoft whore.
As root..

# cpan HTML::FromText
# man html2text

Here’s some example input and output…

Original Text:

I AM TEXT THAT WILL BE TRANSFORMED TO HTML

Let's see and try what happens here.. shall we.

And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will.

And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. This is to test that the next word
will be wrapped up, and there won't be a break between the 'word' and 'will'.

   - thank you
   - i am also thanked of course
   - you think?

ALSO WHAT ABOUT

   A definition.
      I am goint to think so very much

   And what about this on?
      I will also think that. Thank you.

Great. What about a link? http://leocharre.com

Done.

Html output..

I AM TEXT THAT WILL BE TRANSFORMED TO HTML

Let's see and try what happens here.. shall we.

And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will.

And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. And hopefully what we expect to happen will. This is to test that the next word
will be wrapped up, and there won't be a break between the 'word' and 'will'.

  • thank you
  • i am also thanked of course
  • you think?

ALSO WHAT ABOUT

A definition.
   I am goint to think so very much

And what about this on?
   I will also think that. Thank you.

Great. What about a link? http://leocharre.com

Done.


You may want to look at the source of this page for the little details. It’s pretty clean, very nice job. (No, it’s not being trasformed by freaking wordpress.. See wordpress raw html plugin )

help with installing tesseract ocr

# INSTALL.tesseract
# =================
#
# Installing tesseract can be tricky.
#
#
# 1) Some dependencies..
#
#
#
# You’re may need gcc-c++, automake (gnu automake), and svn (subversion).
# You can check if you have these using the ‘which’ command..
# which svn
# which automake
#
# If the command is not present, nothing happens.
#
# If you have ‘yum’ (fedora/rehat) or ‘apt-get’ (debian/ubuntu), you may want
# to simply try:
#
# apt-get install automake
# apt-get install subversion
#
# yum -y install subversion
# yum -y install automake
#
# If this does not work, you need to download the source packages and manually
# install them.
#
# You can get gnu autake from:
# http://www.gnu.org/software/automake/
#
# And subversion from:
# http://subversion.apache.org/
#
# As for gcc-c++ installed on your system- This is likely already present.
# If you’re missing gcc-c++, try using yum or apt-get.
# Here is where to read more about gcc
# http://gcc.gnu.org/
#
# 2) Get the source for tesseract..
#
# You may be able to simply install the SVN version of Tesseract by
# using these commands..

svn checkout http://tesseract-ocr.googlecode.com/svn/trunk/ tesseract-ocr
cd tesseract-ocr
./runautoconf
mkdir build-directory
cd build-directory
../configure
make
make install

#
# for more info, see google project on ocr, they use tesseract
#
# you can also try to run these commands as a script ( lines starting
# with a pound sign are comments and ignored bash/sh
# save this text as something like ‘INSTALL.tesseract’ and then run..
# sh ./INSTALL.tesseract

perl command line usage examples aka one liners

Search and replace..

You have a directory with many html files. In them- you have ocurrences of the email address jim@hardwire.com, you need to change it to james@gmail.com..

First, for curiosity’s sake.. What files have this text ‘jim@hardwire.com’ ?

find /home/myself/www/public_html -type f | xargs grep 'jim@hardwire.com'

This will output what files have that text, and where.1

I wanted to replace usage of one module in a test script with another.
The old module is DMS::AP::Base, I want to change the text in the tests to DMS::Base::AP

perl -p -i -e 's/DMS::AP::Base/DMS::Base::AP/g' ./t/*.t

There are many more detailed sources of information on perl one liners.2

browsing your partition with tree via the command line

These tools are useful for development.

Most of the time you work on the terminal, and to find your way around a project you use things like find, ls, and tab completion.
If you need more of a bird’s eye view, you may fire up a gui browser like konqueror. But that’s a gui, and guis are for users.

Another option is tree. Here is example output of tree:

[leo@localhost devel]$ tree
.
`-- WordPress
    |-- bin
    |   `-- wppost
    |-- lib
    |   `-- WordPress
    |       |-- Base.pm
    |       `-- Post.pm
    |-- t
    |-- wp-content
    |   `-- plugins
    |       |-- akismet
    |       |   |-- akismet.gif
    |       |   `-- akismet.php
    |       |-- hello.php
    |       |-- pictpress.php
    |       |-- pm_admin_menu.php
    |       |-- postmaster
    |       |   `-- readme.txt
    |       |-- postmaster.php
    |       `-- wp-db-backup.php
    |-- wp-mail.php
    `-- xmlrpc.php

9 directories, 13 files

Continue reading