Skip to content

Instantly share code, notes, and snippets.

@bendavis78
bendavis78 / gist:827089ff8f2a8d8975ee
Last active May 29, 2022 17:01
Installing Arch Linux on Chromebook Pixel 2
@bendavis78
bendavis78 / svg-template-support.js
Last active April 23, 2022 19:54
Polymer 1.0 suppoert for template inside svg
// Templates inside SVG won't work in polymer-1.0 without some monkeypatching.
(function(){
var doc = document.currentScript.ownerDocument;
var root = doc.querySelector('dom-module > template').content;
var templates = root.querySelectorAll('svg template');
var el, template, attribs, attrib, count, child, content;
for (var i=0; i<templates.length; i++) {
el = templates[i];
template = el.ownerDocument.createElement('template');
el.parentNode.insertBefore(template, el);
@bendavis78
bendavis78 / db_backup.sh
Last active April 22, 2022 02:11
A simple database backup / rotation / prune script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
@bendavis78
bendavis78 / gist:3157948
Created July 22, 2012 02:14
Installing pygit2 on ubuntu

Download and build libgit2

$ cd ~/.local/src/
$ git clone git://github.com/libgit2/libgit2.git 
$ cd libgit2
$ mkdir build && cd build
$ cmake ..
$ cmake --build .

If debugging, use the following cmake commands instead:

@bendavis78
bendavis78 / emperor.ini
Created January 21, 2020 17:02
uwsgi emperor config
[uwsgi]
plugins-dir = /usr/lib/uwsgi/plugins
emperor = /etc/uwsgi/vassals/*.ini
show-config = 1
uid = http
gid = http
emperor-stats = /run/uwsgi/emperor-stats.sock
umask = 002
logto = /var/log/uwsgi/emperor.log
@bendavis78
bendavis78 / django-vassal.ini
Created January 21, 2020 16:59
UWSGI Django vassal config
[uwsgi]
module = hive.wsgi
workers = 6
plugins = python3
base = /srv/hive
virtualenv = /srv/hive
logto = /srv/hive/log/uwsgi.hive.log
socket = /run/uwsgi/hive.sock
touch-reload = /srv/hive/reload
buffer-size = 32768
<!doctype html>
<html>
<head>
<script src="load-pages.js"></script>
<script>window.PagedConfig = {auto: false};</script>
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
<style>
@media screen {
.pagedjs_sheet {
box-shadow: 1px 1px 4px 1px rgba(0,0,0,0.15);
@bendavis78
bendavis78 / paged-example.html
Created January 20, 2020 21:27
Example for pagedjs issue
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
<style>
@media screen {
.pagedjs_sheet {
box-shadow: 1px 1px 4px 1px rgba(0,0,0,0.15);
margin: 20px auto;
}
/**
* attiny85 pin map:
* +-\/-+
* NC PB5 1|o |8 Vcc --- nRF24L01 3v3, pin2
* nRF24L01 CE, pin3 --- PB3 2| |7 PB2 --- nRF24L01 SCK, pin5
* nRF24L01 CSN, pin4 --- PB4 3| |6 PB1 --- nRF24L01 MOSI, pin6
* nRF24L01 GND, pin1 --- GND 4| |5 PB0 --- nRF24L01 MISO, pin7
* +----+
*/