Skip to content

Instantly share code, notes, and snippets.

jiahaog / main.dart
Created Nov 18, 2020
Dart unhandled exception
View main.dart
void main() async {
try {
await Future(() {
Future(() {
throw 'foo';
print('future completed');
} catch (e) {
jiahaog /
Created Nov 26, 2019 — forked from rust-play/
Code shared from the Rust Playground
fn main() {
println!("Hello, world!");
fn test(holder: Holder) -> impl Animal {
match holder {
Holder::DogHolder(dog) => dog,
Holder::CatHolder(cat) => cat,

Get names of all geotagged photos with Exiftool:

find . -type f -exec sh -c "exiftool {} -GPSLatitude | grep 'GPS' 2>&1 >/dev/null"  \; -print >> withgps.txt

Move them to another directory:

cat withgps.txt | xargs -I '{}' mv {} with_gps/
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 -sSf | sh -s - -y
export PATH=$HOME/.cargo/bin:$PATH
cargo install wasm-pack
We couldn’t find that file to show.
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
- docker info
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
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 / 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