Skip to content

Instantly share code, notes, and snippets.

View chiro-hiro's full-sized avatar
🤖
Bleep bloop, I am a robot. Eh, just kidding.

Chiro Hiro chiro-hiro

🤖
Bleep bloop, I am a robot. Eh, just kidding.
View GitHub Profile
@chiro-hiro
chiro-hiro / part-time-5.md
Created May 26, 2018 12:05
Part time part 5/ chap 6

Kết quả khi mình chạy test, mình có dump data để các bạn có thể theo dõi sự thay đổi.

Contract: Partime
    √ should have 0 total part time job
        Job's details:
         id: 0
         creator: 0x4a8be21d76a3003bf62513907b3a460957086caf
         salary: 1000000000000000000
         start: 0
         end: 0
@chiro-hiro
chiro-hiro / golang-slice.md
Last active June 18, 2023 05:18
first() and last() safe access in Golang

I'm pretty sure, Golang is a good language to learn and do development. I find out Golang doesn't support some popular safe slice access.

package main

import (
	"fmt"
	"reflect"
)

func main() {
@chiro-hiro
chiro-hiro / golang-tls.md
Created August 24, 2018 03:50 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@chiro-hiro
chiro-hiro / node-js-scan-files.md
Created January 3, 2019 04:00
NodeJS -- Scan all files for given path

This function will return an array of files for given path:

function scanDir(scanPath, filelist) {
  var filelist = filelist || [];
  var dirs = fs.readdirSync(scanPath);
  for (var i = 0; i < dirs.length; i++) {
    var _childPath = path.resolve(scanPath, dirs[i])
    if (fs.statSync(_childPath).isDirectory()) {
      scanDir(_childPath, filelist);
 } else {
@chiro-hiro
chiro-hiro / keybase.md
Created September 13, 2019 09:53
keybase.md

Keybase proof

I hereby claim:

  • I am chiro-hiro on github.
  • I am chiro8x (https://keybase.io/chiro8x) on keybase.
  • I have a public key ASCmwC369mu7TJyx0a_QmNetM1A56DLANYB9Q0gQeuFr8wo

To claim this, I am signing this object:

@chiro-hiro
chiro-hiro / golang-uint64-uint32-to-bytes.md
Last active August 25, 2022 17:45
Golang uint64, uint32 to bytes array

Wrote for a joyful journey of Go.

package main

import (
	"fmt"
)

func i64tob(val uint64) []byte {
// Human constructor
function Human(name) {
this.name = name;
}
// Define name as a property
Object.defineProperty(Human.prototype, 'name', {
set: function (value) {
if (typeof value !== 'string') {
throw new TypeError('Name value was not a string');
class Human {
constructor(name) {
this.name = name;
this.race = 'Terran';
}
set name(value) {
if (typeof value !== 'string') {
throw new TypeError('Name value was not a string');
class Foo {
constructor() {
this.constructedAt = (new Date()).toDateString();
}
static getInstance() {
this.foo = 1;
this.instance = this;
return this.instance;
}
getValue() {
class Foo {
constructor() {
this.constructedAt = (new Date()).toISOString();
}
static getInstance() {
if (typeof this.instance === 'undefined') {
this.instance = new Foo();
}
return this.instance;
}