Skip to content

Instantly share code, notes, and snippets.

Kyle Mahan kylewm

Block or report user

Report or block kylewm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View get_micropub_access_token.py
#!/bin/python
import requests
from bs4 import BeautifulSoup
from urllib.parse import urlencode, parse_qs
def get_endpoints(url):
r = requests.get(url)
soup = BeautifulSoup(r.text)
@kylewm
kylewm / tld-regex.txt
Created Jan 28, 2016
Regex matching all TLDs
View tld-regex.txt
(?:a(?:a(?:a|rp)|b(?:b(?:ott)?|ogado)|c(?:ademy|c(?:enture|ountant(?:s)?)|o|t(?:ive|or))?|d(?:ac|s|ult)?|e(?:g|ro)?|f(?:l)?|g(?:ency)?|i(?:g|r(?:force|tel))?|l(?:i(?:baba|pay)|lfinanz|sace)?|m(?:ica|sterdam)?|n(?:alytics|droid)|o|p(?:artments|p(?:le)?)|q(?:uarelle)?|r(?:amco|chi|my|pa|te)?|s(?:ia|sociates)?|t(?:torney)?|u(?:ction|di(?:o)?|t(?:hor|o(?:s)?))?|w|x(?:a)?|z(?:ure)?)|b(?:a(?:idu|n(?:d|k)|r(?:c(?:elona|lay(?:card|s))|gains)?|uhaus|yern)?|b(?:c|va)?|cn|d|e(?:ats|er|ntley|rlin|st|t)?|f|g|h(?:arti)?|i(?:ble|d|ke|ng(?:o)?|o|z)?|j|l(?:ack(?:friday)?|oomberg|ue)|m(?:s|w)?|n(?:l|pparibas)?|o(?:ats|ehringer|m|nd|o(?:k|ts)?|s(?:ch|tik)|t|utique)?|r(?:adesco|idgestone|o(?:adway|ker|ther)|ussels)?|s|t|u(?:dapest|gatti|ild(?:ers)?|siness|y|zz)|v|w|y|z(?:h)?)|c(?:a(?:b|fe|l(?:l)?|m(?:era|p)|n(?:cerresearch|on)|p(?:etown|ital)|r(?:avan|ds|e(?:er(?:s)?)?|s|tier)?|s(?:a|h|ino)|t(?:ering)?)?|b(?:a|n)|c|d|e(?:b|nter|o|rn)|f(?:a|d)?|g|h(?:a(?:n(?:el|nel)|t)|eap|loe|r(?:istmas|ome)|urch)?|i(?:priani|rcle|sco|t(?:ic|y(?
View gist:89fe76aeb6e32af8146b
>>> from bs4 import BeautifulSoup
>>> import requests
>>> soup = BeautifulSoup(requests.get('https://snarfed.org/2015-04-18_kyle-mahan-checked-in-to-nourse-theatre').text)
>>> soup.body.div.find_all()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/srv/www/kylewm.com/redwind/venv/lib/python3.4/site-packages/bs4/element.py", line 1180, in find_all
return self._find_all(name, attrs, text, limit, generator, **kwargs)
File "/srv/www/kylewm.com/redwind/venv/lib/python3.4/site-packages/bs4/element.py", line 491, in _find_all
return ResultSet(strainer, result)
@kylewm
kylewm / reply.js
Created Apr 9, 2015
Tweet-aware reply bookmarklet
View reply.js
javascript:
(function(){
var url=window.location;
if(url.hostname=='twitter.com'&&url.pathname=='/'){
var openedTweet=document.querySelector('.opened-tweet');
if(openedTweet&&openedTweet.dataset.permalinkPath){
url='https://twitter.com'+openedTweet.dataset.permalinkPath;
}
}
window.open('https://kylewm.com/new/reply?url='+url,'_blank')
@kylewm
kylewm / gist:451c59261e3a749b0536
Last active Aug 29, 2015
Nginx configuration for Websockets
View gist:451c59261e3a749b0536
location /_updates {
proxy_pass http://localhost:8077;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400s;
}
@kylewm
kylewm / bridgy-so-draft.md
Last active Aug 29, 2015
bridgy stackoverflow question
View bridgy-so-draft.md

Facebook Graph API: Find graph object from post URL

Given the URL of a public Facebook post, how can one find the post object in the FB Graph API?

We would like to be able to comment on or like a post via the v2.x Graph API, given the post's URL. Doing so requires the post's object ID, which we can make some educated guesses about, but accessing the actual object through the API has proven unreliable (works for some posts but not others).

@kylewm
kylewm / nginx-configuration
Created Dec 20, 2014
redwind-pilbox-setup
View nginx-configuration
proxy_cache_path /srv/www/kylewm.com/cache keys_zone=one:10m max_size=500m;
...
server {
listen 443 ssl;
server_name kylewm.com;
...
@kylewm
kylewm / known-nginx-config
Last active Apr 19, 2017
my Known configuration for nginx
View known-nginx-config
server {
listen 80;
root /home/vagrant/idno;
index index.php;
server_name vagrant.dev;
location ~ (\.ini|known.php)$ {
deny all;
}
@kylewm
kylewm / indie-config.js
Last active Aug 29, 2015
Loads indie-config and if available, apply handlers to <indie-action> tags
View indie-config.js
// Lazy-create and return an indie-config load promise
// The promise will be resolved with a config once the indie-config has been loaded
var loadIndieConfig = function () {
// Create the Promise to return
var loadPromise = new Promise(function (resolve) {
// Parse the incoming messages
var parseIndieConfig = function (message) {
View keybase.md

Keybase proof

I hereby claim:

  • I am kylewm on github.
  • I am kylewm (https://keybase.io/kylewm) on keybase.
  • I have a public key whose fingerprint is D718 74E3 40FB 85B1 21BE 04E6 03AA A9DA C3F7 73CB

To claim this, I am signing this object:

You can’t perform that action at this time.