Skip to content

Instantly share code, notes, and snippets.

Serge Zaitsev zserge

View GitHub Profile
@zserge
zserge / Add.java
Last active Jun 3, 2020
A tiny JVM to run a single method from a single class
View Add.java
public class Add {
public static int add(int a, int b) {
return a + b;
}
}
View container.c
#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@zserge
zserge / guest.S
Created May 10, 2020
A tiny KVM host to run a 16-bit real mode "kernel"
View guest.S
# A tiny 16-bit guest "kernel" that infinitely prints an incremented number to the debug port
#
# Build it:
#
# as -32 guest.S -o guest.o
# ld -m elf_i386 --oformat binary -N -e _start -Ttext 0x10000 -o guest guest.o
#
.globl _start
@zserge
zserge / kvm-host.c
Last active Jun 21, 2020
Tiny KVM host to at least partially run Linux kernel
View kvm-host.c
#define _GNU_SOURCE
#include <asm/bootparam.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/kvm.h>
#include <linux/kvm_para.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
View act.js
const h = (e, p = {}, ...c) => ({e, p, c: [].concat(...c)});
const render = (vlist, dom) => {
vlist = [].concat(vlist);
vlist.forEach((v, i) => {
let n = dom.childNodes[i];
let s = (v.s = (n ? n.s : v.s) || {});
while (typeof v.e === 'function') {
v = v.e(v.p, s, u => Object.assign(s, u) && render(vlist, dom));
}
v.s = s;
View .zshrc
autoload -U compinit colors vcs_info
colors
compinit
REPORTTIME=3
HISTFILE=~/.zhistory
HISTSIZE=5000
SAVEHIST=5000
setopt INC_APPEND_HISTORY
setopt EXTENDED_HISTORY
@zserge
zserge / MainActivity.java
Created Feb 21, 2017
Reproducing Anvil issue #83
View MainActivity.java
package trikita.foo;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import trikita.anvil.RenderableView;
import static trikita.anvil.DSL.*;
View sctp_syscalls.go
//
// This is just a collection of syscalls that are used by libsctp linux implementation.
// Although it supports message-oriented workflow, it can't be wrapped into a net.PacketConn.
//
package main
import (
"log"
"syscall"
View echod.go
//
// A simple echo server for SCTP sockets, it creates a socket with a syscall then wraps it into a net.Listener interface
// to make goroutine-safe (otherwise reading or writing would block the whole host thread).
// All it does is echoing back all the received data from the client.
//
package main
import (
"fmt"
You can’t perform that action at this time.