Skip to content

Instantly share code, notes, and snippets.

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

dd dd86k

✌️
Befriend the software
View GitHub Profile
@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
Created September 19, 2020 17:27
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=...

Important flags

| Flag | Description |

@dd86k
dd86k / notojava.txt
Created August 6, 2017 18:28
why i prefer C# over Java
Java? More like :
- no string padding methods unlike C#
- no repeatable String constructors unlike C#
- no pointers and no pointer arithmetic* unlike C# (Unsafe)
- no fixed buffers unlike C# (Unsafe)
- no address-of operators unlike C# (Unsafe)
- no type extensions unlike C#
- no properties and no setters/getters unlike C#
- no LINQ extensions unlike C#
- no default/optional parameters unlike C#
<#
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; }