Skip to content

Instantly share code, notes, and snippets.

View Cauterite's full-sized avatar

Cauterite Cauterite

  • Australia
View GitHub Profile
@Cauterite
Cauterite / compile-ImGui.cmd
Created August 31, 2016 23:12
compiling ImGui with DMC
dmc -c -DIMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS=1 -DSIZE_T=size_t -Dsnprintf=_snprintf imgui.cpp imgui_draw.cpp
@Cauterite
Cauterite / gcstub.d
Created September 1, 2016 16:09
dmd-frontend GC
/**
* This module contains a minimal garbage collector implementation according to
* published requirements. This library is mostly intended to serve as an
* example, but it is usable in applications which do not rely on a garbage
* collector to clean up memory (ie. when dynamic array resizing is not used,
* and all memory allocated with 'new' is freed deterministically with
* 'delete').
*
* Please note that block attribute data must be tracked, or at a minimum, the
* FINALIZE bit must be tracked for any allocated memory block because calling
/* -------------------------------------------------------------------------- */
import Dll_ = core.sys.windows.dll;
import W32_ = core.sys.windows.windows;
/* -------------------------------------------------------------------------- */
/* --- runtime initialisation --- */
version (CRuntime_DigitalMars) {} else {static assert(0);};
Array(5)
-> [<5 empty slots>]
[...Array(5)]
-> [undefined, undefined, undefined, undefined, undefined]
[...Array(5)].map((_, X) => X)
-> [0, 1, 2, 3, 4]
[...Array(5).keys()]
(() => {
var let = (f) => f();
let a = 2, b = 5;
let c = let((
x = a + b,
y = x * 2
) =>
y * 2
@Cauterite
Cauterite / ident-chars.js
Created February 8, 2017 09:07
valid ANSI characters in JS identifiers
[...Array(256).keys()]
.map(X => String.fromCharCode(X))
.filter(X => !/\s/.test(X))
.filter(X => {
try {
eval(`() => {let _${X} = 0;}`);
} catch (Err) {
return false;
};
return true;
# comments
<# multiline comments #>
# running unsigned scripts
c:\> powershell -ExecutionPolicy Bypass -File foo.ps1
# filter, map
get-process |
where {$_.ProcessName -eq "svchost"} |
foreach {$_.Id}
# ------------------------------------------------------------------------------
# loads libcurl.dll and calls curl_version()
#
set-strictmode -version 'latest'
$erroractionpreference = 'Stop'
#if ([intptr]::size -ne 8) {
# throw 'not a 64-bit powershell instance'}
$w32 = Add-Type -Namespace Win32 -Name Win32 -PassThru -MemberDefinition @'
using System.Linq;
class Foo {
static void Main(string[] _) {
var xs = new[] {"apple", "passionfruit", "banana", "mango", "pear",};
/* https://msdn.microsoft.com/en-us/library/9eekhta0 */
var ys = xs
# ------------------------------------------------------------------------------
# Leopard Systems ? (2017)
# contributors: Adam Laing
# note: requires powershell 2.0 or later
set-strictmode -version 'latest'
$erroractionpreference = 'stop'