Skip to content

Instantly share code, notes, and snippets.

View muhammadghazali's full-sized avatar

Muhammad Ghazali muhammadghazali

View GitHub Profile
GET /accounts

GET /accounts/_mapping

GET /accounts/_search
{
  "sort": [
    {
      "account_number": "asc"
@muhammadghazali
muhammadghazali / nginxproxy.md
Created August 22, 2018 11:14 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@muhammadghazali
muhammadghazali / install the go dep (the dependency management).md
Created July 16, 2018 04:12
install the go dep (the dependency management)
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5110  100  5110    0     0    762      0  0:00:06  0:00:06 --:--:--  1219
ARCH = amd64
OS = linux
Installation requires your GOBIN directory /home/xxx/go/bin to exist. Please create it.
import React, { Component } from "react";
class App extends Component {
constructor() {
super();
this.state = {
input1: ""
};
this.handleChange = this.handleChange.bind(this);
@muhammadghazali
muhammadghazali / setup-prettier-precommit-hook.sh
Last active June 25, 2018 15:37
Setup prettier pre-commit Hook. This bash script is suitable if you have a project without prettier integration and interested to add prettier into your current development workflow.
#!/usr/bin/env bash
npm i -D --save-exact prettier
npm i -D pretty-quick husky --save
# to manipulate the existing package.json file
npm i -g json
# add precommit to package.json scripts
json -I -f package.json -e 'this.scripts.precommit="pretty-quick --staged"'
# add prettier config file
touch .prettierrc
echo '{
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs build-essential gcc g++ make
# fixing npm permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
# use the NPM_CONFIG_PREFIX=~/.npm-global if you don't want to modify the .bashrc
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
Match - 2 instances
./components/A.js:1,36
import React, { Component } from 'react';
import { Link } from 'react-router';
import ExpandImage from '../containers/assets/icon_expand.svg';
import mapUS from '../containers/assets/map-us.svg';
import mapEurope from '../containers/assets/map-europe.svg';
import mapAsia from '../containers/assets/map-asia.svg';
@muhammadghazali
muhammadghazali / Error: there can only be one only test.log
Created October 20, 2017 00:39
tape will complain if there is two exclusive test in the entire process
Error: there can only be one only test
at Function.test.only (/my-node-app/node_modules/tape/index.js:140:25)
at Function.module.exports.lazyLoad.only (/my-node-app/node_modules/tape/index.js:26:34)
at Object.<anonymous> (/my-node-app/test/api-endpoints/submit-registration-token.test.js:47:6)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
@muhammadghazali
muhammadghazali / hello-world-module.js
Created September 13, 2017 16:03
This is a silly world hello module that can be used on the Node.js and browser environment. Credits to this blog post: https://caolan.org/posts/writing_for_node_and_the_browser.html
(exports => (exports.greet = () => "Hello world"))(
typeof exports === "undefined" ? (this["hello"] = {}) : exports
);
@muhammadghazali
muhammadghazali / the-correct-approach-to-handle-stripe-timestamp.js
Created March 20, 2017 05:35
Converting the Stripe epoch timestamp to ISO 8601
export function secondsToISOString(seconds) {
const date = new Date(seconds * 1000);
return date.toISOString();
}