Skip to content

Instantly share code, notes, and snippets.

@jalp
jalp / ConsumerConfiguration.java
Created August 21, 2016 17:53
Initial configuration for sns, sqs and kinesis services
package com.schibsted.notification.queueconsumer.config;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.kinesis.AmazonKinesisClient;
import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sqs.AmazonSQSAsync;
import com.amazonaws.services.sqs.AmazonSQSAsyncClient;
import com.amazonaws.services.sqs.buffered.AmazonSQSBufferedAsyncClient;
import com.amazonaws.services.sqs.buffered.QueueBufferConfig;
@jalp
jalp / CustomErrorController.java
Created April 8, 2015 14:15
Custom Error Controller for Spring Boot(MVC)
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes;
@jalp
jalp / queue_consumer.py
Created April 7, 2014 07:41
Activemq simple client with stompy
import sys
import logging
from stompy.stomp import Stomp, ConnectionError, ConnectionTimeoutError
class QueueConsumer(object):
""" Queue consumer
"""
def __init__(self, host='localhost', port=61613):
@jalp
jalp / supervisor_client.py
Created April 7, 2014 07:39
Supervisor api client in Python
import xmlrpclib
class ProcessStatus(object):
RUNNING = 'RUNNING'
STOPPED = 'STOPPED'
FATAL = 'FATAL'
RESTARTING = 'RESTARTING'
SHUTDOWN = 'SHUTDOWN'
@jalp
jalp / supervisor_client.py
Created March 25, 2014 08:32
Supervisor client
import xmlrpclib
class SupervisorClient(object):
""" Supervisor client to work with remote supervisor
"""
def __init__(self, host='localhost', port=9001):
self.server = xmlrpclib.Server('http://{}:{}/RPC2'.format(host, port))
@jalp
jalp / nginx.conf
Last active October 16, 2017 08:58
Nginx configuration for ssl redirection and serving API through gunicorn server
#user nobody;
worker_processes 1;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
@jalp
jalp / precommit
Created January 27, 2014 07:55
Precommit file using fabric to test and run PEP8 after commit files
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified_re = re.compile(r'^(\s[AM]+)\s+(?P<name>.*\.py)')
@jalp
jalp / precommit
Created January 27, 2014 07:52
Precommit python files testing and running PEP8 control after commit into git
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified_re = re.compile('^[AM]+\s+(?P<name>.*\.py)', re.MULTILINE)
@jalp
jalp / .bash_profile
Last active December 23, 2015 06:49
My own bash_profile
# aliases
alias cd..="cd .."
alias l="ls -al"
alias lp="ls -p"
alias h=history
# Mongo
export MONGO_PATH=/usr/local/mongodb
export PATH=$PATH:$MONGO_PATH/bin