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
import ast | |
import inspect | |
import os | |
def get_short_lambda_source(lambda_func): | |
"""Return the source of a (short) lambda function. | |
If it's impossible to obtain, returns None. | |
""" | |
try: |
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
#!/usr/bin/env python | |
""" | |
Decorator for fluent interface classes. | |
""" | |
import functools | |
import inspect | |
def chained(method): | |
"""Method decorator to allow chaining.""" |
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
from celery import Task | |
from flask import has_request_context, make_response, request | |
from myapp import app | |
__all__ = ['RequestContextTask'] | |
class RequestContextTask(Task): |
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
EffectAsset { | |
name: "particle_swirl", | |
capacity: 8192, | |
spawner: Spawner { | |
num_particles: Single( | |
64.0, | |
), | |
spawn_time: Single( | |
1.0, | |
), |
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/sh | |
# git-today | |
# | |
# Usage: | |
# * Name it `git-today` and put somewhere inside a `$PATH` directory | |
# * Invoke as $ git today | |
LAST_BEFORE_TODAY=$(git log --oneline --until='yesterday 23:59:59' | head -1 | cut -d' ' -f 1) | |
git --no-pager diff ${LAST_BEFORE_TODAY}..HEAD --stat |
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
// License: BSD-3 | |
use std::io::{self, Write}; | |
use std::string::FromUtf8Error; | |
use std::sync::Arc; | |
use antidote::RwLock; | |
use bevy::prelude::*; | |
use bevy::reflect::FromReflect; | |
use bevy::utils::tracing::{self, Dispatch}; |
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
""" | |
Requests' authenticator that attaches given parameters | |
to the URL query string. | |
License: Public Domain. | |
""" | |
from requests.auth import AuthBase | |
class QueryStringAuth(AuthBase): |
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
""" | |
Analyzing keywords from different programming languages. | |
""" | |
def word_stats(words): | |
count = len(words) | |
len_sum = sum(map(len, words)) | |
return { | |
'count': count, | |
'total_chars': len_sum, |
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
def compact(*args): | |
''' compact() function, analoguous to the PHP version. | |
Converts a series of (possible nested) iterables containing variable names | |
into a dictionary mapping those names to variable values. | |
Example: | |
>>> x, y, z, a, b, c = 1, 2, 3, 4, 5, 6 | |
>>> compact('x', ['y','z'], ['a', ['b'], [['c']]]) | |
{'a': 4, 'b': 5, 'c': 6, 'x': 1, 'y': 2, 'z': 3} | |
''' | |
def _compact_arg(res, arg): |
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
import collections | |
missing = object() | |
class MissingDict(dict): | |
"""Dictionary that supports a special 'missing' value. | |
Assigning a missing value to key will remove the key from dictionary. | |
Initializing a key with missing value will result in key not being | |
added to dictionary at all. |
NewerOlder