Skip to content

Instantly share code, notes, and snippets.

@matthewlmcclure
matthewlmcclure / 0_reuse_code.js
Created Jan 18, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@matthewlmcclure
matthewlmcclure / kill-processes-orphaned-by-jenkins.sh
Last active Jan 3, 2016
Kill processes orphaned by Jenkins
View kill-processes-orphaned-by-jenkins.sh
#! /bin/bash
# Kill processes orphaned by Jenkins
# Work around Java's use of SIGTERM rather than SIGKILL and
# Jenkins's lack of any workaroud in the box.
# Suggested usage:
#
# $ crontab -l
@matthewlmcclure
matthewlmcclure / mock.py.diff
Last active Dec 20, 2015
Log information about the objects replaced by Python Mock, patch. Combine with similar logging in your application to debug patching.
View mock.py.diff
--- mock.py~ 2013-07-31 13:20:48.000000000 -0400
+++ mock.py 2013-07-31 17:43:13.000000000 -0400
@@ -32,9 +32,12 @@
__version__ = '0.8.0'
+import logging
import pprint
import sys
@matthewlmcclure
matthewlmcclure / gist:6124117
Created Jul 31, 2013
Log information about the objects replaced by Python Mock, patch. Combine with similar logging in your application to debug patching.
View gist:6124117
--- mock.py~ 2013-07-31 13:20:48.000000000 -0400
+++ mock.py 2013-07-31 13:19:57.000000000 -0400
@@ -32,9 +32,12 @@
__version__ = '0.8.0'
+import logging
import pprint
import sys
@matthewlmcclure
matthewlmcclure / requestascurl.py
Created Jul 12, 2013
Return a curl command string view of a Requests PreparedRequest
View requestascurl.py
def headers_as_curl(headers):
header_args = [
" -H '{key}: {value}'".format(key=key, value=value)
for key, value in headers.iteritems()
]
return ''.join(header_args)
def request_as_curl(preparedrequest):
body = preparedrequest.body if preparedrequest.body else ''
return (
@matthewlmcclure
matthewlmcclure / less.diff
Created Jun 19, 2013
Add incremental search to less. 2013-06-19-02
View less.diff
===================================================================
RCS file: RCS/command.c,v
retrieving revision 1.92
diff -u -r1.92 command.c
--- command.c 2012/07/03 20:10:42 1.92
+++ command.c 2013/06/19 19:37:59
@@ -47,6 +47,8 @@
extern int shift_count;
extern int oldbot;
extern int forw_prompt;
View less.diff
===================================================================
RCS file: RCS/command.c,v
retrieving revision 1.92
diff -u -r1.92 command.c
--- command.c 2012/07/03 20:10:42 1.92
+++ command.c 2013/06/18 23:41:09
@@ -47,6 +47,8 @@
extern int shift_count;
extern int oldbot;
extern int forw_prompt;
@matthewlmcclure
matthewlmcclure / twitter-card-apple-smart-app-banner-ideas.md
Last active Dec 15, 2015
Alternative to Twitter Cards and Apple Smart App Banners
View twitter-card-apple-smart-app-banner-ideas.md
View traceroute 216.81.59.173
[mlm@matt-mmf-macbook.local:~]
$ traceroute 216.81.59.173
traceroute to 216.81.59.173 (216.81.59.173), 64 hops max, 52 byte packets
1 wireless_broadband_router (192.168.1.1) 4.116 ms 0.904 ms 0.913 ms
2 l100.bstnma-vfttp-101.verizon-gni.net (98.110.164.1) 6.852 ms 8.155 ms 9.306 ms
3 g4-3-1801.bstnma-lcr-08.verizon-gni.net (130.81.110.44) 7.124 ms 9.601 ms 9.414 ms
4 so-0-3-0-0.bos-bb-rtr2.verizon-gni.net (130.81.29.254) 7.097 ms 9.724 ms 10.282 ms
5 ge-1-2-0-0.ny325-bb-rtr2.verizon-gni.net (130.81.17.24) 18.991 ms 14.711 ms 14.847 ms
6 0.xe-2-0-8.xt2.nyc4.alter.net (152.63.6.253) 22.222 ms 96.148 ms 38.804 ms
7 tengige0-6-1-0.gw8.nyc4.alter.net (152.63.21.113) 19.362 ms
@matthewlmcclure
matthewlmcclure / gist:4158502
Created Nov 28, 2012
Example using curlish with OAuth 1 / RFC 5489
View gist:4158502
(rfc5849) mlm@matt-mmf-macbook.local:~/Downloads/src/curlish-eeb8e55
$ python curlish.py https://api.twitter.com/1.1/statuses/home_timeline.json
DEBUG:oauthlib.oauth1.rfc5849:Collected params: [(u'oauth_nonce', u'121349683856765093761354066233'), (u'oauth_timestamp', u'1354066233'), (u'oauth_consumer_key', u'...'), (u'oauth_signature_method', u'HMAC-SHA1'), (u'oauth_version', u'1.0'), (u'oauth_callback', u'http://127.0.0.1:62231/')]
DEBUG:oauthlib.oauth1.rfc5849:Normalized params: oauth_callback=http%3A%2F%2F127.0.0.1%3A62231%2F&oauth_consumer_key=...&oauth_nonce=121349683856765093761354066233&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1354066233&oauth_version=1.0
DEBUG:oauthlib.oauth1.rfc5849:Normalized URI: https://api.twitter.com/oauth/request_token
DEBUG:oauthlib.oauth1.rfc5849:Base signing string: POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252F127.0.0.1%253A62231%252F%26oauth_consumer_key%3D...%26oauth_nonce%3D121349683856765093761354066233%26oauth_si