Skip to content

Instantly share code, notes, and snippets.

@ShadowJonathan
ShadowJonathan / haproxy.cfg
Last active April 3, 2024 19:08
A reverse proxy daisy chain config that buffers fediverse traffic
# Place this after your default configuration
frontend fedi_fe
mode http
# this is the address that haproxy will listen on,
# when doing this local loopback, its recommended to set to localhost (127.0.0.1)
bind 127.0.0.1:28080
default_backend fedi_fe
@drewolbrich
drewolbrich / View+WindowGeometryPreferences.swift
Last active April 29, 2024 14:34
A visionOS SwiftUI view modifier that can be used to hide a window's resize handles or to constrain a window's aspect ratio
//
// View+WindowGeometryPreferences.swift
//
// Created by Drew Olbrich on 1/30/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

A funky shell thingy that I've never seen before

So you're in posix sh and you want to do the equivalent of this in bash:

foo | tee >(bar) >(baz) >/dev/null

(Suppose that bar and baz don't produce output. Add redirections where needed if that's not the case.)

@karpathy
karpathy / stablediffusionwalk.py
Last active April 25, 2024 11:25
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
@jdarpinian
jdarpinian / executable.c
Last active March 20, 2024 15:28
Add one line to your C/C++ source to make it executable.
///bin/true;COMPILER_OPTIONS="-g -Wall -Wextra --std=c99 -O1 -fsanitize=address,undefined";THIS_FILE="$(cd "$(dirname "$0")"; pwd -P)/$(basename "$0")";OUT_FILE="/tmp/build-cache/$THIS_FILE";mkdir -p "$(dirname "$OUT_FILE")";test "$THIS_FILE" -ot "$OUT_FILE" || $(which clang || which gcc) $COMPILER_OPTIONS -xc "$THIS_FILE" -o "$OUT_FILE" || exit;exec "$OUT_FILE" "$@"
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
{ stdenv, pkgconfig, cmake, bluez, ffmpeg, libao, gtk2, glib, mesa
, gettext, libpthreadstubs, libXrandr, libXext, readline, openal
, libXdmcp, portaudio, fetchzip, fetchFromGitHub, libusb, libevdev
, wxGTK30, soundtouch, miniupnpc, mbedtls, curl, lzo, sfml
, libpulseaudio ? null }:
stdenv.mkDerivation rec {
name = "dolphin-emu-faster-melee-beta-${version}";
version = "5.8.7";
anonymous
anonymous / playground.rs
Created November 30, 2017 15:36
Rust code shared from the playground
pub struct Convex<T: AsRef<[Point]> + ?Sized> {
vertices: T
}
pub struct Point(f32, f32);
impl<T: AsRef<[Point]>> Convex<T> {
pub fn new(vertices: T) -> Option<Convex<T>> {
fn is_polygon_convex(_: &[Point]) -> bool { true }
let is_convex = {
@taktoa
taktoa / keybase.nix
Created November 22, 2017 20:21
Getting the Keybase GUI to work on NixOS
# Add this file to your /etc/nixos/configuration.nix `imports = [ ... ];` attribute.
#
# After running `nixos-rebuild switch`, `systemctl --user start keybase-gui.service`
# can be used to start the Keybase GUI.
#
# Not sure if it's just my tiling window manager, but there is a bit of wonkiness
# with the tray icon. Other than that it works perfectly (as of 2017/11/22).
{ pkgs, ... }:
@greglearns
greglearns / default.nix
Last active February 13, 2019 20:39
NixOS default.nix for compiling Nightly Rust using Mozilla overlay, also with a specific RustRegistry for specific date, to handle "version not found" issues. Doesn't actually work, so do not use.
{
pkgs ? (
let
pkgs = import <nixpkgs>;
pkgs_ = (pkgs {});
rustOverlay = (pkgs_.fetchFromGitHub {
owner = "mozilla";
repo = "nixpkgs-mozilla";
rev = "1608d31f7e5b2415fb80b5d76f97c009507bc45f";
sha256 = "0mznf82k7bxpjyvigxvvwpmi6gvg3b30l58z36x192q2xxv47v1k";

Where you able to produce a binary directly from the Rust build tools that you could submit to the app/play store?


Not quite, but I tried to get as close to that as was reasonably possible. Alas, things ended up a little convoluted.

For iOS, I have a nearly empty Xcode project with a build script that copies my cargo produced executable into the .app that Xcode generates (before Xcode signs it). The build script also uses lipo to merge the executables for each architecture I’m targeting (e.g. armv7 and aarch64 for non-simulator devices) into a single, universal binary.

On top of that, there are various iOS-y things that need to happen before my application’s main method is called. SDL2 provides the Objective-C code that does all of that. In a C or C++ game, SDL2 renames main to SDL_main, and then [inserts its own mai