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 functools | |
import inspect | |
import os | |
import warnings | |
class _DeprecatedDecorator(object): | |
MESSAGE = "%s is @deprecated" | |
def __call__(self, symbol): |
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 inspect | |
def split(iterable, by): | |
"""Generalized split function that works on any iterable.""" | |
separator = by if inspect.isfunction(by) else lambda x: x == by | |
res = [] | |
curr = [] | |
for elem in iterable: | |
if separator(elem): |
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 L(object): | |
def __init__(self, iterable): | |
self.value = iterable | |
def map(self, fn): | |
self.value = map(fn, self.value) | |
return self | |
def join(self, s): | |
self.value = s.join(self.value) | |
return self | |
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. |
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
""" | |
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
""" | |
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
// 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
#!/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
EffectAsset { | |
name: "particle_swirl", | |
capacity: 8192, | |
spawner: Spawner { | |
num_particles: Single( | |
64.0, | |
), | |
spawn_time: Single( | |
1.0, | |
), |