Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am milleniumbug on github.
  • I am milleniumbug (https://keybase.io/milleniumbug) on keybase.
  • I have a public key whose fingerprint is 61BE F024 E95B CDFC FFE0 354A E069 867F CF5D 84EA

To claim this, I am signing this object:

import collections, csv, itertools
recipes = collections.defaultdict(set)
tolerance = 0
with open('rec.csv') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
recipes[row[0]].add(row[1])
@milleniumbug
milleniumbug / mystatus.hs
Created February 8, 2016 15:28
append xmms2 status to i3status
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Aeson as JS
import qualified Data.Aeson.Types as JST
import Data.Maybe (maybeToList)
import Data.Aeson ((.:), (.:?), (.=))
import qualified Data.Text.Lazy as T
import Data.Text.Lazy.Encoding as E
import qualified Control.Monad as M
import qualified Data.JsonStream.Parser as JSPar
@milleniumbug
milleniumbug / build.sh
Last active March 13, 2016 20:29
Wide on Fedora 23
#!/bin/bash
PREMAKE=$PWD/../premake/bin/release/premake4
$PREMAKE --llvm-path=$PWD/../llvm gmake
cd Wide
make -j `nproc` config=release64
cd ..
@milleniumbug
milleniumbug / getmus.ps1
Last active April 14, 2024 22:29
download video from YouTube, extract music and normalize volume
param(
[string]$url
)
yt-dlp `
$url `
--quiet `
--extract-audio `
--audio-format mp3 `
--audio-quality 3 `
@milleniumbug
milleniumbug / rng.md
Last active May 10, 2018 15:38
Resources on random number generation (PRNGs, CSPRNGs, distributions, statistical tests, and so on)
@milleniumbug
milleniumbug / shared_resource.hpp
Created January 22, 2017 13:29
shared_resource<T>
#pragma once
#include <mutex>
#include <shared_mutex>
#include <type_traits>
#include <tuple>
template<typename Mutex = std::shared_timed_mutex>
struct Shared
{
typedef Mutex MutexType;
@milleniumbug
milleniumbug / java_rant.txt
Last active May 7, 2023 21:49
why Java sucks
Let's start with: Java is a language that one would create when looking at the state of C++ in early 90's and thinking how can I make it "better" in terms of being error prone.
But this was only an evolution instead of a revolution STL introduced as a way of programming
(sure, they weren't first, but I'd say they were the first to introduce it to masses)
The rest is a consequence of being backward
Problem with null pointers? Still there
Speaking of pointers in Java, I like how Java fans continuously say "they're not pointers, they're references"
But guess what happens when you access a null reference? A NullPointerException is thrown
So what I don't like?
Collections API. Just terrible.
The "unmodifiable" lists are your regular lists that throw exceptions on modifications
@milleniumbug
milleniumbug / powershell_fu.md
Last active March 5, 2017 16:44
for Unix converts

Note: PowerShell is object based, as opposed to byte stream based Unix utilities. This means text operations aren't that common, and also means many idioms aren't directly translateable.

Equivalents of common commands and idioms

  • var=text -> $var = object
  • cat file1 file2 file3 > target -> gc -Encoding Byte file1,file2,file3 | sc -Encoding Byte target (binary concatenation, with text files you can specify different encoding or let it guess)
  • curl -> iwr (Invoke-WebRequest)
  • date -> date (Get-Date)
  • man command-name -> help command-name (Get-Help)