Skip to content

Instantly share code, notes, and snippets.

from mpmath import mp, mpf
from fractions import Fraction
from gmpy2 import bit_scan1 as ctz
mp.dps = 999
print(mp)
def ceil(x):
return int(mp.ceil(x))
" Name: No Frils Dark Colorscheme
" Author: robertmeta (on Github)
" URL: https://github.com/robertmeta/nofrils
" (see this url for latest release & screenshots)
" License: OSI approved MIT license
hi clear
if exists("syntax_on")
syntax reset
endif
package main
import (
"crypto/hmac"
"crypto/sha256"
"fmt"
"hash"
"io"
"golang.org/x/crypto/hkdf"
@ericlagergren
ericlagergren / poly.c
Created February 5, 2022 19:23
POLYVAL x86_64
#include <immintrin.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
// hi lo
// Vd, Vn, Vm, #imm
#define vext8(x, y) ({ \
uint64_t xhi = _mm_extract_epi64((x), 1); \
uint64_t ylo = _mm_extract_epi64((y), 0); \
@ericlagergren
ericlagergren / poly.c
Created January 31, 2022 23:54
POLYVAL ARMv8
#include <arm_neon.h>
#include <stdint.h>
typedef uint8x16_t u128;
#define pmullq_u8(a, b) ({ \
u128 r; \
__asm__ __volatile__("pmull %0.1q, %1.1d, %2.1d \n\t" \
: "=w"(r) \
: "w"((a)), "w"((b))); \
@ericlagergren
ericlagergren / spectre.c
Created January 4, 2018 03:57 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
/*-------, .-------*
| +----------------------+ |
*----| THE REALTIME GUILD |----*
`*--------------------*/
#ifndef ListH
#define ListH
#include <stdlib.h>
#include <string.h>
#define LIST_DECLARE_EX(n,t,r) \
typedef struct list_##n { t* v; unsigned c, a; } list_##n; \
void list_init_##n (list_##n * list); \
void list_clear_##n (list_##n * list); \
func makePipe(path string) (file *os.File, err error) {
err = unix.Mkfifo(path, 0777)
if err != nil {
return nil, err
}
// mkfifo(3) states:
// "It is modified by the process's
// umask in the usual way: the permissions of the created file are
// (mode & ~umask)."
// The pipe must be writeable by other users.
loadjs=function(){function h(){}function r(a,c){a=a.push?a:[a];var b=[],d=a.length,e=d,g,f,m;for(g=function(a,d){d.length&&b.push(a);e--;e||c(b)};d--;)f=a[d],(m=n[f])?g(f,m):(f=l[f]=l[f]||[],f.push(g))}function p(a,c){if(a){var b=l[a];n[a]=c;if(b)for(;b.length;)b[0](a,c),b.splice(0,1)}}function t(a,c){var b=document,d=b.createElement("script");d.src=a;d.onload=d.onerror=function(b){c(a,b.type)};b.head.appendChild(d)}function u(a,c){a=a.push?a:[a];var b=a.length,d=b,e=[],g;for(g=function(a,b){"e"==
b[0]&&e.push(a);d--;d||c(e)};b--;)t(a[b],g)}function k(a,c,b,d){var e,g,f;c&&!c.call&&(e=c);g=e?b:c;f=e?d:b;if(e){if(e in q)throw Error("LoadJS: Bundle already defined");q[e]=!0}u(a,function(a){a.length?(f||h)(a):(g||h)();p(e,a)})}var q={},n={},l={};k.a=function(a,c,b){r(a,function(a){a.length?(b||h)(a):(c||h)()});return k};k.done=function(a){p(a,[])};return k}();