Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

xuanyu xuanyu-h

🎯
Focusing
  • Shanghai
View GitHub Profile
View CodeGenerator.java
public class CodeGenerator {
private static final String PROJECT_PATH = System.getProperty("user.dir");
private static final String AUTHOR = "xxx";
private static final String DB_URL = "xxx";
private static final String DB_DRIVER_NAME = "org.postgresql.Driver";
private static final String DB_USERNAME = "xxx";
private static final String DB_PASSWORD = "xxx";
private static final String PARENT_PACKAGE = "com.example.demo";
private static final String[] EXCLUDE_TABLES = List.of("flyway_schema_history").toArray(new String[0]);
private static final Boolean FILE_OVERRIDE = true;
View SnakeCaseConverterFilter.java
import xxx.xxx.xxx.StringUtil;
import org.springframework.core.annotation.Order;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
@xuanyu-h
xuanyu-h / SnakeCaseApplicationConfiguration.java
Created Mar 12, 2020 — forked from azhawkes/SnakeCaseApplicationConfiguration.java
Spring Boot: convert inbound parameters from snake_case to camelCase
View SnakeCaseApplicationConfiguration.java
@Configuration
public class SnakeCaseApplicationConfiguration {
@Bean
public OncePerRequestFilter snakeCaseConverterFilter() {
return new OncePerRequestFilter() {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
final Map<String, String[]> parameters = new ConcurrentHashMap<>();
for (String param : request.getParameterMap().keySet()) {
@xuanyu-h
xuanyu-h / CourseCode.java
Created Dec 2, 2019 — forked from darbyluv2code/CourseCode.java
Spring MVC Validation - FAQ: Is it possible to integrate multiple validation string in one annotation?
View CourseCode.java
package com.luv2code.springdemo.mvc.validation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
View ss.sh
#!/usr/bin/env bash
### BEGIN INIT INFO
# Provides: Shadowsocks-libev
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: Start or stop the Shadowsocks-libev server
@xuanyu-h
xuanyu-h / date.md
Created Sep 9, 2019
go date/time format
View date.md
Go layout Java notation C notation Notes
2016-01-02 yyyy-MM-dd %F ISO 8601
20160102 yyyyMMdd %Y%m%d ISO 8601
January 02, 2006 MMMM dd, yyyyare neat %B %d, %Y
02 January 2006 dd MMMM yyyy %d %B %Y
02-Jan-2006 dd-MMM-yyyy %d-%b-%Y
01/02/06 MM/dd/yy %D US
01/02/2006 MM/dd/yyyy %m/%d/%Y US
010206 MMddyy %m%d%y US
@xuanyu-h
xuanyu-h / gist:a3479b39a6e922f8b0f6b105d7a9b85b
Created Jan 24, 2019 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup
View gist:a3479b39a6e922f8b0f6b105d7a9b85b

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@xuanyu-h
xuanyu-h / Singleton.java
Last active Nov 9, 2018
Java Singleton
View Singleton.java
// 定义单例模式中需要完成的代码逻辑
public interface MySingleton {
void doSomething();
}
public enum Singleton implements MySingleton {
INSTANCE {
@Override
public void doSomething() {
System.out.println("complete singleton");
View thread_pool.rb
# Ruby Thread Pool
# ================
# A thread pool is useful when you wish to do some work in a thread, but do
# not know how much work you will be doing in advance. Spawning one thread
# for each task is potentially expensive, as threads are not free.
#
# In this case, it might be more beneficial to start a predefined set of
# threads and then hand off work to them as it becomes available. This is
# the pure essence of what a thread pool is: an array of threads, all just
# waiting to do some work for you!
@xuanyu-h
xuanyu-h / synchronize_access_object.rb
Created Nov 1, 2018
synchronizing access to an object
View synchronize_access_object.rb
# encoding: utf-8
# frozen_string_literal: true
require 'thwait'
class Object
def synchronize
mutex.synchronize { yield self }
end