Skip to content

Instantly share code, notes, and snippets.

View M4GNV5's full-sized avatar

Jakob Löw M4GNV5

View GitHub Profile
#!/bin/bash
printf "#include <stdio.h>\n" > /tmp/cppmacro.c
while [ $# -gt 1 ]; do
printf "#include <$1.h>\n" >> /tmp/cppmacro.c
shift
done
printf "int main()\n{\n\tprintf(\"%%d\\\\n\", $1);\n\treturn 0;\n}" >> /tmp/cppmacro.c
gcc -D_GNU_SOURCE /tmp/cppmacro.c -o /tmp/cppmacro
ctx: sys
sp: 3ffffd70 end: 3fffffb0 offset: 01a0
>>>stack>>>
3fffff10: 4010502c 001d3def 3ffe9284 00000000
3fffff20: 4010502c 001d45f1 3ffeedf0 00000000
3fffff30: 3ffee6f0 3ffeedf0 40222613 3ffe9284
3fffff40: 00000000 001ccbdf 40201364 00000064
3fffff50: 3ffeedf0 01b12953 60000600 40106895
3fffff60: 40229e70 00000001 00000000 4020207c
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#define WIFI_SSID "<removed>"
#define WIFI_PSK "<removed>"
#define GPIO_LED 13
#define GPIO_RELAY 12
@M4GNV5
M4GNV5 / measure.sh
Created February 10, 2018 13:10
Brainfuck compiler comparasion script
#!/bin/bash
set -e
input="../$1"
stdin="$2"
function measure()
{
total=0
@M4GNV5
M4GNV5 / primes.hs
Last active November 13, 2017 09:23
import Control.Concurrent.Async
import Data.Foldable
import Control.Exception
import Control.DeepSeq
numThreads = 4
maxChunkSize = 1024000
isPrime :: [Int] -> Int -> Bool
isPrime primes x = all ((/=0) . (mod x)) $ takeWhile ((<=x) . (^2)) primes
@M4GNV5
M4GNV5 / alloc.ptrs.js
Last active May 25, 2017 22:03
Buddy Allocator
import "printf", "malloc", "free" from "libc.so.6";
var cfree = free;
var minfactor = 3;
var maxfactor = 7;
var maxsize = 1 << maxfactor;
var startBlock = 1 << maxfactor;
var used = null;
@M4GNV5
M4GNV5 / deathrecap.lua
Created February 22, 2017 01:18
Garrys Mod Death recap
if SERVER then
util.AddNetworkString("deathrecap_show")
util.AddNetworkString("deathrecap_hide")
local recap = {}
local startTime = 0
hook.Add("EntityTakeDamage", "deathrecap_takedmg", function(target, ev)
if target:IsPlayer() then
local name = target:GetName()
recap[name] = recap[name] or {}
@M4GNV5
M4GNV5 / client.sh
Last active June 15, 2017 15:16
radio using Pointerscript + ffserver + ffmpeg + youtube-dl
#!/bin/bash
function printUsage
{
printf "Commands:\n h : show this help\n c : clear the screen\n\
q : quit\n r : restart player\n l : view player log\n\
<id> : add id to queue\n"
}
printUsage
printf "\n"
(function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
var a = typeof require == "function" && require;
if (!u && a) return a(o, !0);
if (i) return i(o, !0);
var f = new Error("Cannot find module '" + o + "'");
throw f.code = "MODULE_NOT_FOUND", f
}
@M4GNV5
M4GNV5 / _calculator.lua
Last active December 23, 2015 11:40
Fully awesome calculator in vanilla Minecraft using MoonCraft
import("chat")
import("math")
import("debug")
import("./calculator.js")
command("gamerule sendCommandFeedback false")
command("scoreboard objectives add calc dummy")
command("scoreboard objectives add calcVal dummy")
curr = score("@e[type=ArmorStand,x=0,y=5,z=-1,r=0]", "calc")