Skip to content

Instantly share code, notes, and snippets.

@alex-hhh
alex-hhh / tetris-3.rkt
Last active April 3, 2020 15:05
Tetris Game -- Third Version
;; A tetris game -- partial implementation, part 3
;; Copyright (c) 2020 Alex Harsányi (AlexHarsanyi@gmail.com)
;; Permission is hereby granted, free of charge, to any person obtaining a
;; copy of this software and associated documentation files (the "Software"),
;; to deal in the Software without restriction, including without limitation
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
;; and/or sell copies of the Software, and to permit persons to whom the
;; Software is furnished to do so, subject to the following conditions:
@alex-hhh
alex-hhh / tetris-2.rkt
Last active March 7, 2020 07:39
Tetris Game -- Second Implementation
;; A tetris game -- partial implementation, part 2
;; Copyright (c) 2020 Alex Harsányi (AlexHarsanyi@gmail.com)
;; Permission is hereby granted, free of charge, to any person obtaining a
;; copy of this software and associated documentation files (the "Software"),
;; to deal in the Software without restriction, including without limitation
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
;; and/or sell copies of the Software, and to permit persons to whom the
;; Software is furnished to do so, subject to the following conditions:
@alex-hhh
alex-hhh / tetris-1.rkt
Created March 7, 2020 01:17
Tetris Game -- First Interactive Application
;; A tetris game -- partial implementation, part 1
;; Copyright (c) 2020 Alex Harsányi (AlexHarsanyi@gmail.com)
;; Permission is hereby granted, free of charge, to any person obtaining a
;; copy of this software and associated documentation files (the "Software"),
;; to deal in the Software without restriction, including without limitation
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
;; and/or sell copies of the Software, and to permit persons to whom the
;; Software is furnished to do so, subject to the following conditions:
@alex-hhh
alex-hhh / racket-gui-157-demo.rkt
Created January 22, 2020 23:14
Snip instances with copy - paste functionality -- note that snips are pasted on top of each other, so you need to drag them around with the mouse to see that they were copied
#lang racket/gui
(define chess-piece-snip-class
(make-object
(class snip-class%
(super-new)
(send this set-classname "chess-piece-snip"))))
(send (get-the-snip-class-list) add chess-piece-snip-class)
@alex-hhh
alex-hhh / tz-lookup-results-7.3.md
Last active August 3, 2019 05:22
tz-lookup performance results using Racket 7.3

https://alex-hhh.github.io/2019/08/timezone-lookup.html

These are the test results when running the tests mentioned in the above blog post against Racket 7.3, I did not run the first test, as it takes way too long. These results indicate that Racket 7.3 is faster than Racket-on-Chez used for the measurements in that blog post, but the aim of the blog post was not to measure the performance difference between Racket versions. Since the results are interesting, I decided to move them here, rther than discard them.

You can run the tests yourself, see https://github.com/alex-hhh/time-zone-lookup-tests

Bounding Boxes (2)

@alex-hhh
alex-hhh / world-map.rkt
Last active August 20, 2019 03:01
World Map, standard-fish competition 2019
#lang racket
(require json racket/draw math/base)
(define (lat-lon->map-point coordinates)
(match-define (list lon lat _ ...) coordinates)
(define-values (x y) (values (degrees->radians lon) (asinh (tan (degrees->radians lat)))))
(list (/ (+ 1 (/ x pi)) 2) (/ (- 1 (/ y pi)) 2)))
(define (draw-polygon dc polygons)
(define path
#lang racket
(require json)
;; Example 0: Load and manipulate the Timezone GeoJSON file
;; You will also need to download timezone data from:
;;
;; https://github.com/evansiroky/timezone-boundary-builder/releases
;; Copyright (c) 2019 Alex Harsányi
@alex-hhh
alex-hhh / pwgen-gui.rkt
Created March 27, 2019 03:46
Password Generator Gui
#lang racket/gui
;; Copyright (c) 2019 Alex Harsányi
;; Permission is hereby granted, free of charge, to any person obtaining a
;; copy of this software and associated documentation files (the "Software"),
;; to deal in the Software without restriction, including without limitation
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
;; and/or sell copies of the Software, and to permit persons to whom the
;; Software is furnished to do so, subject to the following conditions:
#lang racket/base
;; Copyright (c) 2019 Alex Harsanyi
;; Permission is hereby granted, free of charge, to any person obtaining a
;; copy of this software and associated documentation files (the "Software"),
;; to deal in the Software without restriction, including without limitation
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
;; and/or sell copies of the Software, and to permit persons to whom the
;; Software is furnished to do so, subject to the following conditions:
@alex-hhh
alex-hhh / colormap.rkt
Last active March 21, 2022 06:51
plot color maps
#lang racket
(require racket/draw
racket/promise
plot
plot/utils
pict)
;; These color maps correspond to the Matplotlib 3.0.3 qualitative color maps
;; with the same names. See
;; https://matplotlib.org/examples/color/colormaps_reference.html