Skip to content

Instantly share code, notes, and snippets.

View inirudebwoy's full-sized avatar
🏗️
putting things on top of other things

Michael Klich inirudebwoy

🏗️
putting things on top of other things
View GitHub Profile
alias halt_all_vagrants="vagrant global-status | awk '/running/{print $1}' | xargs -r -d '\n' -n 1 -- vagrant halt"
@inirudebwoy
inirudebwoy / django_client_testing.py
Created September 21, 2016 15:18
Setup function simplifying working with a Django client.
def setUp(self):
post = partial(
self.client.post,
path='/api/task/',
content_type='application/json')
self.post = lambda data: post(data=json.dumps(data))
@inirudebwoy
inirudebwoy / meta_debug.py
Created March 22, 2017 20:40
Metaclass wrapping each function call with an argument printer
from functools import wraps
def printer(f):
@wraps(f)
def wrapper(*args, **kwargs):
print(args)
return f(*args, **kwargs)
return wrapper
@inirudebwoy
inirudebwoy / verify_pr.sh
Created November 6, 2017 15:32
Make verifying of PRs easier
#!/bin/bash
UNITTEST_LOG=error_unittest_verify_pr.log
INTEGRATIONTEST_LOG=error_integrationtest_verify_pr.log
CURRENT_GIT_BRANCH=$(git name-rev --name-only HEAD)
# check argument
if [ -z "$1" ]; then
echo "$(tput setaf 1)Please supply name of the branch to verify"
exit 1
fi
#! -*- coding: utf-8 -*-
from resolution import to_text
def test_1():
assert to_text(1) == 'jeden'
def test_12():
assert to_text(12) == 'dwanaście'
@inirudebwoy
inirudebwoy / Convert time to specified timezone using pytz.md
Created November 16, 2023 10:21
This code snippet defines a function that takes a datetime and a timezone name as input and returns the datetime converted to the specified timezone. It assumes that naive datetimes are in UTC.

Convert time to specified timezone using pytz

Preview:
def get_local_time(dt: datetime, timezone_name: str) -> datetime:
    """Convert given time to timezone. Naive datetimes are assumed to be in UTC"""
    tz = pytz.timezone(timezone_name)
    return to_zoned_utc(dt).astimezone(tz)
Associated Context