Skip to content

Instantly share code, notes, and snippets.

View cjus's full-sized avatar

Carlos Justiniano cjus

View GitHub Profile
cjus /
Last active February 20, 2024 17:53
Moose CLI code notes
cjus /
Last active December 31, 2023 18:23
Code test solution
import sys
import time
Solution Notes:
- The code shown here is larger than necessary. I think it's easier to discuss the code solution before it's optimized.
- There are also number of helper functions / features which I could have delete.
- One of my early design decisions was to go with immutable states. That allows me to playback moves as I spent time learning the rules of the game.
- This also proved to be an important decision when it came to my own testing and validation.
- Since I chose to use immutable states I also decided to go with a State Space Search Tree.
cjus /
Created August 28, 2020 13:47
Hydra service - simple shutdown
docker stop hydra-router
docker stop redis
cjus /
Created August 28, 2020 12:59
Hydra service - simple startup
HOSTIP=`echo "show State:/Network/Global/IPv4" | scutil | grep PrimaryInterface | awk '{print $3}' | xargs ifconfig | grep inet | grep -v inet6 | awk '{print $2}'`
echo "Host IP: ${HOSTIP}"
docker run -d -p 6379:6379 --rm --name redis redis:6.0.6
sleep 5
docker run -d -p 5353:5353 --add-host host:${HOSTIP} --rm --name hydra-router pnxtech/hydra-router:1.7.0
cjus / alights.ino
Created June 5, 2019 13:44
Hacking Alzheimers using Light Therapy
View alights.ino
// Project on Github:
#include <Arduino.h>
#include <string.h>
#include <math.h>
#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#define DEBUG
#define LEDPIN 4
#define BUTTONPIN 3
cjus / jobqueue.js
Created August 3, 2018 15:16
Sample job queue code
View jobqueue.js
const redis = require('redis');
const moment = require('moment');
class JobQueue {
constructor() {
this.config = null;
this.redisdb = null;
cjus / message.js
Created July 25, 2018 00:30
Message processing snipit
View message.js
async checkForTasks(callback) {
let message;
try {
message = await this.hydra.getQueuedMessage(this.serviceName);
} catch (e) {
this.logger('fatal', e);
// message processing code lines deleted here...
cjus / segment-transfer.js
Created July 24, 2018 23:54
Job queuing example
View segment-transfer.js
async queueAggregatorJob(jobID, status, statusMessage) {
return hydra.queueMessage(hydra.createUMFMessage({
to: 'aggregator-svcs:/',
frm: 'segment-transfer-svcs',
typ: 'process',
bdy: {
cjus /
Created July 20, 2018 14:05
export STACK_NAME='test'
docker stack rm ${STACK_NAME}
cjus /
Created July 20, 2018 14:04
export STACK_NAME='test'
mkdir -p ~/data/${STACK_NAME}/redis
echo "\nStarting core services"
sudo STACK_NAME=${STACK_NAME} docker stack deploy --compose-file compose.yml ${STACK_NAME}