Friday, April 27, 2012

jquery .click pass parameters to user function

Method 1:
$('.myclass').bind("click", { Param1: "", Param2: 2 }, function(event){

Method 2:
// say your selector and click handler looks something like this...
$("some selector").click({param1: "Hello", param2: "World"}, cool_function);

// in your function, just grab the event object and go crazy...
function cool_function(event){


How to assign select query result to a variable?

SELECT name INTO var1 FROM table1 WHERE name = x ; /* >>> INTO var1 <<< */
SELECT var1;


SET var1 = (SELECT name FROM table1 WHERE name = x);
SELECT var1;

Tuesday, April 24, 2012

run execute powershell script in command line

cmd> powershell -ExecutionPolicy RemoteSigned -File e:/tmp/html2pdf.ps1 html2pdf.ps1

batch print PDF files automatically

Dir E:\tmp\data\*.pdf | Foreach-Object { Start-Process -FilePath $_.FullName -Verb Print }

convert doc to pdf

param (
    [string]$source = $(Throw "You have to specify a source path."))

$extensionSize = 3
if ($source.EndsWith("docx")) {
  $extensionSize = 4

$destiny = $source.Substring(0, $source.Length - $extensionSize) + "pdf"
$saveaspath = [ref] $destiny 
$formatPDF = [ref] 17

$word = new-object -ComObject "word.application"
$doc = $$source)
$doc.SaveAs($saveaspath, $formatPDF)

Sunday, April 22, 2012

How to delete GPT Protective Partition

How to delete GPT Protective Partition

Why we need to delete GPT protective partition?
In Windows XP Professional, you cannot access or modify GPT disk, but you can convert a GPT disk to MBR by using the clean command in DiskPart, which will delete GPT protective partition and remove all data and partition structures from the disk.
Warning: The steps below will erase all data on the GPT disk, please backup your data first.
  1. You might see HD Drive in GPT status on Disk Management.
  2. Go to DOS command line (click on "Start Menu", then "Run", type in "cmd" in textbox, and hit "OK")
    • Type in "DiskPart" in command line.
    • Type in "list disk" in command line to show all disks in this machine.
    • Use "select" to set the focus to the specified partition.
      For example "select disk 1".
    • Use "clean" command to remove GPT disk from the current in-focus disk by zeroing sectors.
  3. Go back to Disk Management, you can see GPT disk is "Not Initialized" now. 
  4. Within Disk Management, right click on disk info, choose "Initialize Disk", You can see GPT disk is "Unallocated" now.
  5. Right click on disk info, choose "New Partition…", follow Partition Wizard and format it. Now you are able to use the disk in Windows XP.


Tuesday, April 17, 2012

The JavaScript Code Quality Tool

What is JSLint?

JSLint is a JavaScript program that looks for problems in JavaScript programs. It is a code quality tool.
When C was a young programming language, there were several common programming errors that were not caught by the primitive compilers, so an accessory program called lint was developed that would scan a source file, looking for problems.
As the language matured, the definition of the language was strengthened to eliminate some insecurities, and compilers got better at issuing warnings. lint is no longer needed.
JavaScript is a young-for-its-age language. It was originally intended to do small tasks in webpages, tasks for which Java was too heavy and clumsy. But JavaScript is a very capable language, and it is now being used in larger projects. Many of the features that were intended to make the language easy to use are troublesome when projects become complicated. A lint for JavaScript is needed: JSLint, a JavaScript syntax checker and validator.
JSLint takes a JavaScript source and scans it. If it finds a problem, it returns a message describing the problem and an approximate location within the source. The problem is not necessarily a syntax error, although it often is. JSLint looks at some style conventions as well as structural problems. It does not prove that your program is correct. It just provides another set of eyes to help spot problems.
JSLint defines a professional subset of JavaScript, a stricter language than that defined by Third Edition of the ECMAScript Programming Language Standard. The subset is related to recommendations found in Code Conventions for the JavaScript Programming Language.
JavaScript is a sloppy language, but inside it there is an elegant, better language. JSLint helps you to program in that better language and to avoid most of the slop. JSLint will reject programs that browsers will accept because JSLint is concerned with the quality of your code and browsers are not. You should accept all of JSLint's advice.
JSLint can operate on JavaScript source, HTML source, CSS source, or JSON text.


Wednesday, April 4, 2012

Best free flowchart software

yED - is a powerful desktop application that can be used to quickly and effectively generate high-quality diagrams. Create diagrams manually, or import your external data for analysis. Our automatic layout algorithms arrange even large data sets with just the press of a button.