Skip to content

Instantly share code, notes, and snippets.

@rduplain
rduplain / MainActivity.java
Created May 8, 2012
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
View MainActivity.java
package com.willowtreeapps.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
View zwave-js-hank-scn04-4-button-remote.yaml
blueprint:
name: Hank Four-button Scene Controller
description: Create automations for Hank Electronics / Technisat 4-button remote using the ZWave-JS integration
domain: automation
input:
hank_scn04:
name: Hank Four-button Controller
selector:
device:
@rduplain
rduplain / README.md
Created Oct 17, 2011
Connect to MSSQL using FreeTDS / ODBC in Python.
View README.md

Goal: Connect to MSSQL using FreeTDS / ODBC in Python.

Host: Ubuntu 11.10 x86_64

Install:

sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy

In /etc/odbcinst.ini:

@rduplain
rduplain / app.py
Created May 20, 2012
Add a second static directory to Flask, in ../static/.
View app.py
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route('/base/<path:filename>')
def base_static(filename):
return send_from_directory(app.root_path + '/../static/', filename)
@rduplain
rduplain / vpn
Last active Oct 10, 2021
OpenVPN rc.d script for VPN client on BSD (i.e. jail): connect to VPN, start another service once VPN is connected.
View vpn
#!/bin/sh
# PROVIDE: vpn
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# vpn: connect to VPN, start another service once VPN is connected.
#
# Uses OpenVPN and assumes the configuration does not need any authentication
# beyond the given .conf file. Consider an approach using `expect` if needed:
#
@rduplain
rduplain / grub_iso.sh
Last active Jul 23, 2021
Bootloader configuration for multiple .iso files on a USB drive.
View grub_iso.sh
#!/bin/sh
# Use grub to boot .iso files directly from /boot/iso.
#
# This file lives at /etc/grub.d/25_iso and is executable.
#
# Open .iso files to inspect internal /boot files for grub config hints.
# /boot is on the third partition of a gpt-partitioned USB drive.
ISO_PART_UUID="0a5086cd-8fdf-4ae0-a248-67411ebbbb18" # UUID of /boot `blkid`.
ISO_PART_NUMBER=3
@rduplain
rduplain / app.py
Created Jan 19, 2012
Plot a PNG using matplotlib in a web request, using Flask.
View app.py
"Plot a PNG using matplotlib in a web request, using Flask."
# Install dependencies, preferably in a virtualenv:
#
# pip install flask matplotlib
#
# Run the development server:
#
# python app.py
#
@rduplain
rduplain / haproxy-servers.cfg
Last active Jun 16, 2021
Rewrite haproxy configuration and reload service.
View haproxy-servers.cfg
# Edit this file then run `update-haproxy haproxy-servers.cfg`.
# Alternatively, use a shell pipeline to build server list `... | update-haproxy`.
server demo1 127.0.0.1:8001 check cookie demo1 weight 100
server demo2 127.0.0.1:8002 check cookie demo2 weight 100
server demo3 127.0.0.1:8003 check cookie demo3 weight 0
server demo4 127.0.0.1:8004 check cookie demo3 weight 0
@rduplain
rduplain / Makefile
Created Apr 27, 2013
Makefile for key interactions on a Flask project deployed on heroku.
View Makefile
# Key project interactions, but not all dependencies are resolved by make.
help:
@heroku help
run:
python manage.py runserver
shell:
python manage.py shell
@rduplain
rduplain / match.hy
Last active Dec 22, 2020
Getting started with hy (hylang.org), a simple example.
View match.hy
#!/usr/bin/env hy
;; match.hy - Getting started with hy (hylang.org), a simple example.
;;
;; As executable, `chmod +x match.hy`:
;;
;; $ ./match.hy '(.*), (.*)!' 'Hello, world!'
;; ('Hello', 'world')
;;
;; Developed on hy master 14c412c (after 0.11.1) on Python 3.5.
;;