Skip to content

Instantly share code, notes, and snippets.

@mhoyer
mhoyer / cupid.xml
Created July 29, 2022 18:57
An attempt to build LineageOS for Xiaomi 12
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<include name="default.xml" />
<remote name="github-los-19.1"
fetch="https://github.com"
revision="lineage-19.1" />
<project path="device/xiaomi/cupid" name="cupid-development/android_device_xiaomi_cupid" remote="github-los-19.1" clone-depth="1" />
@mhoyer
mhoyer / rx-colored-letter-numbers.ts
Last active August 29, 2018 21:10
Reverse stream processing when merging two streams
import { from, zip, timer, Observable } from 'rxjs';
const colors: any = {
'red ': 31,
'green ': 32,
'yellow ': 33,
'blue ': 34,
'magenta': 35,
'cyan ': 36,
'white ': 37,
function stashed-git-command() {
if ! git diff --exit-code -s ; then
echo " >>> stashing"
git stash
stashpop=true
fi
$* && [ $stashpop ] && \
echo " <<< unstashing" && \
git stash pop
@mhoyer
mhoyer / AsyncDollsAggregator.cs
Created March 20, 2016 12:14
A basic async approach for middleware (dolls) using tasks and LINQ aggregate
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using System;
using System.Threading.Tasks;
namespace AsyncDollsAggregator
{
[TestFixture]
public class Test
@mhoyer
mhoyer / single-user-msys-sshd.md
Last active March 11, 2024 09:22
Install single-user SSH daemon as Windows service with pure msys tools

Install single-user SSH daemon as Windows service with pure msys tools

WARNING This approach does not enable impersonation. Thus, only a single user account is able to connect through ssh - the same user we use for running the Windows service. At time of writing it seem to only be possible with cygwin or msys2 to achieve multi-user support for sshd under Windows. E.g. https://ghc.haskell.org/trac/ghc/wiki/Building/Windows/SSHD

Requirements

  • Latest Git for Windows. I tried it with v2.6.0. (Note: with v2.5.3 sshd tried to load authorized keys from /c/.ssh instead of ~/.ssh).

Create unprivileged sshd user

@mhoyer
mhoyer / httpserver.js
Last active August 29, 2015 14:17
Tiny, simple HTTP server
// run with `node httpserve.js` and go to shown url
var http = require('http'),
path = require('path'),
fs = require('fs');
var webroot = __dirname,
port = 8080;
http.createServer(function(req, res) {
@mhoyer
mhoyer / loadbalancer.js
Created September 2, 2014 16:17
Simple Node.js load balancer
var net = require('net');
var globalConnectionCount = 0;
module.exports = function(srcPort, dstMaps) {
var roundRobinIndex = 0;
var balancer = net.createServer(function (inboundSocket) {
var cnx = globalConnectionCount++ + ': ';
var connected = false;
@mhoyer
mhoyer / .zshrc
Created August 2, 2012 12:34
Git log aliases
alias gl="git log --graph --all --format=format:'%C(bold blue)%h %C(bold green)(%cr) %C(bold white)%cn: %C(bold yellow)%d%C(reset) %C(white)%s%C(reset)' --abbrev-commit --date=relative && echo '\033[2A'"
alias gll="git log --graph --all --format=format:'%C(bold blue)%h %C(bold green)(%cr) %C(bold cyan)%cD %C(bold yellow)%d%n'' %C(bold white)%cn:%C(reset) %C(white)%s%C(reset)' --abbrev-commit && echo '\033[2A'"
@mhoyer
mhoyer / NBuilder.nuspec
Created March 26, 2012 13:44
NBuilder nuspec for 3.0.1.2 due to missing SL binaries.
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>NBuilder</id>
<version>3.0.1.2</version>
<title>NBuilder</title>
<authors>Gareth Down</authors>
<owners>Gareth Down</owners>
<licenseUrl>http://www.gnu.org/licenses/lgpl.html</licenseUrl>
<projectUrl>http://nbuilder.org/</projectUrl>
@mhoyer
mhoyer / mspec.delegates.cs
Created February 12, 2012 13:22
Live template for Machine.Specifications delegates
Establish context = () => $END$;
Because of = () => $END$;
It should_$do$ = () => $END$;