Skip to content

Instantly share code, notes, and snippets.

@dyoo
dyoo / fizzbuzz.rkt
Last active December 12, 2015 02:08 — forked from bradclawsie/fizzbuzz.rkt
#lang typed/racket
(define-type T (U String Integer))
(: fizzbuzz/1 : (Integer -> T))
(define (fizzbuzz/1 x)
(define mod3 (zero? (modulo x 3)))
(define mod5 (zero? (modulo x 5)))
(cond [(and mod3 mod5) "fizzbuzz"]
[mod3 "fizz"]
@dyoo
dyoo / gist:4699554
Last active December 12, 2015 02:29
An answer to mithos28's question in http://racket-lang.org/irc-logs/20130201.txt at 2:19
#lang racket
(require unstable/sequence)
(define los (list '(1 2 3)
'("a" "b" "c")))
(define (f elts)
(format "I see: ~s" elts))
(define result
@dyoo
dyoo / gist:4717964
Created February 5, 2013 21:39
debugging output from gzip
128-110-72-21:gzip-1.2.4 dyoo$ ./gunzip -c ~/Desktop/test.gz
inflate
inflate block
nextbyte: 149
nextbyte: 206
nextbyte: 61
nextbyte: 114
nextbyte: 195
nextbyte: 32
nextbyte: 16
@dyoo
dyoo / gist:4718091
Last active December 12, 2015 04:58
Investigating bytes
#lang racket
(require file/gzip
file/gunzip)
(define sample-file
(bytes-append #"(\"5.3.2\" (\"ab7f6f4533252566bc62383ca395f8272851592b\""
#" . \"9364523f1c28f962fb967025aa140670c9b5b9a5\") "
#"#\"/Users/dyoo/work/minipascal/minipascal/lang/../semantics.rkt\""
#" (collects #\"syntax\" #\"parse\" #\"private\" #\"runtime-report.rkt\")"
@dyoo
dyoo / gist:4718185
Created February 5, 2013 22:07
Annotations to observe what bytes deflate.c looks at.
128-110-72-21:updated-gzip-1.2.4 dyoo$ diff -u inflate.c ../gzip-1.2.4/inflate.c
--- inflate.c 2013-02-05 15:05:33.000000000 -0700
+++ ../gzip-1.2.4/inflate.c 1993-08-13 08:50:20.000000000 -0600
@@ -212,16 +212,14 @@
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
-int theByte;
-
#ifdef CRYPT
@dyoo
dyoo / gist:4719330
Created February 6, 2013 01:10
danl-ndl
#lang racket
(require syntax/parse)
(define (test-syntax stx)
(syntax-parse stx
((~and (one two (three four ...) ...) WHOLE)
(syntax/loc stx #'WHOLE))))
@dyoo
dyoo / rl.rkt
Last active December 12, 2015 08:18
attack on pr 13350
#lang racket/base
(require ffi/unsafe
racket/port)
(provide readline start)
(define libreadline (ffi-lib "libreadline" '("5" "6" "4" "")))
(define rl-callback-handler-install
(get-ffi-obj "rl_callback_handler_install" libreadline
#lang racket/base
(require ffi/unsafe
racket/port)
(provide readline start)
(define libreadline (ffi-lib "libreadline" '("5" "6" "4" "")))
(define rl-callback-handler-install
(get-ffi-obj "rl_callback_handler_install" libreadline
@dyoo
dyoo / gist:4798844
Created February 13, 2013 01:18
Testing word breaks
<!DOCTYPE html>
<html>
<head>
<style>
/* A hack, inserted to break some Scheme ids: */
.mywbr {
width: 0;
font-size: 1px;
}
</style>
@dyoo
dyoo / gist:4949192
Created February 13, 2013 23:01
repeating decimal snip play
#lang racket
(require framework)
(number-snip:make-repeating-decimal-snip 22/7 #f)