Archive for the ‘Work’ Category

Publishing shared google reader items to twitter.

Wednesday, March 16th, 2011

Seems Feedburner by google which I’ve been using up until now is unreliable with posting to twitter, so this is a half post on what I’ve done to try getting it working, and half a post trying to test if it works with my wordpress at least 😛

Because Google reader’s rss feed of shared items is formatted a little strangely I made a short php script to parse it into a nicer format. OK, mainly getting rid of the annoying ‘Shared by <username> ‘ bit.

&lt;?php

$username = "Psykar";

$url = "http://www.google.com/reader/public/atom/user/10440293858886564202/state/com.google/broadcast";
$page = file_get_contents($url);

echo preg_replace('/Shared +by +'.$username.'/',null,$page);

?&gt;

To find your shared items url, just open reader, get the url which gets replaced, and remove the html entities %2F either side of the ID
eg for mine:

http://www.google.com/reader/view/#stream/user%2F10440293858886564202%2Fstate%2Fcom.google%2Freading-list

is 10440293858886564202

Plug this ID into the URL above

http://www.google.com/reader/public/atom/user/&lt;userid&gt;/state/com.google/broadcast

I then used feedburner to import this php script (hosted on my server) and activated the ‘socialize’ feature, which should be publishing all my shared items to twitter now, in a nice format.

Replacing notepad on Vista

Friday, March 11th, 2011

Having fun today trying to replace notepad on vista with my favourite text editor of late – Notepad++

I followed most of the instructions here:

http://www.howtogeek.com/howto/12617/how-to-replace-notepad-in-windows-7/

and got the replacment notepad.exe file from here:

http://notepad-plus.sourceforge.net/commun/misc/NppLauncher.bin.zip

But found that upon trying to run it, I would get a very annoying warning:

Despite my efforts, unchecking this box would still produce the same error, even running as administrator.

Even going into the properties of the file and ‘unblocking’ it wouldn’t stick.

 

I found this blog post:

http://blogs.xntrix.com/2007/09/replacing-notepad-on-windows-vista-with.html

But the links in it are dead!

 

My solution in the end: Copy the notepad.exe file I had downloaded somewhere else, unblock it there then copy it into the directories mentioned.

Silly me for not doing that to start with – because obviously it’s not the same executable you find in the notepad++ program files directory.

File recovery

Wednesday, December 22nd, 2010

So someone left us with a corrupt USB stick at work a couple of days ago, no joy with that, but she had a USB stick which was still working which she had deleted the same data off recently, and it hadn’t been used since.
After a crapload of mucking around and a lot of reference to

https://help.ubuntu.com/community/DataRecovery
http://forums.gentoo.org/viewtopic-t-365703.html
http://matt.matzi.org.uk/2008/07/03/reconstructing-heavily-damaged-hard-drives/

I combined elements of all the above to the following script which recovered most of the deleted files.

The main trick was the arguments on icat – I was confused for a while because it was finding all the files, but only creating 4kb of them. Turns out I needed the -r -a arguments.

Script is below, run on a file created by the following command

# The -r argument is used to recover only deleted files
ils -r /media/Images/USBImage | awk -F '|' '{print $1}' &gt; /tmp/inodes
#!/bin/sh
imgpath="/media/Images/USBImage"

# This was due to taking the raw disk data rather than just the partition
# The offset was found using autopsy - part of sleuth tools, used for this.
imgargs=" -f fat -o 63 ${imgpath} "
outpath="/media/Images/Recovered/"

for inode in $(cat /tmp/inodes) ; do

	ffind ${imgargs} $inode

	if [ $? -eq 0 ]
	then
		echo "INODE: $inode"
		INODEDIR=$(ffind ${imgargs} $inode | awk -F "* " '{print $2}')
	 	echo "INODEDIR: ${INODEDIR}"
		REALDIR=${outpath}$(dirname -- "$INODEDIR")
		FILENAME="${outpath}${INODEDIR}"
		mkdir -p "$REALDIR"
		# I found this worked better than the method used by one of the links
		# to create directories. What happens is a directory inode may create
		# a file if a later file tries to write to a directory which IS a
		# file, the file is removed and the directory is created instead
		if [ $? -eq 1 ]
		then
			rm -R "${REALDIR}"
			mkdir -p "${REALDIR}"
		fi

		echo "FILENAME: $FILENAME"
		#echo "${imgargs} $inode &gt; $FILENAME"
		icat -r -s ${imgargs} $inode &gt; "$FILENAME"

		echo ""
	fi
done