Skip to content

Instantly share code, notes, and snippets.

View soareschen's full-sized avatar
🏠
Working from home

Soares Chen soareschen

🏠
Working from home
View GitHub Profile
{
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"no-undef": 1,
@soareschen
soareschen / cuda-setup.md
Last active August 8, 2018 01:04
CUDA setup on Ubuntu 16.04 and LXD

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

@soareschen
soareschen / prototype.go
Created March 28, 2015 12:11
Prototypal Inheritance in Go
package main
import (
"fmt"
"strings"
)
type Base interface {
Foo() string
Bar() string
@soareschen
soareschen / README.md
Last active August 29, 2015 14:15
Zsh scripts leave defunct processes when running under docker exec

Zsh scripts leave defunct processes when running under docker exec

This only happens when the script is running inside a shell spawned by docker exec. When running under bash or under docker run, there is no defunct process.

This bug is first discovered when I run nvm in docker (creationix/nvm#650). It was then discovered that Docker's nsenter did not properly handle the SIGCHLD signal raised from zsh. (docker/libcontainer#369) Even though it is now been fixed by Docker, I am not sure why zsh would cause this bug in the first place.

Steps to reproduce:

# terminal 1
@soareschen
soareschen / quiver-architecture-for-the-front-end.md
Last active August 29, 2015 14:11
Quiver Architecture For The Front End

Quiver Architecture For The Front End

Despite my lack of experience in HTML front end development, I am already itchy to step a foot in and try to create new front end architecture. Is my non-expertise a benefit or red flag? I really don't know.

I find the higher order constructs in Quiver - builder, filter, middleware, component - to be a very robust and general architecture that can be applied to wide range of applications, including GUI apps and perhaps even rendering engines. So let's see how a HTML app can can be defined based on Quiver:

Template

function template(model) => VirtualDOM
@soareschen
soareschen / managing-state-in-react.md
Last active July 13, 2016 10:54
Managing State in React

Managing State in React

After digging more into React I get a better idea on how React states work. It looks like React still have a bit of magic happening behind the scene to make states work.

// 3 Elements mapping to the same real DOM
var element1 = <MyElement awesome=true>My Awesome Content</MyElement>

var element2 = <MyElement awesome=false>My Boring Content</MyElement>
@soareschen
soareschen / go-first-try.go
Last active August 29, 2015 14:07
First try of using Go in Quiver-style
package main
import (
"fmt"
"time"
"net/http"
)
type handlerFunction func(
res http.ResponseWriter,
@soareschen
soareschen / 01-timeout.js
Last active August 29, 2015 14:02
Promise Wrappers
'use strict'
var timeoutPromise = function(timeout, construct) {
return new Promise(function(resolve, reject) {
construct(resolve, reject)
setTimeout(function() {
reject(new Error('timeout error'))
}, timeout)
})
@soareschen
soareschen / quiver-dsl-specs.js
Last active August 29, 2015 14:02
Quiver DSL Draft Specs
/*
* Begin Define
*/
require('quiver-define')
.namespace('my-namespace') // compulsory
// Using Directive
.using('other-namespace::component-name')
.using(require('other-module'))
.using([
@soareschen
soareschen / expr-dsl.js
Last active August 29, 2015 14:02
DSL experiment in JavaScript for building expression AST
/*
* This is a DSL experiment to build
* abstract syntax trees (AST) in Javascript.
* In this example we provide a simplified
* use case of building expression AST.
*
* The expression AST built here are
* equivalent to the following mathematical
* expressions:
*