Skip to content

Instantly share code, notes, and snippets.

View davidnguyen11's full-sized avatar
👋

David Nguyen davidnguyen11

👋
View GitHub Profile
@davidnguyen11
davidnguyen11 / spotify-extension-users.md
Last active November 26, 2020 08:55
spotify-extension-users.md
@davidnguyen11
davidnguyen11 / git.md
Last active May 31, 2023 02:20
Git tips

Disable vim in "git log" & "git branch"

git config --global pager.log false
git config --global pager.branch false

Get current branch name

import { stub } from 'sinon';
describe('Testing localStorage', () => {
let getFunc;
let setFunc;
// Clone the original "localStorage"
const originalLocalStorage = window.localStorage;
beforeEach(() => {
class HashNode<T> {
key: string;
value: T;
next: HashNode<T> | null;
constructor(key: string, value: T) {
this.key = key;
this.value = value;
this.next = null;
}
@davidnguyen11
davidnguyen11 / HttpStatusCode.ts
Created April 8, 2020 06:54 — forked from scokmen/HttpStatusCode.ts
Typescript Http Status Codes Enum
"use strict";
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body
vim ~/.gitconfig
[alias]
  aa = add --all
  br = branch
  bv = branch -vv
@davidnguyen11
davidnguyen11 / release.sh
Created December 9, 2019 01:34 — forked from adamreisnz/release.sh
A script to automate merging of release branches
#!/usr/bin/env bash
# Assuming you have a master and dev branch, and that you make new
# release branches named as the version they correspond to, e.g. 1.0.3
# Usage: ./release.sh 1.0.3
# Get version argument and verify
version=$1
if [ -z "$version" ]; then
echo "Please specify a version"
@davidnguyen11
davidnguyen11 / release.sh
Created December 9, 2019 01:34 — forked from adamreisnz/release.sh
A script to automate merging of release branches
#!/usr/bin/env bash
# Assuming you have a master and dev branch, and that you make new
# release branches named as the version they correspond to, e.g. 1.0.3
# Usage: ./release.sh 1.0.3
# Get version argument and verify
version=$1
if [ -z "$version" ]; then
echo "Please specify a version"
const chalk = require('chalk');
const log = console.log;
function runBenchmark(description, operations, callback) {
const start = process.hrtime.bigint();
for (let i = 0; i < operations; i++) {
callback();
}
const end = process.hrtime.bigint();
function slugify(str) {
var newStr = str;
if (newStr) {
newStr = newStr.toLowerCase();
newStr = newStr.replace(/̀|̣.|΄|̃|̉/g, '');
newStr = newStr.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
newStr = newStr.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, 'e');
newStr = newStr.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
newStr = newStr.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
newStr = newStr.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');