Utils

Install SpamAssassin on Windows Server as a service

Here is a little tutorial on how to install SpamAssassin on Windows Server 2008 as system service:

  • Download and install the binary version of SpamAssassin (for example http://www.jam-software.com/spamassassin/)
  • Download NSSM (http://iain.cx/src/nssm/) and put the nssm.exe within Windows directory.
  • This is a wrapper to run spamd as service on Windows.
  • Now in a console type “nssm install SpamAssassin”, choose the spamd.exe file from the installation directory of SpamAssassin and put your parameters into the Options field.
  • Click on the install button and have a look to the server services. Here you have the SpamAssassin service ready to start.
SQL Server Transact-SQL

SQL SERVER – FIX : Error 15023: User already exists in current database.

Error 15023: User already exists in current database.

1) This is the best Solution.

First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan.

USE YourDB
GO
EXEC sp_change_users_login 'Report'
GO

Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in sysxlogins.

USE YourDB
GO
EXEC sp_change_users_login 'Auto_Fix', 'ColdFusion', NULL, 'cf'
GO

Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Update_One’ links the specified user in the current database to login. login must already exist. user and login must be specified. password must be NULL or not specified

USE YourDB
GO
EXEC sp_change_users_login 'update_one', 'ColdFusion', 'ColdFusion'
GO

more details in http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/

IIS

Select all sites in IIS manager

You should be able to do:

cd %systemroot%\system32\inetsrv\

and then delete them

appcmd list site /xml | appcmd delete site /in
ASP.Net Microsoft

Datetime format / Globalization

<pre class="default prettyprint prettyprinted"><code><span class="tag"><configuration>
</span><span class="tag"><system.web>
</span><span class="tag"><globalization</span><span class="atn">culture</span><span class="pun">=</span><span class="atv">"en-GB"</span><span class="tag">/>
</span><span class="tag"></system.web>
</span><span class="tag"></configuration></span></code></pre>
Tips & tricks

Gmail and Outlook

Login to your google account then access:

https://www.google.com/settings/security/lesssecureapps

Now you can configure your mail client with your gmail account.

Follow these steps:

http://www.configuraroutlook.com

 

 

Code Snippets

CKEditor

CKEditor is a ready-for-use HTML text editor designed to simplify web content creation. It’s a WYSIWYG editor that brings common word processor features directly to your web pages. Enhance your website experience with our community maintained editor

http://ckeditor.com

Tips & tricks

The Domain Name Expiration Process

This article focuses on the pre-release expiration process, which is now used for the majority of expired domain names.

read more »

Android

Make a hyperlink textview in android

TextView textView =(TextView)findViewById(R.id.textView);
textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href='http://www.google.com'> Google </a>";
textView.setText(Html.fromHtml(text));
Utils

JagPDF

JagPDF is a free, open source library for generating PDF documents.

The goal of this project is to provide a fast and reliable library that is usable in both server and desktop environments. The library is written in C++ and provides bindings for other languages. It runs on x86/Linux, amd64/Linux and x86/Windows platforms.

JagPDF aims to be easy to use, have a look at Hello World examples in C++, Python, Java or C. The library implements a fairly large subset of the PDF specification which enables creation of a broad range of document types.

The library is distributed under the MIT license which encourages both commercial and non-commercial usage. Consider contributing to JagPDF to keep it evolving and free.

http://www.jagpdf.org/

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/