Skip to content

Instantly share code, notes, and snippets.

@Tusenka
Tusenka / gist:6f77566a42bf76c041c41544da1c01f6
Created April 30, 2025 03:23
Fixture indirrect params
https://gist.github.com/zobayer1/31f07011f1eaca7e0e5714bf647c2886
Using pytest.mark.parametrize with other fixtures
Introduction
When you want to run tests against multiple test parameters, but you have to use other pytest.fixture objects, you can use pytest.mark.parametrize with indirect parameter to target a fixture for extracting request.param from parametrize list.
Example
# -*- coding: utf-8 -*-
import os
def _iter_swap(m,i,j):
for [x, y] in [(i,j), (len(m)-i-1, j), (i, len(m)-j-1), (len(m)-i-1, len(m)-j-1)]:
yield m[x][y]
def _get_max(m, i, j):
return max(_iter_swap(m, i, j))
def _iter_corner(m):
@Tusenka
Tusenka / grid_search.py
Last active November 16, 2024 17:26
My version of grid search
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'gridSearch' function below.
What is wrong with the code. Why it writes 5<4?
```
#!/bin/python3
import math
import os
import random
import re
import sys
@Tusenka
Tusenka / 2d_matrix_transformation.py
Created October 21, 2024 07:40
Python 2d matrix transformation
#!/bin/python3
import math
import os
import random
import re
import sys
import copy
import pprint
https://www.hackerrank.com/profile/Tusenka
CREATE TABLE post_partitioned (
pk int GENERATED ALWAYS AS IDENTITY,
title TEXT,
content TEXT,
author INTEGER,
category INTEGER,
reply_to INTEGER,
created_on TIMESTAMP WITH TIME ZONE,
last_edited_on TIMESTAMP WITH TIME ZONE,
editable BOOLEAN,
https://www.postgresql.org/docs/current/manage-ag-tablespaces.html
@Tusenka
Tusenka / gist:b5c7fe51fb37dd47229f733395d05bfe
Created October 15, 2024 05:50
search and replace world under cursor
https://vim.fandom.com/wiki/Search_and_replace#substitute_last_search
@Tusenka
Tusenka / simple_graph.py
Created October 15, 2024 05:44
simple_graph
import pandas as pd
import matplotlib.pyplot as plt
MIN_DATA_LENGTH=3;
def to_range(y):
return to_strings(list(range(y.count())))
def to_strings(y):