Monthly Archive for August, 2006

Integrate blogging into the browser

I was starting to explore how to integrate Wordpress into the browser. The default way to blog something is to use the current browserwindow to go to the post page, and the results are that you’re navigating away from the page you want to blog about. Since the Blog button is just a bunch of javascripts, I’ve decided to make it blog in a new window. A Quick google search for “javascript location browser.open” gave me:
Displaying Popup Windows
With a example that shows a hyperlink using the window.open method to open a new browser window.

The Button/Favorite link/bookmark now holds this: Remember to fix example.com to your domain. Here is my modified WordPress Blog button:

javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}window.open('http://www.example.com/wp-admin/post.php?text='+encodeURIComponent(Q)+'&popupurl='+encodeURIComponent(location.href)+'&popuptitle='+encodeURIComponent(document.title), 'blog');void(0);

If you’re new here, you may want to subscribe to my RSS feed.
Thanks for visiting!

Create a lockfile with perl

Create a lock file?

lock.pl

#!/usr/bin/perl
use Fcntl;
sysopen(FH, "file.lock", O__WRONLY|O_EXCL|O_CREAT) or die "Error sysopen: $!";
</perl>
 
Another perl-code for file-locking
<pre lang="perl">#!/usr/bin/perl -wT
use Fcntl ':flock';
sysopen(FH, "File", O_RDWR|O_CREAT) or die "Error sysopen: $!";
flock(FH, LOCK_EX) or die "Error flock: $!";
 
# write file..
 
flock(FH, LOCK_UN) or die "Error flock: $!";
close FH or die "Error close: $!";

Make mini.c program to run the perl code..

main(int argc, char **argv) {
exec("./lock.pl", argv);
}

It makes no sense. I had it on disk, cleaning up, putting the code on web instead. Is it usefull? I belive not…

A link to a webpage with usefull security programs

Most of the programs there have I allready tried out. However, I think the page was nice and worth mention:

http://sectools.org/

Making music mix.. Exploring

I haven’t been mixing much music. So, don’t expect a pro mix. Besides, I don’t think I’ve selected the most easy songs to mix, and the end of the mp3 cuts fast in my opinion.

Download the mix

Content of the mix:


Dreaming (Libra Mix)    BT
Flaming June (BT & PVD Edit)    BT
Tracking Treasure Down  Gabriel & Dresden
humanity        atb
Nothing (Dub Mix)       Holden & Thompson
Ghost vs. Eighties (AvB Mashup) Deepsky feat. Jes Brieden vs. Yilmaz Altanhan
Let Go  Gabriel & Dresden
01 - Tatu - Not gonna get us    Tatu
Grace - Not Over Yet (BT's Spirit of Grace)     BT

And I had to convert the wav file to mp3. I did that using lame.


$ lame --vbr-new mix.wav mix.mp3
LAME version 3.96.1 (http://lame.sourceforge.net/)
CPU features: MMX (ASM used), SSE, SSE2
Using polyphase lowpass filter, transition band: 17960 Hz - 18494 Hz
Encoding mix.wav to mix.mp3
Encoding as 44.1 kHz VBR(q=4) j-stereo MPEG-1 Layer III (ca. 10x) qval=3
Frame          |  CPU time/estim | REAL time/estim | play/CPU |    ETA
30626/30628 (100%)|    1:43/    1:43|    2:19/    2:19|   7.7484x|    0:00
32 [  173] %**
40 [   16] %
48 [   60] %
56 [  125] %*
64 [  251] %***
80 [ 1504] %%*****************
96 [ 2360] %%%**************************
112 [ 3826] %%*********************************************
128 [ 5162] %**************************************************************
160 [11778] %%%%%%%%%%%%%%*********************************************************************************************************************************
192 [ 3368] %%%%%%%**********************************
224 [ 1343] %%%%*************
256 [  482] %%****
320 [  180] %**
average: 146.3 kbps   LR: 2708 (8.842%)   MS: 27920 (91.16%)

Writing LAME Tag...done
ReplayGain: -7.9dB

Plant fly attracted by Idun Red Hot Chili Ketchup

I had some plant fly in my apartment. One day when I had left the Idun Red Hot Chili Ketchup standing on the table, I’ve noticed that the flyes gathered around it. I think the fly are attracted to it because of how it smells. Normal fly often puts their egg in things that are decomposing.

Small Plant Fly

First of all, I think I’ve found a way to attract the fly.

Secound, I’m wondering what Idun serves in their Red Hot Chili Ketchup. Is it decomposing tomates?

Idun Red Hot Chili Ketchup

Find the biggest file

find . -printf "%k %p\n" 2>/dev/null|sort -rn |head -n 50 |more

Capture screenshot and resize to 300x in width

A small perl program with combination of programs from imagemagic does the resizing automatic..

#!/usr/bin/perl
 
$size = 300;
$t = time();
$f = "/tmp/captureIMAGEx300.$t.bmp";
`import $f`;
$info = `file $f`;
$w = 0;
$h = 0;
 
# test.png: PNG image data, 1070 x 865, 16-bit/color RGB, non-interlaced
# bbb.bmp: PC bitmap data, Windows 3.x format, 1025 x 872 x 24
if ($info =~ m/, ([0-9]+) x ([0-9]+)/) {$w = $1; $h = $2; };
print "$w x $h\n";
 
$newh = $h / ($w/$size);
print "new size: $size x $newh\n";
`convert -resize ${size}x${newh} $f screenshot.$t.png`;

A pirate?

I’ve noticed that someone in Oslo has a pirate-flag outside their window..

a pirate

SSH X11forwarding needs xauth to set $DISPLAY variable

To get any program to be forwarded through your ssh connection, you need xauth installed on the ssh-server that you’re logging into.

After just putting the xauth in /usr/X11R6/bin/ on the server, the X11 forwarding worked fine for me, even when X11/XFree86/X.org wasn’t installed.

The fastest way to get xauth installed is to get the binary from the XFree86 package. The alternative way is to build the XFree86 from source.

Next time you login, you will se:

/usr/X11R6/bin/xauth:  creating new authority file /home/user/.Xauthority
 
$ set
...
DISPLAY=localhost:10.0
...

ERROR: ld.so: object ‘/usr/lib/installwatch.so’ from LD_PRELOAD cannot be preloaded: ignored.

Problem:


$ checkinstall

checkinstall 1.5.3, Copyright 2001 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.

Installing with "make install"...

========================= Installation results ===========================
ERROR: ld.so: object '/usr/lib/installwatch.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib/installwatch.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib/installwatch.so' from LD_PRELOAD cannot be preloaded: ignored.

Copying documentation directory...
/var/tmp/aiYblAlLilDCqljYaYdl/installscript.sh: line 13: 7823 Segmentation fault mkdir -p "/usr/share/doc/..."

**** Installation failed. Aborting package creation.

Cleaning up...OK

Bye.

On my system, running checkinstall as root, caused the / on the system to be chmod 700 and some crap where put there. Not smart!
The problem is that the checkinstall package in the debian stable are broken. Solution is to use the version in the unstable(1.6.0). That one worked fine for me!

Mini-howto:

(You will probably want to add testing and unstable repositoies to your /etc/apt/sources.list first. See how to do it here)

apt-get install -t unstable checkinstall