Skip to content

Instantly share code, notes, and snippets.

View infinity0's full-sized avatar
🛠️
build bridges to the stars, not battleships and sports cars

Ximin Luo infinity0

🛠️
build bridges to the stars, not battleships and sports cars
View GitHub Profile

Haskell

This is a quick "zero to hero" guide of various Haskell and FP-related topics. The intended audience (you) is self-directed people that want to quickly become a world-class Haskell programmer. Actually many of the topics are not specific to Haskell, so it can probably also help you become a world-class programmer in a similar language too.

#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <linux/types.h>
size_t max = (size_t)LONG_MAX +1; // (size_t)LONG_MAX+1
loff_t off = 0;
@infinity0
infinity0 / Test.hs
Last active September 3, 2020 18:12
naive benchmarks, rustc vs ghc
import qualified Data.Sequence as S
import qualified Data.ByteString as BS
import Control.DeepSeq
import Data.Foldable
import Data.Traversable
import Data.IORef
import Data.Word
import GHC.Clock
import System.IO
@infinity0
infinity0 / instructions.rst
Last active July 19, 2020 19:12
Chromecast Spotify on Debian Chromium, via a proxy

Tested 2020-07-19 chromium 83

You need to do:

  • chrome://flags and enable load-media-router-component-extension, might have to restart 1-2 times to take effect
  • download libwidevinecdm.so, see README.debian for details, restart to take effect
  • ublock filters (not whitelist, those are something else):
    • @@||www.gstatic.com/cast/*$script,domain=open.spotify.com
    • @@||www.gstatic.com/cv/js/sender/v1/cast_sender.js$script,domain=open.spotify.com
@infinity0
infinity0 / Background
Last active February 4, 2020 12:14
Student project
\section{Background}
\paragraph{Gossip} In a peer-to-peer gossip network we have to figure out how the nodes connect to each other. Two possibilities are a r-regular random graph and the SlimFly topology.
For the current assignment you can assume that the full list of peers is known, and available to each peer. (Networks where this is not the case, are vulnerable to the Sybil attack, which is out-of-scope for the time being.)
The topology should work for any sized network. Some topologies are optimised for particular network sizes (e.g. n = k ^ 2 for some k) and degrade for other sizes. This is bad.
There should be an efficient algorithm that each node can run to figure out its own neighbours. For example, for r-regular random graphs the only known way of doing this[1] is for everyone to generate the whole graph, whose computation costs O(n^3). This is not ideal. For our purposes, anything below O(n^2) can be considered reasonably efficient.
[1] (The naive method of selecting r random outgoing neighbours
@infinity0
infinity0 / Test.hs
Last active December 14, 2019 19:57
dependent fun
{-# LANGUAGE
AllowAmbiguousTypes
, DataKinds
, FlexibleContexts
, FlexibleInstances
, GADTs
, MultiParamTypeClasses
, PolyKinds
, RankNTypes
, ScopedTypeVariables
@infinity0
infinity0 / yanging.rst
Created October 5, 2019 19:54
YangGang2020
[merge]
conflictstyle = diff3
tool = kdiff3
[mergetool]
keepBackup = false
keepTemporaries = false
prompt = false
## then when you get a merge conflict, run "git mergetool" and it will run kdiff3 resolving as many conflicts automatiacyll as possible
$ apt-file search -x ^/usr/bin/ | cut -f2 -d: | sort -u
/usr/bin/[
/usr/bin/0alias
/usr/bin/0desktop
/usr/bin/0install
/usr/bin/0launch
/usr/bin/0store
/usr/bin/0store-secure-add
/usr/bin/0xFFFF
/usr/bin/2csv