Friday, October 29, 2004

Navigate to a desired URL typing one word in internet explorer

(Navegar a una URL escribiendo una solo palabra con Internet Explorer)

A long time ago I read a trick for internet explorer which avoids me a lot of typing. For example to go to the blogspot page for posting, I type in internet explorer the word post and it sends me to the http://www.blogger.com/app/post.pyra?blogID=XXXXXX. How?

Go to the desired URL, once loaded go to bookmarks and click in Add to bookmarks. In the name, put a single word(in the previous example I put post ). Be sure that the folder selected is Bookmarks(it could be has a start at its left), because the trick doesn't work in subfolders. Click on accept and all is done.

Now you type the word in explorer and it goes to the desired page.


Permalink: Navigate to a desired URL typing one word in internet explorer 

Thursday, October 28, 2004

XHTML FAQ. <img> tag disappears!!!

(Preguntas frecuentes de XHTML. La etiqueta <img> desaparece!!!)

As I can read into this FAQ (Same FAQ in Spanish), provided by the W3C(World Wide Web Consortium) many things about relationships between HTML and XHTML 1.0, why migrate to XHTML, which user agent support it, which mime type you must use, but also I have seen something that I'm surprised that img tag disappears!!! in XHTML 2.0.

The title of the section is Is <img> being replaced by in XHTML?, and the reason is very reasonable. All images are equivalent to some piece of content; If XHTML 2.0 allows you to put a src attribute on any element at all, this says that if the image is available, and the browser can process it, use it, otherwise use the content of the element. For example:

<p src="map.png"><span src="map.gif">Exit from station...</span></p>

Although it is better to use content negotiation if your server supports it (and most do):

<p src="map">Exit from station...</p>

Which would negotiate with the browser which sort of image it accepts, and give the browser its preferred sort. If there is no available image, then the content of the element would be used. This has an added advantage that you can later add other image types on your server and you don't have to change the page for it still to work.

One more thing: Other killed. The term browser, which should be replaced, in most cases by user agent. Just read Why do you say "user agent" everywhere, instead of "browser"?



Permalink: XHTML FAQ. <img> tag disappears!!! 

Google Cheat Sheet. Google search tips

(La chuleta de Google. Trucos para las busquedas)

I have read in Dirson that Google brings its Cheat Sheet.

Some examples:

~auto loan: loan info for both the word auto and its synonyms: truck, car, etc.
red * blue: the words red and blue separated by exactly one word.
[#]…[#]: Search within a range. DVD $100...150(DVDs between $100 and $150)

There are more, let's read and enjoy



Permalink: Google Cheat Sheet. Google search tips 

Tips for Google Desktop Search

(Trucos para el Google Desktop Search)

Via InsideGoogle I found this web page with many interested tips about Google Desktop.

Some of them are:

Some preferences you should set
Move index file to a different drive
Files on Mapped Network Drives
Finding a File by Part of the Name


Have a good desktop search :)


Permalink: Tips for Google Desktop Search 

Wednesday, October 27, 2004

Change the owner of all tables in SQL Server

(Cambiar el propietario de todas las tablas en SQL Server)

Normally you use sp_changeobjectowner(SQL Server 2000 SP3)

Sample:
Remenber to have the right permissions. In this sample I'm running as dbo and i have logged by using sa

use Northwind
EXECUTE sp_changeobjectowner 'EmployeeTerritory', 'guest'

To take back this, the parameters change a little:

use Northwind
EXECUTE sp_changeobjectowner 'guest.EmployeeTerritory', 'dbo'

Well you must do it for all tables, but using an undocumented Stored Procedure called sp_MSforeachtable you can do this in one line of code:

use Northwind
sp_MSforeachtable @command1="sp_changeobjectowner '?', 'dbo'"

Another undocumented Stored Procedure is sp_MSforeachdb which could be used for change the owner of all Databases

Of course among of this use you can manage to make more interesting things mainly if You are a DBA


Another tip: If you are into the Entreprise Manager seen the data in a table and you want to modify a field an insert null in it, put the cursor in it and press CTRL+0 (Control and zero).


Permalink: Change the owner of all tables in SQL Server 

Tuesday, October 26, 2004

Taking the max of AdSense. A little tricks

(Usando AdSense a tope. Unos pequeños trucos)

I have started to put AdSense in my weblog one week ago, and I have started to test something things to taking the max of it.

There are 2 tricks using 2 google web tools:

1- One year ago, when Google created its advertising tool called AdWords, Arcadi show me a web tool provided by Google for knowing how many could cost to You put an advertising in AdWords. You put a word in it and the tool told You how many searches by month it brings and how cost it to You based on cost-per-click(aka: CPC). This tool is only accessible while you are trying to create a new account in AdWords.

It's the "Create Ad Groups", the second step in the process. One recommendation, fill the fields with more or less good things because the wizard check all them very intensively. When you are in the this step there will be a button with the text "Calculate estimates". I tried visual basic as keyword and these are the results:

Keyword-Clicks/Day Average-Cost-Per-Click-Cost Average-Position

visual basic-720.0-0.14 Euros-100.09 Euros-1.3

Overall-720.0-0.14 Euros-100.09 Euros-1.32



The word concordance tool gives You the other searches which people search similar to the word You write. This tool can be tested for many languages and for many countries.

Well, the trick are those tools. Using them, I put a google_hints variable in the AdSense code(You can see it in my weblog code), which right now are google_hints="ado+net,Net,asp+net,asp+net+code,compact+framework,
visual+basic,wifi,bluetooth,mobile,dot+net";

Even It is not permitted by AdSense terms, if You are interested in some of the advertising, just click ;)


Permalink: Taking the max of AdSense. A little tricks 

Saturday, October 23, 2004

Joel Spolsky interviewed at Microsoft Watch. A must read

(Joel Spolsky entrevistado en Microsoft Watch. Hay que leerlo)


Two technology titans face to face talking about Microsoft, Google, etc.


Permalink: Joel Spolsky interviewed at Microsoft Watch. A must read 

Get WIFI Adapters signal strength

(Obtener la intensidad de señal de los tarjetas WIFI)


If you want to know if your wifi adapter is in the range of any wifi net(do not do it for making an wifi scanner to warchalk or something else... remember, this code is only for research projects, bla bla bla)

First of all add a reference to System.Management.dll and then an Imports System.Management

Public Function GetSignalStrength() As String
Try
Dim Oq As ObjectQuery = New ObjectQuery("SELECT * FROM MSNdis_80211_ReceivedSignalStrength Where active=true")
Dim Ms As ManagementScope = New ManagementScope("root\wmi")
Dim query As ManagementObjectSearcher = New ManagementObjectSearcher(Ms, Oq)
Dim outp As String = ""
For Each Mo As ManagementObject In query.Get
If CType(Mo("Active"), Boolean) = True Then
outp &= CType(Mo("Ndis80211ReceivedSignalStrength"), String) + Environment.NewLine
End If
Next
If outp = "" Then outp = "There isn't any WIFI adapter active"
Return Trim(outp)
Catch e As Exception
Return e.Message
End Try
End Function




Permalink: Get WIFI Adapters signal strength 

Friday, October 22, 2004

v2.0 Select Random Rows from MS Access

(v2.0 Seleccionar filas aleatoriamente en MS Access)

Adding in the query "ORDER BY Rnd(filedName)" or with code


Dim adapter As New OleDbDataAdapter("SELECT * from myTable", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Request.MapPath("data.mdb") + ";")
Dim data As New DataSet
adapter.Fill(data)
Dim table As DataTable = data.Tables(0)
If table.Rows.Count = 0 Then
Throw New Exception("The query return 0 rows")
End If
Dim Random As New Random(System.DateTime.Now.Millisecond)
'first column of the random row
Dim sResult As String = table.Rows(Random.Next(0, table.Rows.Count)).Item(0).ToString()


Thanks Arcadi



Permalink: v2.0 Select Random Rows from MS Access  

Select Random Rows from MS Access

(Seleccionar filas aleatoriamente en MS Access)

Usually you have to take a random row from an Access DB, the following code makes it.

Tip: If You're accesing Access in a web (.aspx page, web service) You need remenber that ASPnet user must have full access(read, create, delete, modify) to the folder where the mdb lies, because it has to modify the .mdb file and create/deltete the .ldb file.

Added: Better code in v2.0 Select Random Rows from MS Access


Dim adapter As New OleDbDataAdapter("SELECT * from myTable", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Request.MapPath("data.mdb") + ";")

Dim data As New DataSet
adapter.Fill(data)
Dim table As DataTable = data.Tables(0)
If table.Rows.Count = 0 Then
Throw New Exception("The query return 0 rows")
End If
table.Columns.Add("Random", GetType(Double))
Dim random As New Random
For Each row As DataRow In table.Rows
row("Random") = random.NextDouble
Next

Dim dv As DataView = table.DefaultView
dv.Sort = "Random ASC"
Dim sResult As String

'the first column
sResult = dv.Item(0).Row(0).ToString()




Permalink: Select Random Rows from MS Access 

Wednesday, October 20, 2004

Extend Bluetooth coverage on a USB Bluetooth adapter(aka:dongle)

(Ampliar la covertura bluetooth de un adaptador USB(conocido como dongle))

Via blueseeker I found this interested article talking about USB coverage

Enlarge this image




Permalink: Extend Bluetooth coverage on a USB Bluetooth adapter(aka:dongle) 

A critical point of view of Google Desktop

(Una vision critica del Google Desktop)

This post has a very critical point of view of Google Desktop, by the microsoftie Franci Penov.

"1-It hooks up WinInet.dll. Hooking up system level component and intercepting all incoming/outgoing traffic on my machine has nothing to do with my desktop search. (Btw, it's amazing how many antivirus programs Google Desktop is incompatible with because of this)
2-...."

Let's read all his conclusions and take your owns.

Other good article of Google Desktop at Infoworld


Permalink: A critical point of view of Google Desktop 

Bill Gates and his optimism for the future of computing

(Billl Gates y su optimismo sobre el futuro de la informatica)

Here You can find and article written by Bill Gates talking about his ideas about the future/present of computing.

The title of the article is "My optimism for the future of computing has never been greater".

Let's read...


Permalink: Bill Gates and his optimism for the future of computing  

Tuesday, October 19, 2004

Avoid doPostBack and trap the caller object

(Evitar doPostBack y obtener el objeto que lo llama)

Sometimes you want to avoid the execution of the doPostBack, or make something before the doPostBack will be executed.

The following snippet do that. First We replace the __doPostBack with another variable called newPostBack, and maintain the old in another variable called oldPostBack.
When any object calls doPostBack, the function that will be executed will be newPostBack. In newPostBack function We can trap the caller object into the parameter eventTarget.
The ID of the object is btnDoit, and We get its outerHTML and do not execute the doPostBack.
If another object calls the doPostBack it will be executed normally.


<script id="anti_doPostBack" language="javascript">
<!--
// Replace the postback
oldPostBack = __doPostBack;
__doPostBack = newPostBack;

var oldPostBack

function newPostBack(eventTarget, eventArgument) {
if (eventTarget == "btnDoit") {
alert(document.getElementById('btnDoit').outerHTML);
} else {
//If the call to __doPostBack was NOT from btnDoit,
//then call the original __doPostBack.
oldPostBack(eventTarget, eventArgument);
}
}
//-->
</script>



Permalink: Avoid doPostBack and trap the caller object 

Export datagrid to Excel

(Exportar un datagrid a Excel)

Usually I have to export reports to Excel. The most common way is make a web page which put the excel mime type and sends the report table

Response.ContentType = "application/vnd.ms-excel"
Response.Write(sReportTable)


If the reports are only queries to the database, is very simple, because you only have to pass the query to the page, but if you have to make some calculations you have to put the code in the page.

The solution is getting the outerHTML of the datagrid(DataGrid1 is the ID of the datagrid object in my .aspx page) and putting it in the clipboard. How?


<a href="#" onclick="var ret;ret = window.clipboardData.setData('Text',document.getElementById('DataGrid1').outerHTML);if(ret){alert('Copy OK');}else{alert('Copy failed');}">Copy</a>


Just open Excel an Edit-Paste


Permalink: Export datagrid to Excel 

Saturday, October 16, 2004

Openwave Supports I-Mode in Europe

(Openwave soportara imode en Europa)

An agreement between NTT DoCoMo and Openwave had been sign for supporting this technology in all products of Openwave(servers and clients)

Today 51 mobile device manufacturers license the Openwave Mobile Browser, which has shipped in more than 600 million handsets and supports mobile phone networks in use around the world, including WCMDA, CDMA, GSM, TDMA, iDEN, PHS, and PDC.

The Openwave notice

As I can understand(with my more than 5 years old experience in mobility), imode hasn't any sense, but Openwave have taken her decision. Perhaps NTT Docomo has given enough money to Openwave.

Imode as a language(real cHTML) will lose the battle with a more standardized XHTML(Visual Studio .Net 2005 write it as default markup language). Imode as a platform will lose the battle with the phones which use standard internet.



Permalink: Openwave Supports I-Mode in Europe 

Wednesday, October 13, 2004

PalmOne licenses Microsoft Exchange for mobile e-mail

(PalmOne licencia Microsoft Exchange para email movil)

As You can read at Infoworld the first PalmOne device to include the Microsoft technology will be a new Treo smart phone. The Microsoft's Exchange Server ActiveSync protocol, allow users of PalmOne devices will no longer need to install third-party client and server software to be able to access e-mail, calendar and contact information on a server running Microsoft's Exchange Server 2003 software.

More on Microsoft Press


Permalink: PalmOne licenses Microsoft Exchange for mobile e-mail 

Friday, October 08, 2004

Old bugs in new software. Successful proof of concept!

(Viejos agujeros en el nuevo software. Prueba de concepto exitosa!)

While I'm reading blogs I've found the proof of concept of the bug in canonicalization of the URLs.

In my machine the bug works so it's time to patch it with the method 2

A standard forms authentication setup requires the presence of "web.config" to set the authentication method and login procedure. The presence of this file prevents access to certain files (.aspx files for example) unless authenticated.
Put in web.config

<authentication mode="Forms">
<forms name=".FORM" loginurl="login.aspx">
</authentication>

--- Example ---
The webroot for your website is:
c:\inetpub\wwwroot\mysite
You want to secure files in a sub directory "secure"
c:\inetpub\wwwroot\mysite\secure\web.config
A request to http://localhost/secure/somefile.aspx would then redirect the user to a predefined authentication page(login.aspx), as defined in web.config, before allowing the user access to "somefile.aspx".

--- Bug ---
1. Using Mozilla not IE, you make a request to http://localhost/secure\somefile.aspx The use of a backslash rather than a forward slash appears to bypass the expected authentication model invoked in .NET forms authentication
2. Using IE, you make a request to http://localhost/secure\somefile.aspx - IE automatically replaces the backslash "\" with a forward slash "/" and everything appears fine. However, replace the backslash "\" with %5C (%5C being hex value for \) and all is not so fine:
http://localhost/secure%5Csomefile.aspx



Permalink: Old bugs in new software. Successful proof of concept! 

Running multiple versions of .Net Framework(aka:Side-by-Side Execution)

(Usando varias versiones del .Net Framework(Conocido como Side-by-Side Execution))

Three weeks ago I put my hands on .Net Framework 2.o Beta, and I found the problem that my ASP.Net applications compiled under version 1.0 and 1.1 fail. As I usually do on this cases I made a search in google with this text Running multiple versions of .Net Framework and I found the problem quickly.

This page gave me the solution. The problem was that when I installed the new version of framework it registered this version for all sites in the IIS.

The solution is re-register those sites with the correct version. It can be done with the command line ASP.NET IIS Registration Tool (Aspnet_regiis.exe), provided with the framework.

For the very lazy people exits a GUI implementation ASP.NET Version Switcher

Screenshot of ASP.NET Version Switcher
ASP.NET Version Switcher



Permalink: Running multiple versions of .Net Framework(aka:Side-by-Side Execution) 

Old bugs in new software. Solution 2

(Viejos agujeros en el nuevo software. Solucion 2)

This is a trick that Web site administrators can apply to their Web server to protect it from the bug in canonicalization of the URLs.

Microsoft has released an ASP.NET HTTP module that you can download at http://www.microsoft.com/downloads/details.aspx?familyid=DA77B852-DFA0-4631-AAF9-8BCC6C743026&displaylang=en.

Enjoy and pray. Another bug could be waiting for you Out There


Permalink: Old bugs in new software. Solution 2 

Thursday, October 07, 2004

Old bugs in new software

(Viejos agujeros en el nuevo software)

Upss..., it isn't official, but could be a bug in ASP.Net which let users read authorized files through a problem in canonicalization of the URLs.(The article is in http://www.microsoft.com/security/incident/aspnet.mspx)

The "Programmatically check for canonicalization issues with ASP.NET" article gives you a explanation and a solution?¿ for this problem, but I post here the code for vb and C#.

Put in the Application_BeginRequest event handler of the Global.asax file.

Visual Basic .NET

<script language="vb" runat="server">
  Sub Application_BeginRequest(Sender as Object, E as EventArgs)
    If (Request.Path.IndexOf(chr(92)) >= 0 OR System.IO.Path.GetFullPath Request.PhysicalPath) <> Request.PhysicalPath) then
      Throw New HttpException(404, "Not Found")
    End If
  End Sub
</script>


C#

<script language="C#" runat="server">
  void Application_BeginRequest(object source, EventArgs e){
    if (Request.Path.IndexOf('\\') >= 0 System.IO.Path.GetFullPath(Request.PhysicalPath) != Request.PhysicalPath) {
      throw new HttpException(404, "not found");
    }
  }
</script>



Permalink: Old bugs in new software 

3,2,1 Go

3,2,1 Despegue

Well, this is my first post, and I'm sure that only friends going to read this post, but it doesn't matter ;)

The main reason of this blog is to be a share point for interchange impressions about mobility and about .NET development.(but this is not an obstacle for speaking about another things).


Permalink: 3,2,1 Go