Skip to content

Instantly share code, notes, and snippets.

// concepts:
// - actors
// - pattern matching
// - Option (None/Some(x))
// -- enums etc
object Figure extends Enumeration {
type Figure = Value
val Paper, Scissors, Stone = Value
}
// 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
@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
@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 \
@qwerty12
qwerty12 / enable-all-advanced-power-settings.ps1
Last active November 2, 2021 09:07 — forked from raspi/enable-all-advanced-power-settings.ps1
Enable all advanced power settings in Windows.
# List all possible power config GUIDs in Windows
# Run: this-script.ps1 | Out-File powercfg.ps1
# Then edit and run powercfg.ps1
# (c) Pekka "raspi" Järvinen 2017
# https://stackoverflow.com/a/22156833
if (-not ([System.Management.Automation.PSTypeName]'PowrProf').Type)
{
Add-Type -TypeDefinition @"
using System;
@qwerty12
qwerty12 / TermWait.ahk
Last active November 2, 2021 09:07
Slightly modified version of cyruz' and SKAN's TermWait for LogonDesktop
; ----------------------------------------------------------------------------------------------------------------------
; Name .........: TermWait library
; Description ..: Implement the RegisterWaitForSingleObject Windows API.
; AHK Version ..: AHK_L 1.1.13.01 x32/64 Unicode
; Author .......: Cyruz (http://ciroprincipe.info) & SKAN (http://goo.gl/EpCq0Z)
; License ......: WTFPL - http://www.wtfpl.net/txt/copying/
; Changelog ....: Sep. 15, 2012 - v0.1 - First revision.
; ..............: Jan. 02, 2014 - v0.2 - AHK_L Unicode and x64 version.
; ----------------------------------------------------------------------------------------------------------------------
@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
@vurtun
vurtun / lay.c
Last active December 15, 2021 22:37
// gui_lay_row(ctx, 3, (int[]) { 30, -90, -1 }, 0);
/* Layout */
enum gui_lay_dir {
GUI_ROW,
GUI_COL,
};
struct gui_lay_sol {
int fix_siz;
int fix_cnt;

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 / termux-url-opener
Last active July 7, 2023 07:40
Install the followig at least: VLC in Android, `jq`, Termux API, `youtube-dl`, `streamlink`, `gallery-dl` and `aria2c`
#!/data/data/com.termux/files/usr/bin/bash
if [ -z "${1:-}" ]; then
exit 1
fi
url_is_supported() {
REPLY=""
declare -A arr
case "$1" in