Skip to content

Instantly share code, notes, and snippets.

View courtarro's full-sized avatar

Ethan Trewhitt courtarro

View GitHub Profile
@courtarro
courtarro / BetterMatcher.java
Last active December 16, 2015 21:09
Wrapper for Java's Matcher object that implements the basic MatchResult interface and provides a convenient one-call version of matches() for use in if-elseif-else statements
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Wrapper for the built-in object Matcher that runs a pattern matcher and saves
* the results in the same method call. Call matches() first to set up the
* internal matcher, then call the other methods to operate on the results.
*
* @author Ethan Trewhitt
@courtarro
courtarro / pixel_weights.py
Created April 22, 2015 18:57
Pixel weight calculator
import numpy as np
# Author: Ethan Trewhitt <ethan@trewhitt.org>
#
# Given a space of dimension 'dims', determine the length of a line segment between p1 and p2 in terms of its length within
# every pixel in the space. Yields a NumPy array of shape 'dims' where each value is the length of the line segment through
# the corresponding pixel. Maximum output value is sqrt(2), which means the segment went from one corner of the pixel to the
# other. Minimum output value is 0, which means the line segment did not go through that pixel.
#
# dims = NumPy compatible dimension specification (duple)
@courtarro
courtarro / PermChecker.cs
Last active September 22, 2015 19:04
Recursively reads an entire directory tree and lists any permissions that are not inherited from the parent directory.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
namespace PermCheck {
class PermChecker {
Queue<string> paths = new Queue<string>();
@courtarro
courtarro / server.py
Last active January 20, 2016 06:42
Simple Tornado-based webserver for Python
#!/usr/bin/env python
import threading
import time
import tornado.ioloop
import tornado.web
LISTEN_PORT = 8000
class FancyStaticFileHandler(tornado.web.StaticFileHandler):
#include <iostream>
#include "rapidjson/document.h"
#include "rapidjson/pointer.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
/*
Evaluates the deep copy abilities of rapidjson when operating on an entire document.
Output text should match this:

Keybase proof

I hereby claim:

  • I am courtarro on github.
  • I am courtarro (https://keybase.io/courtarro) on keybase.
  • I have a public key whose fingerprint is 8D6F BAD9 461E 928C 7A2E 2138 1EAA A170 DD5A 50E9

To claim this, I am signing this object:

@courtarro
courtarro / 3drsolo.md
Last active February 19, 2017 23:32
3DR Solo Hacking Notes

Connect to a 3DR Solo via MavProxy from a PC

Here's the magic command. This assumes you're on the Solo controller's wifi network.

mavproxy.py --master=udpout:10.1.1.10:14560 --streamrate=1 --mav10

This communicates directly with the Solo's telem_forwarder. If you want to test your command abilities, try these commands without propellers attached:

mode alt_hold

arm throttle

@courtarro
courtarro / solo-services.md
Created February 19, 2017 23:34 — forked from vo/solo-services.md
Solo Network Services / Ports

3DR Solo Network Services / Ports

  • 5005 - Radio control joystick data - pixrc process on the Solo listens to this for rc joystick messages
  • 5010 - Config Stick Axes Msg
  • 5011 - Param Stored Values Msg
  • 5012 - sysDestPort?
  • 5013 - pairReqPort - stm32 process on Artoo listens to pair requests from the pair_server process
  • 5014 - pairReqDestPort - stm32 process on Artoo sends to this port on the pair_server process
  • 5015 - mavDestPort - stm32 process receives telemetry from the telem_ctrl process here
  • 5016 - buttonEventPort (TCP) - Subscribe to button events on the Artoo (pause, home, A, B, etc) by connecting to this port on the Artoo.
@courtarro
courtarro / list-packages.sh
Created October 19, 2017 20:23
List all user-installed packages in OpenWRT / LEDE without dependencies or packages that are included with the firmware
#!/bin/sh
# Original source: https://gist.github.com/devkid/8d4c2a5ab62e690772f3d9de5ad2d978#gistcomment-2223412
FLASH_TIME="$(awk '
$1 == "Installed-Time:" && ($2 < OLDEST || OLDEST=="") {
OLDEST=$2
}
END {
print OLDEST
}
@courtarro
courtarro / xbee_zha_settings.md
Created February 19, 2018 20:01
XBee settings for Zigbee Home Automation (ZHA)

According to https://forms.na1.netsuite.com/app/site/hosting/scriptlet.nl?script=457&deploy=2&compid=818164&h=5928a16f2b6f9582b799&article=zigbee-home-automation

When developing a Zigbee Home Automation application or Wanting to talk with a Zigbee Home Automation Device, the XBee module you should select is the XBee ZB SMT module or XBee ZB (Zigbee) Surface Mount module.

Using our XCTU software or some other Terminal Emulator or processor, the following settings within the XBee ZB SMT module would need to be set:

  • ZS 2
  • AP 1
  • AO 3
  • EE 1