Usual skill collection

Source: Internet
Author: User

Given an integer num, determine whether the integer is the N power of 2
// If a number is the N power of 2, the "bitwise AND" of the two numbers is 0.
Int num = 8;
Response. Write (num & num-1 );

//----------------------------------------------------------------------

Convert decimal number implemented by js to N-Base

/**
* Recursive call
* @ Param {Object} num decimal number
* @ Param {Object} base the number of hexadecimal values to be converted
*/
Function recursive (num, base ){
Var str = "", digit= "0123456789 abcdef ";
If (num = 0 ){
Return "";
} Else {
// Js does not clear decimals except operations. use Math. floor to clear them.
Str = recursive (Math. floor (num/base), base );
Return str + digit. charAt (num % base );
}
}

Use the extended functions provided by SQL2005 to encrypt strings using MD5

The hashbytes () function is provided by Microsoft in SQL SERVER 2005 and can be used to calculate the MD5 and SHA1 values of a string. The usage is as follows:

Select hashbytes ('md5', '123 ')

Select hashbytes ('sha1', '123 ')

The returned result of the hashbytes () function is of the varbinary type, which is binary data starting with 0x in hexadecimal format. Generally, all we need is string-type data. Use the built-in system function sys. fn_VarBinToHexStr (), as follows:

Select sys. fn_VarBinToHexStr (hashbytes ('md5', '123 '))

Html Checkbox and border are compatible with Firefox and Chrome browsers

1. <input type = "checkbox" name = "test" style = "outline: 2px solid red"/> no effect on IE
2. <input type = "checkbox" name = "test1" style = "border: 2px solid red"/> does not work for Firefox or Chrome
3. <input type = "checkbox" name = "test3" style = "outline: 2px solid red; border: 2px solid red"/>

 

Using the splice method in javascript, you can easily insert, delete, and replace array elements.

Method signature:

Array. prototype. splice (index, count [, elm1, elm2... n])

Description:

Array splice can be used to insert, replace, and delete Array elements. This method directly affects the current array object (different from the. slice (index1, index2) method) and returns the deleted array items.

Parameters:

Index: the starting subscript of the element in the array.

Count: number of elements to be deleted or replaced.

Elems: The items to be inserted into the array.

Return Value: return the items removed from the group.

Demo:

Var items = ["a", "B", "c", "d", "e"];

// Delete an element

Result = items. splice (1, 2)

// This operation deletes the element ["B", "c"] in the items array in the example, and returns ["B", "c"] to result.

// Replace Element

Result = items. splice (1, 2, "x", "y ")

// This operation uses the element "x" and "y" to replace the element ["B", "c"] in the items array in the example, and returns ["B ", "c"] to result.

// Insert element

Result = items. splice (1, 0, "x", "y ")

// The result of this operation is to insert ["x", "y"] after the "B" element of the items array in the example. The return value is null.

// Delete duplicate rows in the table and keep one row of data

Delete from tb_kp_mulu_timu
Where exists (select 1 from tb_kp_mulu_timu a where a. id <tb_kp_mulu_timu.id and a. muluid = tb_kp_mulu_timu.muluid and a. tmid = tb_kp_mulu_timutm.id)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.