Skip to content

Instantly share code, notes, and snippets.

View 0xD34D's full-sized avatar

Clark Scheff 0xD34D

View GitHub Profile
function wordwrap( str, width, brk, cut ) {
brk = brk || '\n';
width = width || 75;
cut = cut || false;
if (!str) { return str; }
var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)');
matches = str.match( new RegExp(regex, 'g') );
@0xD34D
0xD34D / MotionDetectorTest.cpp
Last active August 29, 2015 14:15
Program for testing a PIR module on the Intel Edison
/*
* Author: Clark Scheff <clark@scheffsblend.com>
* Copyright (c) 2015 Scheff's Blend
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
#!/bin/bash
EXPECTED_ARGS=1
E_BADARGS=42
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage `basename $0` project_name"
exit $E_BADARGS
fi
@0xD34D
0xD34D / ListenerStatusObserver.java
Last active September 11, 2017 13:34
Listen for when your app is allowed or denied to listen for notifications
/**
* This is just a simple ContentObserver class used to listen for
* changes to the list of enabled notification listeners.
* You'll need to create an instance of this class and call observe()
* to listen for changes and unobserve() when you no longer need it.
*/
class ListenerStatusObserver extends ContentObserver {
/**
* Note: Settings.Secure.ENABLED_NOTIFICATION_LISTENERS is hidden from
* the public API so you'll want to replace it with the actual string
@0xD34D
0xD34D / mass_review.py
Created August 29, 2013 18:40
A python script for conveniently reviewing all open changes in a gerrit project
#!/bin/sh
""":"
exec python $0 ${1+"$@"}
"""
# mass review all open commits for a project.
# you will need to specify extra arguments like --code-review, --verified, --submit
#
# The following example will +1 and verify all commits for android_frameworks_base:
# mass_review.py android_frameworks_base --code-review 1 --verified 1
@0xD34D
0xD34D / generate_comic_book.py
Last active January 9, 2019 21:12
Generate .cbz comic books from readcomics.tv
#!/usr/bin/env python3
from lxml import html
import os
import requests
import shutil
import sys
from urllib import request
from zipfile import ZipFile
AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'
@0xD34D
0xD34D / mass_gerrit_pick.py
Last active September 27, 2019 02:26
A simple python script to mass pick open changes from gerrit in order based on dependencies.
#!/bin/sh
""":"
exec python $0 ${1+"$@"}
"""
# Author: Clark Scheff
#
# Picks all open commits for a given project in the correct
# order based on their dependencies. There is plenty of
# room for improvments but this does work as intended.
#
@0xD34D
0xD34D / battery_meter_demo.sh
Created August 16, 2016 15:21
battery meter demo for CM
#!/bin/bash
adb shell 'dumpsys batterymanager unplug;settings --cm put system status_bar_battery_style 0;sleep 0.5;for i in $(seq 100 -1 16);do dumpsys batterymanager set level $i;sleep 0.05;done;for i in $(seq 16 100);do dumpsys batterymanager set level $i;sleep 0.05;done;settings --cm put system status_bar_battery_style 5;sleep 0.5;for i in $(seq 100 -1 16);do dumpsys batterymanager set level $i;sleep 0.05;done;for i in $(seq 16 100);do dumpsys batterymanager set level $i;sleep 0.05;done;settings --cm put system status_bar_battery_style 2;sleep 1;for i in $(seq 100 -1 16);do dumpsys batterymanager set level $i;sleep 0.05;done;for i in $(seq 16 100);do dumpsys batterymanager set level $i;sleep 0.05;done;dumpsys batterymanager reset'
@0xD34D
0xD34D / runout.cfg
Created September 9, 2023 02:11
Filament sensor config for Ender-3 v3 SE hooked up to z-limit port
[filament_switch_sensor RunoutSensor]
switch_pin: ^PA15
pause_on_runout: True
pause_delay: 3.0
runout_gcode: PAUSE
#insert_gcode: RESUME
@0xD34D
0xD34D / gist:31b78144c7e29e0141c4696999c7af48
Created January 16, 2024 03:58
strings prtouch_v2_wrapper.cpython-38-mipsel-linux-gnu.so
init extras.prtouch_v2_wrapper
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_SELF_CHECK_PRTOUCH
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_TRIG_TEST
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_ACCURATE_HOME_Z
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_SAFE_MOVE_Z
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_PRTOUCH_READY
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_START_STEP_PRTOUCH
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_CHECK_BED_MESH
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_NOZZLE_CLEAR
extras.prtouch_v2_wrapper.PRTouchEndstopWrapper.cmd_DEAL_AVGS