Skip to content

Instantly share code, notes, and snippets.

View codethereforam's full-sized avatar
:octocat:
Focusing

thinkam codethereforam

:octocat:
Focusing
View GitHub Profile
@codethereforam
codethereforam / RollbackInsertSQL.java
Created June 14, 2023 08:47
根据insert sql生成回滚的delete sql
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 根据insert sql生成回滚的delete sql
*
* @author yanganyu
* @date 2023-06-24
*/
@codethereforam
codethereforam / 简书专注模式.js
Created June 8, 2023 09:29
简书专注模式[油猴脚本]
// ==UserScript==
// @name 简书专注模式
// @namespace https://github.com/codethereforam/
// @version 0.1
// @description 去除简书一切不必要的页面元素
// @author https://github.com/codethereforam/
// @match https://*.jianshu.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=jianshu.com
// @grant none
// ==/UserScript==
@codethereforam
codethereforam / check-win-versino.bat
Created June 8, 2023 02:38
a windows batch file: check windows version and then show a pop-up window
for /F %%i in ('powershell -command "[System.Environment]::OSVersion.Version.Major"') do set VER=%%i
msg "%username%" %VER%
@codethereforam
codethereforam / fileServer.go
Created January 5, 2023 09:14
go file server
package main
import (
"flag"
"log"
"net/http"
)
func main() {
port := flag.String("p", "8100", "port to serve on")
@codethereforam
codethereforam / easy-switch.ahk
Last active May 18, 2023 02:55
Switch Between Windows Of The Same Program@www.autohotkey.com
!`::
WinGetClass, OldClass, A
WinGet, ActiveProcessName, ProcessName, A
WinGet, WinClassCount, Count, ahk_exe %ActiveProcessName%
IF WinClassCount = 1
Return
loop, 2 {
WinSet, Bottom,, A
WinActivate, ahk_exe %ActiveProcessName%
WinGetClass, NewClass, A
@codethereforam
codethereforam / FillOneIfEmpty.java
Created January 14, 2022 09:03
使list至少有一个元素
/**
* 如果一个集合为空则返回填充一个对象的新list(不修改原list)
*
* @param list list
* @param constructor constructor
* @param <T> type of list's element
* @return 至少有一个元素的集合
* @author yanganyu
* @date 2022/1/14
*/
@codethereforam
codethereforam / MockRedisTest.java
Created December 28, 2021 08:12
unit test mock redis
@Slf4j
@RunWith(MockitoJUnitRunner.class)
public class MockRedisTest {
private StringRedisTemplate stringRedisTemplate;
@Before
public void setUp() {
stringRedisTemplate = Mockito.mock(StringRedisTemplate.class);
ValueOperations valueOperations = Mockito.mock(ValueOperations.class);
when(stringRedisTemplate.opsForValue()).thenReturn(valueOperations);
@codethereforam
codethereforam / spring_boot_deploy.md
Last active December 28, 2021 08:07
deploy Spring Boot

install software

  • centos install java: yum install java-1.8.0-openjdk-headless.x86_64

deploy

  1. package: mvn clean package
  2. copy to remote server: scp ./xxx.jar root@xxx:/home
  3. installation as System V: ln -s /home/foo.jar /etc/init.d/foo
  4. start:service foo start
  5. path:
  • configuration file:/home/foo.conf
@codethereforam
codethereforam / JavaxValidateUtil.java
Created August 23, 2021 02:46
javax校验工具类
import org.hibernate.validator.HibernateValidator;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import java.util.Objects;
import java.util.Set;
/**
* javax校验工具类
*