Skip to content

Instantly share code, notes, and snippets.


Jichao Ouyang jcouyang

Block or report user

Report or block jcouyang

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
View hypothesis-rss.rb
require "httparty"
require 'json'
url = "*&sort=created"
<?xml version="1.0"?>
<rss version="2.0"
jcouyang / surfingKeys.js
Last active May 2, 2018
Surfingkeys Settings
View surfingKeys.js
settings.stealFocusOnLoad = false;
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Front.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map('gt', 'T');
// an example to remove mapkey `Ctrl-i`
View typeclass-in-typescript.ts
// Higher Kind Type dictionary
interface _<A> { }
type HKT = keyof _<any>
type $<F extends HKT, A> = _<A>[F]
// Functor Type Class
interface Functor<F extends HKT> {
map<A, B>(f: (a: A) => B, fa: $<F, A>): $<F, B>
jcouyang / bmi-calc.rb
Last active Sep 10, 2017
BMI Calculator
View bmi-calc.rb
height = params['height'].to_f
weight = params['weight'].to_f
bmi = weight * 10000.0 / (height * height)
health = if(bmi < 18.5)
elsif (bmi < 24.9)
elsif (bmi < 30)
elsif (bmi >= 30)
jcouyang / syncthing
Created Jul 29, 2017
View syncthing
# Provides: syncthing
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of syncthing.
jcouyang / ipfs
Created Jul 29, 2017
View ipfs
# Provides: ipfs daemon
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the ipfs daemon
# Description: Starts the ipfs daemon using the start-stop-daemon
jcouyang /
Last active Jun 27, 2019
Promise All with Limit of Concurrent N

The Promise All Problem

in case of processing a very large array e.g. Promise.all(A_VERY_LARGE_ARRAY_OF_XHR_PROMISE)

which would probably blow you browser memory by trying to send all requests at the same time

solution is limit the concurrent of requests, and wrap promise in thunk

Promise.allConcurrent(2)([()=>fetch('BLAH1'), ()=>fetch('BLAH2'),...()=>fetch('BLAHN')])

View haskell.hs
import Control.Monad
import Data.List
solution n =
readInt :: IO Int
readInt = readLn
getInputs :: Int -> IO [Int]
getInputs lines = replicateM lines readInt
jcouyang / aqi.ino
Last active Dec 19, 2016
Interface to Shinyei Model PPD42NS Particle Sensor
View aqi.ino
Interface to Shinyei Model PPD42NS Particle Sensor
Program by Christopher Nafis
Written April 2012
JST Pin 1 (Black Wire) => Arduino GND
JST Pin 3 (Red wire) => Arduino 5VDC
View pratical

Practical Monads


  • Monad
  • Promise
  • Observable
  • Demo


You can’t perform that action at this time.