Skip to content

Instantly share code, notes, and snippets.

@kudashevs
kudashevs / config.kbd
Last active March 25, 2026 05:55
My configuration file for kanata keyboard remapper
;; defsrc is necessary
(defcfg
log-layer-changes no
process-unmapped-keys yes
)
(defsrc
1 2 3 4 5 6 7 8 9 0 - =
caps
i
@kudashevs
kudashevs / git_diff_file.sh
Created February 27, 2026 20:56
How to git diff a file with the same file in other branch
git diff --cached <branch> -- <file>
@kudashevs
kudashevs / keybindings.json
Created October 25, 2025 17:41
A gist on how to focus back on the editor's window by hitting Esc. Open the VSCode `keybindings.json` file and add the following keybind.
{
"key": "escape",
"command": "workbench.action.focusActiveEditorGroup",
"when": "!editorTextFocus"
}
@kudashevs
kudashevs / settings.json
Created October 25, 2025 05:26
A gist on how to keybind a command with Vim plugin in VSCode. Open the VSCode `settings.json` file and edit `vim.normalModeKeyBindingsNonRecursive` section.
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<C-]>"],
"commands": [
"editor.action.refactor"
]
}
]
@kudashevs
kudashevs / copy_array_n_times.php
Last active January 28, 2025 07:48
Copy array multiple times in PHP - old way.
$source = [
'a',
'b',
'c',
];
$n = 3;
$repeated = array_fill(0, $n, $source);
$result = call_user_func_array('array_merge', $repeated);
@kudashevs
kudashevs / vim_substitute_annotations.txt
Created January 10, 2025 14:18
A Vim's substitute command that replaces @test annotations (including multi-line annotations) with Test attribute. For more information read the article: https://kudashevs.com/posts/2025/01/phpunit-switch-to-attributes-with-vim
:%s/\/\*\*\_[^\@]*\@test\_[^\/]*\*\//#[Test]/c
@kudashevs
kudashevs / download.sh
Last active December 10, 2024 10:43
Download a list of videos from youtube (with bash and yt-dlp).
#!/bin/sh
videos=(
# list of videos here
https://www.youtube.com/watch?v=8SMOB6k3hkM
https://www.youtube.com/watch?v=IqHaGd9J42s
)
for f in ${videos[@]}; do
./yt-dlp "$f" -f "bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --embed-chapters --embed-thumbnail
@kudashevs
kudashevs / constant_as_field.php
Created June 16, 2024 06:13
Use constant as a field name in PHP
class Post {
const PRIMARY_DATE_FIELD = 'created_at';
public function year(): int
{
return $this->{self::PRIMARY_DATE_FIELD}->format('Y');
}
}
@kudashevs
kudashevs / withConsecutiveReplacement.php
Last active March 19, 2024 07:48
The replacement for withConsecutive() PHPUnit method
<?php
class SUT
{
public function adore(string $arg): void
{
}
public function love(string $first, string $second): void
{
@kudashevs
kudashevs / random_state.php
Last active November 10, 2023 10:03
Change a random associative array value by setting the internal pointer to a random position.
<?php
class RandomState
{
private $state = [
'first' => false,
'second' => false,
'third' => false,
];