Skip to content

Instantly share code, notes, and snippets.

#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 ...]))]
@dino-
dino- / string-conversions.hs
Last active May 3, 2024 08:57
A handy illustration of converting between String, Text and ByteString in Haskell
#! /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).
@SystemFw
SystemFw / Lib.scala
Last active June 7, 2019 05:15
Shapeless: derive JDBC Results for arbitrary case classes
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)
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")
@milleniumbug
milleniumbug / getmus.ps1
Last active April 14, 2024 22:29
download video from YouTube, extract music and normalize volume
param(
[string]$url
)
yt-dlp `
$url `
--quiet `
--extract-audio `
--audio-format mp3 `
--audio-quality 3 `
@JakobOvrum
JakobOvrum / curry_delegate.d
Created October 17, 2015 16:30
Curry implementation using delegates (inefficient but yields known types)
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);
@JakobOvrum
JakobOvrum / curry.d
Last active October 17, 2015 16:31
Curry implementation using structs (efficient but yields unwieldy types)
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]))
@drbrain
drbrain / nightmares.rb
Last active July 25, 2017 17:40
A method that has a default argument that defines a method that contains a here-document
def a l = def b; <<-NIGHTMARES; end; puts send l; end
😱😱😱
NIGHTMARES
a
anonymous
anonymous / playground.rs
Created August 3, 2015 09:09
Shared via Rust Playground
// 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;
package main
import "fmt"
type SomeError struct { string }
var err *SomeError
func (x *SomeError) Error()string { return x.string }
func MaybeLog(err error) {