Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
romankurnovskii committed Mar 12, 2024
1 parent fd23d61 commit b633543
Show file tree
Hide file tree
Showing 2,785 changed files with 107,472 additions and 7,940 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/hugo.yml
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: init step
run: echo "Commit message" ${{ github.event.head_commit.message }}

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: "recursive" # Fetch Hugo themes (true OR recursive)
fetch-depth: 100 # Fetch all history for .GitInfo and .Lastmod
Expand All @@ -43,6 +43,9 @@ jobs:
- name: Create search indexes
run: npm run hugo-lunr-ml

- name: Generate LeetCode problems json
run: python3 gen_leetcode_problems_dict.py

- name: Install pip packages
run: pip install -r requirements.txt

Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -4,6 +4,7 @@ push:
echo "--------"
echo "Started git pull -> update modules -> merge -> push"
echo "--------"
python3 gen_leetcode_problems_dict.py
npm run hugo-lunr-ml
npm run p

Expand Down
25 changes: 25 additions & 0 deletions check_titles.py
@@ -0,0 +1,25 @@
import os


def find_files_with_non_numeric_title(root_dir):
for root, dirs, files in os.walk(root_dir):
for file in files:
if file == "index.ru.md":
file_path = os.path.join(root, file)
with open(file_path, "r") as f:
lines = f.readlines()
if len(lines) >= 2 and lines[1].startswith("title:"):
title = lines[1].strip().split("title:")[1].strip()
# Check if title is not numeric
numeric = title.replace(".", "", 1)
if not numeric[0].isdigit():
dir_name = os.path.basename(os.path.dirname(file_path))
title = lines[1].strip().split("title:")[1].strip()
lines[1] = f"title: {dir_name}. {title}\n"
with open(file_path, "w") as f:
f.writelines(lines)
print(f"Updated file: {file_path}")


root_dir = "content/tracks/algorithms-101/leetcode/"
find_files_with_non_numeric_title(root_dir)
2 changes: 1 addition & 1 deletion config/_default/languages.yaml
Expand Up @@ -77,7 +77,7 @@ en:
weight: 301
- name: LeetCode
identifier: LeetCode
url: /en/categories/leetcode/
url: /en/tracks/algorithms-101/leetcode/
parent: programming
weight: 302
- name: Python
Expand Down
2 changes: 1 addition & 1 deletion config/_default/params.yaml
Expand Up @@ -89,7 +89,7 @@ homeColorButtons:
btn2Url: categories/javascript/
btn2Style:
btn3Title: LeetCode
btn3Url: categories/leetcode/
btn3Url: tracks/algorithms-101/leetcode/
btn3Style:
btn4Title: Linux
btn4Url: categories/linux/
Expand Down
4 changes: 2 additions & 2 deletions content/apps/brewmate/index.ru.md
Expand Up @@ -10,7 +10,7 @@ categories: []
series: []
date: 2023-03-13
featuredVideo:
featuredImage: icon.png
featuredImage: https://romankurnovskii.com/en/apps/brewmate/icon.png
imgWidth: 100px
draft: false
package:
Expand All @@ -23,7 +23,7 @@ package:
link: "#faq"
- name: Github
link: "https://github.com/romankurnovskii/BrewMate"
iconImage: icon.png
iconImage: https://romankurnovskii.com/en/apps/brewmate/icon.png
type: apps
layout: single-app
---
Expand Down
2 changes: 1 addition & 1 deletion content/p/links.en.md
Expand Up @@ -7,7 +7,7 @@ tags:
categories:
series:
date: 2023-01-01
lastmod: 2023-03-04
lastMod: 2023-03-04
featuredImage:
draft: false
---
Expand Down
2 changes: 1 addition & 1 deletion content/p/privacy_ru.ru.md
Expand Up @@ -6,7 +6,7 @@ tags:
categories:
series:
date: "2022-03-12T13:11:22+08:00"
lastmod: "2022-03-12T13:11:22+08:00"
lastMod: "2022-03-12T13:11:22+08:00"
featuredImage:
draft: false
---
Expand Down
2 changes: 1 addition & 1 deletion content/p/publications.ru.md
Expand Up @@ -4,7 +4,7 @@ description: Печатные журналы / сборники
toc: true
authors: [roman-kurnovskii]
date: 2021-03-31T13:11:22+08:00
lastmod: 2023-03-28
lastMod: 2023-03-28
draft: false
tags: null
categories: null
Expand Down
2 changes: 1 addition & 1 deletion content/p/supportme.en.md
Expand Up @@ -6,7 +6,7 @@ tags:
categories:
series:
date: "2022-10-23T07:38:00+03:00"
lastmod: "2022-10-23T07:38:00+03:00"
lastMod: "2022-10-23T07:38:00+03:00"
featuredImage:
draft: false
---
Expand Down
28 changes: 28 additions & 0 deletions content/p/tmp_post/index.en.md
@@ -0,0 +1,28 @@
---
title: tmp_post
seoTitle: tmp_post
description: tmp_post
toc: true
tags: [tmp_post, tmp_post]
categories: [tmp_post, tmp_post, tmp_post]
date: 2024-02-02
lastMod: 2024-02-02
featuredImage: https://picsum.photos/700/241?grayscale
weight: 1
draft: true
---


tmp_post

## Problem Statement

tmp_post

leetcode-grid

style="display:inline-block"

<div id="_react_leetcode_grid_" class='bg-tertiary-bg rounded px-3 py-2 my-2 me-2 text-lg'></div>

{{< reactblock src="<http://localhost:1313/en/p/tmp_post/react/leetcode-grid.jsx?a2>" divRender="_react_leetcode_grid_">}}
117 changes: 117 additions & 0 deletions content/p/tmp_post/react/leetcode-grid.jsx
@@ -0,0 +1,117 @@
import { useEffect, useState, useRef } from "react";
import { createRoot } from "react-dom/client";

// console.log("leetcodeProblems", window.location.host, leetcodeProblems);

const divRender = "_react_leetcode_grid_"; // Make sure this matches the ID of your root div element

const CELL_WIDTH = 50;

const Matrix = () => {
const size = 3032; // Total numbers
const [columns, setColumns] = useState(10);
const [leetcodeProblems, setLeetcodeProblems] = useState({});
const matrixRef = useRef(null); // Ref to the matrix container

useEffect(() => {
const updateColumns = () => {
const matrixWidth = matrixRef.current.offsetWidth; // Get the current width of the matrix container
const cellWidth = CELL_WIDTH + 2; // width + 1px border on each side
const newColumns = Math.floor(matrixWidth / cellWidth);
setColumns(newColumns); // Update the number of columns based on the parent's width
};

window.addEventListener("resize", updateColumns);
updateColumns(); // Initial update

const leetCodeProblemsUrl =
"http://" + window.location.host + "/leetcode-problems.json";
console.log("leetCodeProblemsUrl", leetCodeProblemsUrl);
fetch(leetCodeProblemsUrl)
.then((response) => response.json())
.then((data) => setLeetcodeProblems(data))
.catch((error) =>
console.error("Failed to load leetcode problems:", error),
);

return () => window.removeEventListener("resize", updateColumns);
}, []);

const getCellStyle = (number) => {
const problemInfo = leetcodeProblems[number.toString()];
const _cellStyle = {
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "30px",
border: "1px solid #ccc",
width: CELL_WIDTH + "px",
backgroundColor: "#fff",
};

if (!problemInfo || !problemInfo.languages[userLang]) {
return _cellStyle;
}

if (problemInfo && problemInfo.difficulty === "Easy") {
_cellStyle.backgroundColor = "#ffb800";
return _cellStyle;
}
if (problemInfo && problemInfo.difficulty === "Medium") {
_cellStyle.backgroundColor = "#1cb8b8";
return _cellStyle;
}
if (problemInfo && problemInfo.difficulty === "Hard") {
_cellStyle.backgroundColor = "#f63636";
return _cellStyle;
}
return _cellStyle;
};

const numbers = Array.from({ length: size }, (_, i) => i + 1);

return (
<div
ref={matrixRef}
style={{
display: "grid",
gridTemplateColumns: `repeat(${columns}, ${CELL_WIDTH}px)`,
gap: "1px",
}}
>
{numbers.map((number, index) => {
const cellStyle = getCellStyle(number);
const problemInfo = leetcodeProblems[number.toString()];
let cell = <>{number}</>;
if (problemInfo && problemInfo.languages[userLang]) {
cell = (
<a
href={problemInfo.languages[userLang]} // userLang - global var
target="_blank"
rel="noopener noreferrer"
>
{number}
</a>
);
}
return (
<div key={index} style={cellStyle}>
{cell}
</div>
);
})}
</div>
);
};

const App = () => {
return (
<div className="App" style={{ width: "100%", margin: "auto" }}>
<Matrix />
</div>
);
};

const container = document.getElementById(divRender);
const root = createRoot(container); // Ensure your HTML has a div with the id 'root'
root.render(<App />);
2 changes: 1 addition & 1 deletion content/p/репатриация.ru.md
Expand Up @@ -6,7 +6,7 @@ tags: ["репатриация"]
categories: ["чеклист"]
series: []
date: 2019-12-02T11:55:25+02:00
lastmod: 2023-01-01
lastMod: 2023-01-01
featuredVideo:
featuredImage:
draft: false
Expand Down
2 changes: 1 addition & 1 deletion content/photos/midjourney/index.en.md
Expand Up @@ -6,7 +6,7 @@ tags:
series:
categories: [ai]
date: 2023-05-14
lastmod: 2023-05-14
lastMod: 2023-05-14
featuredImage: https://picsum.photos/700/244?grayscale
authors:
type: gallery
Expand Down
18 changes: 12 additions & 6 deletions content/posts/bash-snippets.en.md
Expand Up @@ -7,29 +7,35 @@ categories: [Linux, Bash, CheatSheet]
series: [CheatSheet, Snippets]
tags: [Linux, Bash, Programming, Snippets]
date: 2023-02-12
lastmod: 2023-06-14
lastMod: 2023-06-14
featuredImage: https://picsum.photos/700/229?grayscale
draft: false
---


## Rename all files by pattern in current directory
## Rename all files in current directory / Remove prefix

```sh
#!/bin/bash
REMOVE_PREFIX=$1
files=(*)

for file in "${files[@]}"
do
# Check if the file name contains the "№" symbol
if [[ $file == *""* ]]; then
if [[ $file == *"${REMOVE_PREFIX}"* ]]; then
# Remove everything before and including the "№" symbol
new_file=${file##*""}
new_file=${file##*"${REMOVE_PREFIX}"}
mv "$file" "$new_file"
echo "Renamed $file to $new_file"
fi
done
```

```
$ ./rename_files.sh abc
renamed file abc123.txt -> 123.txt
```

## Add substring to filename

```sh
Expand Down
2 changes: 1 addition & 1 deletion content/posts/diagram-support.md
Expand Up @@ -8,7 +8,7 @@ tags:
categories:
series:
date: "2021-03-31T13:11:22+08:00"
lastmod: "2021-03-31T13:11:22+08:00"
lastMod: "2021-03-31T13:11:22+08:00"
featuredImage:
draft: true
---
Expand Down
2 changes: 1 addition & 1 deletion content/posts/diploma/index.en.md
Expand Up @@ -7,7 +7,7 @@ tags: ['study', 'it', 'emigration']
categories: ['study']
series: []
date: 2021-01-01T15:31:25+02:00
lastmod: 2021-01-01T15:31:25+02:00
lastMod: 2021-01-01T15:31:25+02:00
featuredVideo:
featuredImage:
draft: false
Expand Down
2 changes: 1 addition & 1 deletion content/posts/diploma/index.ru.md
Expand Up @@ -7,7 +7,7 @@ tags: ['учеба', 'it', 'эмиграция']
categories: ['учеба']
series: []
date: 2021-01-01T15:31:25+02:00
lastmod: 2021-01-01T15:31:25+02:00
lastMod: 2021-01-01T15:31:25+02:00
featuredVideo:
featuredImage:
draft: false
Expand Down
2 changes: 1 addition & 1 deletion content/posts/docker-commands/index.en.md
Expand Up @@ -6,7 +6,7 @@ tags: ["docker", "cheatsheet"]
series: ['CheatSheet']
categories: [docker, CheatSheet]
date: "2022-06-07"
lastmod: "2022-06-07"
lastMod: "2022-06-07"
featuredImage: featured.en.jpg
authors: [roman-kurnovskii]
---
Expand Down
2 changes: 1 addition & 1 deletion content/posts/docker-commands/index.ru.md
Expand Up @@ -6,7 +6,7 @@ tags: ["docker", "cheatsheet"]
series: ['шпаргалки']
categories: [Docker, CheatSheet]
date: "2022-06-07"
lastmod: "2022-06-07"
lastMod: "2022-06-07"
featuredImage: featured.ru.jpg
authors: [roman-kurnovskii]
---
Expand Down
Expand Up @@ -7,7 +7,7 @@ tags: [экономика]
series: []
categories: []
date: 2023-03-05
lastmod: 2023-03-05
lastMod: 2023-03-05
featuredImage:
authors:
---
Expand Down
Expand Up @@ -7,7 +7,7 @@ tags: [экономика]
series: []
categories: []
date: 2023-01-26
lastmod: 2023-02-12
lastMod: 2023-02-12
featuredImage:
authors:
---
Expand Down

0 comments on commit b633543

Please sign in to comment.