Skip to content

Instantly share code, notes, and snippets.

View mikedamage's full-sized avatar

Mike Green mikedamage

View GitHub Profile
@mikedamage
mikedamage / harvest-growler.user.js
Created November 17, 2010 19:29
Fluid userscript for Harvest Timer app. Pops a Growl notification every so often to remind me to track my hours if no timer is currently running.
// ==UserScript==
// @name Harvest Timer Growl Reminder
// @namespace http://harvestapp.com
// @description Displays Growl notifications at a user defined interval, reminding you to track your time.
// @include *
// @author Mike Green
// @version 0.1.1
// ==/UserScript==
(function () {
@mikedamage
mikedamage / email-ping.rb
Last active December 2, 2023 13:10
Ping an email address to see if it exists. This script resolves MX records to find the SMTP server responsible for delivering mail to the address, connects to it, and starts to send a message to the address. It disconnects before the message is sent.
#!/usr/bin/env ruby
#
# = Email Ping
#
# Check to see if an email address exists by looking up MX records and connecting
# to the address's home SMTP server. It then starts to send a message to the address
# but quits before the message is actually sent.
require 'resolv'
require 'net/smtp'
@mikedamage
mikedamage / morse_code_dictionary.rb
Last active October 20, 2023 20:41
Morse code dictionary as a Ruby Hash object
morse_dict = {
"a" => ".-",
"b" => "-...",
"c" => "-.-.",
"d" => "-..",
"e" => ".",
"f" => "..-.",
"g" => "--.",
"h" => "....",
"i" => "..",
@mikedamage
mikedamage / serial-eventmachine.rb
Created February 14, 2010 21:01
EventMachine over Serial Port
# from http://rubyeventmachine.com/wiki/CodeSnippets
$eventmachine_library = :pure_ruby # need to force pure ruby
require 'eventmachine'
gem_original_require 'serialport'
require 'smsrelay/gsmpdu'
module EventMachine
class EvmaSerialPort < StreamObject
def self.open(dev, baud, databits, stopbits, parity)
io = SerialPort.new(dev, baud, databits, stopbits, parity)
@mikedamage
mikedamage / split_str.sql
Created January 15, 2010 03:24
MySQL string split function
-- SPLIT_STR MySQL Function
-- from http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/
CREATE FUNCTION SPLIT_STR(
x VARCHAR(255),
delim VARCHAR(12),
pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
@mikedamage
mikedamage / robots.txt
Created September 28, 2011 23:02
Boilerplate WordPress robots.txt
User-agent: *
Disallow: /cgi-bin
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content/plugins
Disallow: /wp-content/cache
Disallow: /wp-content/themes
Disallow: /trackback
Disallow: /feed
Disallow: /comments
@mikedamage
mikedamage / stdin-bytes.js
Created April 25, 2022 20:06
Get size of piped STDIN in Node
#!/usr/bin/env node
// Borrowed and simplified from pretty-bytes by Sindre Sorhus
// https://github.com/sindresorhus/pretty-bytes/blob/main/index.js
function prettyBytes(num) {
const UNITS = [
'b',
'kb',
'mb',
'gb',
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property

Keybase proof

I hereby claim:

  • I am mikedamage on github.
  • I am mikegreen (https://keybase.io/mikegreen) on keybase.
  • I have a public key whose fingerprint is 9D26 EDB9 CD61 8734 7B20 8B7F 5369 495C F7A1 2392

To claim this, I am signing this object:

@mikedamage
mikedamage / gist-copy.cmd.js
Created February 7, 2009 04:19
Get a Gist by ID and copy to clipboard.
// Get & copy a Gist by ID
CmdUtils.CreateCommand({
name: "gist-copy",
icon: "http://gist.github.com/favicon.ico",
author: {name: "Mike Green", email: "mike.is.green@gmail.com"},
takes: {"gist": noun_arb_text},
preview: function(pblock, theGist) {
var urlTemplate = "http://gist.github.com/${gist}.txt";
var gistURL = CmdUtils.renderTemplate(urlTemplate, {gist: theGist.text});
CmdUtils.previewGet(pblock, gistURL, {}, function(data) {