Skip to content

Instantly share code, notes, and snippets.

@aruis
aruis / pie.groovy
Created November 26, 2021 01:17
随便写的,计算pie
random = new Random()
side = 1000000
def givePiont() {
[random.nextInt(side), random.nextInt(side)]
}
def matchCiyle(def point) {
Math.sqrt((point[0] - side / 2)**2 + (point[1] - side / 2)**2) <= side / 2
}
def rules = [
[
"expression": ' v_name != null && v_name.length()>0 ',
"tip" : "姓名必填"
],
[
"target" : ['v_password', 'v_password_twice'],
"expression": ' v_password == v_password_twice ',
"tip" : "两次密码必须一致"
]
@aruis
aruis / CompletableFutureTest.java
Created September 11, 2018 08:40
CompletableFuture demo
package com.aruistar.studyjavaten;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.*;
import java.util.stream.Collectors;
@aruis
aruis / async2sync.groovy
Created June 13, 2018 03:05
vertx 异步转同步
import io.vertx.core.Vertx
import java.util.concurrent.CompletableFuture
String sayHello() {
def future = new CompletableFuture()
Vertx vertx = Vertx.vertx()
@aruis
aruis / reverseProxy.go
Created May 22, 2018 06:25 — forked from rolaveric/reverseProxy.go
Example of a reverse proxy written in Go
import (
"net/http"
"net/http/httputil"
"net/url"
"fmt"
)
func main() {
// New functionality written in Go
http.HandleFunc("/new", func(w http.ResponseWriter, r *http.Request) {
@aruis
aruis / vertx_cas_pac4j_demo.groovy
Created May 8, 2018 09:10
vertx_cas_pac4j_demo.groovy
package com.longruan.gateway
import groovy.transform.CompileStatic
import io.vertx.core.AbstractVerticle
import io.vertx.core.Future
import io.vertx.core.Vertx
import io.vertx.core.json.JsonObject
import io.vertx.ext.web.Router
import io.vertx.ext.web.handler.BodyHandler
import io.vertx.ext.web.handler.CookieHandler
@aruis
aruis / sql
Created May 1, 2018 10:02
postgres 逻辑复制demo
create extension "uuid-ossp";
CREATE TABLE demo
(
id varchar DEFAULT uuid_generate_v4() PRIMARY KEY,
v_data varchar,
t_create timestamp DEFAULT now(),
v_from varchar
);
import io.grpc.ManagedChannelBuilder
import io.grpc.examples.manualflowcontrol.HelloReply
import io.grpc.examples.manualflowcontrol.HelloRequest
import io.grpc.examples.manualflowcontrol.StreamingGreeterGrpc
import io.grpc.stub.ClientCallStreamObserver
import io.grpc.stub.ClientResponseObserver
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.logging.Logger
import io.grpc.ServerBuilder
import io.grpc.examples.helloworld.GreeterGrpc
import io.grpc.examples.helloworld.HelloReply
import io.grpc.examples.helloworld.HelloRequest
import io.grpc.examples.manualflowcontrol.StreamingGreeterGrpc
import io.grpc.stub.ServerCallStreamObserver
import io.grpc.stub.StreamObserver
import java.util.concurrent.atomic.AtomicBoolean
import java.util.logging.Logger
@aruis
aruis / build.gradle
Created January 12, 2018 01:45
war dependencies
buildscript {
repositories {
maven {
url "http://maven.aliyun.com/nexus/content/groups/public"
}
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:+'