Skip to content

Instantly share code, notes, and snippets.

@thiennguyenenv
thiennguyenenv / git_fetch_pull_all_subfolders.sh
Created February 28, 2024 07:57 — forked from mnem/git_fetch_pull_all_subfolders.sh
Simple bash script for fetching and pulling all repos in the executed folder to the latest of the branch they are on
#!/bin/bash
################
# Uncomment if you want the script to always use the scripts
# directory as the folder to look through
#REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPOSITORIES=`pwd`
IFS=$'\n'
@thiennguyenenv
thiennguyenenv / download.go
Created October 12, 2020 09:51 — forked from albulescu/download.go
golang download file with progress
package main
/**
* @website http://albulescu.ro
* @author Cosmin Albulescu <[email protected]>
*/
import (
"bytes"
"fmt"
@thiennguyenenv
thiennguyenenv / useDialog.js
Created April 3, 2020 05:47 — forked from jz222/useDialog.js
A custom hook for dialogs in React
import React, { useCallback, useEffect, useRef, useState } from 'react';
import Button from 'components/UI/button/button';
import styling from './useDialog.module.scss';
export default (cb) => {
const [{ open, params }, setDialogMeta] = useState({ open: false });
const containerRef = useRef(null);
@thiennguyenenv
thiennguyenenv / currying.md
Created February 11, 2020 02:27 — forked from donnut/currying.md
TypeScript and currying

TypeScript and currying

In functional programming you often want to apply a function partly. A simple example is a function add. It would be nice if we could use add like:

var res2 = add(1, 3); // => 4

var add10To = add(10);
var res = add10To(5); // => 15
@thiennguyenenv
thiennguyenenv / gist:f0a420d4dbddc5330f0b1bbf146a2442
Created September 14, 2019 08:26 — forked from rmatil/gist:8d21620c11039a442964
Connect MySQL database in Vagrant VM from Host machine

Connecting to Vagrant VM MySQL database from host

This gist shows how to connect to your vagrant MySQL database from the host machine.

Change Address Binding from MySQL

  • Connect to vagrant using vagrant ssh
  • Edit file /etc/mysql/my.cnf:
    • Change parameter bind-address to 0.0.0.0 to allow all incoming connection attempts
@thiennguyenenv
thiennguyenenv / curl.md
Created March 2, 2018 04:09 — 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.

<?php
error_reporting(E_ALL);
$charsets = array(
"ISO-8859-1" => "Western European, Latin-1. ",
"ISO-8859-5" => "Little used cyrillic charset (Latin/Cyrillic). ",
"ISO-8859-15" => "Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1). ",
"UTF-8" => "ASCII compatible multi-byte 8-bit Unicode. ",
"cp866" => "DOS-specific Cyrillic charset. ",
@thiennguyenenv
thiennguyenenv / git_branch
Created October 11, 2017 07:18 — forked from shivabhusal/git_branch
Add this snippet in Linux (Ubuntu)'s `~/.bashrc` to see your current git-branch in terminal prompt
# Author : Shiva Bhusal
# github: shivabhusal
# stackoverflow: users/3437900/illusionist
##########################################
# Usages:
# - create a file called ~/.promptrc
# - add following in ~/.bashrc
# `source ~/.promptrc`
# # this will include the source of the file
#!/bin/bash
# What it is: a script to compile and install Nginx manually in Ubuntu 14.04 server
# Author: Pothi Kalimuthu
# Author URL: http://pothi.info
# License: GPL v2
### VARIABLES ###
# Please know that this script should be executed as normal user with __sudo__ privileges.