Skip to content

Instantly share code, notes, and snippets.

View minhd's full-sized avatar

Minh Duc Nguyen minhd

  • Australian Research Data Common
  • Canberra
View GitHub Profile
@minhd
minhd / i++.java
Created October 21, 2019 00:42
Enterprise Java i++
void Main()
{
IIncrementorAbstractFactoryThatCreatesConcreteIncrementorFactoriesForIncrementing factoryFactory = new IncrementorAbstractFactory();
IIncrementorFactoryThatCreatesIIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects incrementorFactory = new IncrementorFactoryThatCreatesIncrementorsUsedForIncrementingThings();
IIncrementorThatIsUsedForIncrementingDifferentTypesOfObjects incrementor = incrementorFactory.CreateIncrementor(IncrementorTypeEnumThatRepresentsAnIncrementorTypeOfSomeSort.Integer);
IntegerIncrementorThatCanTakeAnIntegerAndIncrementItByOne intIncrementor = incrementor as IntegerIncrementorThatCanTakeAnIntegerAndIncrementItByOne;
object incrementedIntObj = intIncrementor.IncrementAnObjectTypeAndReturnAnObjectThatIsAnIncrementOfTheObjectTypePassedIn(5);
int incrementedInt = Convert.ToInt32(incrementedIntObj);
}
@minhd
minhd / ands
Last active May 23, 2019 00:13
Get size of mysql database
SELECT table_schema "DB Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
WHERE table_schema like 'dbs%'
GROUP BY table_schema;
@minhd
minhd / php.md
Last active July 20, 2018 00:16
Install PHP on MacOS Sierra

Use Homebrew/core instead of Homebrew/php

brew install php@5.6 --with-pear
brew install php@7.0 --with-pear
brew install php@7.1 --with-pear
brew install php@7.2 --with-pear

Also, you may have the need to tweak configuration settings of PHP to your needs. A common thing to change is the memory setting, or the date.timezone configuration. The php.ini files for each version of PHP are located in the following directories:

@minhd
minhd / quit.sh
Created July 16, 2018 05:13
Bash script quits if previous return code is not valid #bash
# run something
# rc is not 0, quit
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
# continue
@minhd
minhd / write.sh
Created July 16, 2018 05:12
Bash writes command to logs with date #bash
command.sh >> log_$(date +%Y-%m-%d_%H:%M).log
@minhd
minhd / default.sh
Created July 16, 2018 05:11
Bash script defaul variable #bash
if [[ -z "${DEPLOY_ENV}" ]]; then
MY_SCRIPT_VARIABLE="Some default value because DEPLOY_ENV is undefined"
else
MY_SCRIPT_VARIABLE="${DEPLOY_ENV}"
fi
# or using a short-hand version
[[ -z "${DEPLOY_ENV}" ]] && MyVar='default' || MyVar="${DEPLOY_ENV}"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Singleton<T> : MonoBehaviour where T : Component {
private static T instance;
public static T Instance {
get {
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bouncing : MonoBehaviour {
public float amplitude = 0.3f;
public float speed = 1f;
private float tempVal;
private Vector3 tempPos;
using UnityEngine;
using System.Collections;
public class CameraLook : MonoBehaviour {
float minFov;
float maxFov;
float sensitivity;
int boundary; // distance from edge scrolling starts
int speed;
@minhd
minhd / .htaccess
Created March 31, 2017 23:58
Hide .env file
# Disable index view
Options -Indexes
# Hide a specific file
<Files .env>
Order allow,deny
Deny from all
</Files>