Skip to content

Instantly share code, notes, and snippets.

@autotaker
autotaker / Cargo.toml
Last active September 30, 2022 02:06
[package]
name = "async-share"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1.21.1", features = ["fs","sync","macros","rt"] }
sqlx = { version = "0.6.2", features = ["postgres","runtime-tokio-rustls","chrono"] }
@autotaker
autotaker / Prime.hs
Created March 18, 2019 04:54
Type-level prime number validation
{-# LANGUAGE GADTs, DataKinds, UndecidableInstances, KindSignatures, TypeOperators, TypeFamilies #-}
module Prime where
import Data.Type.Bool
import Data.Type.Equality
import GHC.TypeLits
import Data.Kind
import Data.Proxy
type family IsFactorization (n :: Nat) (l :: [Nat]) :: Bool where
IsFactorization 0 l = False
from Crypto.Util.number import *
from functools import reduce
import random
p = 0xfffffed83c17
phi = p - 1
def factor():
c = phi
res = []
for i in range(2,152):
% -*- coding: utf-8 -*-
@require: stdja
%let-inline ctx \hoge ?:x y =
% match x with
% | Some x -> read-inline ctx x
% | None -> read-inline ctx (embed-string `none`) in
let-inline ctx \piyo ?:x =
match x with
{-# LANGUAGE BangPatterns #-}
module Queue (Queue, empty, snoc, head, tail) where
import Prelude hiding(head,tail)
-- invariant:
-- length (frontList q) - length (tailList q) - length (thunk q) == 0
data Queue a =
Queue {
frontList :: [a] -- O(1) to be evaluated to WHNF
, tailList :: [a] -- should be strict
{-# LANGUAGE BangPatterns #-}
module Queue (Queue, empty, snoc, head, tail) where
import Prelude hiding(head,tail)
-- invariant:
-- length (frontList q) == length (tailList q) + length (thunk q)
data Queue a =
Queue {
frontList :: [a]
, tailList :: [a]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/mman.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
def I(s):
val = 0
for i in range(len(s)):
digit = ord(s[len(s) - i - 1])
val <<= 8
val |= digit
return val
def Sn(i, length):
s = ''
p = 606341371901192354470259703076328716992246317693812238045286463;
g = [ 160057538006753370699321703048317480466874572114764155861735009, 255466303302648575056527135374882065819706963269525464635673824] * Mod(1,p)
A = [460868776123995205521652669050817772789692922946697572502806062, 263320455545743566732526866838203345604600592515673506653173727] * Mod(1,p)
B = [ 270400597838364567126384881699673470955074338456296574231734133, 526337866156590745463188427547342121612334530789375115287956485] * Mod(1,p)
Y0 = (g[1] / g[2] - 1);
Y1 = (A[1] / A[2] - 1);
Y2 = (B[1] / B[2] - 1);
import subprocess
import struct
import binascii
import random
import time
remote = True
if remote:
cmd = "nc inst-prof.ctfcompetition.com 1337"
else: