Skip to content

Instantly share code, notes, and snippets.

@MRsoymilk
MRsoymilk / byProcessName.bat
Created August 8, 2023 07:14
bat file, close multiple programs
@echo off
rem This script is used to close multiple programs with specified process names
rem Please enter the process names of the programs you want to close below, enclosed in double quotes and separated by spaces
set processes="notepad.exe" "mspaint.exe" "calc.exe"
rem Use a for loop to traverse each process name, use the taskkill command to forcibly end the process according to the process name, /f parameter means forced closure, /im parameter means filtering according to image name
for %%p in (%processes%) do (
taskkill /f /im %%p
rem Show operation results
if %errorlevel%==0 (
echo Successfully closed %%p
@MRsoymilk
MRsoymilk / iterate_over_files.py
Created September 23, 2020 09:21
python tools
import os
def iterate_over_files(path):
for filepath, dirnames, filenames in os.walk(path):
for filename in filenames:
print(os.path.join(filepath, filename))
iterate_over_files('/tmp')
@MRsoymilk
MRsoymilk / ls.c
Created September 5, 2020 03:44
C useful code
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
DIR *dp;
struct dirent *dirp;
if(argc!=2){
printf("error: ls directory_name\n");
exit(-1);
@MRsoymilk
MRsoymilk / filelists.cpp
Last active August 26, 2020 16:02
C++ small tools
// usage:
// g++ -stdc++17 filelists.cpp -o filelists
// ./filelists
#include <iostream>
#include <string>
#include <filesystem>
@MRsoymilk
MRsoymilk / autostart
Created July 31, 2020 04:54
i3-gaps settings
#!/bin/sh
# backlight
xbacklight -set 20
# background
xcompmgr&
# background
feh --bg-fill /home/milk/.config/feh/mybackground.png --bg-scale /home/milk/.config/feh/mybackground.png
@MRsoymilk
MRsoymilk / getch.py
Created July 29, 2020 06:06
python real-time reading
class _Getch:
"""Gets a single character from standard input. Does not echo to the screen."""
def __init__(self):
try:
self.impl = _GetchWindows()
except ImportError:
self.impl = _GetchUnix()
def __call__(self): return self.impl()
@MRsoymilk
MRsoymilk / settings.xml
Created July 29, 2020 05:58
Maven mirrors
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
@MRsoymilk
MRsoymilk / init.gradle
Created July 29, 2020 05:56
gradle global repository
def repoConfig = {
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.contains('repo1.maven.org/maven2') || url.contains('jcenter.bintray.com')) {
println "gradle init: (${repo.name}: ${repo.url}) removed"
remove repo
}
}
}
@MRsoymilk
MRsoymilk / CMakeLists.txt
Created July 29, 2020 05:46
opencv cmake
cmake_minimum_required(VERSION 2.8)
project(opencv_cmake)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(main ${OpenCV_LIBS})
@MRsoymilk
MRsoymilk / CMakeLists.txt
Last active August 22, 2020 04:05
sdl2 cmake for image, net, ttf, mixer
cmake_minimum_required(VERSION 3.16)
project(sdl_cmake)
set(CMAKE_CXX_STANDARD 14)
file(GLOB_RECURSE SOURCES "src/*.cpp")
file(GLOB_RECURSE HEADERS "src/*.h")
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})