Skip to content

Instantly share code, notes, and snippets.

Avatar
👻
it is a mystery

Andrea hikari-no-yume

👻
it is a mystery
View GitHub Profile
@hikari-no-yume
hikari-no-yume / !steps.md
Created May 14, 2021
Rust no_std “hello world” compiled to C!
View !steps.md

Requires rustc and llvm-cbe.

  • rustc hello-world-no_std.rs -O --emit=llvm-ir -C panic=abort -o hello-world-no_std-O.ll
  • llvm-cbe ../testfiles/hello-world-no_std-O.ll
@hikari-no-yume
hikari-no-yume / try.py
Last active Aug 18, 2021
bruteforce mojibake decoder
View try.py
# as of python 3.9
all_encodings = ['ascii', 'big5', 'big5hkscs', 'cp037', 'cp273', 'cp424', 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp864', 'cp865', 'cp866', 'cp869', 'cp874', 'cp875', 'cp932', 'cp949', 'cp950', 'cp1006', 'cp1026', 'cp1125', 'cp1140', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'euc_jp', 'euc_jis_2004', 'euc_jisx0213', 'euc_kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004', 'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr', 'latin_1', 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', 'iso8859_7', 'iso8859_8', 'iso8859_9', 'iso8859_10', 'iso8859_11', 'iso8859_13', 'iso8859_14', 'iso8859_15', 'iso8859_16', 'johab', 'koi8_r', 'koi8_t', 'koi8_u', 'kz1048', 'mac_cyrillic', 'mac_greek', 'mac_iceland', 'mac_latin2', 'mac_roman', 'mac_turkish', 'ptcp154', 'shift_jis', 'shift_jis_2004', 'shift_jis
View who-needs-glsl-anyway.c
#include "who-needs-glsl-anyway.h"
#include <stdio.h>
int main(void)
{
vec4 v = { {1.5, 2.5, 3.5, 4.5} };
printf("%f, %f, %f, %f\n", v.rg.x, v.xy.t, v.stp.z, v.w);
for (int i = 3; i >= 0; i--) {
printf("%f\n", v._[i]);
}
}
@hikari-no-yume
hikari-no-yume / 0_hello-world.cbe.c
Created Feb 23, 2021
What would C look like if it had already been compiled to LLVM IR and back again, but then you compiled it to LLVM IR and back again… again? (sequel to https://gist.github.com/hikari-no-yume/3cde016149d0309a80770c5eccd013ad, using https://github.com/JuliaComputing/llvm-cbe)
View 0_hello-world.cbe.c
/* Provide Declarations */
#include <stdarg.h>
#include <setjmp.h>
#include <limits.h>
#include <stdint.h>
#include <math.h>
#ifndef __cplusplus
typedef unsigned char bool;
#endif
@hikari-no-yume
hikari-no-yume / 0_hello-world.c
Last active Feb 24, 2021
What would C look like if you compiled it to LLVM IR and back again? (https://github.com/JuliaComputing/llvm-cbe)
View 0_hello-world.c
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
}
View dril-units.lib
/ https://twitter.com/dril/status/701465049030926343
treat !a!
snack 20 treats
meal 3 snacks
BoysDailyIntake 3 meals
Treat treat
Goody 1 Treat
@hikari-no-yume
hikari-no-yume / !summary.md
Last active Jul 29, 2020
GG2 CRLF versus LF
View !summary.md
View generate-comprehensive-diagram-of-the-salient-layers-of-modern-computer-architecture.js
for (let i = 0; i < 12; i++) {
let elem = document.createElement('div');
elem.textContent = 'cache';
elem.style.textAlign = 'center';
elem.style.borderBottom = '1px solid';
elem.style.font = (10 ** (1 + i / 12)) + 'pt sans-serif';
document.body.appendChild(elem);
}
@hikari-no-yume
hikari-no-yume / glob.php
Created May 25, 2019
makes a directory listing
View glob.php
#!/usr/bin/env php
<?php declare(strict_types=1);
$glob = glob($argv[1] ?? "*");
echo "<!doctype html>";
echo "<meta charset=utf-8>";
echo "<body style=\"font-family: monospace;\">";
echo "<ul>";
foreach ($glob as $blob) {
@hikari-no-yume
hikari-no-yume / taxrates.php
Last active Mar 13, 2019
Calculate UK or Scottish income tax and find the point where one costs more than the other (https://twitter.com/hikari_no_yume/status/1105922831626502147)
View taxrates.php
<?php
const UK_2018 = [
0 => 11850,
20 => 46350,
40 => 150000,
45 => INF,
];
const UK_2019 = [
0 => 12500,