ArcGIS Javascript

Restrict pan and zoom in ArcGIS Javascript API


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Simple Map</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css">
<style>
html, body, #map {
height:100%;
width:100%;
margin:0;
padding:0;
}
body {
background-color:#FFF;
overflow:hidden;
font-family:"Trebuchet MS";
}
</style>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"></script>
<script>
dojo.require("esri.map");
var map = null;
var extent =  null;
var maxExtent = null;

function init() {
map = new esri.Map("map",{
basemap:"topo",
center:[-122.45,37.75], //long, lat
zoom:13,
sliderStyle:"small"
});
//set max extent to inital extent
dojo.connect(map, "onLoad", function(){
maxExtent = map.extent;
});

//check to see if map is within max extent when its extent changes.  If not, roll back to the max
//extent that we set above
dojo.connect(map, "onExtentChange", function(extent){
if((map.extent.xmin < maxExtent.xmin) ||
(map.extent.ymin < maxExtent.ymin)  ||
(map.extent.xmax > maxExtent.xmax) ||
(map.extent.ymax > maxExtent.ymax)
) {
map.setExtent(maxExtent);
console.log("max extent reached, rolling back to previous extent");
}

});

}

dojo.ready(init);

</script>
</head>

<body class="claro">
<div id="map"></div>
</body>
</html>

http://jsfiddle.net/gh/gist/library/pure/6050806/

Tips & tricks

How to configure Microsoft.AspNet.FriendlyUrls

App_code>start>RouteConfig.vb

Imports Microsoft.VisualBasic
Imports System.Web.Routing
Imports Microsoft.AspNet.FriendlyUrls

Public Class RouteConfig
    Public Shared Sub RegisterRoutes(routes As RouteCollection)
        Dim settings = New FriendlyUrlSettings()
        settings.AutoRedirectMode = RedirectMode.Permanent
        routes.EnableFriendlyUrls(settings)
    End Sub
End Class

Global.asax

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    'Friendly URLs
    RouteConfig.RegisterRoutes(RouteTable.Routes)
End Sub

if error on server:

Could not load file or assembly 'Microsoft.Web.Infrastructure,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 or one of its dependencies. The system cannot find the file specified

Run ASP.NET MVC 3 Tools Update
http://www.microsoft.com/en-us/download/confirmation.aspx?id=1491

related links:
http://www.hanselman.com/blog/CommentView.aspx?guid=724141DA-9E27-44AE-A370-9E311BAED472#73cdc003-407d-4d9a-8ea0-d397b5989cf4

Code Snippets .NET ASP.Net regex

ASP.Net Character Length Regular Expression Validators

ASP.Net RegularExpression Validators

Maximum character length Validation (Maximum 6 characters allowed)

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1"
Display = "Dynamic"
ControlToValidate = "TextBox1"
ValidationExpression = "^[\s\S]{0,6}$"
ErrorMessage="Maximum 6 characters allowed.">
</asp:RegularExpressionValidator>

Minimum character length Validation (Minimum 6 characters required)

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator2"
Display = "Dynamic"
ControlToValidate = "TextBox2"
ValidationExpression = "^[\s\S]{6,}$"
ErrorMessage="Minimum 6 characters required.">
</asp:RegularExpressionValidator>

Minimum and Maximum character length Validation (Minimum 2 and Maximum 6 characters required)

<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator3"
Display = "Dynamic"
ControlToValidate = "TextBox3"
ValidationExpression = "^[\s\S]{2,6}$"
ErrorMessage="Minimum 2 and Maximum 6 characters required.">
</asp:RegularExpressionValidator>

Alphanumeric with special Characters
Minimum length 7 and Maximum length 10. Characters allowed – a – z A – Z 0-9 ’@ & # .

<asp:RegularExpressionValidator ID="RegExp1" runat="server"
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate=" txtPassword "
ValidationExpression="^[a-zA-Z0-9'@&#.\s]{7,10}$" />

Alphanumeric Only
Minimum length 7 and Maximum length 10. Characters allowed – a – z A – Z 0-9

<asp:RegularExpressionValidator ID="RegExp1" runat="server"
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate=" txtPassword "
ValidationExpression="^[a-zA-Z0-9\s]{7,10}$" />

Alphabets Only
Minimum length 7 and Maximum length 10. Characters allowed – a – z A – Z

<asp:RegularExpressionValidator ID="RegExp1" runat="server"
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate="txtPassword"
ValidationExpression="^[a-zA-Z]{7,10}$" />

Numeric Only
Minimum length 7 and Maximum length 10. Characters allowed – 0 – 9

<asp:RegularExpressionValidator ID="RegExp1" runat="server"
ErrorMessage="Password length must be between 7 to 10 characters"
ControlToValidate="txtPassword"
ValidationExpression="^[0-9]{7,10}$" />

source:

http://www.aspsnippets.com/Articles/ASP.Net-Regular-Expression-Validator-to-validate-Minimum-and-Maximum-Text-Length.aspx

VBA

VBA environment variables (ENVIRON)

To see a list of variables, create a sub:

 
Sub ListEnvironmentVariables()

    'each environment variable in turn
    Dim EnvironmentVariable As String
    
    'the number of each environment variable
    Dim EnvironmentVariableIndex As Integer
    
    'get first environment variables
    EnvironmentVariableIndex = 1
    EnvironmentVariable = Environ(EnvironmentVariableIndex)
    
    'loop over all environment variables till there are no more
    Do Until EnvironmentVariable = ""
    
    'get next e.v. and print out its value
    Debug.Print EnvironmentVariableIndex, EnvironmentVariable
    
    'go on to next one
    EnvironmentVariableIndex = EnvironmentVariableIndex + 1
    EnvironmentVariable = Environ(EnvironmentVariableIndex)
    
    Loop

End Sub
 

click menu “View” > “Immediate Window” and run it
Doesn’t work on macintosh

Private Sub Workbook_Open()
'Generates a GUID:
Sheet1.Cells(8, 3).Value = Mid$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36)  

'environment variables:
Sheet1.Cells(11, 3).Value = Environ$("computername")  
Sheet1.Cells(12, 3).Value = Environ$("username")
Sheet1.Cells(13, 3).Value = Environ$("USERPROFILE")
 
MsgBox "Hello " & Environ$("username")

End Sub

on Macintosh Excel you can try a AppleScript, something like:

Function GetUserNameMac() As String
    Dim sMyScript As String

    sMyScript = "set userName to short user name of (system info)" & vbNewLine & "return userName"

    GetUserNameMac = MacScript(sMyScript)
End Function
PHP

Warning: Cannot modify header information – headers already sent by ..

error message:

Warning: Cannot modify header information – headers already sent by (output started at C:\…\…\…\…\filexpto.php:1) in C:\…\…\…\…\….php on line xx

 

resolution:

open file filexpto.php and add ob_start(); like

 
<?php
ob_start();
....

 

ob_startTurn on output buffering

This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

 
more in:

http://www.php.net/manual/en/function.ob-start.php

 

Tips & tricks

Import multiple vCards to Gmail contacts manager

Need to concatenate all the VCFs in to a single file

# get a command prompt
Windows_Key + R
run: cmd
# change to the directory where all your VCFs are located
e:
cd vcf
# Run this command

copy   /B   *.vcf   all.vcf

Then upload the “all.vcf” file to google

IIS

IIS6 and Office 2007 MIME types

Error message:

 

    HTTP Error 404 – File or directory not found.
Internet Information Services (IIS)

Since Office 2007 was released after Windows Server 2003 and IIS6, IIS6 knows nothing about the new MIME types. So you need to manually add them:

Open Computer Management. (Right-click My Computer… Manage…)
Right-click Internet Information Services (IIS) Management… Properties…
Click MIME Types…
Click New… and add the following:

Extension     MIME Type
.xlsx     application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx     application/vnd.openxmlformats-officedocument.spreadsheetml.template
.potx     application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx     application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptx     application/vnd.openxmlformats-officedocument.presentationml.presentation
.sldx     application/vnd.openxmlformats-officedocument.presentationml.slide
.docx     application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx     application/vnd.openxmlformats-officedocument.wordprocessingml.template
.xlam     application/vnd.ms-excel.addin.macroEnabled.12
.xlsb     application/vnd.ms-excel.sheet.binary.macroEnabled.12

Code Snippets SQL

Detect invalid(sintax) emails

Detect invalid(sintax) emails in db

SELECT * FROM people WHERE email NOT LIKE '%_@__%.__%'
Code Snippets SQL

Query to list number of records in each table in a database

sql server 2005



SELECT 
    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN 
    sys.schemas s ON t.schema_id = s.schema_id
WHERE 
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
GROUP BY 
    t.Name, s.Name, p.Rows
ORDER BY 
    t.Name





Databases

DBeaver is free and open source (GPL) universal database tool

DBeaver is free and open source (GPL) universal database tool for developers and database administrators.

  • Usability is the main goal of this project, program UI is carefully designed and implemented.
  • It is freeware.
  • It is multiplatform.
  • It is based on opensource framework and allows writing of various extensions (plugins).
  • It supports any database having a JDBC driver.
  • It may handle any external datasource which may or may not have a JDBC driver.
  • There is a set of plugins for certain databases (MySQL and Oracle in version 1.x) and different database management utilities (e.g. ERD)

http://dbeaver.jkiss.org/about/ read more »