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 is_wsl | |
File.exists?('/proc/version') && /WSL[0-9]/.match?(IO.readlines('/proc/version').first) | |
end |
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 code expects there's a config.ini file under the same directory. | |
And the file is expected like below contents | |
See also below if default values isn't needed | |
https://stackoverflow.com/questions/26586801/configparser-and-string-interpolation-with-env-variable | |
-- config.ini -- | |
[testdayo] | |
envuser=${USERNAME:-defusername} |
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 io, requests, sys, zipfile | |
from wsgiref import simple_server | |
url_base = 'http://s3.amazonaws.com/xxxxxxxx' | |
s3_link = 'xxxxx.zip' | |
url = f"{url_base}/{s3_link}" | |
def get_content_type(filename): |
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 csv, io | |
text = """ | |
12345,12345,revise,one line comment | |
12345,13245,revise,"State officials were flying over southeastern Utah looking for sheep as part of a routine task. Instead they found something straight out of a sci-fi movie. | |
From a helicopter, officers from the Utah Department of Public Safety spotted a large metal monolith — a single block of metal — last week. It was sitting in Utah's Red Rock Country in the southeast. Officials have no idea how or when it got there — or who might have placed it." | |
""".strip() | |
def output_lines(c1, c2, c3, c4): |
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 Attribute(object): | |
def __init__(self, param=None, name='default'): | |
self.param = param | |
self.name = name | |
def __get__(self, instance, objtype): | |
return getattr(instance, self.get_private_name()) | |
def __set__(self, instance, val): |
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 get_stuckframe1(): | |
get_stuckframe2() | |
def get_stuckframe2(): | |
curframe = inspect.currentframe() | |
calframe = inspect.getouterframes(curframe, 2) | |
print('inspect = %s' % "\n".join([str(t) for t in calframe])) | |
if __name__ == '__main__': | |
get_stuchframe1() |
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 all_subclasses(model): | |
"""Gets the model from a given key.""" | |
return set(model.__subclasses__()).union([s for c in model.__subclasses__() for s in all_subclasses(c)]) | |
def get_model_from_key(model, key): | |
models = {klass.__name__: klass for klass in all_subclasses(model)} | |
return models.get(key, None) | |
class BaseModel(object): | |
pass |
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
$ echo $(cd target_dir; pwd) |
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
$ curl -v -X POST -F "id=something" -F "pass=something" https://example.com/login | |
> ... | |
> Cookie: PHPSESSID=xxxxxxxxxxxxxxxxxxxxxx | |
> ... | |
# use returned session id | |
$ curl --cookie "PHPSESSID=xxxxxxxxxxxxxxxxxxxxxx" https://example.com/something |
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
$ grep $'\u200b' target.file |
NewerOlder