Skip to content

Instantly share code, notes, and snippets.

View Zhen-hao's full-sized avatar

Zhenhao Li Zhen-hao

  • Natural Transformation
  • Amsterdam
View GitHub Profile
@Zhen-hao
Zhen-hao / arrow-shell.nix
Created April 25, 2020 12:12
how to use apache arrow in R on NixOS
let
old-arrow-cpp = import (
builtins.fetchTarball {
name = "old-arrow-cpp";
url = https://github.com/nixos/nixpkgs/archive/cdbf3f78bfd1f88259116f6f7cbcc6c5df0a9687.tar.gz;
# Hash obtained using `nix-prefetch-url --unpack <url>`
sha256 = "1j0lrjcqfp5pp54ls3wc054yyi4s6wpabs00d7sy9640fdrh8bd4";
}
) {};
arrow-cpp-overlay = self: super: {
@Zhen-hao
Zhen-hao / customized-flink-version.nix
Created August 30, 2019 08:16
how to upgrade a version of existing package yourself
@Zhen-hao
Zhen-hao / jupyterlab_cuda.nix
Created August 30, 2019 07:18
an example of reproducible data science environment
{ pkgs ? import <nixpkgs> {config = { allowUnfree = true; }; } }:
pkgs.stdenv.mkDerivation {
name = "cuda-env-shell";
buildInputs = with pkgs;
[ git gitRepo gnupg autoconf curl
procps gnumake utillinux m4 gperf unzip
cudatoolkit linuxPackages.nvidia_x11
libGLU_combined
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.streaming.api.scala.{DataStream, KeyedStream}
import org.apache.flink.streaming.api.scala._
import shapeless._
import record._
import shapeless.LabelledGeneric
import shapeless.labelled.FieldType
import shapeless.Witness
import shapeless.ops.record.Selector
import shapeless.syntax.RecordOps
@Zhen-hao
Zhen-hao / forkme.md
Last active December 12, 2018 19:34 — forked from skuro/forkme.md
Advent of Clojure solutions

Fork me!

@Zhen-hao
Zhen-hao / clojure_meetup_8_dec_2017.clj
Created November 8, 2017 21:18
a solution to an Anglican exercise
;; To do this we've provided scaffolding
;; that can be modified to achieve
;; your objective:
(with-primitive-procedures
[create-world simulate-world balls-in-box]
(defquery arrange-bumpers []
(let [;; *** TASK: REPLACE THE FOLLOWING LINE WITH
;; STOCHASTIC CODE TO SAMPLE POSSIBLE
;; BUMPER CONFIGURATIONS ***
n-bumpers 4 ;; (sample (poisson 4)) ;; this is to let Anglican select the number of bumpers; maybe (poisson 2) is better
@Zhen-hao
Zhen-hao / new_working_version.scala
Last active June 27, 2017 11:27
code used at the Amsterdam Scala meetup on 22 June 2017
import cats.Id
// inspired by https://stackoverflow.com/questions/26834230/scala-implicit-for-arbitrarily-deep-functor-composition
object CaseStudy {
trait Functor[F[_]] {
def lift[A, B](f: A => B): F[A] => F[B]
def map[A, B](fa: F[A])(f: A => B): F[B] = lift(f)(fa)
}