Wednesday, July 17, 2013

xml validation, on osx

In OSx, you can rely on the libxml package, which includes xmllint. You will call this on a command line, it's fast and reliable.

A couple of example:

To validate a xml file:

xmllint --noout yourxmlfile.xml

To validate a xml file against a schema:

xmllint --noout --schema yourxsdfile.xsd yourxmlfile.xml

Thursday, May 02, 2013

Kindle - how to remove (easily) items from personal documents

If you, like me, have a lot of "personal documents" in your Amazon library, you know how difficult it can be to remove items from that list.
You have to remove titles one by one, or - if you are fast enough - two or three of them for each try.
Now, this is really annoying.

Enter javascript and bookmarklets...

Below you will find some javascript code that can be used to remove all the items you see on a particular page. In the Amazon Kindle Library page you will have to select "Personal Documents" from the drop down list (otherwise the bookmarklet won't work), and enter a search term in the search textbox, in order to limit the deletion only to the items you really want to delete. This is important, as the javascript will kill ALL the docs you see in the page... ok?

Before you can use the bookmarklet, you'll have to create it. In Chrome this is quite easy:
- right click on the bookmarks bar
- click on "Add Page"
- enter a title for the page name
- paste the javascript code in the "URL" field

That's all: be careful to select only the items you really want to delete, click the bookmarklet you created, and all those documents will go... forever!!!

javascript:(function(){ var v = new RegExp("PersonalDocuments"); if (!v.test(document.URL)) { return false; } {a=document.getElementsByClassName('rowBodyCollapsed');for(var i = 0; i<a.length; i++){Fion.deleteItem('deleteItem_'+a[i].getAttribute('asin'));};return; }})();

Saturday, March 16, 2013

Wordament, and date/time settings

Noticed today, while trying to play Wordament on my brand new Nokia 920 (a white one, if you wonder) that I could not connect to my Xbox Live account.

Tried every obvious hint, no way. Then I noticed that in a FAQ page on the wordament site they refer to the correct date and time setting as a needed requirement.

So... I went to the settings page, disabled the "automatic date and time setting", choose the correct date, time zone, and time, and went back to Wordament.

Now it works without a problem!

Hope this helps, maybe the same issue exists with other Xbox live games...

Wednesday, October 03, 2012

PowerShell elevated privileges

Just a quick note: if you need to perform any task that requires elevated privileges, you can throw the following command in PS and gain it: PS> Start-Process powershell -Verb runAs It's the same as "Run as Administrator" bye

Sunday, July 22, 2012

raspberry pi experiences, and some related windows phone apps

So, after some weeks, I received my Raspberry PI card. If you don’t know anything about it please check and

I started a hunt to find the “right” setup for my needs: link the thing to my LCD tv, and use the PI both as a media center and a linux box to surf internet, read mail, download torrents, and to give my sons an idea of a “different” approach to computers :-).

I tried some distribution, Debian, Raspbian, RaspBMC, OpenELEC… and every single setup had its pros and cons. Actually I decided to stick with Debian “Wheezy” and OpenELEC 4 Debian on it (; when I launch OpenELEC I can also use my Windows Phone to control remotely the media center, and it’s quite fun (also the geekness factor in doing that is very high). The WP app I use is “XBMC Remote”, from 7illusions - – they also build a Squeezebox remote control for WinPhones, “SqueezeRemote”.

Right now I’m installing on Debian X session a torrent client (Transmission) and at the same time verifying disk space and network configuration thru ssh with another Windows Phone client (the name is “The SSH Client”, it’s free and it works )

Another approach I’m interested into: Squeezeplug - – I have another empty SD Card… eheh

I’ll tell you how it goes… happyPI :-)

Tuesday, May 08, 2012

Sql Server 2008, disk space

Found these commands useful, when dealing with Sql Server 2008 disk space allocation and log shrinking; in sql 2008 as you probably know you cannot use any more the command BACKUP LOG databasename WITH TRUNCATE ONLY as shown for example here: to obtain the same result you can do the following:

alter database [database_name] set recovery simple        
alter database [database_name] set recovery full        
backup database [database_name] to disk = 'd:\temp\filename.bak' with init        
dbcc shrinkfile (N'DATABASE_NAME_log' , 1)        

To monitor disk space allocated, check for the usage of

EXEC sp_spaceused @updateusage = N'TRUE';

The following procedure uses the sp_spaceused procedure to list each table’s space:

CREATE PROCEDURE GetAllTableSizes      
-- Lists spaced used data for ALL user tables in the database
DECLARE @TableName VARCHAR(100)    --For storing values in the cursor
--Cursor to get the name of all user tables from the sysobjects listing
    select [name]
    from dbo.sysobjects
    where  OBJECTPROPERTY(id, N'IsUserTable') = 1
--A procedure level temp table to store the results      
    tableName varchar(100),
    numberofRows varchar(100),
    reservedSize varchar(50),
    dataSize varchar(50),
    indexSize varchar(50),
    unusedSize varchar(50)
--Open the cursor      
OPEN tableCursor
--Get the first table name from the cursor      
FETCH NEXT FROM tableCursor INTO @TableName

--Loop until the cursor was not able to fetch      
WHILE (@@Fetch_Status >= 0)
    --Dump the results of the sp_spaceused query to the temp table
    INSERT  #TempTable
        EXEC sp_spaceused @TableName

    --Get the next table name      
    FETCH NEXT FROM tableCursor INTO @TableName
--Get rid of the cursor      
CLOSE tableCursor
DEALLOCATE tableCursor
--Select all records so we can use the reults      
FROM #TempTable
--Final cleanup!      

Friday, March 30, 2012

Speed Up Windows 7 Taskbar Navigation with a Registry Hack

As you can read on Lifehacker (here), and on a number of other sites, with a simple registry hack you can modify the way windows handles clicks on stacked apps in the taskbar.

Here is the tweak:

  • Launch regedit.exe (Win+R, then paste regedit.exe)
  • Navigate in the left tree control to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
  • Go to Edit->New->DWORD (32-bit) Value
  • Name the value LastActiveClick
  • Hit enter to assign the value and change it to 1
  • Restart Explorer and you're good to go.

To restart Explorer without rebooting, open the Task Manager (Ctrl+Shift+Esc) and end the Explorer.exe process. Then create a new task (under "File") and paste "explorer.exe".