This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [], | |
i; | |
for (i = 0; i < 10000; i++) { | |
arr[i] = Math.floor(Math.random()*9999); | |
} | |
// console.log(arr); | |
function findLG(arr) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDescendants(node, n) { | |
var res = []; | |
function f(children, lev) { | |
if (lev >= n) { | |
res = res.concat(Array.prototype.slice.apply(children)); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>Test by Jesse</title> | |
</head> | |
<body> | |
<nav id = 'sidenav'> | |
<ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// O(m+n) | |
var foo = function(arrA, arrB) { | |
var iB, | |
iA; | |
for (iA = iB = 0; iB < arrB.length; iB += 1) { | |
while (arrB[iB] > arrA[iA] && iA < arrA.length) { | |
iA += 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseQueryString(str){ | |
var pairs = str.replace(/^.*\?/, '').split('&'), | |
res = {}; | |
for (var i = pairs.length - 1; i > 0; i -= 1) { | |
var p = pairs[i].split('='); | |
res[p[0]] = p[1]; | |
} | |
return res; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bottom-up DP for longest common substring (not subsequence). | |
* Time: O(m*n) | |
* Space: O(min(m,n)) | |
* @author Jesse Wong (@straybugs) | |
*/ | |
function lcstr(sstr, lstr) { | |
'use strict'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function count(s) { | |
var r = s.split('') | |
.sort() | |
.join('') | |
.match(/(\w)\1*/g) | |
.sort(function(a,b) { | |
return a.length < b.length | |
}); | |
return { | |
letter: r[0], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 把所有微博设为“自己可见”。基于档案娘助手修改,提高稳定减少卡死。 | |
$(function() { | |
var mids = []; | |
var pageRecord = []; | |
var oldSearch = window.location.search; | |
var page = getPage(); | |
// 获得当前页码 | |
function getPage() { | |
return parseSearch().page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function singletonify(_Class) { | |
if (typeof singletonify.prototype._singletonifyInstances === 'undefined') { | |
singletonify.prototype._singletonifyInstances = []; | |
} | |
var _instances = singletonify.prototype._singletonifyInstances; | |
var _index = _instances.push(void(0)) - 1; | |
function genSingleton() { | |
if (typeof _instances[_index] !== 'undefined') { | |
return _instances[_index]; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#user_photo_upload").upload("/index.php?act=upload&mdl=upload&is_temp=1", function(ret) { | |
var ret_url = ret.url.replace('/', '\/'); | |
if (ret.status === 'ok') { | |
$.ajax({ | |
type: 'POST', | |
url: "/index.php?act=ajax&mdl=user_photo&func=user_photo_save", | |
data: { | |
"photo": { | |
"240x240_f": ret.filename, | |
"240x240_url": ret_url, |