Skip to content

Instantly share code, notes, and snippets.

View osule's full-sized avatar
✝️
ecce homo

Oluwafemi Sule osule

✝️
ecce homo
View GitHub Profile
@osule
osule / how-to-python-packages.md
Created July 11, 2016 09:00
How to python packages

Setting up custom python packages

I know of one or more reported cases where python imports failed. Because python packages are arranged with reference to the file system structure, running a module that imports a package that is one-level up in the file hierarchy results in an ImportError.

This error can be resolved in any of the following ways:

  1. Export $PYTHONPATH variable in your terminal

export PYTHONPATH=.

@osule
osule / architecture.md
Last active October 15, 2018 11:30
5 Focus points for available systems

5 Focus points for available systems

  • Build with Failure in Mind
  • Always think about Scaling
  • Mitigate risk
  • Monitor availability
  • Respond predictably and in a defined manner to issues

Characteristics of proper response to Dependency/Service Failures

  • Predictability
  • Understandability
@osule
osule / docker_formatting.md
Last active August 23, 2017 10:28
Docker formatting using Go templates

Do you grep?

Docker exposes formatting for most commands using Go templates so that it is possible to programmatically refine/format results of docker commands.

Lets explore some use cases.

Checking for containers created from a particular image.

docker ps --format '{{ if eq (js $.Image ) ""}} \
@osule
osule / package.json
Last active February 27, 2019 09:39
3 Leg POC.
{
"name": "gists",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@request/headers": "request/headers",
"consolidate": "^0.14.5",
"cookie-parser": "^1.4.3",
"express": "^4.15.3",
@osule
osule / parrot.py
Created July 20, 2017 16:32
Play with api.ai (an answer to stackoverflow)
from flask import Flask, current_app, jsonify
from flask_assistant import Assistant, ask, tell, event, context_manager, request
from flask_assistant import ApiAi
app = Flask(__name__)
assist = Assistant(app, '/')
@assist.action('fallback', is_fallback=True)
def say_response():
@osule
osule / duration.sh
Last active July 26, 2017 16:56
Naive bash script to compute how old a project repository is
#!/bin/bash
START_DATE=$(git --no-pager log $(git rev-list --max-parents=0 HEAD) --format="%at")
END_DATE=$(git --no-pager log -n 1 $(git rev-list HEAD^..HEAD) --format="%at")
DURATION=$(( $(($END_DATE - $START_DATE)) / 86400 ))
pluralize() {
echo $1s
}
@osule
osule / regex.md
Last active July 28, 2017 12:53
Regex Cheatsheet

Regex cheatsheet

  • Match any character that is not repeated consecutively.

r"(.)(?!\1)"

@osule
osule / Dockerfile
Created September 19, 2017 16:22
nginx/Dockerfile
FROM nginx
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
ADD sites-enabled/ /etc/nginx/sites-enabled
@osule
osule / canvas
Last active October 3, 2017 12:24
nginx/canvas
upstream web-app {
server canvas-web:9000;
}
server {
listen 80 default_server;
server_name _;
root /var/www/html/canvas/public;
@osule
osule / Dockerfile
Created October 3, 2017 11:41
web/Dockerfile
FROM php:7.0-fpm
ENV WWW_HOME /var/www/html
ENV APP_HOME $WWW_HOME/canvas
ENV COMPOSER_HOME $WWW_HOME/.composer
COPY ./composer.json $APP_HOME/composer.json
COPY ./composer.lock $APP_HOME/composer.lock
WORKDIR $APP_HOME