Skip to content

Instantly share code, notes, and snippets.

View thebirk's full-sized avatar

Aleksander Birkeland thebirk

View GitHub Profile
@thebirk
thebirk / content.js
Created February 5, 2024 23:56
OBS Websocket browser proof of concept
document.addEventListener("contextmenu", async function(e) {
const message = e.target.closest('.chat-line__message');
if (!message) {
return;
}
e.preventDefault();
const obs = new OBSWebSocket();
await obs.connect("ws://127.0.0.1:4455", "4tP1Yw7d5FxnnCjI");
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OBS Websocket</title>
<script src="https://unpkg.com/obs-websocket-js"></script>
<script type="module" async>
document.addEventListener("DOMContentLoaded", async function() {
const obs = new OBSWebSocket();
await obs.connect("ws://192.168.0.158:4455", "4tP1Yw7d5FxnnCjI");
public class DisposableStopwatch : Stopwatch, IDisposable
{
public delegate string OnStopDelegate(TimeSpan time);
private readonly OnStopDelegate _onStop;
public DisposableStopwatch(OnStopDelegate onStop)
{
_onStop = onStop;
Start();
}
package test
Id :: struct(T: typeid) {
value: int,
}
Asset :: struct {
id: Id(Asset),
name: string,
}
@thebirk
thebirk / main.odin
Created April 26, 2020 02:12
minny thing
package emulator
import "core:os"
import "core:fmt"
import "core:time"
import "core:math/rand"
when ODIN_OS == "windows" do foreign import libc "system:libcmt.lib";
when ODIN_OS == "linux" do foreign import libc "system:c";
foreign libc {
@thebirk
thebirk / touch.c
Last active April 5, 2020 12:09
Basic touch clone for windows
// Copyright (c) 2020 Aleksander B. Birkeland (thebirk)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this softwareand associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright noticeand this permission notice shall be included in all
@thebirk
thebirk / install.bat
Last active February 7, 2020 21:29
Copies any file into the folder in which 'install.bat' is located. Useful for copying files into a directory exposed through PATH
@echo off
REM Copyright 2020 Aleksander B. Birkeland <pingnor@gmail.com>
REM
REM Permission is hereby granted, free of charge, to any person obtaining a
REM copy of this software and associated documentation files (the "Software"),
REM to deal in the Software without restriction, including without limitation
REM the rights to use, copy, modify, merge, publish, distribute, sublicense,
REM and/or sell copies of the Software, and to permit persons to whom the
REM Software is furnished to do so, subject to the following conditions:
REM
read_tar :: proc(reader: ^io.Reader) {
Posix_Ustar_Header :: struct #packed {
name: [100]u8,
mode: [8]u8,
uid: [8]u8,
gid: [8]u8,
size: [12]u8,
mtime: [12]u8,
checksum: [8]u8,
typeflag: u8,
read_zip :: proc(reader: ^io.Reader) {
LOCAL_FILE_MAGIC :: 0x04034B50;
END_MAGIC :: 0x06054b50;
Local_File_Header :: struct #packed {
//signature: u32le,
minimum_version: u16le,
flags: u16le,
compression: u16le,
last_mod_time: u16le,
package io
import "core:os"
import "core:mem"
import "core:log"
import "core:runtime"
Error :: enum {
Ok,
Could_Not_Create_File,