Skip to content

Instantly share code, notes, and snippets.

View fuxingloh's full-sized avatar
🦆
quack quack

Fuxing Loh fuxingloh

🦆
quack quack
View GitHub Profile
// Copyright (c) 2016, Scott Motte
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
import { clsx } from 'clsx';
import { ReactElement } from 'react';
export function TruncateMiddle(props: {
children: string;
className?: string;
prefixLength?: number;
suffixLength?: number;
}): ReactElement {
const text = props.children;
@fuxingloh
fuxingloh / Bip32Patch.test.ts
Created April 5, 2021 06:25
Bip32Path TypeScript
import { BIP32Path } from '../../src/utils/bip32_path'
describe('fromPathArray()', function () {
it('should work with proper input', function () {
const bipPath = BIP32Path.fromPathArray([44 | 0x80000000, 1, 1, 0])
expect(bipPath.toString()).toBe("m/44'/1/1/0")
})
})
describe('toPathArray()', function () {
@fuxingloh
fuxingloh / intellij-markdown.css
Created December 11, 2020 06:15
Ultra simple white theme markdown for IntelliJ
body {
filter: invert(1);
background: #fff;
}
img {
filter: invert(1);
}
@fuxingloh
fuxingloh / lightsail.sh
Created September 21, 2020 09:19
Setup Docker & Docker-Compose on AWS Lightsail Amaozn Linux 2
sudo yum install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo chkconfig docker on
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
@fuxingloh
fuxingloh / Data.java
Created April 17, 2020 07:36
Selectively Patch Data with Jackson ObjectMapper in Spring Web & Spring Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Entity
public class Data {
@NotNull
@Id
@Column(length = 255, updatable = false, nullable = false, unique = true)
private String id;
@fuxingloh
fuxingloh / SleepUtils.java
Created January 21, 2020 06:47
Thread.sleep with checked InterruptedException wrapped in unchecked.
package dev.fuxing.utils;
import java.time.Duration;
/**
* Created by: Fuxing
* Date: 20/8/18
* Time: 6:43 PM
*/
public final class SleepUtils {
@fuxingloh
fuxingloh / JsonUtils.java
Created January 21, 2020 06:46
JsonUtils is basically a singleton ObjectMapper that wraps all JSON Error into {@code JsonException}. There are also a bunch of helper method for parsing collections.
package dev.fuxing.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.MapType;
import dev.fuxing.err.JsonException;
@fuxingloh
fuxingloh / Image.md
Last active October 14, 2021 01:08
A list of minimal effort image storage, transformation and delivery.

Minimal effort image storage, transformation and delivery.

IaaS

  • Storage: You upload to S3
  • Delivery + Transformation: CloudFront -> API Gateway -> Lambda (Node, Sharp/Thumbor) -> S3
  • CloudFormation: 1 click and fill up some fields.
  • Only predefined S3 Bucket, no dynamic bucket routing.
  • Transformation is encoded into Base64 that can be generated by anyone. You can add Signed URL but it's quite troublesome.
@fuxingloh
fuxingloh / ProceduralGenerationModification.md
Last active February 2, 2020 10:10
An idea on procedural content generation for games with alteration/grieving/modification.

History

Basically the game No Man's Sky UPS was a world with infinite possibility. I was very excited about the release of such a game because it created new possibility in games and might even inspire some one to do it better. The game flopped on release but the concept was unique, I was excited of what's to come. Fast forward 3 years later, still very little innovation in such genre.

Two incident caught my attention recently, Minecraft 2b2t and Sky Citizen.

Minecraft 2b2t server is a good example of maintaining a world with infinite possibility. 4000 GB of data, and <100 players can be on it at a time.