Skip to content

Instantly share code, notes, and snippets.

@davepoon
davepoon / Instructions.sh
Created June 3, 2018 02:44 — forked from GhazanfarMir/Instructions.sh
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
@davepoon
davepoon / async-await.js
Created February 15, 2018 00:32 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@davepoon
davepoon / promiseAll.js
Created October 4, 2017 22:23
Promise resolves after all the fetching is done
const fetchAllTheRepos = (userName, repoCount) => {
const MAX_PER_PAGE = 100;
const baseUrl = 'https://api.github.com/users/' + userName +
'/repos?per_page=' + MAX_PER_PAGE;
//Start fetching every page of repos.
const fetchPromises = [], pageCount = Math.ceil(repoCount /
MAX_PER_PAGE);
for (let pageI = 1; pageI <= pageCount; ++pageI) {
const fetchPagePromise = fetch(baseUrl + '&page=' + pageI);
@davepoon
davepoon / docker-compose.yml
Created July 17, 2017 13:03
loopback and mysql docker-compose.yml
# The standard now
version: '2'
# All of the images/containers compose will deal with
services:
# our strongloop service shall be known as 'api'
api:
# use your user name
image: davepoon/strongloop-dev
@davepoon
davepoon / Dockerfile
Created July 17, 2017 13:01
loopback, yarn, nodejs and nodemon Dockerfile
From node:8.1.4
# Yarn please
RUN curl -o- -L https://yarnpkg.com/install.sh | bash
ENV PATH="/root/.yarn/bin:${PATH}"
# Installs these globally WITHIN the container, not our local machine
RUN yarn && yarn global add loopback-cli && yarn global add nodemon
@davepoon
davepoon / React Redux Container Component.js
Created July 16, 2017 12:55
React Redux Container Component webstorm template
import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
class $NAME extends Component {
constructor(props, context) {
super(props, context);
}
render() {
@davepoon
davepoon / React Stateless Component.js
Created July 16, 2017 12:55
React Stateless Component webstorm template
import React, { PropTypes } from 'react';
const $NAME = (props) => {
return (
);
}
$NAME .propTypes = {
@davepoon
davepoon / React Class Component.js
Created July 16, 2017 12:54
React Class Component webstorm template
import React, { PropTypes, Component } from 'react';
class $NAME extends Component {
constructor(props) {
super(props);
}
render() {
return (
@davepoon
davepoon / docker helper function
Created February 26, 2017 03:20
docker helper function
To clear containers:
docker rm -f $(docker ps -a -q)
To clear images:
docker rmi -f $(docker images -a -q)
To clear volumes:
docker volume rm $(docker volume ls -q)
To clear networks:
@davepoon
davepoon / install_node
Created August 16, 2016 13:53
Install Latest Nodejs on Amazon Linux/CentOS
yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
yum install nodejs