Skip to content

Instantly share code, notes, and snippets.

View invk007's full-sized avatar
🐢
Focusing

invk007

🐢
Focusing
View GitHub Profile
import { SharedArray } from 'k6/data';
import { randomSeed, randomIntBetween } from 'k6';
randomSeed(123);
const urls = new SharedArray("urls", () =>
open("./urls.txt").trim().split("\n")
);
export default function () {
[[ "${CHECK}" == "prod" ]] && TEST=5 || TEST=10
1. use docker history ${IMAGE}
2. Use dive
3. Use pip --no-cache-dir to prevent writing pip cache -> decrease images.
4. Chain RUN statement for temp
5. Changes to source code invalidate the build cache
6. Hadolint: Dockerfile linter
7. Leverage .dockerignore
8. use correct base image
9. Standard pypi wheels don't work on Alpine
10. consider multi-stage build
Flows .
Centralized .
. Workflow uses a central repository to serve as the single point-of-entry for all changes to the project. The default development branch is called {main} and all changes are committed into this branch. Doesn’t require any other branches besides main.
. Has no defined pull request of forking patterns.
. Suited for teams migrated from SVN and small teams.
Pros .
# simple
Cons .
# not suitable for large teams
@invk007
invk007 / testing_mails.py
Created August 8, 2019 15:24
Testing mails in Django
"""
During tests every outgoing email instead of being sent
to outer world is saved in django.core.mail.outbox.
"""
from django.core import mail
def test_send_mail():
mail.send_mail(
'Example subject',
@invk007
invk007 / monotonic.py
Created August 8, 2019 07:57
Measure time
from contextlib import contextmanager
import time
@contextmanager
def timeit():
start = time.monotonic()
yield
print(time.monotonic() - start)
@invk007
invk007 / closure.py
Created August 8, 2019 07:51
Python closures
def make_closure(x):
def closure():
nonlocal x
print(x)
x *= 2
print(x)
return closure
make_closure(2)()
.doc application/msword
.dot application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.docm application/vnd.ms-word.document.macroEnabled.12
.dotm application/vnd.ms-word.template.macroEnabled.12
.xls application/vnd.ms-excel
.xlt application/vnd.ms-excel
@invk007
invk007 / template.html
Last active June 19, 2019 08:11
django snippets
<li><a href="{% url 'url_name' param1 param2 %}">{{ question.question_text }}</a></li>
@invk007
invk007 / demo.py
Created June 19, 2019 07:10
copy of officegenerator demo
## @namespace officegenerator.demo
## @brief Generate ODF example files
import argparse
import datetime
import gettext
import os
import pkg_resources
from decimal import Decimal
from officegenerator.commons import __version__