Skip to content

Instantly share code, notes, and snippets.

@pdxmph
pdxmph / vowels_and_consonants_and_fractions.rb
Created May 2, 2013 04:47
Yes. This helped my child do his homework this evening.
#!/usr/bin/ruby
dict = File.read("/Users/mike/Desktop/dict.txt")
word_list = [[2,2],[4,3],[3,3],[5,3],[3,2],[2,3],[2,1]]
word_list.each do |a|
consonants = a[0]
vowels = a[1]
word_length = a[0] + a[1]
@pdxmph
pdxmph / ssh_init.pp
Created May 24, 2013 17:41
A simple Puppet manifest you can use to manage sshd configuration. The "file" stanza controls the owner, group, permissions and content of the sshd file. Note how line 13 (`source`) uses the `operatingsystem` fact to name the file to provide to the agent. The "service" stanza ensures that sshd is running on the agent system, so you'll always be …
# === Authors
# Author Name <[email protected]>
#
# === Copyright
# Copyright 2013 Puppet Labs
#
class ssh {
file { '/etc/ssh/sshd_config':
ensure => present,
owner => 'root',
@pdxmph
pdxmph / maxping.rb
Last active December 23, 2015 02:29
So, it'd be nice if I could get an unsolicited ping about upcoming Max arrivals at my two most used stations in the morning, when I'm getting ready to go to work, and in the afternoon when it's almost time to go. It'd also be nice if there were a way to tell the unsolicited ping to shut up. This does that using an ifttt recipe (so I can append a…
#!/usr/bin/env ruby
require 'json'
require 'time'
require 'net/http'
require 'pushover'
# trimet stop ids for easy expansion to other stops
stops = {"lents" => 13135, "union" => 7763}
@pdxmph
pdxmph / Set Evernote Reminder.applescript
Created October 12, 2013 19:10
Gets selected Evernote note(s) and adds a reminder date to them (effectively turning them into todos)
set myRemind to (current date) + 1 * days
tell application "Evernote"
set myNotes to selection
repeat with theNote in myNotes
set the reminder time of theNote to myRemind
end repeat
@pdxmph
pdxmph / Current Net Radio from iTunes to Evernote.applescript
Created October 14, 2013 02:28
Grabs the current track info from the playing Internet stream on iTunes and makes an Evernote note out of it, tagged "music"
tell application "iTunes"
set myURL to the current stream URL
set myStream to the current stream title
set myLabel to myStream & " -- " & myURL
tell application "Evernote"
set myNewNote to create note title myLabel with text "" tags {"music"}
set the source URL of myNewNote to myURL
end tell
end tell
@pdxmph
pdxmph / Net Radio to Things.rb
Created October 14, 2013 02:29
Get the current 'net radio track info from iTunes, make it a todo in Things
#!/usr/bin/env ruby
require "rubygems"
require "appscript"
include Appscript
itunes = app("iTunes")
things = app("Things")
list = "Things to Look Up"
project = things.projects[list]
activate application "Password Generator"
tell application "System Events"
tell process "Password Generator"
set value of text field 1 of tab group 1 of window "Password Generator" to "7"
select checkbox "A-Z" of tab group 1 of window "Password Generator"
select checkbox "0-9" of tab group 1 of window "Password Generator"
select checkbox "a-z" of tab group 1 of window "Password Generator"
click button "Generate" of window "Password Generator"
click button "Copy" of window "Password Generator"
click button 1 of window "Password Generator"
@pdxmph
pdxmph / sprint_animals.rb
Last active August 29, 2015 14:07
Sprint Animal Namerator
#!/usr/bin/ruby
require 'sentimental'
require 'sinatra'
require 'searchbing'
#sprint_letter = ARGV[0]
Sentimental.load_defaults
Sentimental.threshold = 0.5
analyzer = Sentimental.new
@pdxmph
pdxmph / Things2Org.applescript
Created November 16, 2014 22:46
Convert all your Things projects to org mode projects and todos. Understands tags (converts to org-mode-style colon-delimited lists), due dates (converts to deadlines), status (converts "open" to "todo", "completed" to "DONE" and "canceled" to "CANCELED")
tell application "Things"
set myOrgOutput to ""
repeat with theProject in projects
set myName to the name of theProject & return
set myTasks to the to dos of theProject
set myOrgOutput to myOrgOutput & return & return & "* " & myName
repeat with myTodo in myTasks
@pdxmph
pdxmph / mutt_macros.md
Created December 23, 2014 23:56
Some handy mutt macros for this and that

Implement Lightweight Profiles to switch between email personae

Setup: Make personal.profile and work.profile files and use them to configure the things that are unique to each identity, e.g.

	# -*- muttrc -*-                                                                                                                                         
	# Mutt sender profile : personal/default                                                                                                                 

	# get us out of whatever default folder we're in																																																																								 
	unset folder