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
(defpackage #:delimited-continuations | |
(:use #:cl) | |
(:export #:with/dc #:reset #:shift)) | |
(in-package #:delimited-continuations) | |
(defmacro letcont ((&whole binding name lambda-list &body cbody) &body body) | |
(let ((old (gensym "OLD"))) | |
(multiple-value-bind (cforms cdecls) | |
(alexandria:parse-body cbody :whole binding) |
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
#lang racket | |
(require syntax/parse/define "foods.rkt" (for-syntax "foods.rkt")) | |
(add-delicious-food! "pineapple") | |
(add-delicious-food! "sushi") | |
(add-delicious-food! "cheesecake") | |
(define-simple-macro (add-food-combinations! [fst:string ...] | |
[snd:string ...]) | |
#:do [(for* ([fst-str (in-list (syntax->datum #'[fst ...]))] |
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
#! /usr/bin/env stack | |
-- stack --resolver lts-18.8 script | |
{-# LANGUAGE OverloadedStrings #-} | |
{- | |
This is a handy illustration of converting between five of the commonly-used | |
string types in Haskell (String, ByteString, lazy ByteString, Text and lazy | |
Text). |
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 shapeless._ // requires.shapeless | |
import cats._, implicits._, data.Kleisli // requires.cats | |
import cats.sequence._ //requires kittens | |
import cats.effect.IO //requires cats-effect | |
// ofc, uses "-Ypartial-unification" and kind-projector | |
case class Result() // replace with the JDBC equivalent | |
case class DB(val r: Result) { | |
def nextInt: IO[Int] = ??? //IO(g.nextInt) |
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
set(common_extreme_disable_opt "${common_extreme_disable_opt} -O0") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-aggressive-loop-optimizations") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-delete-null-pointer-checks") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-early-inlining") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-function-cse") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-gcse-lm") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-ira-hoist-pressure") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-ira-share-save-slots") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-ira-share-spill-slots") | |
set(common_extreme_disable_opt "${common_extreme_disable_opt} -fno-ivopts") |
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
param( | |
[string]$url | |
) | |
yt-dlp ` | |
$url ` | |
--quiet ` | |
--extract-audio ` | |
--audio-format mp3 ` | |
--audio-quality 3 ` |
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 std.traits : isCallable; | |
private auto curryImpl(F, CurriedArgs...)(F f, CurriedArgs curriedArgs) | |
{ | |
import std.traits : ParameterTypeTuple; | |
alias Args = ParameterTypeTuple!F; | |
static if(CurriedArgs.length == Args.length - 1) | |
return (Args[CurriedArgs.length] lastArg) => f(curriedArgs, lastArg); |
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 std.traits : isFunctionPointer; | |
private struct Curry(uint n, F...) | |
if(F.length == 1) | |
{ | |
import std.traits : ParameterTypeTuple; | |
alias Args = ParameterTypeTuple!F; | |
static if(is(F[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
def a l = def b; <<-NIGHTMARES; end; puts send l; end | |
😱😱😱 | |
NIGHTMARES | |
a |
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
// I'm cheating slightly by using features that aren't entirely stable yet. | |
// The reason is simple: the box matching code below becomes somewhat messier | |
// without `box_patterns`, and `box x` becomes `Box::new(x)` without | |
// `box_syntax`. | |
// This was tested on `play.rust-lang.org`'s nightly channel on 2015-08-03. | |
#![feature(box_patterns)] | |
#![feature(box_syntax)] | |
// Moo! | |
use std::borrow::Cow; |
NewerOlder