Skip to content

Instantly share code, notes, and snippets.

Muhammad Ghazali muhammadghazali

Block or report user

Report or block muhammadghazali

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View practical-intro-to-elasticsearch.md
GET /accounts

GET /accounts/_mapping

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

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 Jul 16, 2018
install the go dep (the dependency management)
View install the go dep (the dependency management).md
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.
View App-1.js
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 Jun 25, 2018
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.
View setup-prettier-precommit-hook.sh
#!/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 '{
View setup-node.sh
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
View jsinspect-report.log
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 Oct 20, 2017
tape will complain if there is two exclusive test in the entire process
View Error: there can only be one only test.log
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 Sep 13, 2017
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
View hello-world-module.js
(exports => (exports.greet = () => "Hello world"))(
typeof exports === "undefined" ? (this["hello"] = {}) : exports
);
@muhammadghazali
muhammadghazali / the-correct-approach-to-handle-stripe-timestamp.js
Created Mar 20, 2017
Converting the Stripe epoch timestamp to ISO 8601
View the-correct-approach-to-handle-stripe-timestamp.js
export function secondsToISOString(seconds) {
const date = new Date(seconds * 1000);
return date.toISOString();
}
You can’t perform that action at this time.