Skip to content

Instantly share code, notes, and snippets.

@jamesbeedy
jamesbeedy / show_juju_env.sh
Created April 5, 2018 00:47
show_juju_env
#!/bin/bash
#
# sudo apt install jq
# add this to ~/.bashrc
# source ~/.bashrc
function show_juju_env {
local model
local controller
@jamesbeedy
jamesbeedy / storage_mock_up.py
Last active March 2, 2018 21:11
hdfs_juju_storage.py
import os
from charms.reactive import when_not, set_flag, hook, when
from charmhelpers.core.host import mount, mkdir
from charmhelpers.core.hookenv import storage_get, storage_list, status_set
from charmhelpers.contrib.storage.linux.utils import is_device_mounted
from charmhelpers.contrib.storage.linux.ceph import make_filesystem
instance-id: maas-region-controller-00
local-hostname: maas-region-controller-00
public-keys:
- ssh-key
import os
basedir = os.path.abspath(os.path.dirname(__file__))
APP_DIR = os.path.abspath(os.path.dirname(__file__))
PROJECT_ROOT = os.path.abspath(
os.path.join(os.path.abspath(os.path.dirname(__file__)), os.pardir)
)
@jamesbeedy
jamesbeedy / forms.py
Created January 22, 2018 00:10 — forked from rombr/forms.py
How to add custom fields order to WTForms
from collections import OrderedDict
# ...
class OrderFormMixin(object):
'''
To apply add to Meta 'order' iterable
'''
def __init__(self, *args, **kwargs):
super(OrderFormMixin, self).__init__(*args, **kwargs)
#!/usr/bin/env python3
import yaml
PRIVATE_IP = "100.100.100.100"
WEB_PORT = 9000
API_PORT = 9001
services = [{'service_name': "mytestservice",
from pyspark.sql import SparkSession
from pyspark.ml import Pipeline
from pyspark.ml.classification import LogisticRegression
from pyspark.ml.feature import HashingTF, Tokenizer
import random
from random import randint
spark = SparkSession.builder.master("local").appName("Word Count").getOrCreate()
class HttpProvides(Endpoint):
@when('endpoint.{endpoint_name}.joined')
def joined(self):
set_flag(self.expand_name('{endpoint_name}.available'))
@when_not('endpoint.{endpoint_name}.joined')
def broken(self):
clear_flag(self.expand_name('{endpoint_name}.available'))
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return "Hello World"
@jamesbeedy
jamesbeedy / k8s-with-spaces.yaml
Last active November 17, 2017 20:42
Upstream k8s bundle with spaces constraints
applications:
easyrsa:
charm: 'cs:~containers/easyrsa-23'
constraints: "spaces=nat"
num_units: 1
annotations:
gui-x: '450'
gui-y: '550'
etcd:
charm: 'cs:~containers/etcd-59'