Skip to content

Instantly share code, notes, and snippets.

View linkerlin's full-sized avatar
🎯
Focusing

Halo Master linkerlin

🎯
Focusing
View GitHub Profile
@linkerlin
linkerlin / test_einops.ipynb
Last active September 18, 2022 13:28
einops爱因斯坦表达式使用教程.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@linkerlin
linkerlin / .ipynb
Created September 10, 2022 04:23
封神榜大模型.ipynb
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": [],
"machine_shape": "hm",
"authorship_tag": "ABX9TyMK+iTIWvrDxWHWBIXKg3Xw",
"include_colab_link": true
@linkerlin
linkerlin / jina-ai.ipynb
Created September 9, 2022 23:56
jina-ai.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@linkerlin
linkerlin / 许诺.js
Created October 25, 2018 05:19
关于Promise的例子
function 获取网络资源(网址) {
return new Promise((解决, 拒绝)=> {
var 请求 = new XMLHttpRequest();
请求.open('GET', 网址, true);
请求.onload = 括弧=> {
if (请求.status === 200) {
解决(请求.responseText);
} else {
拒绝(new Error(请求.statusText));
}
@linkerlin
linkerlin / 许诺.js
Created October 25, 2018 05:19
关于Promise的例子
function 获取网络资源(网址) {
return new Promise((解决, 拒绝)=> {
var 请求 = new XMLHttpRequest();
请求.open('GET', 网址, true);
请求.onload = 括弧=> {
if (请求.status === 200) {
解决(请求.responseText);
} else {
拒绝(new Error(请求.statusText));
}
@linkerlin
linkerlin / bytetrie.go
Last active March 25, 2018 17:41
High Speed Byte Trie
package flashtext
type bytetrie struct {
key byte
next [256]*bytetrie
word string
}
func NewByteTrie(b byte) *bytetrie {
return &bytetrie{
@linkerlin
linkerlin / mmap_demo.go
Created January 24, 2018 15:45
A demo of mmap for Go
package main
import (
"bytes"
"encoding/binary"
"os"
"sync"
"fmt"
"math/rand"
"path/filepath"
@linkerlin
linkerlin / m.groovy
Last active December 20, 2015 04:39
Groovy and load a jar
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...
@linkerlin
linkerlin / with_timer.py
Last active December 19, 2015 16:09
一个简单的Python计时器
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()
@linkerlin
linkerlin / MetaClass.py
Last active December 18, 2015 05:39
Python的计时用metaclass 。演示了Meta Class的用法。
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()