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
fn horspool<T: Eq+Hash>(haystack: &[T], needle: &[T]) -> isize { | |
let hlen = haystack.len(); | |
let nlen = needle.len(); | |
if nlen == 0 { return 0 } | |
// jump table | |
let jmp: HashMap<&T, usize> = needle.iter().zip((1..nlen).rev()).collect(); | |
let last = nlen - 1; | |
let mut j = 0; | |
while j <= hlen - nlen { | |
// search backward |
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
#!/usr/bin/env python3 | |
import os | |
import json | |
import glob | |
import subprocess | |
files = glob.glob(os.path.expanduser('~/miniconda3/pkgs/cache/*.json')) | |
deps = {} | |
for f in files: | |
j = json.load(open(f)) |
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
#!/usr/bin/env python3 | |
import asyncio | |
from vpn import get_proxy | |
proxy = port = auth = None | |
pool = asyncio.Queue(5) | |
psize = 0 | |
async def process_client(client_reader, client_writer, *, CHUNK=4096): | |
global psize |
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
#!/usr/bin/env python3 | |
import os | |
import time | |
import shlex | |
import bottle | |
import pprint | |
import subprocess | |
from threading import Thread | |
blue = lambda s: '\033[94m%s\033[0m' % s |
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
customPandocCompiler :: Compiler (Item String) | |
customPandocCompiler = | |
let extraExtensions = | |
[ Ext_east_asian_line_breaks | |
, Ext_tex_math_double_backslash | |
] | |
customExtensions = foldr S.insert pandocExtensions extraExtensions | |
writerOptions = defaultHakyllWriterOptions { | |
writerExtensions = customExtensions |
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
newtype ContT r m a = ContT { runContT :: (a -> m r) -> m r } | |
instance Functor (ContT r m) where | |
-- :: (a -> b) -> ContT r m a -> ContT r m b | |
fmap a2b ca = ContT $ \b2r -> runContT ca (b2r . a2b) | |
instance Applicative (ContT r m) where | |
-- :: a -> ContT r m a | |
pure a = ContT $ \a2r -> a2r a | |
-- :: ContT r m (a -> b) -> ContT r m a -> ContT r m b |
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
map('F', 'af'); | |
map('gt', 'R'); | |
map('gT', 'E'); | |
map('<Ctrl-n>', 'R'); | |
map('<Ctrl-p>', 'E'); | |
mapkey('H', '#4Go back in history', function() { history.go(-1); }, {repeatIgnore: true}); | |
mapkey('L', '#4Go forward in history', function() { history.go(1); }, {repeatIgnore: true}); | |
map('d', 'x'); | |
map('u', 'X'); | |
map('I', '<Alt-s>'); |
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 sys | |
import json | |
import xmlrpc.client | |
import requests | |
from requests.utils import cookiejar_from_dict | |
def get_aria2(speed_limit=None): | |
aria2 = xmlrpc.client.ServerProxy('http://127.0.0.1:6800/rpc').aria2 | |
while 1: |