Skip to content

Instantly share code, notes, and snippets.

View shams-ali's full-sized avatar

Shams Ali shams-ali

  • San Francisco, CA
View GitHub Profile
@shams-ali
shams-ali / initialize-postgress.sh
Created June 25, 2016 04:16
initialize postgres db
postgres -D /usr/local/var/postgres
@shams-ali
shams-ali / docker-compose-wait-for-db.sh
Last active November 1, 2022 19:03 — forked from mvargeson/docker-compose-wait-for-db.sh
wait for db container to be available before starting server
#!/bin/bash THIS WORKED
bash -c 'while ! </dev/tcp/db/5432; do sleep 1; done; nodal db:bootstrap && nodal s;'
#THIS WORKS ONLY IF NETSTST INSTALLED
while ! nc -w 1 -z db 5432; do sleep 0.1; done
#ANOTHER WAY
until nc -z postgres 5432; do
echo "$(date) - waiting for postgres..."
@shams-ali
shams-ali / sqsSendToQueue.js
Created June 25, 2016 04:20
sqs send to queue
sqs.createQueue({QueueName: 'gmail-channel-webhooks'}, function (err, data) {
if (err) return console.log(err);
var url = data.QueueUrl; // use this queue URL to operate on the queue
// Sending a message
// The following example sends a message to the queue created in the previous example.
var queue = new AWS.SQS({params: {QueueUrl: url}});
var body = JSON.stringify({ email: '[email protected]', 'historyId': '127f90a30t' });
queue.sendMessage({ MessageBody: body }, function (err, data) {
@shams-ali
shams-ali / expressProxy.js
Created June 25, 2016 04:21
Express Proxy Server
var app = require('express')();
var requestProxy = require('express-request-proxy');
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.post('/api/webhooks/:channel', requestProxy({
url: 'http://google.mvargeson.ultrahook.com/api/webhooks/:channel'
}));
@shams-ali
shams-ali / webpack.config.js
Created June 25, 2016 04:23
webpack config es6
odule.exports = {
entry: './client.js',
output: {
filename: 'bundle.js'
},
devtool: 'source-map',
module: {
loaders: [
{
test: /.jsx?$/,
@shams-ali
shams-ali / package.json
Created June 25, 2016 04:24
package.json react-redux es6
{
"name": "react-redux",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack",
"start": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --watch"
@shams-ali
shams-ali / Dockerfile
Created June 25, 2016 04:26
Node Dockerfile
FROM node
RUN mkdir -p /usr/src/your-app-name
WORKDIR /usr/src/your-app-name
COPY package.json /usr/src/your-app-name/
RUN npm install
COPY . /usr/src/your-app-name
EXPOSE 3000
CMD [ "npm", "start" ]
@shams-ali
shams-ali / expressserver.js
Created June 25, 2016 04:31
express server
'use strict';
const express = require('express');
// Constants
const PORT = 8080;
// App
const app = express();
app.get('/', function (req, res) {
@shams-ali
shams-ali / docker-commads.sh
Last active December 27, 2016 06:46
Docker Commands
#Go to the directory that has your Dockerfile and run the following command to build the Docker image
$ docker build -t <your username>/node-web-app .
#to run image and redirect port
$ docker run -p 49160:8080 -d <your username>/node-web-app
# see running containers
$ docker ps
# Print app output
@shams-ali
shams-ali / aws-docker-machine-create.sh
Last active June 25, 2016 04:55
AWS Docker Create
#If you specified your keys in a credentials file, this command looks like this to create an instance called aws-sandbox:
$ docker-machine create --driver amazonec2 aws-sandbox
#no crednetials file
$ docker-machine create --driver amazonec2 --amazonec2-access-key AKI******* --amazonec2-secret-key 8T93C******* aws-sandbox
# specify a region...default is automaticaally set to us-east-1
$ docker-machine create --driver amazonec2 --amazonec2-region us-west-1 aws-01
#make sure new machine is active host