Skip to content

Instantly share code, notes, and snippets.

@o11c
o11c / every-vm-tutorial-you-ever-studied-is-wrong.md
Last active April 30, 2024 09:59
Every VM tutorial you ever studied is wrong (and other compiler/interpreter-related knowledge)

Note: this was originally several Reddit posts, chained and linked. But now that Reddit is dying I've finally moved them out. Sorry about the mess.


URL: https://www.reddit.com/r/ProgrammingLanguages/comments/up206c/stack_machines_for_compilers/i8ikupw/ Summary: stack-based vs register-based in general.

There are a wide variety of machines that can be described as "stack-based" or "register-based", but not all of them are practical. And there are a lot of other decisions that affect that practicality (do variables have names or only address/indexes? fixed-width or variable-width instructions? are you interpreting the bytecode (and if so, are you using machine stack frames?) or turning it into machine code? how many registers are there, and how many are special? how do you represent multiple types of variable? how many scopes are there(various kinds of global, local, member, ...)? how much effort/complexity can you afford to put into your machine? etc.)

  • a pure stack VM can only access the top elemen
@iamnewton
iamnewton / bash-colors.md
Last active April 30, 2024 09:58
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@0xEva
0xEva / IDA Pro lumen.abda.nl public Lumina server.md
Last active April 30, 2024 09:58
Setting up IDA Pro to use lumen.abda.nl public Lumina server

Compiling socat on Cygwin

  1. Get a copy of socat source code here http://www.dest-unreach.org/socat/
  2. Make sure to install gcc-core, libssl-devel, make
  3. In your Cygwin terminal, run ./configure --enable-openssl-base --enable-openssl-method
  4. make optionally make install

Set up IDA Pro to use lumen.abda.nl public Lumina server

  1. Get a copy of lumen.abda.nl's certificate here https://abda.nl/lumen/hexrays.crt
  2. Change PATH_TO_IDA in ida_abda.nl_lumen.bat then run it
  3. Go to Options -> General -> Lumina, set server addr to 127.0.0.1, port 1234, Username guest, Password guest
@jidckii
jidckii / alertmanager.tmpl
Created April 5, 2023 14:08
Alertmanager telegram template
{{ define "__yucca_text_alert_list" }}{{ range . }}
---
🪪 <b>{{ .Labels.alertname }}</b>
{{- if .Annotations.summary }}
📝 {{ .Annotations.summary }}{{ end }}
{{- if .Annotations.description }}
📖 {{ .Annotations.description }}{{ end }}
🏷 Labels:
{{ range .Labels.SortedPairs }} <i>{{ .Name }}</i>: <code>{{ .Value }}</code>
{{ end }}{{ end }}
@bassamsdata
bassamsdata / _Notes.md
Last active April 30, 2024 09:54
MiniFiles Git integration

Below is a code for Minifiles Git integration code snippet.

How to use it

Just insert the code below into this function in your Minifiles config:

config = function()
-- add the git code here
end
@sevaa
sevaa / ToUTF8.sql
Last active April 30, 2024 09:51
Converting an NVARCHAR string to a UTF-8 VARBINARY data block in pure Transact-SQL
create function [dbo].[ToUTF8](@s nvarchar(max))
returns varbinary(max)
as
begin
declare @i int = 1, @n int = datalength(@s)/2, @r varbinary(max) = 0x, @c int, @c2 int, @d varbinary(4)
while @i <= @n
begin
set @c = unicode(substring(@s, @i, 1))
if (@c & 0xFC00) = 0xD800
begin
@sdstrowes
sdstrowes / foo.md
Created September 1, 2017 08:04
Reverse Engineering the Speedtest.net Protocol, Gökberk Yaltıraklı

Source: https://web.archive.org/web/20141216073338/https://gkbrk.com/blog/read?name=reverse_engineering_the_speedtest_net_protocol Author: Gökberk Yaltıraklı

Reverse Engineering the Speedtest.net Protocol

After finishing my command line speed tester written in Rust, I didn't have a proper blog to document this process. A few days ago I wrapped up a simple blogging script in Python so hopefully it works good enough to explain how everything works.

By now I have already figured out the whole protocol for performing a speed test but I will write all the steps that I took so you can learn how to reverse engineer a simple protocol.

The code that I wrote can be found at https://github.com/gkbrk/speedtest-rust.

@zatarra
zatarra / brain.py
Last active April 30, 2024 09:49
Python script to parse data from Mindflex headband and convert it into a powerfull EEG device
#!/usr/bin/python
import serial
import sys
latestByte = ('c')
lastByte = ('c')
inPacket = False
myPacket = []
PLENGTH = 0
@vyv03354
vyv03354 / gist:fa60598c53e98d3e724b15344c0ebe72
Last active April 30, 2024 09:49
(ZF⁻)−3 のモデルについて

『キューネン 数学基礎論講義』の置換公理 のページの内容について質問があります。 「万有集合をもつモデルは基礎の公理 (A2) をみたさない」というのは本当でしょうか?

$A$$0$を除くすべての要素は$0$を要素に持つので、

  • $x=0$の場合:$∃y∈A(y∈_\mathfrak{A}x)$が成り立たないのでよい。
  • $x≠0$の場合:$y$として$0$を取れば$0∈_\mathfrak{A}x∧¬∃z∈A(z∈_\mathfrak{A}x∧z∈_\mathfrak{A}0)$が成り立つのでよい。

となって、A2が$\mathfrak{A}$で成り立っているように見えます。内包公理があると万有集合から自分自身のみを要素に持つ集合が作れてしまうのでだめですが、内包公理がないので問題ないはずです。

@ingridbonnet
ingridbonnet / hello.c
Created April 30, 2024 09:48
mon hello world
int main()
{
printf("Hello world");
return 0
}