Skip to content

Instantly share code, notes, and snippets.

View greghendershott's full-sized avatar

Greg Hendershott greghendershott

View GitHub Profile
@greghendershott
greghendershott / gist:4233480
Created December 7, 2012 14:09
A gist to check if Github has deployed the Racket lexer

Before Github deploys the Racket lexer from pygments-main via pygments.rb, the following will appear as plain, black monospace. After they deploy, this will appear color-coded:

(let ([x 0])
  x)

Then it will look similar to the Scheme lexer (below) but, as the most glaring example, brackets will not be colored as errors:

@greghendershott
greghendershott / racket-personas.md
Created December 12, 2012 16:24
Racket user personas

Racket user personas

Racket doesn't have a full-time "Product Manager", doesn't need one, and I'm certainly not one. However I think it might be useful to borrow an idea from PM and think about so-called user personas.

Somtimes PMs will give each persona name, and tell a story: Bob wants to accomplish X. Here's how he uses the product. What does he expect? How does he get confused? And so on.

@greghendershott
greghendershott / git-workflow.md
Last active September 30, 2016 14:56
Draft of guide for new and/or casual contributors to Racket. Again, this is a DRAFT. Please be careful using. If you spot any mistakes, please let me know.

A guide for new and/or casual contributors to Racket

Maybe you're comfortable with Git, but haven't made a pull request before.

Maybe you've made one-off pull requests, but haven't tried to contribute to the same project over time and stay in sync with the upstream project.

This guide may help. DRAFT

@greghendershott
greghendershott / gist:4381886
Last active December 10, 2015 04:38
Re: danking 12:38 [17:36:45] I'm sure this has been asked a thousand times but how do I get the effect of taking ((a ...) (b ...)) and making (a b a b a b ...) with syntax-patterns?
#lang racket
(require (for-syntax racket/list))
(define-syntax (foo stx)
(syntax-case stx ()
[(_ (as ...) (bs ...))
#`(list #,@(append* (map list
(syntax-e #'(as ...))
(syntax-e #'(bs ...)))))]))
@greghendershott
greghendershott / dict-sugar.rkt
Created January 17, 2013 00:08
Ideas about making Racket `dict` access more succinct.
#lang racket
;; Ideas about making Racket `dict` access more succinct.
;; [0]
;;
;; Macro to define variables and initialize them from a dict.
;;
;; Given a dictionary and some symbols: For each symbol, define a
;; variable whose value is that from the dictionary (else 'UNDEFINED).

Given this:

#lang racket/base

(require ffi/unsafe
         ffi/unsafe/define)

...
#lang racket
;; Goal: Define a function `getback`, which given a number
;; returns a number with the digits reversed.
;; Example: (getback 123) returns 321
;; Let's break it down into a couple of steps.
;; 1. Given a number, return it as a list of digits.
;; number? -> (listof number?)
@greghendershott
greghendershott / gist:5223970
Last active January 20, 2018 15:45
Using `with-handlers` to catch exceptions.
#lang racket
;; The way to catch exceptions is `with-handlers`.
;; See http://docs.racket-lang.org/reference/exns.html
;;
;; You specify the type of exception, and a function to handle it. The
;; exception object is passed to the function.
;;
;; For exmaple, we'll catch the "generic" `exn:fail?` with a function
;; that we define in-place using `lambda`:
#lang racket
(define (f1)
"f1")
(define (f2)
"f2")
(define h (hash "f1" f1
"f2" f2))
#lang racket/base
(provide ~> ~>>)
(require (for-syntax racket/base syntax/parse))
(require (rename-in "app.rkt" [-#%app #%app]))
(require (only-in racket/function curry))
;; Clojure threading macros. This is almost all courtesy of Asumu
;; Takikawa. I did add handling of quote (symbols) to make sure it