Skip to content

Instantly share code, notes, and snippets.

View Lysander086's full-sized avatar
🎯
self-disciplined

Lysander Lysander086

🎯
self-disciplined
View GitHub Profile
$branchName = ""
$repoUrl = ""
$outputFolderName = ""
# 既存のフォルダがあれば削除
if (Test-Path -Path $outputFolderName -PathType Container) {
Remove-Item -Path $outputFolderName -Recurse -Force
Write-Host "既存のフォルダ '$outputFolderName' を削除しました。"
}
@Lysander086
Lysander086 / install_to_OS.sh
Created June 8, 2025 07:06
install the dependencies from a list and using corresponding commands to install
install_pkg() {
pkg="$1"
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -y "$pkg"
elif command -v brew >/dev/null 2>&1; then
brew install "$pkg"
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y "$pkg"
else
echo "No supported package manager found for installing $pkg"
@Lysander086
Lysander086 / language_convert.py
Last active February 23, 2025 01:06
[Drafting and still not working ]The code translates Japanese comments in Git-tracked Python, Java, Kotlin, TypeScript, or JavaScript files into English using DeepSeek via Ollama, then overwrites each file with the translated version.
import subprocess
import os
def get_tracked_files():
"""Get a list of all files tracked by Git"""
result = subprocess.run('git ls-files', capture_output=True, text=True, shell=True)
if result.stderr:
raise Exception(f"Failed to retrieve Git files: {result.stderr}")
return result.stdout.splitlines()
import subprocess
def test_ollama(number):
# Create a prompt based on the number
prompt = f"Return the result of this expression: 1+{number}"
# Output the prompt with echo and pass it to ollama via pipe
command = f'echo "{prompt}" | ollama run deepseek-r1:latest'
result = subprocess.run(
command,
capture_output=True, text=True, shell=True
@Lysander086
Lysander086 / tree_generator.py
Last active April 10, 2025 13:32
convert the ls-file generated by `git ls-files` to a structured and readable file about tree.`
import os
import subprocess
def create_tree_from_lines(lines):
tree = {}
for line in lines:
parts = line.strip().split("/")
current_level = tree
for part in parts:
@Lysander086
Lysander086 / GPT_scroll.js
Created November 2, 2024 00:33
GPT scroll to top
// Get the element by class name
const scrollableDiv = document.querySelector('.react-scroll-to-bottom--css-gkooh-1n7m0yu');
if (scrollableDiv) {
scrollableDiv.scrollTo({
top: 0,
behavior: 'smooth' // Smooth scroll
});
} else {
console.log("Element not found.");
@Lysander086
Lysander086 / expand_diff.js
Created October 31, 2024 04:29
expand all files diff to let Copilot review
const buttons = document.querySelectorAll('button.btn-octicon.js-details-target');
buttons.forEach(button => button.click());
@Lysander086
Lysander086 / find_file_paths.py
Created July 22, 2024 04:17
Find file path within the root dir according to the filenames.
from typing import List, Dict
import os
def find_file_paths(root_dir: str, target_files: List[str]) -> Dict[str, List[str]]:
"""
Search for specific files within a directory and its subdirectories using depth-first search.
Args:
root_dir (str): The root directory to start the search from.
target_files (List[str]): A list of target file names to search for.
@Lysander086
Lysander086 / error.log
Created August 23, 2022 06:50
error log of connecting to redis sentinel
%xwEx2022-08-23 15:33:09.160 INFO 28024 --- [ost-startStop-1] r.c.j.JedisSentinelPool : Trying to find master from available Sentinels...
%xwEx2022-08-23 15:33:11.183 WARN 28024 --- [ost-startStop-1] r.c.j.JedisSentinelPool : Cannot get master address from sentinel running @ 10.48.32.11:6379. Reason: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out. Trying next one.
%xwEx2022-08-23 15:33:11.187 ERROR 28024 --- [ost-startStop-1] o.s.b.c.e.t.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'webMetricsFilter' defined in class path resource [io/micrometer/spring/autoconfigure/web/servlet/WebMvcMetricsAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.micrometer.spring.web.servlet.Web
@Lysander086
Lysander086 / install dependencies.py
Last active May 15, 2021 14:46
install dependency at ease
import os
from pip._internal import main as pip_main
# config part START
fail_file_name = "failed-dependencies.config"
total_fails = 0
to_retry = True