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
from collections import namedtuple, defaultdict | |
EarleyItem = namedtuple("EarleyItem", ["rule", "dot", "origin"]) | |
def item_advance(item): | |
return EarleyItem(rule=item.rule, dot=item.dot + 1, origin=item.origin) | |
class Generator: | |
def __init__(self, G, terminals): | |
self.G = [["S'", G[0][0]]] + list(G) |
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
from __future__ import unicode_literals | |
import sys | |
# We only use unicode in our parser, except for __repr__, which must return str. | |
if sys.version_info.major == 2: | |
repr_str = lambda s: s.encode("utf-8") | |
str = unicode | |
else: | |
repr_str = lambda s: 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
#ifndef ASCII_CTYPE_H | |
#define ASCII_CTYPE_H | |
#define ASCIIRANGE(c, start, len) (char32_t((c) - (start)) < char32_t(len)) | |
inline bool aislower(char32_t c) { return ASCIIRANGE(c, 0x61, 26); } | |
inline bool aisupper(char32_t c) { return ASCIIRANGE(c, 0x41, 26); } | |
inline bool aisdigit(char32_t c) { return ASCIIRANGE(c, 0x30, 10); } | |
inline bool aisbdigit(char32_t c) { return ASCIIRANGE(c, 0x30, 2); } | |
inline bool aisodigit(char32_t c) { return ASCIIRANGE(c, 0x30, 8); } | |
inline bool aisxdigit(char32_t c) { return ASCIIRANGE(c | 32, 0x61, 6) || aisdigit(c); } |
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
local driver = CreateFrame("Button", "casthack_driver", nil, "SecureHandlerClickTemplate") | |
local executor = CreateFrame("Button", "casthack_executor", nil, "SecureActionButtonTemplate") | |
driver:SetAttribute("_onclick", [[ | |
local executor = self:GetFrameRef("executor") | |
if math.random() < 0.5 then | |
executor:SetAttribute("type", "spell") | |
executor:SetAttribute("spell", "Concussive Shot") | |
else |
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 sympy as sp | |
import itertools as it | |
from sympy.physics.quantum import TensorProduct | |
def companion_matrix(p): | |
"""Gives companion matrix for polynomial p.""" | |
p = sp.Poly(p) | |
assert p.is_monic |
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
#include <stdint.h> | |
#include <string.h> | |
#define ROTL32(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) | |
#define LOAD_LE32(x) \ | |
(((x)[0] << 0) | \ | |
((x)[1] << 8) | \ | |
((x)[2] << 16) | \ | |
((x)[3] << 24)) |
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
// Pattern-defeating quicksort | |
// Copyright Orson Peters 2017. | |
// Distributed under the Boost Software License, Version 1.0. | |
// (See accompanying file LICENSE_1_0.txt or copy at | |
// http://www.boost.org/LICENSE_1_0.txt) | |
// See http://www.boost.org/libs/sort/ for library home page. |
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
#include <stdio.h> | |
#include <sodium.h> | |
int main(int argc, char **argv) { | |
int tries = 1; | |
sodium_init(); | |
while (1) { | |
unsigned char zero_public_key[crypto_sign_PUBLICKEYBYTES] = {0}; |
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
inline double fast_sin(double x) { | |
// Polynomial constants generated with sollya. | |
// fpminimax(sin(x), [|1,3,5,7|], [|D...|], [-pi/2;pi/2]); | |
// Both relative and absolute error is 9.39e-7. | |
const double magicround = 6755399441055744.0; | |
const double negpi = -3.14159265358979323846264338327950288; | |
const double invpi = 0.31830988618379067153776752674502872; | |
const double a = -0.00018488140186756154724131984146140; | |
const double b = 0.00831189979755905285208061883395203; | |
const double c = -0.16665554092439083255783316417364403; |
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
# Standard, Hardcore, tmpstandard, tmphardcore | |
league = "tmpstandard" | |
categories = [ | |
"DivinationCards", | |
"Essence", | |
"UniqueMap", | |
"UniqueFlask", | |
"UniqueWeapon", | |
"UniqueArmour", | |
"UniqueMap", |