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 sort = function(arr, left, right){ | |
if (right <= left) return; | |
// 取中間值作為 pivot | |
var pivotIndex = parseInt((left + right) / 2), | |
pivot = arr[pivotIndex]; | |
// pivot 移至最右方 | |
swap(arr, pivotIndex, right); |
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 unique = function(arr){ | |
var a = [], | |
l = arr.length; | |
for (var i = 0; i < l; i++){ | |
for (var j = i + 1; j < l; j++){ | |
if (arr[i] === arr[j]) j = ++i; | |
} | |
a.push(arr[i]); | |
} | |
return a; |
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 flatten = function(arr){ | |
for (var i = 0, len = arr.length; i < len; i++){ | |
var item = arr[i]; | |
if (Array.isArray(item)){ | |
len += item.length - 1; | |
[].splice.apply(arr, [i, 1].concat(item)); | |
i--; | |
} | |
} | |
return 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
hexo.extend.console.register('gzip', function(args, callback){ | |
hexo.call('generate', function(err){ | |
if (err) return callback(err); | |
// do gzip here... | |
}); | |
}); |
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(window){ | |
var cache = 0; | |
var scrollBarWidth = function(){ | |
if (cache) return cache; | |
var elem = document.createElement('div'); | |
elem.style.position = 'absolute'; | |
elem.style.top = '-9999px'; | |
elem.style.overflow = 'scroll'; |
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
import java.util.*; | |
public class s401631741HW1 { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.print("i = "); | |
int number = scanner.nextInt(); | |
Random random = new Random(); | |
int[][] arr = new int[number][]; |
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
#!/bin/sh | |
function find_gateway(){ | |
gateway=$(netstat -nr | grep "default" | awk "{print \$2}") | |
if [[ "$(grep "163.13." <<< $gateway)" == "" ]]; then | |
echo "Gateway $gateway is not a valid TKU IP!" | |
exit 1 | |
fi | |
} |
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
line 1705: unknown code state: 0x7fff5fbfdf90 | |
line 1708: unknown code state: /Users/SkyArrow/Dropbox/Projects/Hexo/hexo/node_modules/lodash/dist/lodash.js:10 | |
line 1710: unknown code state: 0x100649000 | |
line 1722: unknown code state: 0x7fff5fbfd3b0 | |
line 3090: unknown code state: 0x7fff5fbf7348 | |
Statistical profiling result from v8.log, (1634265 ticks, 222436 unaccounted, 0 excluded). | |
[Unknown]: | |
ticks total nonlib name | |
222436 13.6% |
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
class Test { | |
public static void main(String[] args){ | |
System.out.println("======= myGetChars ======="); | |
String str = "test"; | |
char[] arr1 = new char[4]; | |
myGetChars(str, 0, 4, arr1, 0); | |
System.out.printf("copy %s => %s\n", str, new String(arr1)); | |
char[] arr2 = new char[2]; |
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> | |
<meta charset="utf-8"> | |
<title>留言板</title> | |
</head> | |
<body> | |
<% messages.forEach(function(line, i){ %> | |
<p> | |
<strong><%= line.author %></strong>: <%= line.content %> |
OlderNewer