Skip to content

Instantly share code, notes, and snippets.

View rnkoaa's full-sized avatar

Richard Agyei rnkoaa

View GitHub Profile

How to set up a system system using Redis as a pub/sub queue to push data between a node.js application and a java application running on the same system.

To Configure this, we will need jedis, a java driver for jedis and node-redis a node driver.

  1. create a new node project
  2. Install the node driver using npm install node_redis
  3. Create the node app file with the following contents.

Node.js app.js

Uploading Files using NodeJS and Angular Js The files will be uploaded to public/img folder. we can then run image processing on the file to convert it to several formats we want.

//Node.js app.js
/**
 * Module dependencies.
 */
var express = require('express');
var routes = require('./routes');
@rnkoaa
rnkoaa / .gitignore
Created October 27, 2013 20:13
a gitignore for android build using intellij and eclipse
# intellij files
*.iml
*.idea/
# gradle build folder
.gradle/
# application files
*.apk
*.ap_
@rnkoaa
rnkoaa / Logger.java
Created November 17, 2013 17:36
A logging facade which is helpful in debugging android applications. Anytime a log is called, it displays the class name as well as the method name and line number. this can help immensely when debug failures in our application
import android.util.Log;
/**
* @Author: Richard Amoako-Agyei
* @Date: 11/17/2013
*/
public class Logger {
private static Logger instance = null;
private final Class<?> clzz;
private static final String TAG = ""; //Add the Tag for easy filtering.
@rnkoaa
rnkoaa / xmlbase.groovy
Created November 18, 2013 17:01
A simple example of creating xml in groovy using streaming markup builder.
StreamingMarkupBuilder builder = new StreamingMarkupBuilder()
builder.encoding = 'UTF-8'
String filterSoapMessage = builder.bind {
mkp.xmlDeclaration()
'root'(){
}
}
filterSoapMessage.toString()
@rnkoaa
rnkoaa / node_environment_variables.md
Last active January 3, 2016 05:39
A process in which we can run node apps with different environment settings which are declared in a different file. This helps in scalability and deployment.

How to run node in an environment aware setting.

  1. Create a config folder /config
  2. Create an /config/env.json in the config folder which will hold the environmental properties for each environment. example
	{
	    "development": {
	        "port": 3000
	    },
@rnkoaa
rnkoaa / jenkins-2_0-Dockerfile
Created June 4, 2016 09:18
A dockerfile based on jenkins 2.0 with ant and gradle already installed to ease in building applications.
FROM jenkinsci/jenkins:2.7
MAINTAINER Richard Agyei <richard.agyei@tr.com>
# Hard coding these environment variables, probably a good idea to pass them through.
ENV ANT_VERSION 1.9.7
ENV GRADLE_VERSION 2.13
USER root
#RUN apt-get update && apt-get install -y ant
@rnkoaa
rnkoaa / logback.xml
Last active February 2, 2017 22:57
A Custom Simple logback file to use in Spring boot to generate logs to custom locations. Just drop this into the classpath, preferably the resources folder. When running, make sure to include these variables from the environment: ```-DAPPLICATION_NAME=... -DAPP_LOG_DIR=... -DAPP_LOG_FILE_NAME=...```
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<property name="APPLICATION_NAME" value="${APPLICATION_NAME}"/>
<property name="APP_LOG_DIR" value="${APP_LOG_DIR}" />
<property name="APP_LOG_FILE_NAME" value="${APP_LOG_FILE_NAME}" />
<property name="MAX_FILE_SIZE" value="10MB"/>
<property name="MAX_DAYS_TO_KEEP" value="30" />
<property name="APP_LOG_FILE"
value="${APP_LOG_DIR}/${APP_LOG_FILE_NAME}.log}"/>
.PHONY: generate-ssh vagrant-stretch base clean-playbooks
ENV_PROFILE ?= dev
TARGET_HOST ?= dev
NODE_PORT := $(shell vagrant port stretch --guest 22)
PRIVATE_KEY := .vagrant/machines/stretch/virtualbox/private_key
PLAYBOOKS := playbooks
ENV_FILE=.env
ENV_VARS=`cat $(ENV_FILE)`
INVENTORY := environments/${ENV_PROFILE}/hosts
# either environment variables or kubestorage
inside the container:
ip route show | awk '/default/ {print $3}'
route | awk '/^default/ { print $2 }'
This gives the default docker0 bride to the host and can be used to communicate to the host
route | awk '/^default/ { print $2 }'
vagrant ubuntu stretch (with network ip) get ip address on eth1
ip addr show eth1 | grep "inet " | cut -d: -f2 | awk '{print $2}'