Skip to content

Instantly share code, notes, and snippets.

View toast38coza's full-sized avatar

Christo Crampton toast38coza

View GitHub Profile
@toast38coza
toast38coza / App.vue
Last active January 13, 2017 07:06
Quickstart Framework7-vue setup for a typical VueJS webpack project
<template>
<!-- App -->
<div id="app">
<!-- Statusbar -->
<f7-statusbar></f7-statusbar>
<!-- Left Panel -->
<f7-panel left reveal layout="dark">
<f7-view id="left-panel-view" navbar-through :dynamic-navbar="true">
@toast38coza
toast38coza / vuex_persist.js
Created January 18, 2017 13:20
Dump the entire vuex store to localStorage and retrieve it again.
// key to use for get/set state:
export const LOCALSTORAGE_KEY = '..'
// as an action:
export const PERSIST_ACTION = ({ rootState }) => {
let stateAsString = JSON.stringify(rootState)
window.localStorage.setItem(LOCALSTORAGE_KEY, stateAsString)
}
// restore a cached vuex store:
@toast38coza
toast38coza / what.three.words.py
Created March 16, 2017 15:57
Playing around with What.Three.Words in python
# pip install what3words
# setup:
api_key = environ['W3W_API_KEY']
w3w = what3words.Geocoder(api_key)
# forward: 3 words to address:
In [18]: w3w.forward(addr='prom.cape.pump')
Out[18]:
FROM python:3.4
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
@toast38coza
toast38coza / http_status.py
Last active April 2, 2018 11:13
HTTP status codes as a dict. Source: https://httpstatuses.com/
STATUS_CODES = {
100: "100 Continue",
101: "101 Switching Protocols",
102: "102 Processing",
200: "200 OK",
201: "201 Created",
202: "202 Accepted",
203: "203 Non-authoritative Information",
204: "204 No Content",
@toast38coza
toast38coza / create-secret.sh
Last active July 23, 2017 23:30
Secrets with docker-compose
echo "This is a secret" | docker secret create my_secret_data -
@toast38coza
toast38coza / play.yml
Created July 23, 2017 23:00
Ansible to run code only on a single manager node
- hosts: server_swarm
tasks:
- command: "docker info --format '{%raw%}{{json .Swarm.ControlAvailable}}'{%endraw%}"
register: result
become: true
- debug: msg='Deploy on this host'
when: result.stdout == 'true'
run_once: true
@toast38coza
toast38coza / docker-compose.yml
Created August 31, 2017 09:29
Konga Dashboard for Kong API Gateway
version: "3"
services:
konga:
image: pantsel/konga:latest
env_file: 'kong.env'
ports:
- '8999:1337'
mongo:
image: mongo
volumes:
@toast38coza
toast38coza / zoom_send_sms.py
Last active November 16, 2017 14:36
Zoom Connect send SMS
import requests
def send_sms(to, content):
token = '..'
email = '..'
headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
params = {
token: token,
email: email
}
@toast38coza
toast38coza / .bumpversion.cfg
Created February 1, 2019 16:38
Fun times with Sentry (and Django)
[bumpversion]
current_version = 1.0.0
commit = False
tag = False
[bumpversion:file:api/custom_settings.py]