miércoles, octubre 10, 2007

Aprendiendo a Utilizar Google Maps (Primera Entrega)




Leyendo algunos posts que llegan a mi cuenta encontré este interesante artículo en otro blog, sobre como realizar aplicaciones que aprovechen las enormes caracteristicas del google maps. Articulo aqui.

jueves, octubre 04, 2007

Crear un virtual directory con .net

Es relativamente fácil implementar una rutina para crear directorios virtuales desde codigo, aqui el post original

Private Sub CreateVirtualDir(ByVal WebSite As String, ByVal AppName As String, ByVal Path As String)
Dim IISSchema As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/Schema/AppIsolated")
Dim CanCreate As Boolean = Not IISSchema.Properties("Syntax").Value.ToString.ToUpper() = "BOOLEAN"
IISSchema.Dispose()

If CanCreate Then
Dim PathCreated As Boolean
Try
Dim IISAdmin As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/W3SVC/1/Root")

'make sure folder exists
If Not System.IO.Directory.Exists(Path) Then
System.IO.Directory.CreateDirectory(Path)
PathCreated = True
End If

'If the virtual directory already exists then delete it
For Each VD As System.DirectoryServices.DirectoryEntry In IISAdmin.Children
If VD.Name = AppName Then
IISAdmin.Invoke("Delete", New String() {VD.SchemaClassName, AppName})
IISAdmin.CommitChanges()
Exit For
End If
Next VD

'Create and setup new virtual directory
Dim VDir As System.DirectoryServices.DirectoryEntry = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
VDir.Properties("Path").Item(0) = Path
VDir.Properties("AppFriendlyName").Item(0) = AppName
VDir.Properties("EnableDirBrowsing").Item(0) = False
VDir.Properties("AccessRead").Item(0) = True
VDir.Properties("AccessExecute").Item(0) = True
VDir.Properties("AccessWrite").Item(0) = False
VDir.Properties("AccessScript").Item(0) = True
VDir.Properties("AuthNTLM").Item(0) = True
VDir.Properties("EnableDefaultDoc").Item(0) = True
VDir.Properties("DefaultDoc").Item(0) = "default.htm,default.aspx,default.asp"
VDir.Properties("AspEnableParentPaths").Item(0) = True
VDir.CommitChanges()

'the following are acceptable params
'INPROC = 0
'OUTPROC = 1
'POOLED = 2
VDir.Invoke("AppCreate", 1)

Catch Ex As Exception
If PathCreated Then
System.IO.Directory.Delete(Path)
End If
Throw Ex
End Try
End If
End Sub

miércoles, octubre 03, 2007

Util, seleccionar un registro aleatoriamente

A veces, necesitamos obtener información aleatoria de una Base de Datos por diferentes razones, aquí unas rutinas muy útiles para cuando queremos generar información de prueba.

articulo original aqui

-------------------------------------------------------------------------------

Select a random row with MySQL:

SELECT column FROM table
ORDER BY RAND()
LIMIT 1

Select a random row with PostgreSQL:

SELECT column FROM table
ORDER BY RANDOM()
LIMIT 1

Select a random row with Microsoft SQL Server:

SELECT TOP 1 column FROM table
ORDER BY NEWID()

Select a random row with IBM DB2

SELECT column, RAND() as IDX
FROM table
ORDER BY IDX FETCH FIRST 1 ROWS ONLY

Thanks Tim
Select a random record with Oracle:

SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum = 1