Skip to content

Instantly share code, notes, and snippets.

View jiahut's full-sized avatar
🎯
Focusing

zhijia,.zhang jiahut

🎯
Focusing
View GitHub Profile
buildscript {
repositories {
// maven { url 'http://repo.spring.io/plugins-release' }
// maven { url 'https://plugins.gradle.org/m2/'}
jcenter()
}
dependencies {
classpath 'io.github.lukehutch:fast-classpath-scanner:2.4.5'
}
@jiahut
jiahut / dropall.js
Last active April 4, 2018 07:02 — forked from cschlyter/dropall.js
MongoDB: Drop all mongodb databases
// Usage: $ mongo dropAll.js
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
print( "dropping db " + db.getName() );
db.dropDatabase();
}
print("done.")
apps = hs.application.runningApplications()
for key, value in pairs(apps) do
print(key)
print(value)
end
@jiahut
jiahut / time_cached.py
Last active June 4, 2018 07:46
基于过期时间的LRU缓存
from datetime import datetime, timedelta
from functools import lru_cache, wraps
def time_cached(maxsize=None, **timedelta_kwargs):
"""
基于时间过期的LRU缓存
`timedelta_kwargs`:
days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0
"""
// https://ppt.geekbang.org/list/qconbj2019?from=timeline&isappinstalled=0
JSON.stringify(jQuery.map(jQuery(".last-line > a"), e => jQuery(e).attr('href') ))
@jiahut
jiahut / findAny_vs_findFirst.groovy
Created July 30, 2018 06:34
Difference between findAny() and findFirst() in Java 8
def l = Arrays.asList("B","A","C")
def r = l.stream().parallel().filter { e -> e != "B" } .findAny()
def s = l.stream().parallel().filter { it != "B"}.findFirst()
println l
println r.get()
println s.get()
@jiahut
jiahut / findAny_vs_findFirst.groovy
Last active September 25, 2024 11:54
Difference between findAny() and findFirst() in Java 8
import java.util.concurrent.ForkJoinPool
println ForkJoinPool.commonPool().getParallelism()
def l = Arrays.asList("A","B","C","D")
// def l = new LinkedList<String>(["B","A","C"])
println Runtime.getRuntime().availableProcessors()
import org.slf4j.LoggerFactory
import org.slf4j.bridge.SLF4JBridgeHandler
import java.util.logging.Logger
class MyLog {
private Logger logger = Logger.getLogger("jul")
private org.slf4j.Logger log = LoggerFactory.getLogger(MyLog.class);
void log() {
SLF4JBridgeHandler.removeHandlersForRootLogger()
# log4j.configuration=log4j.properties Use this system property to specify the name of a Log4J configuration file. If not specified, the default configuration file is log4j.properties.
# log4j.rootCategory=priority [, appender]*
# Set the default (root) logger priority. log4j.logger.logger.name=priority Set the priority for the named logger and all loggers hierarchically lower than, or below, the named logger. logger.name corresponds to the parameter of LogFactory.getLog(logger.name), used to create the logger instance. Priorities are: DEBUG, INFO, WARN, ERROR, or FATAL.
#Log4J understands hierarchical names, enabling control by package or high-level qualifiers: log4j.logger.org.apache.component=DEBUG will enable debug messages for all classes in both org.apache.component and org.apache.component.sub. Likewise, setting log4j.logger.org.apache.component=DEBUG will enable debug message for all 'component' classes, but not for other Jakarta projects.
# log4j.appender.appender.Threshold=priority
log4j.rootCatego
{
"keymaps": {
"0": { "type": "scroll.home" },
":": { "type": "command.show" },
"o": { "type": "command.show.open", "alter": false },
"O": { "type": "command.show.open", "alter": true },
"t": { "type": "command.show.tabopen", "alter": false },
"T": { "type": "command.show.tabopen", "alter": true },
"w": { "type": "command.show.winopen", "alter": false },
"W": { "type": "command.show.winopen", "alter": true },