Instantly share code, notes, and snippets.

View CompletableFutureTest.java
public class CompletableFutureTest {
static class User {
private String nickname;
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
View edit_distance.py
def main():
result = edit_distance("fox", "fab")
print(result)
def edit_distance(str1, str2):
len1 = len(str1)
len2 = len(str2)
maxtrix = [[i for j in range(len2 +1)] for i in range(len1 + 1)]
maxtrix[0] = [i for i in range(len1 + 1)]
View 素书.md

素 书

原始章第一

夫道、德、仁、义、礼,五者一体也。
道者,人之所蹈,使万物不知其所由。
德者,人之所得,使万物各得其所欲。
仁者,人之所亲,有慈惠恻隐之心,以遂其生成。
义者,人之所宜,赏善罚恶,以立功立事。
礼者,人之所履,夙兴夜寐,以成人伦之序。\

View AutomateProcess.java
public class AutomateProcessor {
private UserExceptionAnalysisListener userExceptionAnalysisListener = new UserExceptionAnalysisListener();
private UserModelingListener userModelingListener = new UserModelingListener();
private HardRuleFilterListener hardRuleFilterListener = new HardRuleFilterListener();
private AntiRubbishListener antiRubbishListener = new AntiRubbishListener();
View epoll_test.c
#include <stdio.h>
#include <unistd.h>
#include <sys/epoll.h>
#include <string.h>
int main() {
int epoll_fd = epoll_create1(0);
struct epoll_event event, events[5];
char read_buffer[11];
int running = 1, event_count, i;
View idea_bash.bat
@echo off
SET bashbin="f:\tools\cmder\vendor\git-for-windows\bin"
SET currentpath=%cd%
REM replace \ to /
SET unixpath=%currentpath:\=/%
REM replace : to empty
SET unixpath=%unixpath::=%
REM add / at begnning
SET unixpath=/%unixpath%
View ForwardService.java
package com.vamdt.fox.fox.service;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
View ssh_connection_test.sh
for i in $(cat ip.txt)
do
ssh -q -p 16322 -o "BatchMode=yes" -o "ConnectTimeout=3" "$i" "echo 2>&1" && echo "$i OK" || echo "$i NOK"
done
View KafkaTopicUtil.java
package com.hello.world;
import joptsimple.internal.Strings;
import kafka.admin.AdminUtils;
import kafka.admin.RackAwareMode;
import kafka.utils.ZKStringSerializer$;
import kafka.utils.ZkUtils;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.ZkConnection;
View ajax_window_open.js
$.ajax({
url: "/",
async: false,
dataType: "json",
success: function() {
window.open("http://google.com", "_blank");
}
});