Skip to content

Instantly share code, notes, and snippets.

View darfink's full-sized avatar
🛠️
Oxidizing

Elliott Linder darfink

🛠️
Oxidizing
View GitHub Profile
@darfink
darfink / Dockerfile
Created December 8, 2023 14:58
Build Gstreamer (1.23) from source for Ubuntu 23.04
# Use Ubuntu as the base image
FROM ubuntu:23.04
# Update package lists and install necessary dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
libgstreamer1.0-dev \
meson \
flex \
@darfink
darfink / Dockerfile
Created October 27, 2023 16:04
Dockerfile for building GStreamer from source (gst-plugins-base)
# Use Ubuntu as the base image
FROM ubuntu:23.04
# Update package lists and install necessary dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
libgstreamer1.0-dev \
meson \
ninja-build \
@darfink
darfink / cdf.sh
Last active April 24, 2021 16:47
Windows WSL: CD into the most recently used explorer directory from bash
pfd() {
local windir="$(pwsh.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -Command - <<"EOF"
$Win32API = Add-Type -Name Funcs -Namespace Win32 -PassThru -MemberDefinition @'
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, IntPtr lpWindowName);
'@
$topmostHwnd = $Win32API::FindWindow('CabinetWClass', [IntPtr]::Zero)
$topmostWindow = (New-Object -COM 'Shell.Application').Windows() | Where-Object {$_.HWND -eq $topmostHwnd}
$topmostWindow.Document.Folder.Self.IsFileSystem ? $topmostWindow.Document.Folder.Self.Path : $null
@darfink
darfink / ld64
Last active November 22, 2023 15:01
Drop-in replacement/wrapper around macOS' linker (ld) that respects segprot's `max_prot` value
#!/usr/bin/python2
import argparse
import sys
import subprocess
from itertools import takewhile
from macholib import MachO, ptypes
def parse_rwx(text):
return ('r' in text and 1) | ('w' in text and 2) | ('x' in text and 4)
#######################################
# Modes
######################################
:: default : yabai -m config active_window_border_color 0xffffffff
:: resize : yabai -m config active_window_border_color 0x99ff0000
# Navigating windows
rshift + rcmd + rctrl + ralt - h : yabai -m window --focus west
rshift + rcmd + rctrl + ralt - j : yabai -m window --focus south
@darfink
darfink / demo-script.js
Last active January 24, 2020 18:35
ItemAutocomplete demo script (AppleScript) - JXA
const getRandomNumber = (min, max) => Math.random() * (max - min) + min;
const KeyCode = function(code, shift) {
this.code = code;
this.shift = shift;
};
const ENTER = new KeyCode(36);
const TAB = new KeyCode(48);
const SHIFT_TAB = new KeyCode(48, true);
@darfink
darfink / lib.rs
Last active June 12, 2019 19:09
Example of detouring MessageBoxW in Rust using detour-rs
#[macro_use]
extern crate detour;
extern crate winapi;
// --- std ---
use std::mem;
use std::ffi::CString;
// --- external ---
use kernel32::{GetModuleHandleW, GetProcAddress};
use winapi::{
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo', 'module:react-native-dotenv'],
};
};
import R from 'ramda';
import attractions from '../assets/attractions.json';
export default new Set(R.chain(R.prop('categories'), attractions));
@darfink
darfink / rle.c
Created June 2, 2017 11:49
Decompress
u32 rle_decompress(u8** out, const u8* src) {
// Extract the size of the data
u32 originalSize = *((u32*) src) >> 8;
u8* originalDst = calloc(originalSize, 1);
// Advance past the header
src += sizeof(u32);
u8* dst = originalDst;
for(u32 size = originalSize; size > 0;) {