Skip to content

Instantly share code, notes, and snippets.

View circa10a's full-sized avatar

Caleb Lemoine circa10a

View GitHub Profile
from pyouroboros import VERSION
import yaml
org = 'pyouroboros'
project = 'ouroboros'
namespace = f"{org}/{project}"
yaml_arr = []
tags = ['latest', VERSION]
@circa10a
circa10a / local_playbook.yaml
Last active February 24, 2020 01:15
example local ansible playbook
---
- name: Configure files
hosts: 127.0.0.1
connection: local
vars:
dirs:
dir1: ~/Desktop/dir1
dir2: ~/Desktop/dir1
tasks:
- name: whattomine_json
@circa10a
circa10a / auth.js
Created July 5, 2019 05:31
github oauth2 with express and sessions
const express = require('express')
const passport = require('passport');
const session = require('express-session');
const app = express()
app.use(session({secret: "soeffingsecret"}));
app.use(passport.initialize());
app.use(passport.session());
@circa10a
circa10a / logger.py
Last active September 27, 2019 01:08
python example logger
#!/usr/bin/env python3
from logging import getLogger, basicConfig
def create_logger():
logger = getLogger(__name__)
basicConfig(format='[%(levelname)s] %(asctime)s %(message)s',
datefmt='%Y-%m-%dT%H:%M:%S', level='INFO')
return logger
@circa10a
circa10a / json_request_urllib.py
Created September 27, 2019 02:09
fetch json, convert to dict with urlllib
#!/usr/bin/env python3
import urllib.request as request
import json
url = "https://raw.githubusercontent.com/typicode/demo/master/db.json"
webURL = request.urlopen(url)
data = webURL.read()
encoding = webURL.info().get_content_charset('utf-8')
JSON_object = json.loads(data.decode(encoding))
@circa10a
circa10a / build.yaml
Created December 27, 2019 02:33
ec2 image build step to install tomcat 9
name: "Tomcat 9"
description: "Install tomcat 9 from tar via apache US mirror"
schemaVersion: 1.0
phases:
- name: build
steps:
- name: install
action: ExecuteBash
inputs:
@circa10a
circa10a / k8s-metrics.go
Last active December 29, 2019 01:55
render terminal ui of cluster usage metrics
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"strconv"
package main
import (
"net/http"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
)
func handleWebhook(c *gin.Context) {
c.JSON(http.StatusOK, buildFulfillment())
// Modeled after google docs
// https://developers.google.com/assistant/conversational/responses#browsing_carousel
// Response is the entire JSON payload response
type Response struct {
Payload Payload `json:"payload"`
}
// Payload is a google defined higher structure, see https://developers.google.com/assistant/conversational/responses#browsing_carousel
type Payload struct {
func buildFulfillment() *Response {
return &Response{
Payload{
Google{
ExpectUserResponse: false,
RichResponse: RichResponse{
Items: []Item{
{
SimpleResponse: &SimpleResponse{
TextToSpeech: "This is the default audio response",