Skip to content

Instantly share code, notes, and snippets.

Yang Wei yang-wei

Block or report user

Report or block yang-wei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
yang-wei / BarChart.jsx
Created Aug 7, 2016
react d3 (v4.0) stacked bar chart using rd3
View BarChart.jsx
'use strict';
import { scaleOrdinal, schemeCategory20c } from 'd3-scale';
import React from 'react';
module.exports = React.createClass({
displayName: 'BarChart',
propTypes: {
yang-wei / fixed-data-table.cljs
Created May 4, 2016
Porting FixedDataTable to Reagent
View fixed-data-table.cljs
(ns gannet.components.result-table
(:require [reagent.core :as r]
[ :as style]
(def Table(r/adapt-react-class js/FixedDataTable.Table))
(def Column (r/adapt-react-class js/FixedDataTable.Column))
(def Cell (r/adapt-react-class js/FixedDataTable.Cell))
  1. git stash, then git stash pop

  2. git commit --amend

  3. git checkout -

  4. コンフリクトのとき動作がう? ====

  5. git add -p

yang-wei / fetch.clj
Created Apr 11, 2016
Clojure fetch url
View fetch.clj
(defn fetch-url[address]
(with-open [stream (.openStream ( address))]
(let [buf (
( stream))]
(apply str (line-seq buf)))))
(fetch-url "")
yang-wei /
Last active Sep 24, 2019
Elm Json.Decode tutorial and cheatsheet

When receiving JSON data from other resources(server API etc), we need Json.Decode to convert the JSON values into Elm values. This gist let you quickly learn how to do that.

I like to follow working example code so this is how the boilerplate will look like:

import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=))

import Http
yang-wei / keyValuePairs.elm
Last active May 1, 2019
Json.Decode example
View keyValuePairs.elm
import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=), at, keyValuePairs)
import Http
type alias Languages =
List (String, Int)
mailbox =
yang-wei / bmi.cljs
Created Feb 29, 2016
ClojureScript BMI Calculator
View bmi.cljs
;; -------------------------
;; BMI Calculator
(def bmi-data
(reagent/atom {:height 180
:weight 60}))
(defn slider [min max val param]
[:input {:type "range"
:value val
:min min
yang-wei /
Last active Dec 13, 2019
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !


myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
yang-wei /
Last active Sep 19, 2019
ES6 destructing (and rest parameter)

We will first discussed how destructing and rest parameters can be used in ES6 - in arrays and objects. Then we will look at a few examples and also discuss some quiz.


var array = [1, 2, 3, 4];
var nestedArray = [1, 2, 3, 4, [7, 8, 9]];

var [a, b, c, d] = array;
console.log(a, b, c, d)
You can’t perform that action at this time.