Skip to content

Instantly share code, notes, and snippets.

@vxhviet
vxhviet / regex.md
Created August 8, 2017 04:03
Regular Expression to find a string included between two characters while EXCLUDING the delimiters

Source: StackOverflow

Question: Regular Expression to find a string included between two characters while EXCLUDING the delimiters

Answer:

Easy done:

(?<=\[)(.*?)(?=\])

Connect Firebase Hosting to Namecheap Custom Domain

SOURCE, SOURCE, SOURCE

  1. Go to Firebase's Dashboard > Develop > Hosting > Connect Domain.
  2. Enter the custom domain that you'd like to connect to your Hosting site.
  3. (Optional) Check the box to redirect of all requests on the custom domain to a second specified domain.
  4. Click Continue to initiate the validation process.
  5. Go to Namecheap's Dashboard > Domain List > Manage > Advanced DNS.
  6. Under Host Records, add a new record with:
@vxhviet
vxhviet / saveToExternalStorage.md
Last active March 3, 2024 20:19
Android saving Bitmap to external storage.

Source: StackOverflow

Question: How do I save Bitmap to extrenal storage in Android?

Answer:

Use this function to save your bitmap in SD card:

public void saveTempBitmap(Bitmap bitmap) {
        if (isExternalStorageWritable()) {
@vxhviet
vxhviet / javaCV.md
Last active February 26, 2024 22:59
How to fucking add JavaCV to Android Studio

Source: Me, GitHub, following this for update GitHub

Question: How to fucking add JavaCV to Android Studio so I can use the fucking annoying FFmpeg?

Answer: This tut will use JavaCV 1.1, version 1.2 currently has SIGSEGV issue. JavaCV 1.1 comes with FFmpeg 2.8.1.

  1. Obtain the prebulit binaries here.
  2. Extract it and copy these files:
  • javacpp.jar (essential).
  • javacv.jar (essential).
@vxhviet
vxhviet / LUTFilter.md
Last active November 1, 2023 18:25
How to Apply Color LUT to bitmap images for filter effects in Android?

Source: StackOverflow, StackOverflow

Question: How to Apply Color LUT to bitmap images for filter effects in Android?

Answer:

    final static int X_DEPTH = 64;
    final static int Y_DEPTH = 64; //One little square in the LUT has 64x64 pixels in it
    final static int ROW_DEPTH = 8;

[JavaScript] - Encapsulation

SOURCE

There are 2 ways to achieve Encapsulation in JS:

  • Protected Properties and Methods: coding convention (not true private), use _ before a property to notify other developer this property is protected and should not be used directly.
  • Private Class Fields and Methods: languague feature that is still under proposal, might not work for every browser and are subjected to syntax change.
// 1) Public fields
// 2) Private fields
@vxhviet
vxhviet / simplifiedGitFlow.md
Last active August 11, 2023 18:31
A simplified version of Git Flow

Simplified Git-flow

                        RELEASE TAG
o----------------------------o-----------------o------------o------> MASTER
 \                          /  \                \----------/ HOTFIX
  \                        /    \                          \
   \----------------------/      \--------------------o-----o------> DEVELOP
                                  \                  /
 \----------------/ FEATURE

[JavaScript] - Inheritance Between Classes

Constructor Function

const Person = function (firstName, birthYear) {
  this.firstName = firstName;
  this.birthYear = birthYear;
};

[JavaScript] - Object.create()

SOURCE

// Basically this is a way to link a prototype to any object that we want.

// the prototype
const PersonProto = {
  calcAge() {
 console.log(2037 - this.birthYear);

[JavaScript] - ES6 Classes

SOURCE

// syntactic sugar, behind the scene it's still prototypal inheritance/ delegation

// Class expression
// const PersonCl = class {} // behind the scene class is still a special type of function

// Class declaration