Skip to content

Instantly share code, notes, and snippets.

Avatar
Taking some time off personal open source work

Leandro A. F. Pereira lpereira

Taking some time off personal open source work
View GitHub Profile
View find-potentially-unmappable.py
#!/usr/bin/python
import subprocess
unmappable_funcs = set()
out, err = subprocess.Popen(["objdump", "-t", "Build/Kernel/Kernel"], stdout=subprocess.PIPE).communicate()
for line in out.splitlines():
line = line.strip()
line = line.decode('ascii')
View jsonjit.c
/* Maps a page of the request size near the text page that contains
* a symbol. Useful for hand-rolled JIT compilers to avoid indirect
* calls to symbols in a program on x86-64. (Part of the code here is
* a JIT compiler to encode JSON based on a struct descriptor, but it's
* not finished yet.)
*
* Written by Leandro Pereira <leandro@tia.mat.br>
*
* Thanks to Ole André V. Ravnås for the idea to use the NOREPLACE flag
* in mmap(), and to Paul Khuong for helping me make it more robust in
@lpereira
lpereira / WebServerHelloWorld.cs
Last active Feb 19, 2021
C# Web Server Hello World
View WebServerHelloWorld.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
View corobench.cc
/* link with liblwan and google benchmark */
#include <stdbool.h>
#include <stdio.h>
#include <benchmark/benchmark.h>
extern "C" {
#include <lwan-coro.h>
}
struct coro *coro;
View co.c
#include <stdio.h>
#include <stdbool.h>
struct coro {
void *state;
};
struct range_coro {
struct coro base;
int cur, max, step;
View crcbench.cpp
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <benchmark/benchmark.h>
unsigned int odd_constant = 0xdeadbeef | 1;
static unsigned int hash_crc32_orig(const void *keyptr)
{
unsigned int hash = odd_constant;
View error-codes.c
#include <stdio.h>
struct error_code {
int code;
};
struct error_context {
const struct error_code *code;
const char *msg;
const char *file;
View comefrom.diff
Index: include/clang/AST/RecursiveASTVisitor.h
===================================================================
--- include/clang/AST/RecursiveASTVisitor.h (revision 315357)
+++ include/clang/AST/RecursiveASTVisitor.h (working copy)
@@ -2147,6 +2147,7 @@
DEF_TRAVERSE_STMT(DoStmt, {})
DEF_TRAVERSE_STMT(ForStmt, {})
DEF_TRAVERSE_STMT(GotoStmt, {})
+DEF_TRAVERSE_STMT(ComeFromStmt, {})
DEF_TRAVERSE_STMT(IfStmt, {})
View gist:4e09f5a038b740d61860488679427c4e
/* Build with google benchmark */
#include "benchmark/benchmark.h"
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
View keyboardmouse.ino
/* Based on code by user DorianRudolph on GitHub
https://gist.github.com/DorianRudolph/ca283dfdfd185bc812b7
*/
/*
TODO:
- use menu key as a Fn key to enable multimedia control
- Fn+F1 = toggle mute
- Fn+F2 = vol up
- Fn+F3 = vol dn