Skip to content

Instantly share code, notes, and snippets.

@ar7ch
ar7ch / donut.rs
Created February 28, 2026 20:52
donut.rs
/*
* donut.rs - donut.c rewrite in rust
* based on pseudocode from https://www.a1k0n.net/2011/07/20/donut-math.html
*/
use std::{f64::consts::PI, thread::sleep, time::Duration};
const WIDTH: usize = 50;
const HEIGHT: usize = 50;
@ar7ch
ar7ch / wifi-ap-chsw.cc
Last active April 26, 2024 09:00
STA broken scanning example (based on examples/wireless/wifi-ap.cc)
/*
* Copyright (c) 2005,2006,2007 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ar7ch
ar7ch / binsearch_recursive.c
Created August 11, 2019 14:03
recursive binsearch in C
// ex. 4.4
#include <stdio.h>
#include <stdlib.h>
void test_binsearch();
int binsearch_rec(int * arr, int len, int val, int l, int r);
int comparator(const void * a, const void * b);
int main()
{
@ar7ch
ar7ch / usbasp.md
Last active June 11, 2018 13:25
USBasp setup in GNU/Linux
  1. Connect USBasp programmer, then # journalctl -f You will see something like:
15:36:44 arch-home kernel: usb 1-1.1: new low-speed USB device number 9 using ehci-pci
15:36:44 arch-home kernel: usb 1-1.1: New USB device found, idVendor=16c0, idProduct=05dc
15:36:44 arch-home kernel: usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
  1. Copy idVendor=16c0 and idProduct=05dc values, create file /etc/udev/rules.d/60-objdev.rules and paste the following text:
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", MODE="0666", SYMLINK+="USBasp"
@ar7ch
ar7ch / after.jpg
Last active November 30, 2017 17:19
Hardware acceleration on Chromium
after.jpg

Debian cheatsheet

Set locale

The Easy Way

  1. Install debconf (i.e. run apt-get update then apt-get install debconf, as root)
  2. Run dpkg-reconfigure locales as root

The Hard Way

  1. Edit /etc/locale.gen as root. If /etc/locale.gen does not exist, create it. An example /etc/locale.gen is below.
  2. Run /usr/sbin/locale-gen as root
@ar7ch
ar7ch / cheatsheet.md
Last active August 23, 2017 20:15
cheatsheet

xfce4-xkb-plugin .svg location: /usr/share/xfce4/xkb/flags/

distro release info: /etc/os-release

freedesktop policy: /usr/share/polkit-1/actions/org.freedesktop.login1.policy