Thursday, May 31, 2012

Fatal error: Call to undefined function session_start() in Php 6

you may get this error you are not a PHP guy ,

Fatal error: Call to undefined function session_start()
run phpinfo session is enabled.

image

then what’s wrong? the answer is short. this functio has been removed since php 5.4, so your php is too new for this code.
image

Tuesday, May 22, 2012

C#, Chained lambda expression to validate Email

image

>

image

JAVA regular expression, encode &#[0-9]+ form html

private static String ReplceSpecialChars(String s) {
        String orig=s;
        Pattern pnum=Pattern.compile("&#([0-9]+);");
        Matcher m=pnum.matcher(s);
        while(m.find())
        {
            int t=Integer.parseInt(m.group(1));
            char ch=(char)t;
            orig=orig.replaceFirst(m.group(0), ""+ch);
        }
        return orig;
    }

CàT will be parsed to CàT
CàáT , will be CàáT

Thursday, May 17, 2012

How to: Get ProcessID of a given application pool on IIS

there are couple ways to get the processed of a given application pool, here is some quick ways to do that.

Using WMIC, this works for IIS6/IIS7

Go command prompt, type “wmic”
  put the query like “process where name=”w3wp.exe” get processid, commandline” , you will see the app pool name and the processid.
image

or just put in one line,
image 

using task manager for windows 7 or 2008,add commandline to the columns
image

Or run cmd as admin, go to “c:\Windows\System32\inetsrv” run “appcmd.exe list wp”, using the IIS admin tools , this works only for iis 7 and above

image

or using DebugDiag, this works for all IIS version,
go to the process tab, it has the web application pool name,
image

Monday, May 14, 2012

Using the async node.js library to get twitter content in a parallel

Quick test: setup the node.js to pull the contents from twitter in a parallel, and parse the json data back,
  If search, http://search.twitter.com/search.json?q=lakers&rpp=5&include_entities=true&result_type=mixed, will show lakes news. 
  Here is one quick code to search 5 NBA teams, and get the text back.
 


var async=require("async");var http=require("http"); var fs=require("fs");

function getwebPageContents(keyword,callback)
{
    var client=http.get({"host":"search.twitter.com","port":"80",
        "path":"/search.json?q=" + keyword + "&rpp=5&include_entities=true&result_type=mixed"
    }, function(data)
    {   
        var p="";
        data.on("data",function(chunk)
        {
            p+=chunk;
        } );
        data.on("end",function()
        {
            callback(null, p);
        })
    })
}

async.parallel([
    function(callback){
            getwebPageContents("lal",callback)
    },
    function(callback){
            getwebPageContents("lac",callback)
    },
     function(callback){
            getwebPageContents("okc",callback)
    },
    function(callback){
            getwebPageContents("mia",callback)
    }, function(callback){
            getwebPageContents("phi",callback)
    }
], function(e,data)
{
    
    for(p in data)
    {
        console.log( "result- " +p +  "  " +JSON.parse(data[p]).results[0].text);
    }
    
});


you will get some data, like this,
image

Node.js and Sublime auto completion and Build integration / windows 7

Sublime Text is a Super IDE for developers, if you are looking the same experience for Node.js, there is one plug-in which supports Both.  you can check it here, https://github.com/tanepiper/SublimeText-Nodejs

for the installation, if you don’t have any GIT on windows, just go to https://github.com/tanepiper/SublimeText-Nodejs
click the zip to download all the bits,
image
then unzip the file, to  F:\Users\Androidyou\AppData\Roaming\Sublime Text 2\Packages\Nodejs, must be no further subfoder in this directory. otherwise, the build wont work, so the final resutlsl looks like<

image

once done, restart the sublime, you can see the node.js build /and run profle are there.
image

image

Friday, May 11, 2012

Java regular expression to extract Date format like April 12, 2012

String s = "Department May 89 , 2012 - May 09 , 2011, June 12, 2011";
        Pattern p = Pattern.compile(
                "(jan|feb|mar|apr|may|jun|jul|aug|sep|nov|dec)[a-z]{0,6}[\\s]*[0-9]{1,2}[\\s]*,[\\s]*[0-9]{4}",
                Pattern.CASE_INSENSITIVE);
        Matcher m = p.matcher(s);
        while (m.find()) {
                System.out.println(m.group(0));
        }


You will get all 3 dates,
image

 
Locations of visitors to this page