Skip to content

Instantly share code, notes, and snippets.

View ojengwa's full-sized avatar
🏠
Working from home

Bernard Ojengwa ojengwa

🏠
Working from home
View GitHub Profile
from __future__ import absolute_import, unicode_literals
from celery import current_app
from celery.bin import worker
if __name__ == '__main__':
app = current_app._get_current_object()
worker = worker.worker(app=app)
@ojengwa
ojengwa / routific-local-motion.js
Created January 12, 2017 22:52 — forked from mck-/routific-local-motion.js
Routific solution to Local Motion challenge
var drivingSchedule = {};
var turnNumber = 0;
var MIN_VISITS_PER_VEHICLE = 1; // to keep everyone busy
var OPTIMIZE_EVERY_X_TURNS = 5;
var turn = function(vehicles, people, buildings) {
'use strict';
if(turnNumber % OPTIMIZE_EVERY_X_TURNS === 0 && turnNumber < 1000) {
// Parse data to be suitable for Routific's API
@ojengwa
ojengwa / deploy_with_ebcli3_on_circleci.md
Created January 15, 2017 01:19 — forked from RobertoSchneiders/deploy_with_ebcli3_on_circleci.md
Settings to deploy to AWS Elastic Beanstalk on CircleCi (EB Cli 3)

This is how I configured the deploy of my rails apps to AWS Elastic Beanstalk through CircleCI.

Configure Environments Variables

On Project Settings > Environment Variables add this keys:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
    The aws user must have the right permissions. This can be hard, maybe, this can help you.

Create a bash script to create the eb config file

{
"type": "service_account",
"project_id": "max-v2",
"private_key_id": "edb744c66db9f8cf0b2454aa3136fa09305c3230",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDg10zdfcJZ3zb1\n47WD6DoEyUMGIFBLaC+Pms2jNNxmparyPhQXnEJ3v7DQAptOsDoNC4hGVkfiWzy3\ncE/Ss46LaldMKQzAzUjCEoH7YJUJ1XFt05OByTPIj85FsibZMWIdIGC31vPhvN3z\nDyVG5e9hxyW3dwiyLlNMM+C7l0ahp38cGFXlQH6LTdTqIIIcZ/PVgY7zCeAqZVqJ\nsD9XmQWpTi2cpCqn2x8rG4LrEAh0ACVvjGlMe7LcA+UeHozx8md150AaWBtYTH5X\ngJwRXYwx9TA3EkQuxMVIay5MvwLrri1cb1LVbMl4Wyyu3MRmtySYdXlir0btGqUQ\nosJ4lt6hAgMBAAECggEAeGUxZqURrfglwPNG3jQ65Rc0SZKCDG7kkNwO4ybKIjjx\n2bc+IQpuWRsPPcM3kKIy44taVHedFGtQjtWYGLZHTQYLat/MUW1bWXh5m7ay98oQ\nbAPQR74KeYnvpUhpHwIfjIMq5yY1/5mXq7BfgKBdV5lA7AXUZT0DI5nf6/NsQeCi\nzJtyZlD/YLJ3MMaaRW2KGKiVim81Sq1syo5d1mjZp/0ivZ1ZaeYETOJP6pDJIVZx\n2q9X5Gyto4C+3KtEo0Tj3veITXfXzoRcDUPewEaPG0N3BvZPMwW7LBOO3evt0KuN\naC7u9XiQcT7GEMFOp9QHBSe6qBPa7niyQQroDE4xJQKBgQD4OHp39UR5EKcu3tdI\nP1LHoCaPjoSnHO2Aj+5GgCQrF3hxuoAkDbo8h+pq4Gk5rToSOGK/brLjE1aR9JGs
@ojengwa
ojengwa / DJANGO_TWISTED_HAPROXY.md
Created February 26, 2017 04:35 — forked from sspross/DJANGO_TWISTED_HAPROXY.md
Serving Django and Twisted using HAproxy

Serving Django and Twisted using HAproxy

Why?

Because we wanted to achive the following while developing a webapp using websockets:

Static serving (nginx), Django application (gunicorn) and Websockets service (twisted)

  • on the same IP
let unassigned = realtime.unassigned.child(attrs.body.order_id)
let assigned = realtime.assigned.child(attrs.body.order_id)
unassigned.ref.once('value', (data) => {
data = data.val()
data['status'] = 'assigned'
assigned.set(data, (error) => {
if (!error) {
let champion_ref = realtime.champions.child(attrs.body.champion_id + '/assigned/' + attrs.body.order_id)
champion_ref.set(data, (error) => {
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
.PHONY: all
assets:
gsutil -m rsync -R <public_dir>/ gs://<bucket_id>/<public_dir>
worker:
gcloud app deploy worker.yaml --stop-previous-version --verbosity=info --promote --project=<project_id>
web:
@ojengwa
ojengwa / docker-compose2aws
Last active January 18, 2024 17:58
Set by step guide on deploying your docker containers to AWS using docker-compose and docker-machine
# Deploy to AWS using docker-machine and docker-compose
## 1. Prepare your machine
Please follow this steps:
1.1 Install docker in your localhost. [Installation link](https://docs.docker.com/engine/installation/)
1.2 Install docker-machine in your localhost. [Installation link](https://docs.docker.com/compose/install/)
1.3 Install docker-compose in your localhost. [Installation link](https://docs.docker.com/machine/install-machine/)
1.4 Create an account in AWS (skip this step if you already have one). [AWS](https://aws.amazon.com/)