Skip to content

Instantly share code, notes, and snippets.

@rduplain
rduplain / isatty.py
Created June 3, 2014 14:34
Is stdin a tty? Use this to determine whether to provide prompt or just read stdin for input.
import sys
if sys.stdin.isatty():
print('you are a tty')
else:
print('you are not a tty')
@rduplain
rduplain / gist:1377951
Created November 18, 2011 22:16
Produce CSV of each installed package and full copyright of each package. (Debian/Ubuntu)
#!/bin/bash
# Produce CSV of each installed package and full copyright of each package. (Debian)
#
# Sample CSV:
# Package,Version,Section,Homepage,Source
# bash,4.1-2ubuntu3,shells,http://tiswww.case.edu/php/chet/bash/bashtop.html,
# git-core,1:1.7.0.4-1ubuntu0.2,vcs,,
# python,2.6.5-0ubuntu1,python,,python-defaults
AUDIT_DIR="${HOSTNAME}-package-audit/`date +'%Y-%m-%d'`"
@rduplain
rduplain / README.md
Created October 17, 2011 20:04
Connect to MSSQL using FreeTDS / ODBC in Python.

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 / README.rst
Created February 13, 2011 05:21
Demonstrate use of fixture with Flask-SQLAlchemy and Flask-Testing.

Demonstrate use of fixture with Flask-SQLAlchemy and Flask-Testing. February 13, 2011 Ron DuPlain <ron.duplain@gmail.com>

Post any feedback to: flask@librelist.org

Get this gist:

git clone git://gist.github.com/824472.git Flask-SQLAlchemy-Fixture
cd Flask-SQLAlchemy-Fixture
@rduplain
rduplain / MainActivity.java
Created May 8, 2012 20:08
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
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 {
@rduplain
rduplain / README.md
Last active December 6, 2023 15:08
Demo of the Python `code` module, for interaction and DSLs.

import code

This is a demonstration of the Python [code][1] module, which allows for an interactive interpreter to be embedded into a Python program.

code.interact(banner=None, readfunc=None, local=None)

Convenience function to run a read-eval-print loop. This creates a new instance of [InteractiveConsole][2] and sets readfunc to be used as the

@rduplain
rduplain / app.py
Created May 20, 2012 16:45
Add a second static directory to Flask, in ../static/.
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 / zwave-js-zooz-paddle-scene-control.yaml
Last active January 3, 2023 01:40
Z-Wave JS Zooz Paddle Scene Control (ZEN21/ZEN22/ZEN27/..., forked from https://community.home-assistant.io/t/zooz-zen27/303161)
blueprint:
name: Zooz Paddle Scene Control (Z-Wave JS)
description: Zooz Dimmer/Switch Paddle Scene Control (ZEN21/ZEN22/ZEN27/...)
domain: automation
input:
switch:
name: Zooz Device
description: Paddle supporting up/down 1-5x presses. Note that scene control adds actions to run alongside default behavior (and does not replace defaults).
selector:
device:
blueprint:
name: Hank Four-button Scene Controller (Z-Wave JS)
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 / zwave-js-zooz-zen32.yaml
Last active December 28, 2022 23:22 — forked from Matt-PMCT/ZoozZen32forZwaveJs.yaml
Zooz ZEN32 for Z-Wave JS integration
# Copied from blhoward2 at https://community.home-assistant.io/t/zen32-scene-controller-z-wave-js/292610/8?u=mattmattmattmatt
# Modified by MattMattMattMatt for clarity on button / scene associations.
blueprint:
name: ZEN32 (Z-Wave JS)
description: Create automations for the Zooz ZEN32 switch using the Z-Wave JS integration.
domain: automation
input:
zooz_switch:
name: Zooz Switch
description: List of available Zooz ZEN32 switches.