Skip to content

Instantly share code, notes, and snippets.

@RaviH
RaviH / TimeoutRetryExample.groovy
Created November 25, 2014 02:09
Spring Batch Retry with Timeout
import com.rackspace.monitoring.BaseLoggingThing
import org.springframework.retry.RetryCallback
import org.springframework.retry.RetryContext
import org.springframework.retry.policy.TimeoutRetryPolicy
import org.springframework.retry.support.RetryTemplate
class TimeoutRetryExample extends BaseLoggingThing {
RetryTemplate retryTemplate = new RetryTemplate()
CarRepository carRepository
from bottle import Bottle, run, request, response, HTTPResponse
APP1 = Bottle()
@APP1.hook('before_request')
def before_request():
print "APP 1 - Before Request {}".format(request.url)
@APP1.hook('after_request')
def after_request():
from bottle import Bottle, HTTPResponse
class CustomHttpException(BaseException):
def __init__(self, status_code, message):
self.status_code = status_code
self.message = message
APP1 = Bottle()
def access_status_correctly(callback):
@RaviH
RaviH / gist:48d9a423efa7e098d05f
Last active August 29, 2015 14:11
Logstash: Parsing logs, reading stats and sending it to graphite.
input {
stdin { }
file {
path => "/var/log/your_app/your_app.log"
start_position => beginning
codec => multiline {
'negate' => true
'pattern' => '^\d'
'what' => 'previous'
}
@RaviH
RaviH / github_release_management.py
Last active June 26, 2020 13:29
Manages GitHub repository releases
import json
import os
from optparse import OptionParser
import requests
import sys
import logging as log
__author__ = 'ravi'
API_URL = 'https://github.com/api/v3/repos/{}/{}/releases'
@RaviH
RaviH / delete_git_tags.py
Last active August 29, 2015 14:14
Delete git tags from remote as well as local repo
__author__ = 'ravi'
from subprocess import call
import logging as log
import os
os.chdir('/home/ravi/dev/projects/spiderman')
for i in range(115, 280):
try:
# Remove locally
call(['git', 'tag', '-d', '1.0.{}'.format(i)])
@RaviH
RaviH / ObservableFlatMapTest.groovy
Created October 28, 2015 20:38
Test the concept that if first Observable doesn't contain satisfactory value then try the next one.
package com.charter.aesd.deviceactivation.middle.services
import rx.Observable
import rx.functions.Func1
import spock.lang.Specification
/**
* Created by rhasija on 10/28/15.
*/
class ObservableTest extends Specification {
package com.charter.aesd.deviceactivation.middle.rest;
import rx.Observable;
import java.util.Optional;
/**
* Created by rhasija on 10/28/15.
*/
public class ObservableTest {
@RaviH
RaviH / ObservableSwitchIfEmpty.java
Created October 28, 2015 23:05
Observable Switch If Empty
package com.charter.aesd.deviceactivation.edgeservice.rest;
import rx.Observable;
import rx.functions.Func1;
import java.util.Optional;
/**
* Created by rhasija on 10/28/15.
*/
@RaviH
RaviH / ObservableIntersect.java
Created November 3, 2015 20:23
Demo Observable Intersect of 2 lists.
package com.charter.aesd.deviceactivation.edgeservice.rest;
import org.apache.commons.collections.CollectionUtils;
import rx.Observable;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static java.util.Arrays.asList;