Skip to content

Instantly share code, notes, and snippets.

View composite's full-sized avatar
🤡
This is the face. 이것은 면상이다.

Ukjin Yang composite

🤡
This is the face. 이것은 면상이다.
View GitHub Profile
@composite
composite / monitor.sh
Created August 3, 2021 08:53
Conditional infinite loop shell template for monitoring something (it might be helpful on docker with ENTRYPOINT ["dumb-init", "--", "/monitor.sh"] )
#!/usr/bin/env bash
pid=
loop=1
cleanup() {
echo "cleaning up..."
loop=
if [ $pid ]; then kill $pid; fi
}
@composite
composite / BeanConfig.java
Created August 2, 2021 04:54
ReloadableResourceBundleMessageSource for YAML (you need follow dependencies: no extra dependencies for Spring Boot, sprring-beans and SnakeYAML (or jackson-databind-yaml) for plain Spring)
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
@Configuration
public class BeanConfig {
@Bean
public MessageSource messageSource() {
@composite
composite / allowip_typical.conf
Created July 21, 2021 03:22
Wireguard exclude IP tips and tricks (with python3 script)
# from Wireguard for Android (https://github.com/ViRb3/wgcf/issues/42)
AllowedIPs = 0.0.0.0/5, 8.0.0.0/7, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4, 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/3, 160.0.0.0/5, 168.0.0.0/6, 172.0.0.0/12, 172.32.0.0/11, 172.64.0.0/10, 172.128.0.0/9, 173.0.0.0/8, 174.0.0.0/7, 176.0.0.0/4, 192.0.0.0/9, 192.128.0.0/11, 192.160.0.0/13, 192.169.0.0/16, 192.170.0.0/15, 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4, ::/0, 193.138.218.74/32
@composite
composite / QueryDslUtils.java
Created May 3, 2021 04:47
QueryDsl EntityPath to RelationalPath Wrapper for QueryDsl JPA with QueryDsl SQL (SQLQueryFactory)
import com.querydsl.core.types.EntityPath;
import com.querydsl.sql.RelationalPath;
import com.querydsl.sql.RelationalPathBase;
import javax.persistence.Table;
import java.lang.reflect.AnnotatedElement;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@composite
composite / commands.js
Created April 26, 2021 01:37
A Cypress addon command that frame or iframe should be loaded.
/*
usage: cy.frameLoaded('#myFrame')
*/
Cypress.Commands.add('frameLoaded', (selector, timeout) => {
const sleep = timer => new Promise(go => setTimeout(go, timer)),
log = Cypress.log({name: 'loaded',
message: [selector]
}).snapshot()
return cy.get(selector, nolog).then({ timeout: isNaN(+timeout) ? 10000 : +timeout }, async ($frame) => {
@composite
composite / NetworkUtils.java
Created March 23, 2021 02:33
My Network utility static methods with Apache HttpClient (4.5.x or later)
import org.apache.http.*;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.config.RequestConfig.Builder;
import org.apache.http.client.entity.UrlEncodedFormEntity;
@composite
composite / PostCSS.targets
Last active December 21, 2023 22:00
PostCSS build tool for asp.net core or blazor
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NodeCli Condition=" '$(NodeCli)'=='' ">npm</NodeCli>
<PostCssRunner Condition=" '$(PostCssRunner)'=='' ">run postcss --</PostCssRunner>
<PostCssCli Condition="('$(PostCssCli)'=='' Or '$(PostCssCli)'=='true')">-o</PostCssCli>
</PropertyGroup>
<ItemGroup>
<PostCssFiles Include="$(MSBuildProjectDirectory)\**\*.pcss" Condition="!($([System.String]::Copy(%(Filename)).StartsWith('_')))" >
@composite
composite / ListenableFutureUtils.java
Created September 14, 2020 08:43
ListenableFutureUtils (for java 7 or older)
public class ListenableFutureUtils {
public static <T> ListenableFuture<List<T>> allOf(final List<? extends ListenableFuture<? extends T>> futures) {
// we will return this ListenableFuture, and modify it from within callbacks on each input future
final SettableListenableFuture<List<T>> groupFuture = new SettableListenableFuture<>();
// use a defensive shallow copy of the futures list, to avoid errors that could be caused by
// someone inserting/removing a future from `futures` list after they call this method
final List<? extends ListenableFuture<? extends T>> futuresCopy = new ArrayList<>(futures);
// Count the number of completed futures with an AtomicInt (to avoid race conditions)
@composite
composite / SimpleBeanAccessor.java
Created April 24, 2020 06:08
Dynamic getter/setter, faster than reflection for java 8 or later. check out also: https://dzone.com/articles/java-reflection-but-faster
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.invoke.*;
import java.lang.reflect.Method;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
@composite
composite / SpelLoggerEvaluator.java
Created February 13, 2020 09:29
Logback Appender filter with Spring EL based evaluator. If you are using Spring, no other dependency required.
package your.logging.util;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.boolex.EventEvaluatorBase;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.spel.standard.SpelExpressionParser;