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
from unittest.mock import patch | |
from core.utils import list_dirs_only | |
# specify what should be patched | |
# i.e. if one wants to mock datetime.datetime but it used by your module x.py | |
# then it required to mock x.datetime but not datetime.datetime | |
patcher = patch('__main__.list_dirs_only') | |
# attach the original function to the variable because it will be modified | |
# when the patcher will start |
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
from unittest.mock import patch | |
from core.utils import list_dirs_only | |
# specify what should be patched | |
# i.e. if one wants to mock datetime.datetime but it used by your module x.py | |
# then it required to mock x.datetime but not datetime.datetime | |
patcher = patch('__main__.list_dirs_only') | |
# attach the original function to the variable because it will be modified | |
# when the patcher will start |
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 bash | |
# A dummy script incorporated to a gist for the sake of simplicity to install srm. | |
# Credit: http://techies-world.com/install-srm-secure-remove-command/ | |
cd "$(mktemp -d)" || exit | |
echo "Starting to download srm file..." | |
sudo apt install build-essential | |
wget http://downloads.sourceforge.net/project/srm/1.2.15/srm-1.2.15.tar.gz | |
tar -zxvf srm-1.2.15.tar.gz | |
cd srm-1.2.15 || exit |
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 re | |
import subprocess | |
from collections import defaultdict | |
from dataclasses import dataclass, field | |
from pprint import pprint | |
TEMPLATE = """## {code} ({text_code}) | |
### :x: Problematic code: |
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
package main | |
import "fmt" | |
func main() { | |
/* | |
i initial value is 0 | |
j initial value is 0 | |
i initial address is 0xc0000b4010 | |
j initial address is 0xc0000b4018 |
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
package main | |
import "fmt" | |
func main() { | |
/* | |
array address is 0xc000016420. | |
array values are [5]int{1, 2, 3, 4, 5}. | |
array type is [5]int. | |
array length is 5. |
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 resource | |
from functools import wraps | |
def mem_it(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
pre = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024 | |
print(f'Pre-memory usage: {pre} (mb)') | |
f = func(*args, **kwargs) |
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 resource | |
from functools import wraps | |
from time import time | |
def time_it(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
start = time() | |
f = func(*args, **kwargs) |
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 python3 | |
import os | |
import pathlib | |
import sys | |
import django | |
# Set a project root to a const, this file should be placed in a project root | |
# as well | |
PROJECT_ROOT = pathlib.Path(__file__).resolve().parent |
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
version: "3.7" | |
services: | |
postgresql: | |
image: postgis/postgis | |
environment: | |
POSTGRES_DB: "geo" | |
POSTGRES_USER: "geo" | |
POSTGRES_PASSWORD: "geo" |