Skip to content

Instantly share code, notes, and snippets.

View encima's full-sized avatar
🐴
selling spare horse kidneys. PM me

Chris Gwilliams encima

🐴
selling spare horse kidneys. PM me
View GitHub Profile
@encima
encima / supabase-api-logger.py
Last active November 15, 2023 10:53
Supabase API to rsyslog
import requests
import datetime
import config # create file with necessary vars (or use env)
headers = {
'Authorization': f'Bearer {config.supabase_token}',
'Content-Type': 'application/json'
}
response = requests.get(
@encima
encima / inspect_snapshot.sh
Created November 6, 2023 13:09
Supabase DB Inspect Snapshot (requires Supabase CLI)
#!/bin/zsh
# Run as ./inspect_snapshot.sh $DB_URI $OUTPUT_DIR
inspect_help=$(supabase inspect db -h)
cmds=("${(@f)$(echo "$inspect_help" | awk '/^[[:space:]]{2}[[:alpha:]]+/{print $1}')}")
shift cmds #remove supabase at index 0
current_date=$(date +%F)
@encima
encima / cpu.py
Created October 9, 2023 06:32
CPU Usage Visualization using Bokeh
import time
import psutil
from bokeh.plotting import figure, show
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource
from bokeh.layouts import layout
from threading import Thread
# Prepare empty data source
source = ColumnDataSource(data=dict(time=[], cpu=[]))
@encima
encima / tefter_convert.py
Created May 27, 2023 08:15
Convert bookmarks exported from tefter.io from JSON to Netscape HTML format
import json
data = json.load(open('bookmarks.json','r'))
html = """
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!--This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
@encima
encima / nvim
Created August 4, 2020 21:34
Minimal Configs
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
set hidden
nnoremap <Leader>f :Files<CR>
nnoremap <Leader>b :buffers<CR>:buffer<Space>
@encima
encima / Dockerfile
Last active March 17, 2021 10:01
Docker Core Image|-|{"files":{"run.sh":{"env":"plain"},"docker-daemon.json":{"env":"plain"},"build.sh":{"env":"plain"},"build.cmd":{"env":"plain"},"Dockerfile":{"env":"plain"},"bashrc":{"env":"plain"}},"tag":"Aiven"}
# syntax=docker/dockerfile:1.0.0-experimental
FROM fedora:33
ARG SSH_PRV
ARG SSH_PUB
ARG UNAME
RUN dnf update -y && dnf install -y git make findutils iputils openssh-clients && dnf clean all
@encima
encima / mvp-bigquery-connector.tf
Last active September 14, 2020 19:43
Aiven Connector Terraform Examples|-|{"files":{"mvp-bigquery-connector.tf":{"env":"plain"}},"tag":"Aiven"}
resource "aiven_kafka_connector" "kafka-bq-con" {
project = var.project
service_name = var.services
connector_name = "kafka-bq-con"
config = {
"name": "bq-demo",
"connector.class": "com.wepay.kafka.connect.bigquery.BigQuerySinkConnector",
"tasks.max": "2",
"topics": "test_topic",
@encima
encima / getting-started.tf
Created May 13, 2020 11:54
Terraform Aiven Single File Example
terraform {
# go get -u github.com/aiven/terraform-provider-aiven
# cp $GOPATH/bin/terraform-provider-aiven $PWD/terraform.d/plugins/linux_amd64/terraform-provider-aiven_v1.2.4
required_providers {
aiven = ">= 1.2.4"
}
}
variable "aiven_api_token" {
type = string
@encima
encima / Program.cs
Last active September 14, 2020 19:44
Datastax Cassandra C# Driver SSL Connection|-|{"files":{"Program.cs":{"env":"plain"}},"tag":"Aiven"}
using System;
using System.Linq;
using System.Collections.Generic;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Cassandra;
namespace cassandra_c_
{
@encima
encima / timesheet.go
Last active June 11, 2018 12:52
Add your times at UZH (or any other company that uses questionable user defined formatting for their timesheets). Requires openpyxl and Python 3+
package main
import (
"fmt"
"os"
"time"
"github.com/akamensky/argparse"
"github.com/tealeg/xlsx"
)