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 http://en.wikipedia.org/wiki/Raspberry_pi and http://www.raspberrypi.org/.

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 (http://www.raspberrypi.org/phpBB3/viewtopic.php?t=9210); 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 - http://www.windowsphone.com/it-it/apps/7eb3b1d3-0183-46c0-8c55-5f1cf652eb30 – 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 http://www.windowsphone.com/it-it/apps/e8aa1299-e011-486c-9f61-3232c892b17b )

Another approach I’m interested into: Squeezeplug - http://www.squeezeplug.eu/?p=201 – 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        
go
checkpoint        
go
alter database [database_name] set recovery full        
go
backup database [database_name] to disk = 'd:\temp\filename.bak' with init        
go
dbcc shrinkfile (N'DATABASE_NAME_log' , 1)        
go

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      
AS
-- 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
DECLARE tableCursor CURSOR
FOR
    select [name]
    from dbo.sysobjects
    where  OBJECTPROPERTY(id, N'IsUserTable') = 1
FOR READ ONLY
--A procedure level temp table to store the results      
CREATE TABLE #TempTable
(
    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)
BEGIN
    --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
END
--Get rid of the cursor      
CLOSE tableCursor
DEALLOCATE tableCursor
--Select all records so we can use the reults      
SELECT *
FROM #TempTable
--Final cleanup!      
DROP TABLE #TempTable
GO 

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".

Tuesday, March 06, 2012

Facebook again–apps on fan page

How can I publish an app on a fan page?

Obviously you need to have admin rights on the destination page, then you can use this url:

https://www.facebook.com/dialog/pagetab?app_id=APP_ID&next=APP_URL

Substitute APP_ID with your app id (get it from the settings page on https://developers.facebook.com/apps) and insert the “Secure canvas url” (find it on the same settings page).

Then, if everything’s ok, you will be prompted with a list of pages; choose one and you’re done.

New Fan page look (“Timeline”)

After the switch to the new fanpages look and feel, I noticed that there is a limit on the number of apps that you can “pin” in the apps thumbnails list. The limit is 12 (three rows of 4 apps).

This is not a limit to the number of apps that a fan page can host; only a limit to the thumbnails list.

Monday, October 10, 2011

Facebook–how to set the height of your tab

Today I had to set to more than 800 pixels the height of my tab. I found here a simple solution, thanks a lot to Amit Jain.

Steps in brief:

  1. in the app “canvas settings” set the height to “Settable”, like in the image shown below.
  2. add to the <body> line: style="overflow: hidden" (to remove the scrollbars)
  3. add to your main <div> (the one that contains your html) the style: style="height:2000px; width:520px;" – obviously you will set your desired height
  4. finally, just below the <body> tag, add this code:

<div id="fb-root"></div> 
<script> 
  window.fbAsyncInit = function() { 
FB.Canvas.setAutoResize(); 
  }; 
  (function() { 
var e = document.createElement('script'); e.async = true; 
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
document.getElementById('fb-root').appendChild(e); 
  }()); 
</script>
 

that’s it – worked for me!

2011-10-10_1630

Monday, September 05, 2011

Windows Phone traffic on Fiddler? Here’s how

Yes, it’s possible, and there is a fantastic page that explains how, here’s the link.

All the configuration needed took a couple minutes, and it worked perfectly.

Thanks Eric for this great article!

Thursday, September 01, 2011

Sql Server–find some texts in Stored Procedures

I often need to search for some texts in the body of stored procedures. This query can help:

SELECT routine_name, routine_definition
FROM information_schema.routines
WHERE UPPER(routine_definition) LIKE UPPER('%texttobesearched%')
AND routine_type='procedure'

EDIT: just discovered that this method has some problems with long stored procedures; found another one that works better:

declare @searchString varchar(100)

Set @searchString = '%' + 'text to be searched' + '%'

SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @searchString
ORDER BY SO.Name

Wednesday, August 31, 2011

Windows Phone 7 - NavigateToString, WebBrowser, and anchors

I needed to show some html in a page, using a WebBrowser control and the NavigateToString method.

The html was ok; it has some anchor in it to move from a section to another.

When I tested it in a standard web browser, or loading it with the phone IE9, worked perfectly.

But when I loaded the same html in the app page, using as I said the Navigatetostring method, the anchors didn't work anymore.

Then I tried to use some javascript to move to the anchors, using location.replace(#anchorname) – but again when I tested the html outside the app it worked… but not in the app.

I posted the question to the MSDN Forums, end Eric Fleck suggested me to use another approach, while confirming that the wrong behavior is in the latest RC of the WP7 tools.

The new approach is described in detail in this MSDN page, and basically uses IsolatedStorage to save the html fragments in order to load them in the WebBrowser using the .Navigate method. This way all the anchor links work… and I’m happy Sorriso

G’day everybody!

Tuesday, August 23, 2011

Some “metro style” windows phone backgrounds

Found today: I like these backgrounds, see if you like them:

- Metro Lock for Windows Phone

- Metro Lock 2 for Windows Phone

A couple images, in Mango Occhiolino flavour:

Metro Lock (Mango)Metro Lock 2 (Mango)

Windows Phone 7 – Mango time

Today I uploaded my first Mango update. My “Fatto Quotidiano” app now id 7.1 compatible!

To celebrate this I also rewdesigned completely the layout, now the app is more readable, I think that it’s really better than before.

A couple of useful links / resources:

- To download the Windows Phone SDK 7.1 Release Candidate go here: SDK 7.1 RC

- With the RC you will also have at your disposal a great tool: the “Marketplace Test Kit”, integrated with Visual Studio. The tool “provides a suite of automated, monitored, and manual tests to help make sure that your applications are accepted in the Marketplace the first time you submit them”. Read about it here.

To see the list of my WP7 apps, click here

Wednesday, March 23, 2011

Sql Server Management Studio & “WTF”

Open Sql ServerManagement Studio, Open a New Query, Type WTF and press Enter.

Have fun.

Saturday, February 26, 2011

Some WP7 apps

ilomilo got a new refresh, a whole bunch of new puzzles to solve! great game - check this link: http://blog.ilomilo.com/2011/02/ilomilo-windows-phone-7-title-update/

Yelp! is available on the italian marketplace - http://officialblog.yelp.com/2010/11/yelp-gets-a-windows-phone-7-app.html

Resco Radio is a really good internet radio manager – check out this link http://wmpoweruser.com/resco-radio-for-windows-phone-7-preview/

Birdsong is my favorite Twitter client, in the next days the 1.2 release will be out, http://red-badger.com/Blog/

Friday, February 25, 2011

Mail in spam? Try (also) this…

Recently some messages from one of my site started being marked as spam by gmail and others.

The particular message is the “confirm registration” one, and it’s easy to understand that it’s imperative that it does not go to the spam folders… if you want regitered users, I mean.

I noticed that in the standard routine that we use to send mail messages there was no setting for the “Message-ID” header. I tried to add it (see below a code sample) and now the “marked as spam” rate is incredibly low!

See here (Wikipedia) a brief explanation of what the particular Message-ID header field is.

Here is the code sample, in bold the three new lines:

private bool PrepareAndSendMail(string emailKey, string senderName, string senderEmail, string destName, string destEmail, StringDictionary args)
{
    try
    {
        MailMessage m = new MailMessage();

        m.From = new MailAddress(senderEmail, senderName);
        m.To.Add(new MailAddress(destEmail, destName));
        m.Subject = MailSettings.Emails[emailKey].Subject;

        // this is to limit the "marked as spam" messages
        Guid messageGuid;
        messageGuid = Guid.NewGuid();
        m.Headers.Add("Message-ID", messageGuid.ToString());

        m.IsBodyHtml = true;
        m.BodyEncoding = Encoding.GetEncoding("iso-8859-1");
        m.Body = ReadTemplateFromFile(Globals.MapPath(MailSettings.Emails[emailKey].Template), args);

        return SendMail(m);
    }
    catch (Exception ex)
    {
        Log.Error("An error occurred sending mail", ex);
        return false;
    }

}

Friday, October 01, 2010

Windows Phone 7 – emulator’s shortcut

I discovered about these shortcut only today, so maybe this short post it can be useful to other devs.

When you enter a textbox in the emulator, the virtual keyboard comes up; and you can use it with your mouse. But if you need to enter text in a faster way, you can hit PageUp, and use the “real” pc keyboard.

Then you can switch back to the virtual keyboard with PageDown.

Other useful shortcut:

  • F1 – corresponds to the Back button on the emulator
  • F2 – the "Start" button on the emulator
  • F3 – the Search button on the emulator

Windows Phone 7 – my first app :-)

I’m working on a little application for the new Windows Phone 7 operating system.

The app, TimeToRead, is a client for Read It Later (http://readitlaterlist.com). Its goal is to let you access your “reading list” when you have time… to read something you pinned earlier.

It will provide you the lists of read / unread / all articles; tapping an article you can read it directly from the web version or choose to read only the “text version” (this is a service provided by readitlaterlist.com site), mark as read an article and finally tweet about the article on your Twitter account.

The app uses some libraries like json.net and Hammock for REST in order to access the external sites. It’s not very complicated, still I think that it can be useful – let’s see.

A few screenshots:

image

image

image

and here’s a little video I posted on Msdn Italy’s Facebook page – it’s not of the latest release, but it gives an idea.

Ciao!

Monday, August 02, 2010

Sql Server Fragmentation

Found in an article on SqlServerCentral (VERY useful site), some scripts that show the fragmentation degree of your database objects:

-- check fragmentation on @db
Declare @db     SysName;
Set @db = 'MCD_SAWFC_PROD';

SELECT CAST(OBJECT_NAME(S.Object_ID, DB_ID(@db)) AS VARCHAR(20)) AS 'Table Name',
CAST(index_type_desc AS VARCHAR(20)) AS 'Index Type',
I.Name As 'Index Name',
avg_fragmentation_in_percent As 'Avg % Fragmentation',
record_count As 'RecordCount',
page_count As 'Pages Allocated',
avg_page_space_used_in_percent As 'Avg % Page Space Used'
FROM sys.dm_db_index_physical_stats (DB_ID(@db),NULL,NULL,NULL,'DETAILED' ) S
LEFT OUTER JOIN sys.indexes I On (I.Object_ID = S.Object_ID and I.Index_ID = S.Index_ID)
AND S.INDEX_ID > 0
ORDER BY avg_fragmentation_in_percent DESC

The following SQL can be used to rebuild all indexes for the specified table;

ALTER INDEX ALL ON <Table Name> REBUILD;


while the following SQL can be used to rebuild a specific index.



ALTER INDEX <Index Name> ON <Table Name> REBUILD;


Alternatively, indexes can be reorganised. The following SQL can be used to reorganise all indexes for the specified table;



ALTER INDEX ALL ON <Table Name> REORGANIZE; 


while the following SQL can be used to reorganise a specific index.



ALTER INDEX <Index Name> ON <Table Name> REORGANIZE; 

Tuesday, June 29, 2010

stsadm, where is it?

I often forget the location of stsadm, the admin command line tool for MOSS. Here it is:

%COMMONPROGRAMFILES%\microsoft shared\web server extensions\12\bin

bye