Skip to content

Instantly share code, notes, and snippets.

View bennn's full-sized avatar

Ben Greenman bennn

View GitHub Profile
@niw
niw / libpng_test.c
Last active November 18, 2024 00:15
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng16 libpng_test.c
@drawveloper
drawveloper / compress-pdf-with-gs.md
Created August 30, 2013 14:39
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active November 19, 2024 11:06
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
#lang racket
;; Updated plot library required, https://github.com/alex-hhh/plot/tree/ah/interactive-overlays
(require plot pict)
;; Helper function to add a pict as a plot overlay -- don't want to add "pict"
;; as a dependency to the "plot" package
(define (add-pict-overlay plot-snip x y pict)
(send plot-snip add-general-overlay x y
(lambda (dc x y) (draw-pict pict dc x y))
(pict-width pict)
@AndiH
AndiH / tikz-arrows.pdf
Last active April 23, 2024 01:54
TikZ Arrow Tip Overview
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#lang scratch
(require compiler/zo-structs
(for-syntax compiler/zo-structs
racket/struct-info))
(begin-for-syntax
(define-values (exports expsyn)
(module->exports 'compiler/zo-structs))
(define struct-types
@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
@LiberalArtist
LiberalArtist / default-lightbulb.png
Last active October 2, 2019 01:20
A Racket lightbulb for the Standard Fish Summer Competition 2019
default-lightbulb.png
@brianhempel
brianhempel / remove_rightslink_images
Last active April 23, 2021 20:31
Remove ugly “RightsLink” images in PDFs from the new ACM Digital Library.
@graninas
graninas / What_killed_Haskell_could_kill_Rust.md
Last active November 5, 2024 02:15
What killed Haskell, could kill Rust, too

At the beginning of 2030, I found this essay in my archives. From what I know today, I think it was very insightful at the moment of writing. And I feel it should be published because it can teach us, Rust developers, how to prevent that sad story from happening again.


What killed Haskell, could kill Rust, too

What killed Haskell, could kill Rust, too. Why would I even mention Haskell in this context? Well, Haskell and Rust are deeply related. Not because Rust is Haskell without HKTs. (Some of you know what that means, and the rest of you will wonder for a very long time). Much of the style of Rust is similar in many ways to the style of Haskell. In some sense Rust is a reincarnation of Haskell, with a little bit of C-ish like syntax, a very small amount.

Is Haskell dead?