Skip to content

Instantly share code, notes, and snippets.

@alex-hhh
alex-hhh / plot-interactive-overlay-demo.rkt
Last active February 7, 2018 08:57
Plot interactive overlay demo
#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)
@SimonDanisch
SimonDanisch / 2_7billion_points.jl
Created October 31, 2017 11:25
Plotting 2.7 billion points
using TextParse
using TextParse: Record, Field, Numeric, tryparsenext
# Helper type to memory map a file as a string
struct MMapString{T}
# using Type parameter, too lazy to write out the result type of mmap,
# but also don't want to loose performance
x::T
end
MMapString(path::String) = MMapString(Mmap.mmap(open(path), Vector{UInt8}))
@egbulmer
egbulmer / struct-by-value.ss
Created March 30, 2017 11:56
Chez Scheme FFI - Structs returned by value
(load-shared-object "./libsbv.so")
(define-ftype color
(struct
[r float]
[g float]
[b float]
[a float]))
(define make-rgba
@Jaykul
Jaykul / You Need To Implement Non-Generic.md
Created April 27, 2016 01:48
Implementing IEnumerator<T> in PowerShell

In order to implement IEnumerator<T> you have to explicitly implement the Current member for IEnumerator<T> and IEnumerator ... but PowerShell won't let you have two different implementations of the same property, nor will it let you explicitly implement an interface member. So we do one at a time, like this:

First, make a non-generic IEnumerator, but implemented with the type you want in the end:

    class __Generator : System.Collections.IEnumerator {
        [int]$Actual = 0

        [object]get_Current() {
            return $this.Actual
@p3t3r67x0
p3t3r67x0 / openssl_commands.md
Last active May 15, 2025 17:31
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@ahillo
ahillo / llvm+mingw+gdb.md
Last active September 9, 2022 12:59
Using LLVM+MinGW to compile LLVM IR to an exe on Windows, with gdb-compatible debug symbols

Pseudo-C file (03.cpp)

int main(int argc, const char *argv[]) {
	print("hello 123 world");
	print("hello 123 world");
	print("hello 123 world");
	return 0;	
}
@ctigeek
ctigeek / PowershellAes.ps1
Last active May 30, 2025 11:47
Aes Encryption using powershell.
function Create-AesManagedObject($key, $IV) {
$aesManaged = New-Object "System.Security.Cryptography.AesManaged"
$aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC
$aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros
$aesManaged.BlockSize = 128
$aesManaged.KeySize = 256
if ($IV) {
if ($IV.getType().Name -eq "String") {
$aesManaged.IV = [System.Convert]::FromBase64String($IV)
}
@mattmight
mattmight / pythedral.py
Created December 2, 2014 22:48
Church Python
# Void
VOID = lambda void: void
# Booleans / Conditionals
IF = lambda c: lambda t: lambda f: c(t)(f)

How I Wish Racket Was First Explained To Me

I've been taking a compilers class this semester from Matt Might, which has been a great experience. Amongst the most challenging/interesting aspects of the course has been taming Racket, a Scheme-y/LISP-y language (I'll leave it at that).

Having never used anything functional/LISP-y in my days, this was a brand new experience. On the whole, it was good, but here's how I wish my first introduction to the language had gone as it would have set me on the right foot. While I'm focusing on Racket here, I imagine this same thing applies to LISP/Scheme and its derivatives.

Code vs. Data

I read everywhere that, "In Racket, code and data are the same thing." That sentence alone was useless to me, and it took a number of weeks before I "got it." Perhaps this explanation may have been more helpful:

@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`: