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 random | |
class TemperamentalClass(type): | |
@classmethod | |
def __instancecheck__(cls, other): | |
return random.choice([True, False]) | |
class MyClass(metaclass=TemperamentalClass): | |
pass |
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 urllib.parse | |
def order_query_string(url): | |
parsed_url = list(urllib.parse.urlparse(url)) | |
# Put the query string params in determinisitic order. | |
# According to docs.python this is in [3], but docs.python is a liar. | |
parsed_url[4] = urllib.parse.urlencode(sorted(urllib.parse.parse_qsl(parsed_url[4]))) | |
return urllib.parse.urlunparse(parsed_url) |
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
e = lambda x: "".join(u":lazer_{}:\u200b".format(c) if (c.isalpha() or c.isdigit()) else " {} ".format(c) for c in x.upper()) |
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
def get_github3_client(): | |
"""See | |
https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app | |
for an explanation of how/why this is like it is. | |
Requires requests, pyjwt, and github3. Make sure you intall a newer | |
version of cryptography for pyjwt as well.""" |
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
local class = require("middleclass/middleclass") | |
local Keyboard = class("Keyboard") | |
function Keyboard:initialize() | |
self.keys = {} | |
self.keypresses = {} | |
function love.keypressed(key) | |
-- set time pressed down to 0 for key |
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
ascii12 | |
------- | |
mmmm mmmmmmmm mm mmm mm mmmmm mm mm mmmmmm | |
m#""""# """##""" #### ### ## ##"""## ## ## ##""""#m | |
##m ## #### ##"# ## ## ## ## ## ## ## | |
"####m ## ## ## ## ## ## ## ## ## ## ######" | |
"## ## ###### ## #m## ## ## ## ## ## | |
#mmmmm#" ## m## ##m ## ### ##mmm## "##mm##" ## | |
""""" "" "" "" "" """ """"" """" "" |
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 time | |
from github3.models import GitHubCore | |
def throttle_github(github_like, requests_needed): | |
"""Takes any github3 objects (repo, org, etc) and will throttle if there are | |
not at least requests_needed requests remianing before the API starts | |
throttling. If there are not enough requests left, sleep until the window | |
resets. Note this uses up one API call to get the rate limit headers, so be |
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
#! /bin/bash | |
SESSION_NAME=$( tmux display-message -p '#S' 2> /dev/null ) | |
WINDOW_TITLE="Workspace" | |
check_session() | |
{ | |
if [ x$SESSION_NAME == "x" ] | |
then | |
echo "Please do this in a tmux session" |
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
// MaxSum.cpp : Just a silly little problem to solve -- what is the | |
// maximum sum of non-adjacent numbers in an array? | |
#include "stdafx.h" | |
#include <algorithm> | |
#include <deque> | |
#include <iostream> | |
#include <string> | |
#include <vector> |
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
def export_fc_to_csv(fc, out_csv): | |
""" | |
Export each vertex in a line or poly fc to a csv with OID | |
user requested at http://arcpy.wordpress.com/about/#comment-348 | |
example | |
import geom_snippets | |
geom_snippets.export_fc_to_csv(r"c:\proj\fc1.shp", r"c:\proj\fc1.csv") |