Skip to content

Instantly share code, notes, and snippets.

View trung's full-sized avatar
🏕️
...

⚆ Trung Nguyen trung

🏕️
...
View GitHub Profile
@trung
trung / start_unifi.sh
Created April 20, 2023 13:10
Run Unifi Controller on Docker
#!/bin/bash
docker run -d --init \
--restart=unless-stopped \
-e TZ='America/New_York' \
--net=host \
-v /home/trung/unifi:/unifi \
--user unifi \
--name unifi \
jacobalberty/unifi
@trung
trung / MyClass.java
Last active April 14, 2023 19:41
Jackson Custom Serializer for Class extending HashMap
public class MyClass extends HashMap<String, Object> {
private String name;
// getter .. setter
}
@trung
trung / install-unifi.sh
Last active March 10, 2022 18:35
Install Unifi Controller in Raspberri Pi (32-bit only)
#/bin/bash
# Partially copied from https://raw.githubusercontent.com/SmokingCrop/UniFi/master/install-unifi-pihole-English.sh
Colour='\033[1;31m'
less='\033[0m'
if [[ -z "$version" ]]; then
version='7.0.23'
fi
@trung
trung / git.diff
Created May 22, 2020 19:35
deploy-simple-storage-contract.js
- rawTransactionManager.sendRawRequest(privateSignedTx, privateFor);
+ let response = web3.eth.currentProvider.send({
+ jsonrpc: "2.0",
+ method: "eth_sendRawPrivateTransaction",
+ params: [privateSignedTx, { privateFor }],
+ id: "1"
+ });
+ console.log(response);
+ console.log(`\nTransaction Hash = ${response.result}`);
+ getTransactionReceiptMined(response.result).then(console.log);
@trung
trung / notify.yml
Last active July 10, 2024 12:11
Notify slack about Github Actions workflow and its jobs status. `notify` job must be the last job in the workflow and it must depend on all other jobs
notify:
if: always()
name: Notify
needs:
- job1
- job2
- job11
- job3
- job4
runs-on: ubuntu-latest
@trung
trung / keybase.md
Created August 13, 2019 15:53
keybase.io

Keybase proof

I hereby claim:

  • I am trung on github.
  • I am 1run9 (https://keybase.io/1run9) on keybase.
  • I have a public key ASC9zd-0DFAhbsi89B08b9kr0IQ_d3U9bVAO0BkdHK6ckgo

To claim this, I am signing this object:

@trung
trung / instructions.diff
Last active March 12, 2019 21:06
CodeCopy
func opCodeCopy(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
var (
memOffset = stack.pop()
codeOffset = stack.pop()
length = stack.pop()
)
codeCopy := getDataBig(contract.Code, codeOffset, length)
memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)
+ if length.Cmp(big.NewInt(32)) == 0 {
@trung
trung / source_jdk_switcher.sh
Last active February 13, 2019 20:00
Travis - jdk_switcher: command not found
# This works for trusty but not xenial
if test -f ${HOME}/.jdk_switcher_rc; then
. ${HOME}/.jdk_switcher_rc
fi
if test -f /opt/jdk_switcher/jdk_switcher.sh; then
. /opt/jdk_switcher/jdk_switcher.sh
fi
@trung
trung / aws_default_route_table.tf
Last active July 14, 2017 15:12
How to retrieve default route table id for a VPC
variable "vpcId" {
default = "vpc-5f98eb36"
}
data "aws_route_table" "all" {
vpc_id = "${var.vpcId}"
filter {
name = "association.main"
values = ["true"]
}
@trung
trung / JarReader.java
Last active January 2, 2024 14:33
Reading files from Jar file recursively
package xyz.com;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;