Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jmswag on github.
  • I am johnymoswag (https://keybase.io/johnymoswag) on keybase.
  • I have a public key whose fingerprint is 746D 73C3 E4F1 6E2A 69A2 305B 5CCC 9553 BB92 F302

To claim this, I am signing this object:

#!/usr/bin/env python
import bz2
import datetime
import os
import sys
import time
import urllib2
import warnings
@JMSwag
JMSwag / commands.txt
Last active August 29, 2015 14:23 — forked from lmars/commands.txt
# create a redis app
flynn create --remote "" redis
# create a release using the latest (at the time of writing) Docker Redis image
flynn -a redis release add -f config.json "https://registry.hub.docker.com/_/redis?tag=3.0.2"
# scale the server to one process. This may time out initially as the server pulls the image, but watch "flynn -a redis ps" and should come up.
flynn -a redis scale server=1
# redis should now be running in the cluster at redis.discoverd:6379
@JMSwag
JMSwag / Contract Killer 3.md
Last active August 29, 2015 14:26 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

deployment_id | app_id | old_release_id | new_release_id | strategy | processes | created_at | finished_at
--------------------------------------+--------------------------------------+--------------------------------------+--------------------------------------+-------------+------------+-------------------------------+-------------------------------
a61572f3-a0bc-48c5-bee2-ac9a83acc6be | 35ceb222-9824-4260-b23d-04d74957c9d3 | | 22be1c6b-1838-4d22-abe8-7ce569d69700 | all-at-once | | 2015-08-09 03:17:38.305919+00 | 2015-08-09 03:17:38.305824+00
8d8c220c-3a68-4b52-84bb-fc5b0a774e41 | 0e91b750-e134-4039-9129-76bfe513c051 | | 6839526d-14f3-4152-8422-68b966d27e8d | all-at-once | | 2015-08-09 03:17:39.202328+00 | 2015-08-09 03:17:39.202213+00
1398a565-3e7f-4706-b9cc-ba2fef10ba98
@JMSwag
JMSwag / producer-consumer-go.md
Last active March 1, 2024 18:53 — forked from drio/producer-consumer-go.md
producer consumer in go explained

Producer consumer pattern

Question: Can you write code implementing the consumer and producer pattern?

This is a classic concurrency problem where we have threads generating data to be consumed (producers) by other threads (consumers).

The implementation with POSIX threads can be a pain in the ass but it is quite straight forward in golang thanks to its concurrency constructs.

# Add bittorent sync repo
add-apt-repository ppa:tuxpoldo/btsync
# Update repo
apt-get update
# Upgrade server packages
apt-get dist-upgrade
# Install dev stuff
apt-get install -y build-essential btsync htop pbzip2 python-dev python-pip
# Install virtualenvwrapper
pip install virtualenvwrapper
add-apt-repository -y ppa:formorer/icinga
apt-get update
apt-get install -y icinga2 nagios-plugins postgresql icinga2-ido-pgsql apache2 pnp4nagios
service icinga2 start
cd /tmp
sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD 'icinga'";
sudo -u postgres createdb -O icinga -E UTF8 icinga
sudo -u postgres createlang plpgsql icinga
@JMSwag
JMSwag / singleton_scheduler.py
Created October 23, 2015 22:52 — forked from reclosedev/singleton_scheduler.py
Singleton Scheduler for celery-beat with Redis Sentinel
from os import urandom
from celery.beat import PersistentScheduler
from some_place import create_readis_connection # !
class SingletonScheduler(PersistentScheduler):
def __init__(self, *args, **kwargs):
super(SingletonScheduler, self).__init__(*args, **kwargs)
@JMSwag
JMSwag / bs3-login-form.html
Created October 25, 2015 16:51 — forked from bMinaise/bs3-login-form.html
Bootstrap 3 - Login Form Example From: http://bootsnipp.com
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<h1 class="text-center login-title">Sign in to continue to Bootsnipp</h1>
<div class="account-wall">
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120"
alt="">
<form class="form-signin">
<input type="text" class="form-control" placeholder="Email" required autofocus>
<input type="password" class="form-control" placeholder="Password" required>