Skip to content

Instantly share code, notes, and snippets.

View jmhungdev's full-sized avatar
🐢
this is a turtle emoji

Jimmy Hung jmhungdev

🐢
this is a turtle emoji
  • CDK Global
  • Austin, TX
  • 14:54 (UTC -12:00)
  • X @jmhungdev
View GitHub Profile
@jmhungdev
jmhungdev / launch.json
Created June 1, 2023 05:40 — forked from cecilemuller/launch.json
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
@jmhungdev
jmhungdev / rename_go_mod.sh
Last active March 17, 2023 06:54
rename go module and update import paths
#!/bin/bash
OLD_MODULE_NAME=jmhungdev/go-example
NEW_MODULE_NAME=jmhundev/go-lessons
# replace module name in go.mod
go mod edit -module $NEW_MODULE_NAME
# find all .go files in current dir and sub dirs
# for each file replace old module name with the new one in place
@jmhungdev
jmhungdev / struct2csv.go
Last active March 16, 2023 04:02
Manipulating struct into csv in Golang
// stackoverflow post:
// https://stackoverflow.com/questions/75739563/converting-struct-to-csv-string/75740486#75740486
// [][]string or []Struct{} are preferred types to represent table data (csv) because of golang package ecosystem
// The case below is a special Data struct type that doesn't fit either
// which requires an additional step to transform it into [][]string before "encoding/csv" package can transform it into csv
package main
import (
@jmhungdev
jmhungdev / markdown_refresh.txt
Last active March 8, 2023 16:08
Markdown Syntax
// Heading H1 - H6
# H1
## H2
### H3
###### H6
// Use blank line to create a new paragraph
// Bold text
**here bold text**
@jmhungdev
jmhungdev / post_resp_html_parser.js
Last active November 20, 2022 06:28
Postman Scripting
// load html reponse in cheerio and retrieve the text of first h2 tag
const $ = cheerio.load(pm.response.text());
let latestDate = $("h2").first().text()
const requrl = `https://postman-echo.com/get?date=${latestDate}`
// send async request with callback
pm.sendRequest(requrl, function (err, response) {
console.log(response.json());
});

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@jmhungdev
jmhungdev / optional_chaining.js
Last active August 16, 2020 00:19
Optional Chaining - ES2020 - Chrome 80+
// Use case: when dealing with deeply nested objects.
// example: { dog : { cat : { parrot : peacock }}}
let obj = { dog : { cat : { parrot : 'peacock' }}};
let iWantPeacock = obj.dog.cat.parrot; //can throw an error
// Alternatively, one can do preliminary checks before the assignment
@jmhungdev
jmhungdev / 1_ReactClassComponent.jsx
Last active June 12, 2020 22:52
A generic template for a React class component
import React from 'react';
//alternatively you can write: import { Component } from 'react'
//and define your class this way: class App extends Component
class App extends React.Component {
//initiate your class component with a constructor
constructor(props) {
//inherit the props from React.Component class by using super()
@jmhungdev
jmhungdev / add.js
Last active June 22, 2023 19:37
a simple addition function
function add(x,y){
return x+y;
}