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 functools | |
import asyncio | |
from concurrent.futures import ThreadPoolExecutor | |
def to_async(func): | |
"""Turns a sync function to async function using event loop""" | |
@functools.wraps(func) | |
async def run(*args, loop=None, executor=None, **kwargs): | |
if loop is None: |
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
# use a certain pyenv version | |
use_python() { | |
if [ -n "$(which pyenv)" ]; then | |
local pyversion=$1 | |
pyenv local ${pyversion} | |
fi | |
} | |
layout_virtualenv() { | |
local pyversion=$1 |
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
// Open all links on a page in new tab -- for MBW | |
// Requires ECMAScript 6's `Set()` for getting unique urls | |
// I'm too lazy to write a `uniq` function nor do I want to pull in a 3rd party lib | |
// Works in Firefox 25+, Chrome 38+, Opera 25+, Safari 7.1+, Internet Explorer 11+ | |
Set( | |
Array.prototype.filter.call(document.querySelectorAll('[href]'), function(el) { | |
return el.tagName.toLowerCase() !== 'link' && el.href[0] !== '#' | |
}).map(function(el) { | |
return el.href | |
}) |
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 | |
# Runs the specified command (provided by the first argument) in all tmux panes | |
# in every window. If an application is currently running in a given pane | |
# (e.g., vim), it is suspended and then resumed so the command can be run. | |
all-panes() | |
{ | |
all-panes-bg_ "$1" & | |
} |
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 | |
# Credit to frogor for the objc | |
from Foundation import NSBundle | |
import json | |
import objc | |
import os | |
import plistlib | |
import subprocess |
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
""" | |
Url: https://gist.github.com/wassname/1393c4a57cfcbf03641dbc31886123b8 | |
""" | |
import unicodedata | |
import string | |
valid_filename_chars = "-_.() %s%s" % (string.ascii_letters, string.digits) | |
char_limit = 255 | |
def clean_filename(filename, whitelist=valid_filename_chars, replace=' '): |
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 contextlib | |
import io | |
import warnings | |
import pytest | |
from click.testing import CliRunner | |
""" | |
In your tests: |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist> | |
<array> | |
<dict> | |
<key>AudioList</key> | |
<array> | |
<dict> | |
<key>AudioBitrate</key> | |
<string>128</string> |
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/sh | |
# Sets up auto-tracking of a remote branch with same base name. | |
# Can set up "git track" so it feels built-in: | |
# git config --global --add alias.track '!git-track' | |
# | |
branch=$(git branch 2>/dev/null | grep ^\*) | |
[ x$1 != x ] && tracking=$1 || tracking=${branch/* /} | |
git config branch.$tracking.remote origin |
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 | |
# -*- coding: utf-8 -*- | |
import boto3 | |
SCRIPT_RUNNER_JAR = 's3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar' | |
BASE_ARGS_HIVE_STEP = [ | |
'/usr/share/aws/emr/scripts/hive-script', | |
'--run-hive-script', | |
'--args', |
NewerOlder