Skip to content

Instantly share code, notes, and snippets.

@troy
troy / 1_view_in_google_maps_bookmarklet.js
Last active Dec 11, 2020
Browser bookmarklet to view a highlighted venue name, highlighted street address, or the place about the current URL in Google Maps (where you can click Save to save it to a list)
View 1_view_in_google_maps_bookmarklet.js
javascript:( function() {q = window.getSelection().toString(); if (q.length == 0) {q = window.location.hostname.replace(/^www./,''); if (['instagram.com', 'facebook.com'].includes(q)) {q = window.location.hostname + '/' + window.location.pathname.split('/')[1] } else if (['yelp.com'].includes(q)) { q = document.title.split(' - ')[0] } } window.open('http://maps.google.com?q='+q.trim().replace(/\r\n|\r|\n/g,", ")); }) ();
@troy
troy / bookmarklet.js
Last active May 8, 2018
Seattle Public Library (SPL.org) search bookmarklet
View bookmarklet.js
javascript:(function(){window.open('https://www.spl.org/search?terms='+window.getSelection());})();
@troy
troy / search-on-spotify.js
Created Nov 29, 2015
Bookmarklet to search/play highlighted artist on Spotify Web Player
View search-on-spotify.js
javascript:window.location.href="https://play.spotify.com/search/"+encodeURIComponent(window.getSelection())
@troy
troy / Battery at Denny, northbound
Created Mar 22, 2015
Towards a graph of Seattle Metro delay by stop and route -- on-time ratings for routes
View Battery at Denny, northbound
13944 seconds ago: #16 (NORTHGATE WALLINGFORD) arrived -3454 seconds off.
16632 seconds ago: #5 (SHORELINE GREENWOOD) arrived 54 seconds off.
16005 seconds ago: #E Line (AURORA VILLAGE TRANSIT CENTER) arrived -102 seconds off.
15804 seconds ago: #16 (NORTHGATE WALLINGFORD) arrived 652 seconds off.
14205 seconds ago: #E Line (AURORA VILLAGE TRANSIT CENTER) arrived 76 seconds off.
13032 seconds ago: #5 (SHORELINE GREENWOOD) arrived 135 seconds off.
12705 seconds ago: #E Line (AURORA VILLAGE TRANSIT CENTER) arrived 114 seconds off.
12144 seconds ago: #16 (NORTHGATE WALLINGFORD) arrived 540 seconds off.
11232 seconds ago: #5 (SHORELINE GREENWOOD) arrived -27 seconds off.
10313 seconds ago: #16 (NORTHGATE WALLINGFORD) arrived 322 seconds off.
@troy
troy / 01papertrail.config
Last active Dec 12, 2015
Aggregate logs from AWS Elastic Beanstalk instances (Java, PHP, Ruby, etc.) to Papertrail without a custom AMI. (DEPRECATED)
View 01papertrail.config
# DEPRECATED
# You probably want one of these newer, better examples:
# http://help.papertrailapp.com/kb/hosting-services/amazon-elastic-beanstalk
# Credits:
# Jason Pirkey, Táve Corporation, http://www.tave.com/
# Jeremy Mickelson, https://github.com/CyborgMaster
# See http://help.papertrailapp.com/kb/hosting-services/amazon-elastic-beanstalk
@troy
troy / oneline_detailed_logging.rb
Created Aug 10, 2012
One-line detailed logging for Rails 3 (ActiveSupport::Notifications) and later
View oneline_detailed_logging.rb
# Outputs this at warn log level:
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]}
#
# Save as config/initializers/oneline_detailed_logging.rb. Consider
# decreasing the log level from "info" to "warn" (in production.rb) so
# the one-line log message replaces the standard request logs.
# override process_action to add 2 things to the payload:
# - remote IP
@troy
troy / send_remote_syslog.php
Last active Jan 28, 2021
Send UDP remote syslog message from PHP (RFC 3164)
View send_remote_syslog.php
# replace PAPERTRAIL_HOSTNAME and PAPERTRAIL_PORT
# see http://help.papertrailapp.com/ for additional PHP syslog options
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
foreach(explode("\n", $message) as $line) {
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT);
}
socket_close($sock);
@troy
troy / phone_call_to_webhook.json
Created Mar 19, 2010
Send a Growl, tweet, Jabber IM, or other webhook request from Cloudvox phone call API
View phone_call_to_webhook.json
[{"name":"onhangup","url":"http://api.notify.io/v1/notify/your_notifyio_id?api_key=your_source_api_key","method":"post","url_options":{"title":"Call","text":"from ${callerid}"}},
{"name":"onhangup","url":"http://watercoolr.nuklei.com/messages","method":"post","url_options":{"channel":"channel_id","message":"Cloudvox call from ${callerid}"}},
{"name":"speak","phrase":"in a moment, all of my notify.io recipients will know you've called. indeed."}]
View nytimes-malware-html-2.html
<!-- part of a security explanation - see
http://www.nytimes.com/2009/09/13/business/media/13note.html and
http://troy.yort.com/anatomy-of-a-malware-ad-on-nytimes-com -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My computer Online Scan</title>
<script type="text/javascript" src="img/jquery.js"></script>
View nytimes-malware-javascript-2.js
// part of a security explanation - see
// http://www.nytimes.com/2009/09/13/business/media/13note.html and
// http://troy.yort.com/anatomy-of-a-malware-ad-on-nytimes-com
if (top.location!= self.location) {
top.location = action_URL;
} else {
window.location = action_URL;
}