Skip to content

Instantly share code, notes, and snippets.

View maishsk's full-sized avatar

Maish Saidel-Keesing maishsk

View GitHub Profile
const express = require('express')
mysql = require('mysql')
const app = express()
const port = 3000
let winston = require('winston');
let logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.printf(info => {
@maishsk
maishsk / gist:88303dc3b1b0feb960b0c86aa8696399
Created January 10, 2019 20:59
server retrieve value from database
const express = require('express')
mysql = require('mysql')
const app = express()
const port = 3000
let winston = require('winston');
let logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.printf(info => {
CREATE DATABASE maishsk;
USE maishsk;
CREATE TABLE mytable ( id smallint unsigned not null auto_increment, name varchar(20) not null, constraint pk_example primary key (id) );
INSERT INTO mytable ( id, name ) VALUES ( null, 'Hello World' );
@maishsk
maishsk / gist:922835b06d848c4afe7be69762e8ee0b
Created January 8, 2019 15:46
server with logging to file
const express = require('express')
const app = express()
const port = 3000
let winston = require('winston');
let logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.printf(info => {
return `${info.timestamp} ${info.level}: ${info.message}`;
const express = require('express')
const app = express()
const port = 3000
app.get('/hello', (request, response) => {
response.send('Hello from Express!')
})
app.listen(port, (err) => {
if (err) {
@maishsk
maishsk / pink_lemonade
Created January 8, 2019 14:26
simple loop
for number in {1..100}
do
if (( $number % 15 == 0 )); then
echo "pinklemonade"
elif (( $number % 5 == 0 )); then
echo "lemonade"
elif (( $number % 3 == 0 )); then
echo "pink"
else
@maishsk
maishsk / gist:4ea0a0d7772056ab59cc91855ac3b6d0
Created December 24, 2018 20:58
Get changed files in the last commit.
changed_files=$(git diff --numstat HEAD~1 HEAD | awk '{ print $NF }')
---
- name: Launch haproxy EC2 instances
hosts: localhost
connection: local
gather_facts: True
vars:
component_name: "{{ component_name }}"
stack_name: "{{ stack_name }}"
vars_files:
- vars/vars.yml
@maishsk
maishsk / endpoints
Created August 20, 2018 14:45
List of all endpoint URLS in AWS console
a4b
acm
amazon-mq
apigateway
appstream2
appsync
artifact
athena
awsautoscaling
batch
@maishsk
maishsk / update_route53_record.sh
Created August 15, 2018 14:04
Update Route53 record from within an instance
#!/bin/bash
## Create a IAM policy as follows and attach it to your instance
#
# {
# "Version": "2012-10-17",
# "Statement": [
# {
# "Sid": "UpdateRecords",
# "Effect": "Allow",