Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"collapsed_sections": [], | |
"machine_shape": "hm", | |
"authorship_tag": "ABX9TyMK+iTIWvrDxWHWBIXKg3Xw", | |
"include_colab_link": true |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 获取网络资源(网址) { | |
return new Promise((解决, 拒绝)=> { | |
var 请求 = new XMLHttpRequest(); | |
请求.open('GET', 网址, true); | |
请求.onload = 括弧=> { | |
if (请求.status === 200) { | |
解决(请求.responseText); | |
} else { | |
拒绝(new Error(请求.statusText)); | |
} |
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 获取网络资源(网址) { | |
return new Promise((解决, 拒绝)=> { | |
var 请求 = new XMLHttpRequest(); | |
请求.open('GET', 网址, true); | |
请求.onload = 括弧=> { | |
if (请求.status === 200) { | |
解决(请求.responseText); | |
} else { | |
拒绝(new Error(请求.statusText)); | |
} |
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
package flashtext | |
type bytetrie struct { | |
key byte | |
next [256]*bytetrie | |
word string | |
} | |
func NewByteTrie(b byte) *bytetrie { | |
return &bytetrie{ |
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
package main | |
import ( | |
"bytes" | |
"encoding/binary" | |
"os" | |
"sync" | |
"fmt" | |
"math/rand" | |
"path/filepath" |
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
this.class.classLoader.rootLoader.addURL(new URL("file:////Users/linkerlin/.m2/repository/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar")) | |
import groovy.sql.Sql | |
sql = Sql.newInstance("jdbc:mysql://localhost:3306/test", "root", "", "com.mysql.jdbc.Driver") | |
sql.eachRow("SELECT id, username FROM users") | |
{ | |
println "The employee's name is ${it.username}" | |
} | |
// Or using grape | |
@GrabConfig(systemClassLoader=true) // this is very important... |
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 Timer(object): | |
def __init__(self, name): | |
print("%s: " % name, end="") | |
def __enter__(self): | |
self.t0 = time.time() | |
def __exit__(self, *args): | |
print("%.3fs" % (time.time() - self.t0)) | |
with Timer("XXX"): | |
call_function() |
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 Profiler(type): | |
def __new__(mcl, name, bases, dict): | |
from time import clock | |
from types import FunctionType | |
def timing(func): | |
def wrapper(*args, **kwds): | |
start = clock() | |
value = func(*args, **kwds) | |
end = clock() |
NewerOlder