Skip to content

Instantly share code, notes, and snippets.

@kylewm
kylewm / tld-regex.txt
Created January 28, 2016 22:00
Regex matching all TLDs
(?: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(?
@kylewm
kylewm / compilers_ast_to_dot.java
Created November 4, 2012 16:04
export AST to GraphViz DOT file
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.lang.reflect.Field;
public class AstToDot {
/**
* @param args
* @throws Exception
@kylewm
kylewm / known-nginx-config
Last active April 19, 2017 09:19
my Known configuration for nginx
server {
listen 80;
root /home/vagrant/idno;
index index.php;
server_name vagrant.dev;
location ~ (\.ini|known.php)$ {
deny all;
}
#!/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 / GradleDependencyExample.md
Last active December 21, 2015 11:19
Gradle: question about dependency on an alternate configuration within a multi-project build

settings.gradle:

include 'core'
include 'plugin'

build.gradle:

project('core') {
 apply plugin: 'java'
@kylewm
kylewm / gist:5613537
Created May 20, 2013 16:53
Testing gradle duplicate handling behavior
package org.gradle.api.internal.file.copy
import org.gradle.api.Project
import org.gradle.api.file.FileTree
import org.gradle.api.file.FileVisitDetails
import org.gradle.api.file.RelativePath
import org.gradle.testfixtures.ProjectBuilder
import spock.lang.Shared
import spock.lang.Specification
public class DynamicDispatch {
interface GeometricValue {
void intersects(GeometricValue v);
}
static class Point implements GeometricValue {
@Override
public void intersects(GeometricValue v) {
throw new UnsupportedOperationException();
@kylewm
kylewm / gist:4978663
Last active December 13, 2015 21:38
For "Java Infinite Streams" discussion on Coursera
class Cons<T, R> {
T car;
R cdr;
Cons(T car, R cdr) {
this.car = car;
this.cdr = cdr;
}
>>> 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 / BuildWithCMakeMojo.java
Created December 10, 2012 04:25
First attempt at a Maven plugin that delegates to CMake
import java.io.*;
import java.util.*;
import org.apache.maven.plugin.*;
import org.apache.maven.plugin.logging.Log;
/**
*
* @author kmahan