Skip to content

Instantly share code, notes, and snippets.

View rsyring's full-sized avatar

Randy Syring rsyring

View GitHub Profile
@rsyring
rsyring / app.py
Created May 26, 2022 04:19
Write CSV files to a Zip file and serve with Falcon (Python)
import csv
import io
import tempfile
import zipfile
import falcon
GB = 1024 ^ 3
MEM_MAX_SIZE = 1 * GB
# 1) Activate your virtualenv
# 2) Change directory into the webgrid source
# 3) Change the line at the following location to have "sqlite:///example.db" at the end:
# https://github.com/level12/webgrid/blob/7d99df84d32b0e70b1531c4d67ad53b1af6bfcb3/webgrid_ta/app.py#L33
# 4) Remove the two requirements from the following line that have "pyodbc" in them:
# https://github.com/level12/webgrid/blob/7d99df84d32b0e70b1531c4d67ad53b1af6bfcb3/setup.py#L11
~/projects/webgrid-src$ pip install --quiet -e .[develop,i18n]
~/projects/webgrid-src$ cd webgrid_ta/
~/projects/webgrid-src/webgrid_ta$ python manage.py create-db
@rsyring
rsyring / fstab
Last active December 26, 2019 00:58
zfs on linux notes
# <device> <dir> <type> <options> <dump> <fsck>
PARTLABEL=boot /boot ext4 defaults,nodev,relatime 0 1
PARTLABEL=samd-efi /boot/efi vfat defaults,nodev,relatime 0 2
@rsyring
rsyring / recipe.md
Last active September 27, 2022 15:14
Randy's Italian Sandwich Recipe

Bread: Ciabatta bread, split in half, or good Italian bread

On both halves of the sandwich:

  • provolone
  • oregano
  • 1-2 slices smoked ham (not sweet)
  • 2 slices salami (or enough to cover the ham, depends on how big and thick the salami is)
  • pepperoni to cover salami (we like smaller pepperoni, like for pizza, because the edges crisp easier)
  • red onion
@rsyring
rsyring / events.py
Last active June 8, 2018 21:24
Streaming salt-api events using python requests
import requests
import arrow
session = requests.Session()
resp = session.post(
'http://172.18.0.3:8765/login',
json={
'username': 'tang-api',
'password': 'notsecure',
'eauth': 'pam',
@rsyring
rsyring / loadit.py
Created March 22, 2018 18:29
Script for initializing virtualenvs from app's that have wheelhouses
#!/usr/bin/env python3
#PROJ_PATH=$(git rev-parse --show-toplevel)
#PROJ=${PROJ_PATH##*/}
#rmvirtualenv $PROJ
#vex -m $PROJ pip install "git+https://github.com/level12/wheelhouse#egg=Wheelhouse"
#vex $PROJ wheelhouse install -- -r requirements/dev-env.txt
#vex $PROJ pip install -e .
#vex -r $PROJ
@rsyring
rsyring / example.js
Created November 20, 2017 04:44
Mithril Contacts
function Contacts(vn) {
let contacts = [
{name: 'Fred', email: 'fred@example.com'},
{name: 'Bob', email: 'bob@example.com'},
]
function addContact(contact) {
contacts.push(contact)
}
@rsyring
rsyring / librato-ping.py
Created September 24, 2017 07:09
A python script that pings a host and uploads metrics to Librato
import re
import librato
from sh import ping, hostname
host = 'google.com'
# How many pings should we do before we process the results
ping_for = '30'
# How many times should we ping, process results, and send to Librato
repeat = 2
liberato_token = '<censored>'
@rsyring
rsyring / gist:2787e484b3c3202c654061bf4e4aaef1
Created April 14, 2017 19:24
Troubleshooting zfs snapshot size usage
$ sudo zfs list -r rpool -o name,used,compression,readonly,mounted
NAME USED COMPRESS RDONLY MOUNTED
...
rpool/insig/tmp/playground 6.91M lz4 off yes
$ ls -lh /tmp/playground/
total 512
-rw-rw-r-- 1 rsyring rsyring 2 Apr 14 14:59 foo
# I think snapshot @5 should have more used space.
@rsyring
rsyring / gist:74654ef6b97386354e7377bb350c635f
Created April 5, 2017 17:23
installing scudcloud 1.5 with error message "Depends: python3-pyqt5 but it is not going to be installed"
# See for more context: https://github.com/raelgc/scudcloud/issues/550
rsyring@loftex:~$ sudo apt-get install scudcloud
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.