Skip to content

Instantly share code, notes, and snippets.

// concepts:
// - functional style: higher-order functions, type aliases
// - testing in REPL
object AreaCalculatorApp {
def main(args: Array[String]) = println(area(readVertices(args(0))))
type Vertex = (Double, Double)
def area(vertices: Seq[Vertex]) = triangulate(vertices) map(triangleArea _) sum
// concepts:
// - actors
// - pattern matching
// - Option (None/Some(x))
// -- enums etc
object Figure extends Enumeration {
type Figure = Value
val Paper, Scissors, Stone = Value
}
@endolith
endolith / LICENSE.txt
Last active January 14, 2024 07:37
Arduino hardware true random number generator
MIT License
Copyright (c) 2012 endolith
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:
@hashmal
hashmal / shirka_draft.mkd
Last active July 3, 2020 14:03
Design of the Shirka programming language.

Shirka

Automatic garbage collection has made possible the implementation of many flexible, high-level languages in which memory management can simply be ignored most of the time. Unfortunately, garbage collectors have some properties that make their use in several fields (namely real-time applications) unpractical or even impossible:

  • Program execution is suspended during garbage collection cycles ("GC
@suxue
suxue / WebSocketServer.sh
Created March 16, 2014 11:52
simple WebSocket Server make use of netcat
#!/bin/ksh
typeset port=$((RANDOM % 60000))
while ((port < 30000)); do
port=$((RANDOM % 60000))
done
typeset pipe=`mktemp -u`
mkfifo $pipe
trap "rm -f $pipe" INT
@tlrobinson
tlrobinson / docker-pull.sh
Last active October 18, 2023 21:59
Quick and dirty "docker pull"-like shell script.
#!/usr/bin/env bash
set -eu
name="library/redis"
tag="latest"
registry="https://registry-1.docker.io"
blobs="blobs"
data="images/$name/$tag"
@mauron85
mauron85 / letsencrypt-cert
Last active March 9, 2021 03:20
Auto refresh LetsEncrypt cert for NGINX with letsencrypt-auto
#!/bin/bash
echo "Running as user $USER"
DIR=/home/letsencrypt/letsencrypt
DOMAIN=mydomain.com
$DIR/letsencrypt-auto -a webroot --webroot-path /home/letsencrypt/webroot/ \
--config-dir /home/letsencrypt/etc \
--logs-dir /home/letsencrypt/log \

Listpack specification

Version 1.0, 1 Feb 2017: Intial specification.

Version 1.1, 2 Feb 2017: Integer encoding simplified. Appendix A added.

Version 1.2, 3 Feb 2017: Better specify the meaning of the num-elements
                         field with value of 65535. The two 12 bits

positive/negative integers encodings were

@qwerty12
qwerty12 / AHKLogonMediaKeys.ahk
Last active December 3, 2021 01:30
Sample script for LogonDesktop. Enables media keys on the lockscreen
#NoTrayIcon
#Persistent
#NoEnv
#Include *i %A_ScriptDir%\Lib\FastDefaults.ahk
SetKeyDelay, -1, -1
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Off ; This same script is launched multiple times
#UseHook Off ; Remove if you need complex hotkeys. WM_HOTKEY suits me fine; I don't want a low-level keyboard/mouse hook installed on WinSta0\Winlogon
#Include %A_ScriptDir%\Lib\LogonDesktop.ahk ; Naturally, this one is needed
@qwerty12
qwerty12 / LogonDesktop.ahk
Last active February 13, 2024 19:48
Bunch of functions to help facilitate running AutoHotkey on the Winlogon desktop - https://autohotkey.com/boards/viewtopic.php?f=6&t=27709
; LogonDesktop - run scripts on the Winlogon desktop
; 26/02/17 - qwerty12
; Modified version of RunAsTask() by SKAN: https://autohotkey.com/boards/viewtopic.php?t=4334
LogonDesktop_AddTask(runNow, runOnStartup)
{
local TaskName, XML, TaskSchd, TaskRoot, RunAsTask
local TASK_CREATE := 0x2, TASK_LOGON_SERVICE_ACCOUNT := 5, scriptDir := A_ScriptDir
try