Chivil blog

Aller au contenu | Aller au menu | Aller à la recherche

avril, 04 2011

Unix, clear screen

Once again, since I didn't find anything relevant using Google, I'm posting a solution here to a simple problem I had.

To simply clear (reset) your terminal's screen in a shell, the character sequence is escape character, then c

in python

import sys
sys.stdout.write("\033c")

or in perl

print "\033c";

mars, 09 2011

Screen, vim, 256 colors

Since I had to dig a little to find how to make vim works fine in 256 color mode (using set t_Co=256), I'm pasting it here so it might help some people :)

So, I only had to add this:

termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce on

to my .screenrc file.

Then just screen -r again and it should work fine (did for me, on a Debian Lenny, and an Ubuntu 10.10)

edit: seems that in some cases, you have to start a new screen session :-/

septembre, 01 2010

Readability bookmarklet on Android 2.2

Since I've been trying use Readability for quite a while on my Android phone and just found out how to do so today, I'm posting it here :)

For those who don't know Readability, it's a bookmarklet that, once triggered, will remove all layout of a website, only to keep the contents. It's really useful when reading pretty much any article.

Since phones have a very limited space to display content, it's often painful to zoom in and try to fit an article's text in the screen. Readability is really helpful here.

Since Android's browser doesn't allow bookmarking javascript, we'll have to trick him a bit.


First, go to http://lab.arc90.com/experiments/readability/ and customize your layout.

Then copy the link

read.png


Then, go to Pastebin to paste the javascript you just copied

pastebin.png

(triggered their antispam here)


You'll get an url that you will be able to type inside your Android browser (that's a pain, be careful of lower/upper case)


Once you get the Pastebin url on your phone, just long "click" (press) on the textarea (not the first block ;) to copy the link in your phone's clipboard

copy.png


Then, go to your bookmarks, add a new one, and just paste the link using the long click on the Location field

addbookmark.png


And your done, now you just have to visit that bookmark when reading an article to trigger the script readme.png

décembre, 09 2009

Git: find commit pointing to specific file

Just posting here a solution to a problem I had and could not find easily.

The problem was .. how do I find which commit contained a specific version of a file?

With the file at hand, I could simply use git-hash-object to have its hash

git-hash-object file.pl

afb2de5691078405dde84b3c1ba07ae3611f5396

Easy enough. The real problem was : how do I find references to this hash?

The only command I found to do that is git whatchanged

git whatchanged

commit 8296847023cf52d9273f59e93da1f18fa1313004
Author: TrucMuche <muche@54c5169c-8210-0410-b4c6-88e7fb53b929>
Date:   Fri Nov 27 13:49:37 2009 +0000

    some stuff

Then just search for the short version of the hash (afb2de5):

commit 8d7e23f9589a2858afd7b4f0f5f8f26c8c440541
Author: TrucMuche <muche@54c5169c-8210-0410-b4c6-88e7fb53b929>
Date:   Mon Nov 16 15:26:57 2009 +0000

    some more stuff

:100644 100644 426edf6... afb2de5... M  path/to/file.pl

If anyone knows a better way let me know :-)

juin, 09 2009

Disable Safari 4 Webpage Previews

The easy lazy way :

chmod a-w ~/Library/Caches/com.apple.Safari/"Webpage Previews"

Safari (or anything else) won't be able to write to this directory afterward, it should not grow day after day.