Archive

Posts Tagged ‘programming’

Iosevka: a very nice font for coding

January 21, 2025 Leave a comment

I found a very nice font for coding, called Iosevka ( https://github.com/be5invis/Iosevka ). Under Manjaro, I installed the following packages: ttf-iosevka-fixed and ttf-iosevka-nerd .

When you want to specify these fonts, for instance in VS Code, they are called “Iosevka Fixed” and “Iosevka Nerd Font”. The nerd version replaces mathematical signs with their ligatures, e.g. “>=” becomes “≥”. I hated it, so I use the “fixed” version, which behaves normally.

VS Code settings

I have this line in my settings.json:

"editor.fontFamily": "Iosevka Fixed, Hack, Consolas, 'Courier New', monospace",

[rust] fast hashmap

December 4, 2019 Leave a comment

Problem
In Rust, the stdlib’s HashMap is quite slow. It’s secure, resistant against DOS attacks, but slow. If I write a tool that I want to use myself, it doesn’t have to be cryptographically secure. I want it to be fast.

Solution
I tried several alternatives and fxhash proved to be the fastest. I compared the stdlib, hashbrown, ahash and fxhash, and fxhash proved to be the fastest.

Usage
In Cargo.toml:

[dependencies]
fxhash = "0.2"

In your code:

use fxhash::FxHashMap as HashMap;    // after these renames, it can be used
use fxhash::FxHashSet as HashSet;    // as a drop-in replacement

fn main() {
    let mut map: HashMap = HashMap::default();    // !!! it's called ::default(), not ::new()
    map.insert(1, "one");
    map.insert(2, "two");

    println!("{:?}", map);                  // {2: "two", 1: "one"}
    println!("{}", map.get(&1).unwrap());   // one
}

Credits
I asked on GitHub how to have a fast hashmap in Rust, and the author of hashbrown directed me to these crates. As Amanieu explained, FxHashMap and AHashMap are aliases of the stdlib’s hashmap with custom hashers.

Categories: rust Tags: , , ,

[Nim] A URL shortener command-line app.

October 23, 2018 Leave a comment

This afternoon I wrote a URL shortener command-line application in Nim. It uses the bit.ly URL shortener service.

You can find the project here: https://github.com/jabbalaci/UrlShortener .

Categories: nim Tags: , , ,

Hackr.io: Share and discover the best programming tutorials and courses online

April 7, 2015 Leave a comment

Here you can find a nice collection of programming tutorials.

Categories: Uncategorized Tags: ,

black magic: 0x5f3759df

April 5, 2013 Leave a comment

The number 0x5f3759df is a magic constant that can be used to calculate the inverse square root of a number very efficiently. See this post for a detailed explanation. Now if you come across this number (which can happen anywhere, anytime), you will say “aha, I know that one”.

Programming, Motherfucker!

June 15, 2012 Leave a comment

We are a community of motherfucking programmers who have been humiliated by software development methodologies for years. We are tired of XP, Scrum, Kanban, Waterfall, Software Craftsmanship (aka XP-Lite) and anything else getting in the way of…Programming, Motherfucker.

http://programming-motherfucker.com/

reddit discussion

Categories: fun Tags:

List of freely available programming books

June 14, 2012 Leave a comment
Categories: Uncategorized Tags: , ,

brute force

April 13, 2012 Leave a comment

When in doubt, use brute force.” — Ken Thompson

Eh :)

Design a site like this with WordPress.com
Get started