Skip to content

Instantly share code, notes, and snippets.

View joeywhelan's full-sized avatar

Joey Whelan joeywhelan

View GitHub Profile
@joeywhelan
joeywhelan / TimeStamper
Last active January 1, 2016 22:59
Custom Timestamp function along with how to call it out of winston.
var timeStamper = function()
{
var date = new Date();
var sec = date.getSeconds();
if (sec < 10)
sec = '0' + sec;
var min = date.getMinutes();
if (min < 10)
min = '0' + min;
@joeywhelan
joeywhelan / cryptdemo.js
Last active June 9, 2017 08:31
Node.js Crypto Module Examples
/**
* Joey Whelan
* 3 examples on usage of the node crypto module
*/
var crypto = require('crypto');
var plainText = '1234567812345678';
try
{
@joeywhelan
joeywhelan / authdemo.js
Created April 17, 2014 00:22
Password Storage with MongoDB and Node
var crypto = require('crypto');
var mongodb = require('mongodb');
var Binary = require('mongodb').Binary;
var userColl = undefined;
var saltLengthBytes = 64;
var hashIterations = 10000;
var keyLengthBytes = 64;
function authenticateUser(id, password, callback)
/*jshint esversion: 6 */
'use strict';
'use esversion 6';
const MongoClient = require('mongodb').MongoClient;
const CONNECTION_URL = 'mongodb://admin:mongo@localhost:27017';
const DB_NAME = 'testDB';
const COLLECTION = 'testCollection';
@joeywhelan
joeywhelan / funcExamples.js
Created December 11, 2021 21:59
Javascript Function Argument Options and Object Conditionals
/**
* @fileoverview Various function argument and object constructor examples
* @author Joey Whelan
*/
//base example
function example1(p1,p2,p3) {
console.log('example1');
const params = {
@joeywhelan
joeywhelan / conntest.c
Created October 17, 2024 15:04
Connectivity Test Loop with Hiredis
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hiredis/hiredis.h>
#include <stdbool.h>
#include <unistd.h>
int main (int argc, char **argv) {
redisReply *reply;
redisContext *c;
@joeywhelan
joeywhelan / kind.sh
Created December 31, 2024 16:26
Kind Deployment
echo -e "\n*** Deploy Cloud Provider Kind ***"
docker run -d --rm --name cloud-provider-kind --network kind \
-v /var/run/docker.sock:/var/run/docker.sock registry.k8s.io/cloud-provider-kind/cloud-controller-manager:v0.4.0
echo -e "\n*** Deploy Kind Cluster ***"
kind create cluster --config=$PWD/kind/config.yaml --name demo-kind-cluster
if [ -z "$(docker image ls -q ms1:1.0)" ]
then
echo -e "\n*** Build Microservice 1 Container ***"
@joeywhelan
joeywhelan / gloo.sh
Created December 31, 2024 16:28
Gloo Gateway Deployment
echo -e "\n*** Deploy Gloo Gateway ***"
./glooctl install gateway
echo -e "\n*** Create Routes to Microservices ***"
./glooctl add route --name vs1 --path-exact /ms1 --dest-name default-ms1-service-8000 --prefix-rewrite /service1
./glooctl add route --name vs1 --path-exact /ms2 --dest-name default-ms2-service-9000 --prefix-rewrite /service2
@joeywhelan
joeywhelan / micro.sh
Created December 31, 2024 16:31
Deploy Microservices
echo -e "\n*** Deploy Microservices ***"
kubectl apply -f $PWD/ms1/ms1.yaml
kubectl apply -f $PWD/ms2/ms2.yaml
kubectl rollout status deployment/ms1-app
kubectl rollout status deployment/ms2-app
re1:
image: redislabs/redis:latest
container_name: re1
restart: unless-stopped
tty: true
cap_add:
- sys_resource
ports:
- 12000:12000
- 8443:8443