Skip to content

Instantly share code, notes, and snippets.

Jiahao jiahaog

Block or report user

Report or block jiahaog

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
@jiahaog
jiahaog / rust_wasm_bootstrap
Last active Jan 22, 2019
Install Rust with wasm-pack (useful for CI bootstrap)
View rust_wasm_bootstrap
#!/usr/bin/env bash
set -euo pipefail
curl https://sh.rustup.rs -sSf | sh -s - -y
export PATH=$HOME/.cargo/bin:$PATH
cargo install wasm-pack
View borrow_lifetimes.rs
#![allow(dead_code)]
// Using Rust without NLL (2015 edition)
// Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=b30d40f9558112878ba526cbaa6b27fc
fn consume<T>(_: T) {}
struct SimpleStruct {}
fn borrow_simple(_: &SimpleStruct) -> SimpleStruct {
@jiahaog
jiahaog / .gitlab-ci.yml
Created Jan 31, 2018
Generic way to build docker images on GitLab
View .gitlab-ci.yml
# Drop this file into GitLab repos containing a Dockerfile at the root
image: docker:1.12.3
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
@jiahaog
jiahaog / hash.cabal
Created Dec 6, 2017
MD5 Hex Representation in Haskell
View hash.cabal
build-depends: base >= 4.7 && < 5
, base16-bytestring
, bytestring
, cryptohash-md5
@jiahaog
jiahaog / transactions.go
Created Jun 22, 2017
Simulating transactions in Go
View transactions.go
package main
// This file attempts to simulate trasactions, that can be used to run tasks in a chain and
// rollback everything if the chain fails. For example, this can be used to simulate a database
// transaction to clean up dirty data.
// While I am aware that this abstraction is not truely a atomic transaction as it does not
// obtain locks on the affected objects, it is sufficient for our use cases to cleanup dirty data
const txLogTag = "transaction"
View shaped_struct.rb
# frozen_string_literal: true
# This class creates a object which behaves like a hash, except that it also
# responds to hash keys sent as messages. We need this type for GraphQL
# because the Gem sends messages to our objects instead of accessing it with
# `:[]`.
#
# It also performs type checking based on a type provided to the shape:
#
# === Example ===
#
View gist:c78196e35b3556b5127ca832d88bb636
wget -r -N http://people.csail.mit.edu/tlp/AI_SUTD_WWW/
View keybase.md

Keybase proof

I hereby claim:

  • I am jiahaog on github.
  • I am jiahaog (https://keybase.io/jiahaog) on keybase.
  • I have a public key ASAnzRnL5FxfaHCJ_M4O1HsYS_yzzBKTo5sHDrBRpU3t6wo

To claim this, I am signing this object:

@jiahaog
jiahaog / good_practice
Last active Mar 10, 2016
Template for shell scripts with proper error catching
View good_practice
#!/bin/sh
# Template for shell scripts with proper error catching
# Modified from http://www.alittlemadness.com/2012/06/25/bash-tip-reliable-clean-up-with-trap/
# immediately fail on error anywhere
set -e
# Defines a working area on the file system.
TEMP_DIR=/tmp/$$.scratch
@jiahaog
jiahaog / gist:f78765301b8c6cd8aa6a
Created Jan 23, 2016
Browserify Node.js files
View gist:f78765301b8c6cd8aa6a
browserify app/src/main.js --node --ignore-missing --detect-globals false --debug -o app/lib/main.js && cp app/src/preload.js app/lib/preload.js
You can’t perform that action at this time.