Skip to content

Instantly share code, notes, and snippets.

View scottgwald's full-sized avatar

Scott W. Greenwald scottgwald

View GitHub Profile
@scottgwald
scottgwald / argparse_with_default.py
Last active December 24, 2015 20:59
use argparse when args are present, run default main() otherwise
if len(sys.argv) > 1:
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
subparser = subparsers.add_parser('easter_egg')
subparser.set_defaults(func=easter_egg)
args = parser.parse_args()
args.func(**vars(args))
else:
main()
@scottgwald
scottgwald / adb_revoke_root.sh
Last active March 28, 2020 20:25
restart adbd as non-root
# warning: may fail (`adb devices` subsequently doesn't show the device).
# If so, then restart device.
adb shell setprop service.adb.root 0
adb shell "stop adbd && start adbd"
@scottgwald
scottgwald / logcat_monitor.py
Last active May 15, 2023 08:00
monitor logcat for a string match
#! /usr/bin/env python
# from http://stackoverflow.com/questions/11524586/accessing-logcat-from-android-via-python
import Queue
import subprocess
import threading
import datetime
class AsynchronousFileReader(threading.Thread):
'''
@scottgwald
scottgwald / sensor_log.html
Created October 9, 2013 05:31
wearscript to draw sensor values in webview
<html style="width:100%; height:100%; overflow:hidden">
<head>
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<h2>
<span id="lat"></span>,
<span id="lng"></span>,
<span id="deg"></span>
</h2>
<h2>
@scottgwald
scottgwald / colors.html
Created October 9, 2013 20:08
WearScripts
<html style="width:100%; height:100%; overflow:hidden">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="wearscript.js"></script>
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block">
</canvas>
@scottgwald
scottgwald / config.go
Last active December 28, 2015 19:39
example config.go
package main
const (
// You can leave these
version = 0 // Defines the websocket protocol version
debug = true // Set to false to turn off logging every API request.
allowAllUsers = true // If true then all users who auth can access the server, false admin must verify
sessionName = "wearscript"
scopes = "https://www.googleapis.com/auth/userinfo.profile"
ravenDSN = "" // Leave blank unless you are using Raven/Sentry for logging
@scottgwald
scottgwald / config.go.local
Created November 19, 2013 20:57
local config.go
package main
const (
// You can leave these
version = 0 // Defines the websocket protocol version
debug = true // Set to false to turn off logging every API request.
allowAllUsers = true // If true then all users who auth can access the server, false admin must verify
sessionName = "wearscript"
scopes = "https://www.googleapis.com/auth/userinfo.profile"
ravenDSN = "" // Leave blank unless you are using Raven/Sentry for logging
@scottgwald
scottgwald / glassdata.html
Last active December 29, 2015 14:38
Send data from Glass to a python server. Uses the Go server as an intermediary. #wearscript
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
function server() {
WS.say('About to send some data.');
WS.blobSend('glassdata', 'Some nonsense 234234');
}
function main() {
if (WS.scriptVersion(0)) return;
@scottgwald
scottgwald / AndroidManifest.xml
Created December 2, 2013 01:22
basic video capture in android
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.openshades.wearvideo"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
@scottgwald
scottgwald / takePhotoAndShow.html
Created January 8, 2014 06:52
take photo and show
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<img id="image" width="640" height="360" />
<script>
function photoPath(data) {
WS.say("I got your photo");
img = document.getElementById("image");
img.src = data;
}