Skip to content

Instantly share code, notes, and snippets.

View mt40's full-sized avatar
🎶

Minh Thai mt40

🎶
  • Sea Ltd
  • Viet Nam
View GitHub Profile
@mt40
mt40 / consolelogger.go
Created January 31, 2024 04:42
Design Pattern: Chain Of Responsibility
type ConsoleLogger struct {
next Logger
}
func (l *ConsoleLogger) Log(level LogLevel, text string) {
fmt.Printf("%s | %s\n", level, text)
if l.next != nil {
l.next.Log(level, text)
}
}
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release \
vim
@mt40
mt40 / gist:452942f4314982f072167111e81eac92
Created February 17, 2021 03:11
Recent Files - Finder raw query
(kMDItemContentCreationDate >= $time.today(-30)) && ((kMDItemContentTypeTree = public.content) || (kMDItemContentTypeTree = "com.microsoft.*"cdw) || (kMDItemContentTypeTree = public.archive))
@mt40
mt40 / main.dart
Created September 17, 2019 04:02
Dart Static Enum Pattern
/// As of Dart 2.5, `enum` can still only support very simple use case.
/// To have a "rich enum" with custom value type and methods, we need
/// to use static class member. This is an example implementation.
void main() {
final s1 = 'done', s2 = 'waiting';
final done = Enum.parse(Status.values, s1);
final waiting = Enum.parse(Status.values, s2);
print(done);
@mt40
mt40 / sbt_shading_fix.md
Created December 14, 2018 08:17
Fix SBT incorrect shading on Linux

Description

Shading using [SBT Assembly][assembly] plugin doesn't produce the correct jar structure

Reason

Inconsistent locale

Solution

Run these commands

export LC_ALL="en_US.UTF-8"
@mt40
mt40 / curl.md
Created January 25, 2018 14:05 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@mt40
mt40 / Gulpfile.js
Created September 17, 2017 04:27 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@mt40
mt40 / notes.md
Last active March 14, 2017 14:11
Golang cheatsheet

Array

Array type includes the type and the length. So [2]int is different from [3]int.

Type

Type binding (~ type alias)

type IntSlice []int
a := IntSlice{1, 2}

However, IntSlice is different from []int. []int is the underlying type of IntSlice.

@mt40
mt40 / settings.json
Created September 1, 2016 11:59
My Vscode User Settings
{
// Configure glob patterns for excluding files and folders.
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/*.cs.meta": true,
"**/node_modules": true
},
"workbench.editor.showTabs": false,
"editor.renderIndentGuides": true,
@mt40
mt40 / keybindings.json
Last active August 28, 2016 01:46
My custom VSCODE key bindings
// Place your key bindings in this file to overwrite the defaults
[
/**
* Group: Editing
* Prefix: ctrl+e
*/
// Section: new bindings
{
"key": "ctrl+e ctrl+f",
"command": "editor.action.format",