Note
|
See graphgist view. |
This file contains 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 | |
# Replace the repo's default branch with a README explaining this fork is only for its submitted pull requests. | |
set -e -x -o pipefail | |
REMOTE=origin | |
GH_USERNAME="${GH_USERNAME:-$USER}" | |
TRUNK="$(git symbolic-ref --short refs/remotes/$REMOTE/HEAD | sed "s:${REMOTE}/::")" | |
REMOTE_URL="$(git remote get-url $REMOTE)" |
This file contains 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
plugins { | |
eclipse | |
idea | |
kotlin("jvm") version "1.2.71" | |
} | |
allprojects { | |
version = "1.0" | |
val appName by extra { "MY_PROJECT_NAME" } |
This file contains 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
This builds off the excellent work of @lmarkus & @dogeared. | |
The scripts below can be used in conjunction with the Slack Emoji Tools Google Chrome extension to export emojis from | |
one Slack team and import into another team. | |
Original work here: | |
* https://gist.github.com/lmarkus/8722f56baf8c47045621 | |
* https://gist.github.com/dogeared/f8af0c03d96f75c8215731a29faf172c |
This file contains 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
$ docker-compose run --rm django | |
[I 22:09:16.284 NotebookApp] Writing notebook server cookie secret to /home/django/.local/share/jupyter/runtime/notebook_cookie_secret | |
Traceback (most recent call last): | |
File "./notebug/manage.py", line 22, in <module> | |
execute_from_command_line(sys.argv) | |
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line | |
utility.execute() | |
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute | |
self.fetch_command(subcommand).run_from_argv(self.argv) | |
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv |
This file contains 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
class FloatingPointCursorPagination(CursorPagination): | |
__rounding_down = decimal.Context(prec=14, rounding=decimal.ROUND_FLOOR) | |
__rounding_up = decimal.Context(prec=14, rounding=decimal.ROUND_CEILING) | |
def _get_position_from_instance(self, instance, ordering): | |
field_name = ordering[0].lstrip('-') | |
if isinstance(instance, dict): | |
attr = instance[field_name] | |
else: | |
attr = getattr(instance, field_name) |
This file contains 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
# -*- coding: utf-8 -*- | |
"""THIS IS PROBABLY NOT A GOOD IDEA. | |
""" | |
def test_cases(): | |
cases = [ | |
(N(), "()"), | |
(E, "[]"), | |
(E[:], "[]"), |
This file contains 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 | |
# requires AWS CLI: https://aws.amazon.com/cli/ | |
# and jq: https://stedolan.github.io/jq/ | |
set -e | |
EC2_NAME="$1" | |
if [ -z "${EC2_NAME}" ] ; then | |
echo Usage: "$0" '<ec2-name> [ssh args ...]' | |
fi | |
shift | |
EC2_HOSTNAME=$(aws --output json ec2 describe-network-interfaces --filter "Name=group-name,Values=${EC2_NAME}" | |
This file contains 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
""" | |
Can we have a "nested function", but have definition of the inner function not lexically within its parent? | |
Question by https://www.reddit.com/r/compsci/comments/44o18l/do_any_programming_languages_allow_you_to_give/ | |
This file was written as an intellectual exercise. I do not recommend using it. Ever. | |
The implementation below works by using the descriptor protocol to return a newly bound method every time the outer | |
function makes a new reference to the inner function, and uses the outer method's *locals* as the inner method's | |
*globals*. The primary disadvantage here is that means the inner method doesn't have access to the actual globals. |
This file contains 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
# -*- coding: utf-8 -*- | |
from django.utils.encoding import force_str | |
class BadStr(object): | |
def __init__(self, content): | |
self.content = content | |
def __str__(self): | |
assert isinstance(self.content, unicode), "returning it from __str__ anyway" |