Skip to content

Instantly share code, notes, and snippets.

View rnkoaa's full-sized avatar

Richard Agyei rnkoaa

View GitHub Profile
@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 / app.js
Created January 9, 2014 13:14
A simple angularjs with angular-ui modal form which includes validation on the client side. Thanks http://scotch.io/tutorials/javascript/angularjs-form-validation
var app = angular.module("modalFormApp", ['ui.bootstrap']);
app.controller("modalAccountFormController", ['$scope', '$modal', '$log',
function ($scope, $modal, $log) {
$scope.showForm = function () {
$scope.message = "Show Form Button Clicked";
console.log($scope.message);
var modalInstance = $modal.open({
@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
	    },

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 / 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 / FlowableUtils.java
Created January 11, 2017 18:12
Convert a listenable future to an rxjava-2 flowable or single
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import io.reactivex.*;
/**
* Created on 1/11/2017.
*/
public class FlowableUtils {
@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}"/>