Skip to content

Instantly share code, notes, and snippets.

@goliatone
goliatone / README.md
Last active July 5, 2021 21:01
[RPi Utilities] #rpi

RPi Utilities

Get mac addresses:

ifconfig -a | grep HWaddr | tr -s " " | cut -d' ' -f5

Output:

b8:27:eb:34:53:7e //eth0
@goliatone
goliatone / nodejs-rfid.js
Created September 22, 2016 15:12 — forked from basham/nodejs-rfid.js
Use NodeJS to read RFID ids through the USB serial stream.
/*
DESCRIPTION
-----------
Use NodeJS to read RFID ids through the USB serial stream. Code derived from this forum:
http://groups.google.com/group/nodejs/browse_thread/thread/e2b071b6a70a6eb1/086ec7fcb5036699
CODE REPOSITORY
---------------
https://gist.github.com/806605
@goliatone
goliatone / ngrok-selfhosting-setup.md
Created September 9, 2016 18:54 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@goliatone
goliatone / bean_reader.py
Created August 4, 2016 21:54 — forked from jsiverskog/bean_reader.py
Python snippet to read data from Lightblue Bean scratch characteristics
from __future__ import print_function
import dbus
import sys
import dbus.service
import dbus.mainloop.glib
import gobject as gobject
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
@goliatone
goliatone / flynn-mongodb.txt
Created August 4, 2016 20:30 — forked from lmars/flynn-mongodb.txt
Flynn MongoDB
# create a mongo app
flynn create --remote "" mongo
# create a release using the latest (at the time of writing) Docker MongoDB image
flynn -a mongo release add -f config.json "https://registry.hub.docker.com?name=mongo&id=216d9a0e82646f77b31b78eeb0e26db5500930bbd6085d5d5c3844ec27c0ca50"
# scale the server to one process. This may time out initially as the server pulls the image, but watch "flynn -a mongo ps" and it should come up.
flynn -a mongo scale server=1
# mongo should now be running in the cluster at mongo.discoverd:27017
@goliatone
goliatone / article.md
Created August 4, 2016 14:07 — forked from zubairov/article.md
Running a docker private registry on EC2

tl;dr This blog post describes the best way to host private Docker Registry instance on Amazon EC2 and Amazon S3. You can skip the lyrics and go to the 'Resources' section to get the ECS Task Definition JSON.

When working with microservices nowadays you can hardly avoid using Docker. After building your first Docker container your next step woudl be to share it with the world (or your colleauge). To achieve it you have three alternatives:

  1. Use a Docker Hub or any other SaaS registry.
  2. Deploy your own instance of open source Docker Registry project (now called 'Distribution').
  3. Buy an enterprise version of the Docker registry which is based on open source docker registry project with some addons from Docker Inc.

For a small project the Docker Hub 'way' is the best alternative, you can host one 'private' image for free, where commercial pricing plans will allow you to upload more. For a more serious projects we would like to re

@goliatone
goliatone / bootstrapping-example-using-rttc-compile-and-sails.md
Created July 17, 2016 03:00 — forked from mikermcneil/bootstrapping-example-using-rttc-compile-and-sails.md
An example of bootstrapping dynamic data onto the page, and then exposing it for programmatic access with `rttc.compile()`. This makes it possible to expose our view locals in our client-side js for access in the browser. This example uses Sails.js, but is equally applicable for Hapi or Express.

Bootstrapping dynamic data onto the page with rttc.compile()

An example of bootstrapping dynamic data onto the page, and then exposing it for programmatic access with rttc.compile(). This makes it possible to expose our view locals in our client-side js for access in the browser. This example uses Sails.js, but is equally applicable for Hapi or Express.

UPDATE: Check out balderdashy/sails#3522 and https://github.com/mikermcneil/expose-locals-to-browser-xss-test-app


Let's assume you are building a website about vampires.

@goliatone
goliatone / background-job-example.js
Created July 17, 2016 02:54 — forked from mikermcneil/background-job-example.js
example of a background job
/**
* Module dependencies
*/
var SailsApp = require('sails').Sails;
// e.g. `jobs/clean-up-orphaned-images`
var sails = new SailsApp();
sails.load({ hooks: {grunt: false} }, function afterwards(err) {
if (err) {
@goliatone
goliatone / redis-backup.sh
Created July 12, 2016 17:50 — forked from acenqiu/redis-backup.sh
redis rdb backup script
#!/bin/bash
#
## redis backup script
## usage
## redis-backup.sh port backup.dir
port=${1:-6379}
backup_dir=${2:-"/data/backup/redis"}
cli="/usr/local/bin/redis-cli -p $port"
@goliatone
goliatone / redis_sentinel.sh
Created July 11, 2016 21:10 — forked from jedi4ever/redis_sentinel.sh
Redis - Redis Sentinel - Docker
#!/bin/bash
DOCKER_IP=$(ip addr show docker0|grep "inet "|sed -e 's/^[ ]*//g'| cut -d ' ' -f 2| cut -d '/' -f 1)
docker stop redis_0
docker stop redis_1
docker stop sentinel_0
docker stop sentinel_1
docker stop sentinel_2