Skip to content

Instantly share code, notes, and snippets.

@takikawa
takikawa / gist:6253646
Created August 16, 2013 21:28
Internal definition context stages of grief
<samth> my experience is that the internal definition context stages of grief are:
<samth> (1) what are these int-def-ctx arguments?
<samth> (2) this stuff makes no sense
<samth> (3) why is it so imperative?
<samth> (4) i can't think of a better way
<samth> (5) i am ryan culpepper
#!/bin/bash
set -e
(raco pkg show $1 | grep clone) || (raco pkg remove $1 && raco pkg install --no-setup --clone $1)
cd $1
hub fork || echo "fork already exists"
hub checkout -b auto-fix-deps || hub checkout auto-fix-deps
hub reset --hard origin/master
raco setup --fix-pkg-deps || echo "fixed"
@eu90h
eu90h / rand.rkt
Last active September 17, 2015 02:07
OS-based rng access
#lang racket/base
(require racket/contract/base "unix_rand.rkt" "windows_rand.rkt" (only-in file/sha1 bytes->hex-string))
(provide (contract-out [crypto-random-bytes (-> exact-positive-integer? (or/c bytes? string?))]
[crypto-random (-> exact-positive-integer? exact-positive-integer?)]))
(define bytes->number (compose (lambda (s) (string->number s 16)) bytes->hex-string))
; (: crypto-random-bytes (-> Positive-Integer Bytes))
; returns n random bytes from the os.
(define (crypto-random-bytes n)
@greghendershott
greghendershott / pkgs.md
Created November 11, 2015 20:05
Some interesting Racket packages

Sound and Vision

identikon

rsound

Testing and Coverage

rackunit-chk

#lang racket/base
(require net/url
racket/match)
(define pkgs
(let ([pkgs (call/input-url (string->url "https://pkgs.racket-lang.org/pkgs-all")
get-pure-port
read)])
(for/fold ([pkgs pkgs])
@greghendershott
greghendershott / trace.log-rkt
Last active October 25, 2018 22:48
Make racket/trace output go to a logger
#lang racket/base
(require racket/format
racket/list
racket/match
racket/trace)
(provide (all-defined-out)
(all-from-out racket/trace))
@deeglaze
deeglaze / standard-cat.rkt
Last active July 20, 2019 14:11
working out the definition of Racket's to-be standard-cat
#lang racket
(require pict/color)
(provide
(contract-out
[cat-silhouette
(->i ([width positive?] [height positive?])
(#:left-ear-extent [left-ear-extent (>=/c 0)]
#:left-ear-arc [left-ear-arc (real-in 0 (* 2 pi))]
#:left-ear-angle [left-ear-angle (real-in 0 (* 2 pi))]
@greghendershott
greghendershott / validate-email.rkt
Created November 3, 2017 21:48
Validating email addresses
#lang racket/base
(require racket/match
net/dns)
(provide validate-address)
(define (validate-address s)
(match s
[(regexp "^([^@]+)@(.+)$" (list _ user domain))
@modernserf
modernserf / bestiary.md
Last active December 27, 2020 21:54
Syntax bestiary

Simple value literals

Numbers

syntax examples languages
decimal literals -123.45 (most languages)
scientific notation 1.23e-2
prefix hexadecimal 0xDEADBEEF
prefix binary 0b1110
prefix octal 0o777
@samdphillips
samdphillips / 00-README.md
Last active November 5, 2019 00:30
Using Rebellion in Anger

Rebellion Examples

Here are some "real world" (some day to day one-time tasks from my work) using Rebellion(pkg, github) an infrastructure library for Racket.