Skip to content

Instantly share code, notes, and snippets.

View ZhangSen1's full-sized avatar

Zhang Sen ZhangSen1

View GitHub Profile
using System;
using System. Collections.Generic ;
using System. Linq;
using System. Text;
using System. Threading;
namespace ConsoleApplication3
{
class Program
{
var getNewArrayByMoveElement = function( array, insertIndex, predicate ) {
var tmpDeepCopyArray;
try {
tmpDeepCopyArray = array.slice( 0 );
var tmpIndex = _.findLastIndex( tmpDeepCopyArray, predicate );
var removedElements = tmpDeepCopyArray.splice( tmpIndex, 1 );
if ( removedElements.length > 0 ) {
tmpDeepCopyArray.splice( insertIndex, 0, removedElements[ 0 ] );
}
} catch ( e ) {
@ZhangSen1
ZhangSen1 / async,await.cs
Last active October 23, 2017 06:54
async,await.cs
static void Main(string[] args)
{
DisplayAsync();
Console.Write("1");
}
public static Task<int> GetTaskAsync()
{
return Task.Run(() =>
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
@ZhangSen1
ZhangSen1 / stringbuilder.html
Created September 2, 2014 05:26
StringBuilder
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
</head>
<body>
<script>
function StringBuilder(str) {
this.tmp = new Array();
# -*- coding: utf-8 -*-
import webbrowser
def Init():
urlTxt = open('url.txt', 'r')
content = urlTxt.readlines()
print u'\n\n当前所保存的URL,共有 ' + str(len([i for i in content if i != '\n'])) + u'个:'
print '###############################'
for url in content:
if url != '\n':
@ZhangSen1
ZhangSen1 / JQuery-Defferd.js
Created August 13, 2014 03:53
JQuery Deferred
~function( window ) {
var objExtend = function( tObj, sObj ) {
for ( var i in sObj ) {
if ( typeof sObj[ i ] !== "object" ) {
tObj[ i ] = sObj[ i ];
} else if ( sObj[ i ].constructor == Array ) {
tObj[ i ] = Object.clone( sObj[ i ] );
MethodInfo method = typeof(string).GetMethod("StartsWith", new[] { typeof(string) });
var target = Expression.Parameter(typeof (string), "x");
var methodArg = Expression.Parameter(typeof (string), "y");
Expression[] methodArgs = new[] { methodArg };
Expression call = Expression.Call(target, method, methodArgs);
var lambdaParameters = new[] {target, methodArg};
formatNumber = function( value ) {
value = value.toString();
if ( value.length <= 3 ) {
return value;
} else {
return formatNumber( value.substr( 0, value.length - 3 ) ) + ',' + value.substr( value.length - 3 );
}
}