Skip to content

Instantly share code, notes, and snippets.

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])
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
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]:
# -*- 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
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
@ruoyu0088
ruoyu0088 / gist:e75975aed2dda6ffd906
Created February 6, 2015 14:09
How to install zmq into pypy on Windows.
windows pypy 安装zmq:
下载源代码,解压之后把_verify.c中的代码改成如下:
#include <stdio.h>
//#include <sys/un.h>
#include <string.h>
#include <zmq.h>
// 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);},
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()
%%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)):
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"")