Skip to content

Instantly share code, notes, and snippets.

View sleepylee's full-sized avatar
😒
Focusing

Trung Le sleepylee

😒
Focusing
  • nimblehq
  • Bangkok
View GitHub Profile
@sleepylee
sleepylee / clean_code.md
Created November 15, 2024 07:19 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

$printerName = "REC"
$printer = Get-Printer -Name $printerName
$job = Start-PrintJob -PrinterName $printerName
Write-Printer -Job $job -InputObject ([byte[]]@(27,112,0,50,250))
####
Write-Printer -Job "Start-PrintJob -PrinterName REC"-InputObject ([byte[]]@(27,112,0,50,250))
####
@sleepylee
sleepylee / image_util.dart
Last active December 20, 2021 11:34
Adding custom Text next to a custom Marker - Flutter
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
/// A custom method that allow you to draw customizable-positioned text next to a Google Map's Marker.
/// The Marker is essentially a custom image that is loaded from the assets dir.
///
@sleepylee
sleepylee / gen_pin.sh
Created April 30, 2021 08:00
Generating certificate pins for SSL Pinning from a pem file
cat your_pem_file.pem | openssl x509 -pubkey -noout |
openssl rsa -pubin -outform der 2>/dev/null |
openssl dgst -sha256 -binary | openssl enc -base64
@sleepylee
sleepylee / keybase.md
Last active September 11, 2019 11:26

Keybase proof

I hereby claim:

  • I am sleepylee on github.
  • I am sleepylee (https://keybase.io/sleepylee) on keybase.
  • I have a public key ASCVLjQRnDDbK5rD-EEsCWdQFBIogGt9US0MOZEdleW_FAo

To claim this, I am signing this object:

@sleepylee
sleepylee / regexCheatsheet.js
Created April 8, 2019 15:24 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@sleepylee
sleepylee / gist:654429d5188a3d863604e2b4bca6d1f7
Created November 27, 2018 07:14
Fixing 5Ghz WIFI hotspot on OnePlus 6
1. Connect your phone to adb, execute:
`adb shell settings put global tether_dun_required 0`
2. Go to: Settings -> Wi-Fi & internet -> SIM & network -> Choose your active SIM (e.g SIM 1) -> Access Points Names
-> Choose the chosen Option -> scroll to: APN type -> Edit -> add `,DUN` (a comma and DUN) to the end of it
package main
import (
"fmt"
"regexp"
"strconv"
)
const sample = `
<?xml version="1.0" encoding="utf-8"?>
@sleepylee
sleepylee / aws-listing
Created September 12, 2018 07:55
Listing All AWS EC2 Instances and Lambdas in All Regions
for region in `aws ec2 describe-regions --output text | cut -f3`
do
echo "\nListing Instances & Lambdas in:'$region'..."
aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, name: .KeyName, type: .InstanceType, key: .KeyName})'
aws lambda list-functions --region $region
done
@sleepylee
sleepylee / howto-installing-vault-on-aws-linux.md
Last active August 9, 2018 08:35 — forked from cludden/howto-installing-vault-on-aws-linux.md
HOWTO: Installing Vault on AWS Linux

HOWTO: Installing Vault On AWS Linux

This is quick howto for installing vault on AWS Amazon Linux AMI, so the setup can be replicated easily without the concerns of detailed steps on securing. At the end of this tutorial, you'll have a working vault server, using s3 for the backend, ensure the vault server is always running, and starts on reboot.

Setting up S3

First things first, let's set up an S3 bucket to use as the storage backend for our S3 instance.

  1. From the AWS Mangement Console, go to the S3 console.

  2. Click on the Create Bucket button