Skip to content

Instantly share code, notes, and snippets.

@goliatone
goliatone / aggregate.js
Created May 31, 2018 18:12
Aggregate data from MongoDB with Node.js and mongoose
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//Database connection
var uristring = 'mongodb://localhost/test';
var mongoOptions = { };
mongoose.connect(uristring, mongoOptions, function (err, res) {
if (err) {
console.log('Error when connecting to: ' + uristring + '. ' + err);
@goliatone
goliatone / s3.sh
Created March 28, 2018 15:34 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@goliatone
goliatone / awc-ecs-access-to-aws-efs.md
Created March 19, 2018 22:05 — forked from duluca/awc-ecs-access-to-aws-efs.md
Step-by-step Instructions to Setup an AWS ECS Cluster

Configuring AWS ECS to have access to AWS EFS

If you would like to persist data from your ECS containers, i.e. hosting databases like MySQL or MongoDB with Docker, you need to ensure that you can mount the data directory of the database in the container to volume that's not going to dissappear when your container or worse yet, the EC2 instance that hosts your containers, is restarted or scaled up or down for any reason.

Don't know how to create your own AWS ECS Cluster? Go here!

New Cluster

Sadly the EC2 provisioning process doesn't allow you to configure EFS during the initial config. After your create your cluster, follow the guide below.

New Task Definition for Web App

If you're using an Alpine-based Node server like duluca/minimal-node-web-server follow this guide:

@goliatone
goliatone / RFID_EEPROM.ino
Created February 1, 2018 15:52 — forked from tuxmartin/RFID_EEPROM.ino
Arduino Mifare 13.56 MHz MFRC522 reader
/*
* Dump block 0 of a MIFARE RFID card using a RFID-RC522 reader
* Uses MFRC522 - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
-----------------------------------------------------------------------------
* Pin layout should be as follows:
* Signal Pin Pin Pin
* Arduino Uno Arduino Mega MFRC522 board
* ------------------------------------------------------------
* Reset 9 5 RST
* SPI SS 10 53 SDA
@goliatone
goliatone / taskfile.template
Last active April 18, 2025 03:06
Taskfile template
#!/bin/bash
# Check for -debug flag
if [[ $* == *-debug* ]]; then
set -x
fi
export LGR_NO_TIMESTAMP=true
VERSION_FILE="./.version"
@goliatone
goliatone / lambda.md
Created November 24, 2017 22:07 — forked from KyleAMathews/lambda.md
Using Kafka and a Samza-like node.js architecture

Disclaimer

I'm still very new to Kafka, eventsourcing, stream processing, etc. I'm in the middle of building my first production system with this stuff and am writing this at the request of a few folks on Twitter. So if you do have experience, please do me and anyone else reading this a favor by pointing out things I get wrong :)

Inspirations

@goliatone
goliatone / Makefile
Created November 7, 2017 02:08 — forked from itamarhaber/Makefile
Module development environment walkthrough
SHOBJ_CFLAGS ?= -fno-common -g -ggdb
SHOBJ_LDFLAGS ?= -shared -Bsymbolic
CFLAGS = -Wall -g -fPIC -lc -lm -Og -std=gnu99
CC=gcc
all: example.so
example.so: example.o
$(LD) -o $@ example.o $(SHOBJ_LDFLAGS) $(LIBS) -lc
@goliatone
goliatone / .gitignore
Created October 21, 2017 22:34 — forked from itamarhaber/.gitignore
Cron-like Redis module
*.xo
*.so
*.o
@goliatone
goliatone / module.md
Created October 15, 2017 19:12 — forked from dvirsky/module.md

Creating a redis Module in 15 lines of code!

A quick guide to write a very very simple "ECHO" style module to redis and load it. It's not really useful of course, but the idea is to illustrate how little boilerplate it takes.

Step 1: open your favorite editor and write/paste the following code in a file called module.c

#include "redismodule.h"
/* ECHO <string> - Echo back a string sent from the client */
int EchoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
@goliatone
goliatone / README.md
Last active October 13, 2017 13:17 — forked from auremoser/README.md
Chart: Chart.js + CartoDB