Skip to content

Instantly share code, notes, and snippets.

View dd86k's full-sized avatar
✌️
Befriend software

dd dd86k

✌️
Befriend software
View GitHub Profile
@dd86k
dd86k / .nanorc
Created March 9, 2025 20:19
Nano configuration
set constantshow
set linenumbers
set nonewlines
set noconvert
set smarthome
set nohelp
set minibar
#set mouse
bind ^F whereis all
@dd86k
dd86k / scopebench.d
Created December 16, 2022 16:32
Quick benchmark thing for evaluating scoped allocation
import std.stdio;
import std.getopt;
import std.digest.sha : SHA1;
import std.datetime.stopwatch : StopWatch;
import std.range : chunks;
import std.mmfile : MmFile;
import std.file : getSize;
import core.memory : GC;
enum CHUNKSIZE = 4096;
@dd86k
dd86k / getcmdline.d
Created April 22, 2022 22:58
A simple GetCommandLineW-x86 implementation. Works from Windows XP to 11 thanks to the instroduction of TLS.
wchar* GetCommandLineWFast() {
version (X86_64) asm {
mov RAX,GS:[0x60];
mov RAX,[RAX+0x20];
mov RAX,[RAX+0x78];
} else version (X86) asm {
mov EAX,FS:[0x30];
mov EAX,[EAX+0x10];
mov EAX,[EAX+0x44];
}
@dd86k
dd86k / hashbench.md
Created December 27, 2020 19:56
Hash Benchmark

Average (-a) rates

  • Processor: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
  • Platform: AMD64
  • Hypervisor: VirtualBox 6.1.16 with KVM
  • Command pv -a /dev/urandom

The values are taken after the rate has been stable for a few seconds.

GNU Coreutils / Busybox

@dd86k
dd86k / phone_install_guide.md
Last active April 16, 2025 15:43
Quick guide/reminder when installing phone images onto disks

Phone Image Installation Guide

Examples

  • With dd: tar -Oxz image.tar.gz | dd of=... status=progress
  • With pv: pv image.tar.gz | tar -Oxz | dd of=...
    • Not a tar archive: pv image.img.xz | xzcat | dd bs=2M of=/dev/sde1

Important flags

<#
Bored shit
by dd86k
#>
function ErasePlayer() {
[Console]::SetCursorPosition($x, $y); ' '
}
function PrintPlayer() {
[Console]::SetCursorPosition($x, $y); '@'
}
@dd86k
dd86k / fizzbuzz.rs
Created April 6, 2016 03:48
Rust FizzBuzz two-liner
fn main() {
let mut x;
for i in 0..101 { println!("{}", if i % 15 == 0 { "FizzBuzz" } else if i % 5 == 0 { "Buzz" } else if i % 3 == 0 { "Fizz" } else { x = format!("{}", i);x.as_str() } ); }
}
@dd86k
dd86k / FizzBuzz.cs
Last active April 6, 2016 03:54
"One-liner" FizzBuzz in C# 6.0
using static System.Console;
namespace FizzBuzz
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 100; i++) { WriteLine(i % 15 == 0 ? "FizzBuzz" : (i % 5 == 0 ? "Buzz" : (i % 3 == 0 ? "Fizz" : i.ToString()))); }
}
@dd86k
dd86k / readme.md
Last active May 16, 2017 17:12
Some languages and their first appearance year
Language First appeared
Assembly 1949
Speedcoding 1953
Fortran 1957
Lisp 1958
ALGOL 58 1958
COBOL 1959
ALGOL 60 1960
CPL 1963
@dd86k
dd86k / bg.rs
Last active March 24, 2016 04:31
Simple Console Box Generator (Windows) in Rust
fn main() {
generate_box(10, 4, 5, 4);
}
// ┌┐└┘─│
fn generate_box(x: i32, y: i32, width: i32, height: i32) {
let mut nwidth = width - 2; // Corners included
let mut nheight = height - 2;
if nwidth < 2 { nwidth = 0; }