Skip to content

Instantly share code, notes, and snippets.

View navneetkumar's full-sized avatar

Navneet Kumar navneetkumar

View GitHub Profile
@navneetkumar
navneetkumar / lambda-cf-execute.sh
Created December 5, 2016 18:36
Lambda CF execute
sed -i -e 's/<ACCOUNTID>/1234/g' aws-provision-cf.json
sed -i -e 's/<BUCKETNAME>/nexus-test/g' aws-provision-cf.json
sed -i -e 's/<REGION>/us-east-1/g' deployment/aws-provision-cf.json
aws --profile admin cloudformation create-stack --stack-name polarisInfra --template-body file:///aws-provision-cf.json --capabilities CAPABILITY_NAMED_IAM
@navneetkumar
navneetkumar / aws-provision-cf.json
Created December 5, 2016 18:30
Lambda Infra Cloud Formation
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Stack to create Infra resources for polaris",
"Parameters": {
"BucketName": {
"Description": "Deployment S3 Bucket is where project is deployed after mvn deploy command.",
"Type": "String",
"MinLength": "3",
"MaxLength": "63",
"Default": "<BUCKETNAME>"
@navneetkumar
navneetkumar / Handler.java
Last active December 5, 2016 12:06
Lambda-Handler
public class Handler implements RequestStreamHandler {
static final Logger logger = Logger.getLogger(Handler.class);
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
throws IOException {
try {
Properties props = new Properties();
props.load(Thread.currentThread().getContextClassLoader().getResource("lambda.properties").openStream());
String runnableClass = props.getProperty("deployment.lambdaRunnabe");
alert("Executing from script");
alert("updating script");
alert("new");
ok
@navneetkumar
navneetkumar / code_optimization.js
Created September 14, 2013 13:11
Code optimizaton
//Use underscore library(http://underscorejs.org) for sample codes below
//Memoize a long running function
var optimized_function = _.memoize(function(n) {
//Code for a long running task
});
//Function throttling to avoid multiple execution
var wait_time = 100 //in ms
var throttled_function = _.throttle(updatePosition, wait_time);
@navneetkumar
navneetkumar / cache_manager.js
Created September 14, 2013 12:49
A sample client side cache implementation using local-storage
app = {}
app.cacheManager = function() {
var self = {};
var namedSpacedKey = function(key) {
if(app.release.version && app.release.version != "") return app.release.version + "." + key;
else return key;
};
@navneetkumar
navneetkumar / queue.js
Last active December 23, 2015 01:39
Use of javascript queue for long-running tasks
//avoid zombie objects
app.views.home = app.views.home || new app.views.Home()
//Use queue for executing long-running tasks
var queue = async.queue(function (task, callback) {
console.log('started ' + task.name);
callback();
}, 2);
@navneetkumar
navneetkumar / dynamic_script.js
Created September 14, 2013 12:23
Load javascript dynamically
function loadFile(url) {
var script = document.createElement('SCRIPT');
script.src = url
document.getElementsByTagName('HEAD')[0].appendChild(script);
}
require 'timeout'
namespace :android do
DEPLOYABLES_ANDROID_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'deployables', 'android'))
IBA_ANDROID_PKG = 'br.com.iba.readers'
ASSETS_RUNTIME = "/data/data/#{IBA_ANDROID_PKG}/#{IBA_ANDROID_PKG}/Local\\ Store/assets_runtime/htmlresources/buttons"
desc 'Runs the automated testing for Android'
task :ci =>