Skip to content

Instantly share code, notes, and snippets.

View spacejam's full-sized avatar
💭
internet denier

Tyler Neely spacejam

💭
internet denier
View GitHub Profile
@inanna-malick
inanna-malick / eval.rs
Last active July 17, 2022 06:57
in haskell idioms, fused ana and cata - based on https://gist.github.com/Gankra/db892282bc7d579a0afe83c965f2320b
pub fn generate_layer(x: Box<ExprAST>) -> Expr<Box<ExprAST>> {
match *x {
ExprAST::Add(a, b) => Expr::Add(a, b),
ExprAST::Sub(a, b) => Expr::Sub(a, b),
ExprAST::Mul(a, b) => Expr::Mul(a, b),
ExprAST::LiteralInt(x) => Expr::LiteralInt(x),
}
}
pub fn eval_layer(node: Expr<i64>) -> i64 {
@porglezomp
porglezomp / Leftpad.idr
Last active October 7, 2023 23:25
Taking on Hillel's challenge to formally verify leftpad (https://twitter.com/Hillelogram/status/987432181889994759)
import Data.Vect
-- `minus` is saturating subtraction, so this works like we want it to
eq_max : (n, k : Nat) -> maximum k n = plus (n `minus` k) k
eq_max n Z = rewrite minusZeroRight n in rewrite plusZeroRightNeutral n in Refl
eq_max Z (S _) = Refl
eq_max (S n) (S k) = rewrite sym $ plusSuccRightSucc (n `minus` k) k in rewrite eq_max n k in Refl
-- The type here says "the result is" padded to (maximum k n), and is padding plus the original
leftPad : (x : a) -> (n : Nat) -> (xs : Vect k a)
@jcloutz
jcloutz / .golang-example-gitlab-ci.yml
Last active December 6, 2022 11:20
Example Gitlab CI setup for Go using the official golang docker image
image: golang:1.7
stages:
- build
- test
before_script:
- go get github.com/tools/godep
- cp -r /builds/user /go/src/github.com/user/
- cd /go/src/github.com/user/repo
@14427
14427 / hkt.rs
Last active February 7, 2024 10:18
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@denji
denji / golang-tls.md
Last active May 18, 2024 16:33 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@cmeiklejohn
cmeiklejohn / gist:8346377
Last active January 2, 2016 18:49
Think Distributed Systems Summer School; Providence, RI
Think Distributed Systems Summer School
Providence, RI
Curriculum
Friday (night session, open discussion)
* Background, introductions
* What are you working on in distributed systems?
* Lightning talks on research or open problems
@HeinrichApfelmus
HeinrichApfelmus / ForkLift.hs
Created June 7, 2012 14:26
Forklift - a pattern for performing monadic actions in a worker thread
-- see also
-- http://apfelmus.nfshost.com/blog/2012/06/07-forklift.html
module ForkLift where
import Control.Concurrent
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.State
@mardambey
mardambey / KafkaEmbedded.scala
Created May 10, 2012 02:58
Embedded Kafka broker / producer / simple consumer in a single process useful for testing or for persistent queues.
import java.util.Properties
import kafka.server.KafkaServer
import kafka.server.KafkaConfig
import kafka.producer.ProducerConfig
import kafka.producer.Producer
import kafka.message.Message
import kafka.producer.ProducerData
import kafka.consumer.ConsumerConfig
import kafka.consumer.Consumer
import kafka.utils.Utils