Skip to content

Instantly share code, notes, and snippets.

View cjus's full-sized avatar

Carlos Justiniano cjus

View GitHub Profile
@cjus
cjus / moose-cli-notes.md
Last active February 20, 2024 17:53
Moose CLI code notes
View moose-cli-notes.md
@cjus
cjus / solution.py
Last active December 31, 2023 18:23
Code test solution
View solution.py
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
cjus / shutdown.sh
Created August 28, 2020 13:47
Hydra service - simple shutdown
View shutdown.sh
docker stop hydra-router
docker stop redis
@cjus
cjus / startup.sh
Created August 28, 2020 12:59
Hydra service - simple startup
View startup.sh
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
cjus / alights.ino
Created June 5, 2019 13:44
Hacking Alzheimers using Light Therapy
View alights.ino
// Project on Github: https://github.com/cjus/brainlights
#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
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;
this.redisKey;
}
@cjus
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);
return;
}
// message processing code lines deleted here...
@cjus
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: {
jobID,
status,
statusMessage
}
@cjus
cjus / stackdn.sh
Created July 20, 2018 14:05
stackdn.sh
View stackdn.sh
#!/bin/sh
export STACK_NAME='test'
docker stack rm ${STACK_NAME}
@cjus
cjus / stackup.sh
Created July 20, 2018 14:04
stackup.sh
View stackup.sh
#!/bin/sh
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}