Skip to content

Instantly share code, notes, and snippets.

@tommy351
tommy351 / tku_wifi.sh
Last active August 29, 2015 13:57
TKU WiFi Utilities
#!/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
}
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%
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];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>留言板</title>
</head>
<body>
<% messages.forEach(function(line, i){ %>
<p>
<strong><%= line.author %></strong>: <%= line.content %>
import exp.*;
import flowd.*;
class P99 extends FunNode {
P99(){
super("P99");
Var i = addVar("i");
Var j = addVar("j");
addBeginNode("L0");
@tommy351
tommy351 / gist:73f8c34d839c67a0732f
Last active August 29, 2015 14:10
The solution to the question 3. https://paiza.jp/poh/enkoi
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
input += chunk;
});
process.stdin.on('end', function() {
@tommy351
tommy351 / benchmark.js
Last active August 29, 2015 14:15
hexo-util highlight benchmark
'use strict';
var highlight = require('highlight.js');
var Highlights = require('highlights');
var highlighter = new Highlights();
var util = require('../lib');
var fs = require('fs');
var pathFn = require('path');
var fixture = fs.readFileSync(pathFn.join(__dirname, 'fixtures', 'q3.js'), 'utf8');
@tommy351
tommy351 / gist:4961934
Created February 15, 2013 17:31
Quick sort
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);
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;
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;