Skip to content

Instantly share code, notes, and snippets.

@dougtoppin
dougtoppin / KindleReturn
Last active December 15, 2015 08:49
I regularly have a thunderbolt cinema display on my MacBook Pro with the Kindle app running on it for reference while I'm working on the MBP screen. To go to the next page on the Kindle I have to move the cursor, select the app and hit return. This is the start of coming up with an easier way to do that. Using shortcuts I added option-return to …
(*
Simple OSX ML Automator/Applescript to send a carriage return to a running Kindle app
*)
on run {input, parameters}
global okflag
set appname to "Kindle"
set okflag to false
tell application "System Events"
@dougtoppin
dougtoppin / ForeFlight.pl
Last active December 15, 2015 09:19
ForeFlight is an excellent iOS application for all aspects of aviation (planning, filing, monitoring, situational awareness, browsing, weather). It uses GPS (internal or external via bluetooth) for position data. It also supports external position data which means you can use ForeFlight to display data from something other than where you are. Th…
#!/usr/bin/perl
# ForeFlight.pl
# Simple perl script to send position data via udp to a running instance
# of the iOS ForeFlight aviation app.
# A description can be found at: http://foreflight.com/support/network-gps
# FF expects the following:
# - updates once a second
# - udp protocol
# - port 49002
@dougtoppin
dougtoppin / gist:6407432
Last active May 27, 2018 13:12
Simple example of using LeapMotion and Javascript in html to detect swipe gestures
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>LeapMotion Testing of Swipe</title>
<script src="http://js.leapmotion.com/0.2.0/leap.js"></script>
</head>
<body>
@dougtoppin
dougtoppin / gist:7903596
Created December 11, 2013 01:28
Capturing AWS Configuration Information Using the AWS cli
Over time I've developed a lot of AWS configuration informtion and I recently realized that I was not capturing it anywhere. I've made mods to my security groups once or twice and then did not have a record of what they were before the mod so I've been looking around for a way to get a record of it. What I've been able to come up with is to use the aws cli (command line interface) and do various describe commands to get it.
To find the commands you can do this:
aws ec2 help | grep describe-
You should see something like the following. It might not be the best way to do it but it's what I've come up with so far. You can do these in a script, save the output to a file and keep that in your cm system.
o describe-account-attributes
o describe-addresses
o describe-availability-zones
@dougtoppin
dougtoppin / applescript-readtextfile
Last active August 29, 2015 14:12
example of using AppleScript to read a text file with 4 tab delimited fields in it and echo the fields in each line
(*
example of using AppleScript to read a text file with 4 tab delimited fields in it and echo the fields in each line
example input lines (tabs between each field except blank between date and time):
1 field2 field3 2013-10-25 20:57:48
2 field2 field3 2013-11-18 02:53:34
Output should look something like:
(*item number: 1*)
@dougtoppin
dougtoppin / applescript-evernoteimport
Last active August 29, 2015 14:12
AppleScript script to read a text file and import each line as a note into Evernote
(*
example of using AppleScript to read a text file with 4 tab delimited fields in it, echo each field in each line and then send that
entry as a new note into Evernote in the notebook called ImportedNotes
Field 1 is just a record number and is not inserted into the note
Field 2 is treated as an Evernote tag (will also be tagged with 'imported_from_notes')
Field 3 is the text of the note
Field 4 is a timestamp in the format of mm/dd/yyyy, the note creation and modification dates will be set to this
example input lines (tabs between each field):
@dougtoppin
dougtoppin / Multivaluemap.java
Last active August 12, 2019 12:57
Simple example of using an apache commons MultiValueMap to store and retrieve entries with multiple values
package Multivaluemap1.multivaluemap;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import org.apache.commons.collections4.map.MultiValueMap;
/**
Postman is an exceptionally useful tool for testing ReST apis.
The following is an example of how to use the xml2Json method in a test if you are getting back xml and want to test elements in the response. The reason that I am posting this is that I could not get xml2Json to work until I discovered (using the new console in Version 4.7.2) that I needed the include the .$. in the object reference.
So that this is completely self contained all this is doing is setting an env var with an xml string, getting that
var, converting it to json and then evaluating the content.
postman.setEnvironmentVariable("testresponse", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><myResponse isError=\"false\"/>");
var xmlresponse = postman.getEnvironmentVariable("testresponse");
@dougtoppin
dougtoppin / rekognition.md
Last active June 7, 2018 09:17
Amazon rekognition service usage via the aws cli

Rekognition

Amazon announced their Rekognition image analysis service in Nov-2016. The documentation page at that time did not include a specific example of how to use it via the aws cli so I thought that it might be helpful to show an example.

The aws cli must already be setup and usable.

The picture is of my dog laying down and waiting for his dinner.

Replace bucketname and imagename with an s3 bucket and image file that are accessible to the cli.

@dougtoppin
dougtoppin / ytl-livestreaming.md
Created April 27, 2017 15:14
How to live stream an event using YouTube Live (previously Google Hangouts On Air)

Live Streaming Instructions

An event (such as a meetup) can be live streamed using the YouTube Live (YTL) service. This was originally called Google Hangouts On Air (GHOA) and was rebranded in 2016. The service is free and works very well.

YTL is very useful for live streaming because it makes the stream available via YT and automatically records and saves on YT.

Another advantage is that the event creator can select what will appear in the stream. This can be the presenter camera, desktop, window or if the presenter joins the YTL event they can stream from their desktop or a slide window. The event creator can then select the presenter stream to go in the output stream.