This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
urlnorm.py - URL normalisation routines | |
Ported to python3. | |
urlnorm normalises a URL by; | |
* lowercasing the scheme and hostname | |
* taking out default port if present (e.g., http://www.foo.com:80/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.core.magic import line_magic | |
from IPython.display import Math | |
@register_line_magic | |
def math(tex): | |
return Math(repr(eval(tex, get_ipython().user_ns))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import sys | |
import os | |
import re | |
import ctypes | |
import argparse | |
ulseek = ctypes.cdll['libc.so.6'].lseek | |
ulseek.restype = ctypes.c_uint64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=PHP FastCGI Server | |
After=syslog.target network.target remote-fs.target nss-lookup.target | |
[Service] | |
Type=forking | |
PIDFile=/run/php-fpm.pid | |
ExecStart=/usr/sbin/php-fpm --fpm-config /etc/php5/fpm/php-fpm.conf | |
ExecReload=/bin/kill -s HUP $MAINPID | |
ExecStop=/bin/kill -s QUIT $MAINPID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# (c) 2014, Juan Luis Boya García <ntrrgc () gmail.com> | |
# (c) 2012, Jan-Piet Mens <jpmens () gmail.com> | |
# | |
# This file is part of Ansible | |
# | |
# Ansible is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import shlex | |
if hasattr(shlex, "quote"): | |
# Python 3 | |
shquote = shlex.quote | |
else: | |
# Backport of shlex.quote for Python 2 | |
import re | |
_find_unsafe = re.compile(r'[^\w@%+=:,./-]').search |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Minimal library to create events | |
import inspect | |
from weakref import ref | |
from weakmethod import WeakMethod | |
class Event(object): | |
def __init__(self, handlers=[]): | |
self.handlers = set(handlers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quick and dirty ES6 promise testing (because I couldn't find any better) | |
// MIT License | |
function makeResolvedPromise(value) { | |
return new Promise(function(success) { | |
success(value); | |
}); | |
} | |
function makeRejectedPromise(errorValue) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# TODO: Does not support woff2 fonts (as served for Chrome) | |
import os, sys, re | |
import requests | |
def fetch_fonts(input_css, font_path="fonts"): | |
output_css = [] | |
for line in input_css.split("\n"): | |
if "https://" in line: | |
name = re.match(r".*local\('(.*?)'\).*", line).groups()[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import dbus | |
session_bus = dbus.SessionBus() | |
players = [x for x in session_bus.list_names() | |
if x.startswith('org.mpris.MediaPlayer2')] | |
if len(players) < 0: | |
print("No players found! :(", file=sys.stderr) | |
sys.exit(1) |
OlderNewer