Skip to content

Instantly share code, notes, and snippets.

View orklann's full-sized avatar
🏠
Working from home

Tommy Jeff orklann

🏠
Working from home
View GitHub Profile
#!/bin/bash
#Variables
IP=$(hostname -I | awk '{print $2}')
PasswordGenerator=$(</dev/urandom tr -dc '[:alnum:]' | head -c15; echo "")
PSK=$(openssl rand -base64 24)
export DEBIAN_FRONTEND=noninteractive
#Set proper mirrors
mv /etc/apt/sources.list /etc/apt/sources.list_backup
@orklann
orklann / BBC-Radio-HLS-UK.m3u
Created June 19, 2022 06:08 — forked from bpsib/BBC-Radio-HLS.m3u
BBC Radio Streams
#EXTM3U
#EXTINF:-1,BBC - Radio 1
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_radio_one.m3u8
#EXTINF:-1,BBC - Radio 1Xtra
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_1xtra.m3u8
#EXTINF:-1,BBC - Radio 1Dance
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_radio_one_dance.m3u8
#EXTINF:-1,BBC - Radio 1Relax
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_radio_one_relax.m3u8
#EXTINF:-1,BBC - Radio 2
[
{
"name": "NHK FM",
"status": "ACTIVE",
"country_code": "jp",
"country_name": "Japan",
"streams": [
{
"quality": 0,
"url": "https://nhkradioakfm-i.akamaihd.net/hls/live/512290/1-fm/1-fm-01.m3u8"
@orklann
orklann / mac-enable-libfuzzer.md
Created February 20, 2022 03:33 — forked from mcandre/mac-enable-libfuzzer.md
macOS Enable libFuzzer
  1. Run brew install llvm --HEAD.
  2. Update certain shell variables:
# Prefer newer LLVM with fuzzing enabled
# shellcheck source=/dev/null
export CC='clang'
export CXX='clang++'
export LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
PATH="$(brew --prefix)/opt/llvm/bin:$PATH"
@orklann
orklann / 32.asm
Last active February 10, 2022 14:11 — forked from FiloSottile/32.asm
NASM Hello World for x86 and x86_64 Intel Mac OS X(get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4
@orklann
orklann / gdcc.py
Created October 28, 2021 08:38
Generating .clang_complete for current folder
#!/usr/bin/env python3
import os
def walk_through_files(path, file_extension='.h'):
for (dirpath, dirnames, filenames) in os.walk(path):
for filename in filenames:
if filename.endswith(file_extension):
yield os.path.join(dirpath, filename)
current_dir = os.getcwd()
for fname in walk_through_files(current_dir):
@orklann
orklann / config
Created October 24, 2021 13:58
cargo behid proxy (~/.cargo/config)
[http]
proxy = "http://127.0.0.1:4780"
[https]
proxy = "https://127.0.0.1:4780"

Real depth in OpenGL / GLSL

http://olivers.posterous.com/linear-depth-in-glsl-for-real

So, many places will give you clues how to get linear depth from the OpenGL depth buffer, or visualise it, or other things. This, however, is what I believe to be the definitive answer:

This link http://www.songho.ca/opengl/gl_projectionmatrix.html gives a good run-down of the projection matrix, and the link between eye-space Z (z_e below) and normalised device coordinates (NDC) Z (z_n below). From there, we have

A   = -(zFar + zNear) / (zFar - zNear);

B = -2zFarzNear / (zFar - zNear);

@orklann
orklann / keystroke-toggle-linenumbers-settings.json
Created July 15, 2021 13:09 — forked from pid/keystroke-toggle-linenumbers-settings.json
Sublime Text keystroke toggle line numbers show/hide
{
"keys": ["ctrl+alt+l"],
"command": "toggle_setting",
"args": {
"setting": "line_numbers"
}
@orklann
orklann / rw_flash.py
Last active June 18, 2021 07:44
Meowbit read and write Flash
from meowbit import screen
from meowbit import pyb
fl = pyb.Flash()
# Doc:
# 1. https://docs.micropython.org/en/latest/library/pyb.Flash.html#pyb-flash
# 2. https://docs.micropython.org/en/latest/reference/filesystem.html#stm32-pyboard
# 4000th blocks to read and write, as Meowbit has 2MB flash size,