Skip to content

Instantly share code, notes, and snippets.

View arvind-india's full-sized avatar

Arvind Singh arvind-india

  • Bangalore
View GitHub Profile
@arvind-india
arvind-india / node-red-sensortag.js
Created April 12, 2017 12:44 — forked from LosantGists/node-red-sensortag.js
Node-RED function node to combine SensorTag messages into single payload.
// This function node combines all of the async values
// reported by the sensor tag node into a single
// payload. The flow will only continue when all values
// have been received.
var payload = context.get('payload') || { data: {} };
// Number of total attributes to report.
// When we collect all attributes from the
// sensor tag, the flow will continue.
@arvind-india
arvind-india / cc2650.py
Created August 3, 2017 13:15 — forked from jpmens/cc2650.py
CC2650 read via BLE and publish to MQTT
#!/usr/bin/env python
# read CC2650 SensorTag by JP Mens
# follow https://smidgeonpigeon.wordpress.com/2015/07/21/raspberry-pi-2-ble-ti-sensor-tag/
# to get started, but use Sensortag2650.py
import time
import json
import struct
import Sensortag2650 as sensortag
import paho.mqtt.publish as mqtt
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@arvind-india
arvind-india / gist:7513b931ac27ceef9d646b93942224d7
Created August 10, 2017 21:37 — forked from carmark/gist:4aa32cacd4d041448c39ad8deb87135f
A sample Docker workflow with Nginx, Node.js and Redis

For this example, I have a very simple Node.js applications that increments a counter stored on Redis. I want to run Redis and the node application independently as I want to have the ability to scale the node application depending on the load. To start off, I have 3 instances of the node server running the application. I have an Nginx server in front of node for load balancing the node instances.

Let’s now talk in terms of containers, specifically Docker containers. Simple; 1 container for each service/process!

  • 1 Redis container
  • 3 Node containers
  • 1 Nginx container So, the overall picture looks something like this:

@arvind-india
arvind-india / docker-cleanup-resources.md
Created August 10, 2017 22:18 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@arvind-india
arvind-india / docker_utility.sh
Created August 18, 2017 14:05 — forked from anubhavsinha/docker_utility.sh
Some utility command to clean up docker dirt
# cleans all images
docker images | awk '{print $3}' | xargs docker rmi
# cleans all stopped containers
docker rm $(docker ps -q -f status=exited)
@arvind-india
arvind-india / csv-to-mysql.py
Created August 18, 2017 14:06 — forked from radaniba/csv-to-mysql.py
Python CSV to MySQL
#!/usr/bin/env python
# Run with no args for usage instructions
#
# Notes:
# - will probably insert duplicate records if you load the same file twice
# - assumes that the number of fields in the header row is the same
# as the number of columns in the rest of the file and in the database
# - assumes the column order is the same in the file and in the database
#
@arvind-india
arvind-india / excel2mysql.py
Created September 7, 2017 06:46 — forked from anubhavsinha/excel2mysql.py
simple excel to mysql in python
# following Python packages needs to be installed
# xlrd, xlsxrd, unidecode, MySQLdb
import xlrd
import xlsxrd
import MySQLdb as mdb
import re
import unidecode
import csv
import MySQLdb
# open the connection to the MySQL server.
# using MySQLdb
mydb = MySQLdb.connect(host='igor.gold.ac.uk', user='co304so', passwd='*********', db='co304so_LondonCrime')
cursor = mydb.cursor()
csv_data = csv.reader(file('1.csv'))
# execute and insert the csv into the database.
for row in csv_data:
cursor.execute('INSERT INTO AprilNov2013(Date,Westminster,HACKNEY,Tower_Hamlets)''VALUES(%s, %s, %s, %s)',row)
@arvind-india
arvind-india / Dockerfile
Created September 18, 2017 13:30 — forked from dceejay/Dockerfile
Dockerfile for Node-RED
# Dockerfile for Node-RED - pulls latest master code from git
# Use the node.js v4 LTS engine
FROM node:4-slim
MAINTAINER ceejay
RUN mkdir -p /root/.node-red
WORKDIR /root/.node-red
# download latest stable node-red
RUN npm install -g --unsafe-perm node-red