Skip to content

Instantly share code, notes, and snippets.

View joeljames's full-sized avatar

Joel James joeljames

  • Cirium
  • Portland OR
View GitHub Profile
@joeljames
joeljames / pre-commit
Last active August 29, 2015 13:57
Pre commit hook that prevents code from being commited if tests fails or if code has break points
#!/bin/sh
#Pre commit hook that prevents code from being commited if tests fails or if code has break points.
# Stash the changes that has not been added
git stash -q --keep-index
echo "Testing....."
python manage.py test
TEST_RESULT=$?

Keybase proof

I hereby claim:

  • I am joeljames on github.
  • I am joeljames (https://keybase.io/joeljames) on keybase.
  • I have a public key whose fingerprint is F0B4 996B 8EED 7CA5 5512 7740 2449 64A7 1F03 A944

To claim this, I am signing this object:

@joeljames
joeljames / urls.py
Created August 4, 2016 19:18
Health App urls
from django.conf.urls import url
from health.views import StatusQueueView
urlpatterns = [
url(r'^queue/$',
StatusQueueView.as_view(),
name='status-queue'),
]
@joeljames
joeljames / settings.py
Last active August 4, 2016 19:33
Health Monitoring Settings
# ----------------------------------------------------------------------------
# Health monitoring
# --------------------------------------------------------
REDIS_URL = environ.get('REDIS_URL', '')
# Queue Heath Monitoring
# Allowable max queue size to monitor queue health.
ALLOWABLE_MAX_QUEUE_SIZE = int(
environ.get(
@joeljames
joeljames / views.py
Created August 4, 2016 19:35
Health App View
from collections import defaultdict
from django.views.generic.base import TemplateResponseMixin, View
from rest_framework import status
from annoying.functions import get_config
from redis import StrictRedis
__all__ = [
@joeljames
joeljames / status_queue.djhtml
Last active August 4, 2016 19:38
Health HTML
{% block header %}
<h1>Application Queue Status</h1>
<dl>
{% for name, size in queue_summary.items %}
<dt>Queue Name: {{ name }}</dt>
<dd>Queue Size: {{ size }}</dd>
</br>
{% endfor %}
</dl>
@joeljames
joeljames / pypi_push.doc
Created September 19, 2016 16:47
Push to pypi
## Push to test server
## Register ##
python setup.py register -r pypitest
## Upload ##
python setup.py sdist upload -r pypitest
## Push to main server
## Register ##
python setup.py register -r pypi
## Upload ##
@Slf4j
public class KafkaProducerApp {
private static final String topic = "my-topic";
public static void main(String[] args) {
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092,localhost:9093,localhost:9094");
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
@Slf4j
public class KafkaConsumerWithThreads {
private static final AtomicBoolean shutdownRequested = new AtomicBoolean(false);
private static final List<String> topics = List.of("my-topic");
private static final int noOfWorkerThreads = 3;
public static void main(String[] args) {
ExecutorService service = Executors.newFixedThreadPool(noOfWorkerThreads);
IntStream.range(0, noOfWorkerThreads)
.forEach(i -> service.execute(getRunnableTask()));