Instantly share code, notes, and snippets.

View bookmarklet.js
javascript:(function(){window.open('https://www.spl.org/search?terms='+window.getSelection());})();
View search-on-spotify.js
javascript:window.location.href="https://play.spotify.com/search/"+encodeURIComponent(window.getSelection())
View delete-completed-google-tasks.rb
# Google retains all Google Tasks forever, which is scary if you have years of completed
# tasks which have been hidden. To scare yourself, visit
# https://mail.google.com/tasks/canvas?pli=1 and click "Completed tasks" (upper right)
#
# This snippet deletes all hidden tasks. You may need to run it multiple times
# because the API only returns at most 100 rows per request.
# You'll have to setup an environment with an OAuth token, activesupport, etc,
# but this gist should show the API calls and arguments. Note that
# deleted tasks still remain for about 3 months:
# https://groups.google.com/d/msg/google-tasks-api/Zxs3734Ifzg/hWU0Ew337_QJ
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.
View gist:5e4f1c32e6cdc2d726cf
require "rubygems"
require "braintree"
# Rails v3.0+
require "active_support/core_ext"
require "faraday"
require "faraday_middleware"
# example output:
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
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
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);
View papertrail_webhook_test.rb
#!/usr/bin/ruby -w
# See http://help.papertrailapp.com/kb/how-it-works/web-hooks
require 'yajl'
require 'faraday'
class PapertrailWebhookRequest
def self.connection
Faraday::Connection.new
View ami-event-to-file.rb
#!/usr/bin/env ruby
# This needs the latest adhearsion gem
require 'adhearsion'
require 'adhearsion/logging'
require 'adhearsion/foundation/event_socket'
require 'adhearsion/foundation/pseudo_guid'
require 'adhearsion/foundation/string'
require 'adhearsion/foundation/future_resource'