Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Soares Chen soareschen

🏠
Working from home
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am soareschen on github.
  • I am soareschen (https://keybase.io/soareschen) on keybase.
  • I have a public key ASBFlptlH9b-PeBx6_1vQOQoQ-_rUPKhr-kSRwSkf4znswo

To claim this, I am signing this object:

@soareschen
soareschen / dict-typing.hs
Last active Apr 8, 2018
Dict Typing - Duck Typing in Haskell using dictionaries and implicits
View dict-typing.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
import GHC.Exts
-- Dict Typing - Duck Typing in Haskell using dictionaries and implicits
@soareschen
soareschen / implicit-parameter.hs
Last active Mar 29, 2018
Implicit Parameter Experiments
View implicit-parameter.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE ConstraintKinds #-}
import GHC.Exts
-- A handler holds a function that takes in any a that
-- satisfies constraint p. Note that we are simply returning
-- string in here for the sake of simplifying the demo.
@soareschen
soareschen / has-field.hs
Created Mar 24, 2018
Experiment for simple implementation of HasField for extensible records
View has-field.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@soareschen
soareschen / row-polymorphic-composition.purs
Created Feb 12, 2018
Composition of row polymorphic functions in PureScript
View row-polymorphic-composition.purs
module Main where
import Prelude
import Data.Record
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
fooHandler :: forall r. { foo :: String | r } -> String
fooHandler args = "(foo-handler " <> args.foo <> ")"
@soareschen
soareschen / constraint-composition.hs
Last active Feb 11, 2018
Constraint-preserving composition of functions with constraints
View constraint-composition.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FunctionalDependencies #-}
@soareschen
soareschen / constraint-composition.hs
Last active Feb 8, 2018
Row Polymorphic-like composition in Haskell
View constraint-composition.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
import GHC.Exts
@soareschen
soareschen / metaprogramming-with-proxy.js
Created Sep 25, 2017
Metaprogramming in JavaScript using proxy and with statement
View metaprogramming-with-proxy.js
/*
This code snippet demonstrates how to do metaprogramming
in JavaScript using proxy and with statement.
Run this in non-strict mode.
*/
const proxy = new Proxy({}, {
get(target, key) {
if(key === Symbol.unscopables) return {}
return `${key.toUpperCase()} `
},
View .eslintrc.json
{
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"no-undef": 1,
@soareschen
soareschen / cuda-setup.md
Last active Aug 8, 2018
CUDA setup on Ubuntu 16.04 and LXD
View cuda-setup.md

This gist explains the steps required to install CUDA on Ubuntu 16.04 as well as enabling it inside LXD containers.

The setup assumes GTX 10 series hardware, tested with my GTX 1070.

Driver Installation

Download the latest Nvidia driver at http://www.nvidia.com/Download/index.aspx.

On 64-bit systems, install 32-bit OpenGL libaries first so that the driver will install