Skip to content

Instantly share code, notes, and snippets.

@NoCheroot
NoCheroot / You Need To Implement Non-Generic.md
Created April 8, 2019 14:15 — forked from Jaykul/You Need To Implement Non-Generic.md
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
#![windows_subsystem = "windows"]
extern crate winapi;
extern crate user32;
extern crate kernel32;
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use std::iter::once;
use std::mem;
use std::ptr::null_mut;
@NoCheroot
NoCheroot / combinators.js
Created November 8, 2018 20:21 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@NoCheroot
NoCheroot / state-example-game.js
Created October 24, 2018 14:15 — forked from hallettj/state-example-game.js
Implementation of a State monad in JavaScript
/*
* Example of a state monad in use. This is adapted from an example on
* the Haskell Wiki:
* http://www.haskell.org/haskellwiki/State_Monad#Complete_and_Concrete_Example_1
*/
require(['state', 'qunit'], function(state, qunit) {
/*
* playGame() is a recursive function that given an array of moves
* defines an algorithm for constructing a final game score. Along
@NoCheroot
NoCheroot / reset-wsl.sh
Created May 25, 2018 19:20 — forked from ishu3101/reset-wsl.sh
Resetting your Windows Subsystem for Linux (WSL) Environment
# Resetting your Windows Subsystem for Linux (WSL) Environment
lxrun.exe /uninstall /full
lxrun.exe /install
@NoCheroot
NoCheroot / struct-by-value.ss
Created May 12, 2018 18:52 — forked from egbulmer/struct-by-value.ss
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
@NoCheroot
NoCheroot / gist:1262a5bfbaa3dfe750ccc77c30fb18fc
Created February 2, 2018 21:53 — forked from mbrochh/gist:964057
Fast Forward Your Fork
# kudos to https://github.com/drewlesueur
# stolen from here: https://github.com/blog/266-fast-forward-your-fork#comment-11535
git checkout -b upstream-master
git remote add upstream git://github.com/documentcloud/underscore.git
git pull upstream master
git checkout master // [my master branch]
git merge upstream-master
git push origin master