Blog switch
I completely switched my blog. Now all new entries should be at http://yannesposito.com
I almost all done from Scratch using a web page generator engine called nanoc (http://nanoc.stoneship.org). I use the old 2.2 version.
I’ve got some work to enable all feature wordpress had given to me. I’ve almost finished doing so.
GitHub behind the evil corporate firewall
Thanks to github providing git using port 443, because it is mostly open.
Simple and efficient, create an ssh alias
> cat ~/.ssh/config Host github User git Port 443 Hostname ssh.github.com
edit the file .git/config into your project :
... [remote "github"] url = git@github:user/Project.git fetch = +refs/heads/*:refs/remotes/github/*
Multi-line grep
After many, many times I use many different tricks to implement a multi-line grep, I’ve done one myself I called it <code>mlegrep</code>:
#!/usr/bin/env zsh
separator='\n\n'
while [[ ${1[1]} = '-' ]]; do
case ${1[2]} in
F) separator="${1[3,-1]}" ; shift ;;
*) print "unknown option : $1" >&2; exit 2 ;;
esac
done
if (($#>1)); then
print "usage: $0:t [-Fseparator] REGEXP [FILE ...]" >&2
exit 1
fi
value="$1"
shift
perl -ne 'BEGIN{$/="'$separator'";} if ( $_ =~ m/'$value'/ ) { print }' "$@"
hope this help,
Y.
YPassword v1.4
I updated the last version of YPassword to 1.4, mostly bug correction.
More informations or direct download.
get disk usage by file type
A simple and usefull script to evaluate usage of your disk by filetype. Should be improved
to manage extension with more than 3 letters. For this you can just replace the /\.{2,3}$/ by
/\..{2-6}$/ to accepts extension from 2 to 6 letters long.
#!/usr/bin/env zsh
if (($#<1)); then
cible='.'
else
cible=( "$@" )
fi
find $cible -type f -exec du -k {} \; | awk --posix '
{
if ($2 ~ /\.[^/]{2,3}$/) {
ext=$2;
sub(/.*\./,"",ext);
} else {
ext="withoutExtension";
}
taille[ext]+=$1 ;
nb[ext]++ ;
}
END{
for (x in taille) {
printf "%10d ", nb[x];
print x" for "taille[x]" Ko";
}
}' | sort -n
hope this is usefull
Better passwords for YPassword
I recently updated YPassword to 1.3. Just added the base64 output in order to make my password shorter. See my blog entry on yannesposito.com.
From fluid to fixed layout and why
I recently changed my mind about fixed layout in web design. Click to see why.
How to manage accessibility with iWeb
I discovered this week-end iWeb use JavaScript to manage the navigation bar. The resulting problem is: no blog post is referenced in Google.
Now I did manage the problem with a simple trick.
- First I opened the Web directory in the interface (I have a bug, and have to remove the Web link). It then reappear and create a second mount: yannesposito-1 which contain the Web directory on my iDisk.
- My site’s name is YBlog
Once my iDisk Web folder was mounted then I opened a terminal and did :
cd /Volumes/yannesposito-1/Web/Sites/ { print '<div style="display: none">' for fic in YBlog/**/*.html(.); do print '<a href="/'$fic'">'$fic:t'</a><br/>' done print '</div>' } > /tmp/hiddenReferences.txt
I then “copy/paste” the content of /tmp/hiddenReferences.txt into an HTML snippet in my “welcome” page.
But tonight, I’ll do a much better thing (to automatize a little more), and to prevent the problem that, in fact the iFrame is not searched by Google.
I’ll make a simple text box, relatively small and hidden, containing only one link to:
http://yannesposito.com/hiddenReferences.html
And I’ll create a script called updateiWebReferences.sh with the following content
#!/usr/bin/env zsh WebDirectory="/Volumes/yannesposito-1/Web/Sites" cd $WebDirectory { : ###### Print XHTML 1.0 Strict prefix ##### cat << END_TAG <?xml version="1.0" encoding="utf-8"?>' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>all site references</title> </head> <body> <h1>All pages of my site</h1> <ul> END_TAG : ###### Add all pages with their title ##### for fic in YBlog/**/*.html(.); do pageTitle=$( perl -pe 'if(m#<title>(.*)</title># ) { if ( $1 ) { $_=$1."\n";} else { $_="" ; } } else { $_=""; }' < $fic ) if [[ $pageTitle = "" ]]; then pageTitle=span style="font-weight:bold;color:#aa55aa;">"$fic:t:gs#_# #" fi print '<li><a href="/'$fic'">'$pageTitle'</a></li>' done : ###### End of the XHTML page ##### cat << END_TAG </ul> </body> </html> END_TAG } > $WebDirectory/hiddenReferences.html
And I’ll just have to launch this script once per new blog entry, or each time I change a blog post title, just after I published my iWeb website. And now all my blog entries are referenced in google.
Tell me if you founded this trick usefull.
join in zsh
Unlike the join utility which make a join similar to SQL ones. Here is a function to make the same work as the join function in javascript, Perl or Python:
> join ';' 'hello world!' "I'm here!" "I'm happy"
hello world!;I'm here!;I'm happy
Here is a short solution:
function join { local res="" if (($#>0)); then local sep="$1" shift if (($#>0)); then res=$1 shift while (($#>0)); do res=$res$sep$1 shift done fi fi print $res }
My two cents on Cappuccino
Here is one of my long post: My two cents on Cappuccino.
This was my first impression of Cappuccino after trying to do the tutorials.
In substance: I like the concept and I dislike the implementation. But there is very few to add to convince me.