This file contains hidden or 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
from array import array | |
import bisect | |
import struct | |
import operator | |
import sys | |
class WordList(object): | |
def __init__(self, words): | |
self.buf = "".join(words) | |
self.offsets = array("L", [0]) |
This file contains hidden or 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
from __future__ import print_function | |
import os | |
from os import path | |
from array import array | |
import struct | |
import sys | |
import re | |
from bisect import bisect_right | |
This file contains hidden or 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
x = "001111111010001" | |
t = "0101" | |
def match(i, j, prev=[]): | |
if i == len(x) or j == len(t): | |
if len(prev) == 4: | |
print prev, "".join(x[k] for k in prev) | |
return 1 | |
return 0 | |
if x[i] == t[j]: |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
cdef extern from "ahocorasick/ahocorasick.h": | |
int AC_PATTRN_MAX_LENGTH | |
ctypedef enum AC_ERROR_t: | |
ACERR_SUCCESS = 0 | |
ACERR_DUPLICATE_PATTERN | |
ACERR_LONG_PATTERN | |
ACERR_ZERO_PATTERN | |
ACERR_AUTOMATA_CLOSED |
This file contains hidden or 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 PLL(object): | |
count = 120 | |
count2 = 60 | |
p = np.arange(count) * 2 * np.pi / count | |
SIN_WAVE = np.sin(p) / count | |
COS_WAVE = np.cos(p) / count | |
p = np.arange(count2) * 2 * np.pi / count2 | |
SIN_WAVE2 = np.sin(p) / count2 | |
COS_WAVE2 = np.cos(p) / count2 |
This file contains hidden or 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
windows pypy 安装zmq: | |
下载源代码,解压之后把_verify.c中的代码改成如下: | |
#include <stdio.h> | |
//#include <sys/un.h> | |
#include <string.h> | |
#include <zmq.h> |
This file contains hidden or 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
// add button to make codecell read-only | |
"use strict"; | |
var group_extension = (function() { | |
var groupColors = ["#f5f5f5", "#efefff", "#efffef", "#ffefef"]; | |
var groupKey = { | |
"Alt-0" : function(){setSelectedGroup(0);}, | |
"Alt-1" : function(){setSelectedGroup(1);}, |
This file contains hidden or 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 AttrDict(dict): | |
def __getattr__(self, attr): | |
return self[attr] | |
def __setattr__(self, attr, value): | |
if isinstance(value, dict): | |
value = AttrDict(value) | |
self[attr] = value | |
p = AttrDict() |
This file contains hidden or 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
%%cython | |
#cython: boundscheck=False, wraparound=False | |
import numpy as np | |
cimport numpy as np | |
from cpython cimport array | |
def sum_array(array.array arr): | |
cdef int i | |
cdef double s = 0 | |
for i in range(len(arr)): |
This file contains hidden or 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
from pip import _vendor | |
import os | |
from io import BytesIO | |
ScriptMaker = _vendor.distlib.scripts.ScriptMaker | |
ZipFile = _vendor.distlib.compat.ZipFile | |
sm = ScriptMaker("", "") | |
launcher = sm._get_launcher("t") | |
shebang = sm._get_shebang('utf-8', b"") |
OlderNewer