Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Linker nlinker

View GitHub Profile
@nlinker
nlinker / command_modal.rs
Last active May 6, 2020
Test view for command_modal
View command_modal.rs
#[test]
fn test_view() {
let command = vec![make_command(
1,
&[39, 40, 41, 42, 43, 44, 45, 46, 47, 48],
"The command",
)];
let jobs = vec![
make_job(39, &[10, 20], &[], "Install packages on server oss2.local."),
make_job(40, &[11, 21], &[39], "Configure NTP on oss2.local."),
View 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 Mar 30, 2019 — 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
View msi-gtx1060-ubuntu-18.04-deeplearning.md
View functional core, imperative shell.md

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 Dec 7, 2018 — forked from Chandler/slack_history.py
Download Slack Channel/PrivateChannel/DirectMessage History
View slack_history.py
# 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 Dec 7, 2018 — forked from parsonsmatt/prismatic.hs
I figured out a nice way to pluck exceptions out of a constraint!
View prismatic.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
@nlinker
nlinker / Bijection.md
Created Nov 26, 2018 — forked from andrejbauer/Bijection.md
A bijection between numbers and pairs of numbers.
View Bijection.md

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)
View pyproject.toml
[tool.poetry]
name = "mnist"
version = "0.1.0"
description = ""
authors = ["Nick Linker"]
[tool.poetry.dependencies]
python = "^3.6"
[tool.poetry.dev-dependencies]
@nlinker
nlinker / playground.rs
Created Nov 17, 2018 — forked from rust-play/playground.rs
Code shared from the Rust Playground
View playground.rs
#[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 Oct 26, 2018 — forked from dusty-nv/pytorch_jetson_install.sh
Install procedure for pyTorch on NVIDIA Jetson TX1/TX2
View pytorch_jetson_install.sh
#!/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.