Skip to content

Instantly share code, notes, and snippets.

Jörg Thalheim Mic92

Block or report user

Report or block Mic92

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View default.nix
with import <nixpkgs> {};
stdenv.mkDerivation rec {
name = "mbpoll-${version}";
version = "1.4.11";
src = fetchFromGitHub {
owner = "epsilonrt";
repo = "mbpoll";
rev = "v${version}";
View rdtsc.h
#pragma once
int printf(const char* f,...);
static inline int64_t rdtsc_s(void)
{
unsigned a, d;
asm volatile("cpuid" ::: "%rax", "%rbx", "%rcx", "%rdx");
asm volatile("rdtsc" : "=a" (a), "=d" (d));
return ((unsigned long)a) | (((unsigned long)d) << 32);
View gist:be9139d06dfd446996bd74ceb52bdce0
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/5ca93kmwij3phrlv60vfcdba7ap4a8mz-rustc-1.37.0-src.tar.gz
source root is rustc-1.37.0-src
setting SOURCE_DATE_EPOCH to timestamp 1565685005 of file rustc-1.37.0-src/vendor/yaml-rust/tests/specs/libyaml_fail-03.yaml
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
applying patch /nix/store/wv76qr6gg2gx95xnr6sf0k5vwvavf1rq-net-tcp-disable-tests.patch
patching file src/libstd/net/tcp.rs
patching script interpreter paths in src/etc
View sslh.nix
{ lib, ... }:
with lib;
{
options.services.nginx.virtualHosts = mkOption {
type = types.attrsOf (types.submodule {
listen = mkOption {
type = with types; listOf (submodule {});
default = [
{ addr = "127.0.0.1"; port = 443; ssl = true;}
View wtf.c
static void spdk_read_completion_cb(void *ctx, const struct spdk_nvme_cpl *cpl)
{
struct spdk_cmd *cmd = (struct spdk_cmd *)ctx;
struct bio_vec bvec;
struct request *req = cmd->req;
struct req_iterator iter;
char *p = (char *)cmd->spdk_buf;
if ((req->bio)) for (iter.bio = (req)->bio; iter.bio; iter.bio = iter.bio->bi_next) for (iter.iter = ((iter.bio)->bi_iter); (iter.iter).bi_size && ((bvec = ((struct bio_vec) { .bv_page = ((&(((((iter.bio))->bi_io_vec)))[(((((iter.iter))))).bi_idx])->bv_page), .bv_len = __builtin_choose_expr(((!!(sizeof((typeof(((((iter.iter)))).bi_size) *)1 == (typeof((&(((((iter.bio))->bi_io_vec)))[(((((iter.iter))))).bi_idx])->bv_len - ((((iter.iter)))).bi_bvec_done) *)1))) && ((sizeof(int) == sizeof(*(8 ? ((void *)((long)(((((iter.iter)))).bi_size) * 0l)) : (int *)8))) && (sizeof(int) == sizeof(*(8 ? ((void *)((long)((&(((((iter.bio))->bi_io_vec)))[(((((iter.iter))))).bi_idx])->bv_len - ((((iter.iter)))).bi_bvec_done) * 0l)) : (int *)8))))), ((((((iter.iter)))).bi_size) < ((&(((((
@Mic92
Mic92 / desperate_print.h
Last active Jun 26, 2019
Don't ask, why one need this... :(
View desperate_print.h
static long syscall3(long n, long a1, long a2, long a3) {
unsigned long ret;
__asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2),
"d"(a3) : "rcx", "r11", "memory");
return ret;
}
static void desperate_print(const char* format, ...) {
char buf[1024]; // enough !1!
va_list args;
@Mic92
Mic92 / printf.zig
Created May 31, 2019
printf aquivalent for the zig programming language
View printf.zig
const std = @import("std");
const io = std.io;
const File = std.fs.File;
var stdout_file: File = undefined;
var stdout_file_out_stream: File.OutStream = undefined;
var stdout_stream: ?*io.OutStream(File.WriteError) = null;
var stdout_mutex = std.Mutex.init();
// Write to stdout ignoring errors
View main.py
def main():
a = 1
import pdb; pdb.set_trace()
# (Pdb) list
# 1
# 2 def main():
# 3 a = 1
# 4 -> import pdb; pdb.set_trace()
# 5 #
@Mic92
Mic92 / nginx-config
Last active Mar 20, 2019
Pretty print nginx configuration on NixOS
View nginx-config
#!/usr/bin/env nix-shell
#!nix-shell -p nginx-config-formatter python3 -i python3
import os
import re
import shutil
import subprocess
import sys
from tempfile import TemporaryDirectory
View main.py
#!/usr/bin/env python3
import itertools
import os
import sys
from typing import *
if sys.version_info < (3, 6):
print("Program requires least Python 3.6", file=sys.stderr)
sys.exit(1)
You can’t perform that action at this time.