Skip to content

Instantly share code, notes, and snippets.

@nlinker
nlinker / config.h
Created September 16, 2022 19:18 — forked from aashreys/config.h
Adding RGB Timeout functionality to your QMK keyboard
/* In your config.h define a new variable RGBLIGHT_TIMEOUT and give it a value in milliseconds */
#define RGBLIGHT_SLEEP // allows us to use rgblight_suspend() and rgblight_wakeup() in keymap.c
#define RGBLIGHT_TIMEOUT 30000 // 30 seconds
@nlinker
nlinker / id.hs
Created September 26, 2019 12:17 — forked from cblp/id.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedLabels #-}
import Control.Lens
import Data.Generics.Labels
import GHC.Generics
import Prelude hiding (id)
import qualified Prelude
@nlinker
nlinker / msi-gtx1060-ubuntu-18.04-deeplearning.md
Created March 30, 2019 06:20 — forked from hereismari/msi-gtx1060-ubuntu-18.04-deeplearning.md
Setting up a MSI laptop with GPU (gtx1060), Installing Ubuntu 18.04, CUDA, CDNN, Pytorch and TensorFlow

1. Separation of immutable and mutable logic

Quite a lot of different people have been on the same trail of thought. Gary Bernhardt's formulation of a "functional core, imperative shell" seems to be the most voiced.

"Boundaries" - Gary Bernhardt

"Imperative shell" that wraps and uses your "functional core".. The result of this is that the shell has fewer paths, but more dependencies. The core contains no dependencies, but encapsulates the different logic paths. So we’re encapsulating dependencies on one side, and business logic on the other side. Or put another way, the way to figure out the separation is by doing as much as you can without mutation, and then encapsulating the mutation separately. Functional core — Many fast unit tests. Imperative shell — Few integration tests

https://www.youtube.com/watch?v=yTkzNHF6rMs

@nlinker
nlinker / slack_history.py
Created December 7, 2018 18:45 — forked from Chandler/slack_history.py
Download Slack Channel/PrivateChannel/DirectMessage History
# MIT License
# Copyright (c) 2016 Chandler Abraham
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@nlinker
nlinker / prismatic.hs
Created December 7, 2018 04:40 — forked from parsonsmatt/prismatic.hs
I figured out a nice way to pluck exceptions out of a constraint!
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
@nlinker
nlinker / Bijection.md
Created November 26, 2018 20:00 — forked from andrejbauer/Bijection.md
A bijection between numbers and pairs of numbers.

A bijection between numbers and pairs of numbers

Every once in a while I am faced with someone who denies that the rational numbers (or fractions, or pairs of integers) can be put into a bijective correspondence with natural numbers. To deal with the situation, I coded up the bijection. So now I can just say: "Really? Interesting. Please provide a pair of numbers (i,j) which is not enumerated by f, as defined in my gist." I am still waiting for a valid counter-example.

Anyhow, here is a demo of f and g at work. I am using the Python version, but a Haskell variant is included as well.

The 100-th pair is:

>>> f(100)

(10, 4)

@nlinker
nlinker / playground.rs
Created November 17, 2018 09:41 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[derive(Debug)]
struct OrderBook {
pair_name: String,
pair_id: u64,
bids: HashMap<String, String>,
asks: HashMap<String, String>,
}
fn parse_poloniex_full_order_book(msg: &str) -> OrderBook{
@nlinker
nlinker / pytorch_jetson_install.sh
Created October 26, 2018 06:23 — forked from dusty-nv/pytorch_jetson_install.sh
Install procedure for pyTorch on NVIDIA Jetson TX1/TX2
#!/bin/bash
#
# pyTorch install script for NVIDIA Jetson TX1/TX2,
# from a fresh flashing of JetPack 2.3.1 / JetPack 3.0 / JetPack 3.1
#
# for the full source, see jetson-reinforcement repo:
# https://github.com/dusty-nv/jetson-reinforcement/blob/master/CMakePreBuild.sh
#
# note: pyTorch documentation calls for use of Anaconda,
# however Anaconda isn't available for aarch64.
@nlinker
nlinker / stockfish.py
Created December 15, 2017 17:34 — forked from notbanker/stockfish.py
Python call to stockfish chess engine
import subprocess
from lib.common.dominoUtil import running_on_local
from lib.config import PROJECT_PATH
import time
import psutil
import os
import numpy as np
def _recommended_threads():
return psutil.cpu_count()-2