Skip to content

Instantly share code, notes, and snippets.

View sunng87's full-sized avatar
👑
keep calm and git push -f

Ning Sun sunng87

👑
keep calm and git push -f
View GitHub Profile
@sunng87
sunng87 / rdp.py
Last active December 29, 2023 08:55
Greptimedb script for Ramer–Douglas–Peucker algorithm
import math
@coprocessor(
returns=["lon", "lat"],
)
def simplify(**params) -> (vector[f64], vector[f64]):
from greptime import query
results = query().sql(params["sql"])
lon = results[0]
@sunng87
sunng87 / Jetty11.java
Last active September 3, 2023 18:30
Dead simple setup of Jetty servers
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.eclipse.jetty:jetty-server:11.0.15
//DEPS org.eclipse.jetty:jetty-servlet:11.0.15
import static java.lang.System.*;
import java.io.IOException;
import org.eclipse.jetty.server.Server;
@sunng87
sunng87 / leancustomerdevelopment.org
Created May 23, 2022 09:58
Notes on Lean Customer Development
@sunng87
sunng87 / init.el
Created April 30, 2022 13:04
My emacs configuration
(require 'package)
;; (dolist (source '(("marmalade" . "http://marmalade-repo.org/packages/")
;; ("elpa" . "http://tromey.com/elpa/")
;; ("melpa" . "http://melpa.milkbox.net/packages/")
;; ("org" . "http://orgmode.org/elpa/")))
;; (add-to-list 'package-archives source t))
;;
;; ("marmalade" . "http://elpa.emacs-china.org/marmalade/")
;; ("org" . "http://elpa.emacs-china.org/org/")
;; ("elpa" . "http://elpa.emacs-china.org/gnu/")
@sunng87
sunng87 / gist:d4c06119224cd9ee4a927fccbb591af0
Created May 13, 2020 08:14
regex for matching json key/value
"(tomcat|jetty)":\s*"((\\"|[^"])*)",?
[global]
### Display ###
# Which monitor should the notifications be displayed on.
monitor = 0
# Display notification on focused monitor. Possible modes are:
# mouse: follow mouse pointer
# keyboard: follow window with keyboard focus
# none: don't follow anything
(defn camelcase-to-delimitered [k delimeter]
(->> (clojure.string/split k #"(?=[A-Z])")
(map clojure.string/lower-case)
(clojure.string/join delimeter)))
(defn camelcase-to-delimitered-keys [m delimiter]
(let [trans (fn [[k v]]
(let [[strfn keyfn] (if (keyword? k)
[name keyword]
[identity identity])
INFO [epollEventLoopGroup-2-6] 2018-08-26 11:33:10,003 Message.java:623 - Unexpected exception during request; channel = [id: 0xf72d6e2f, L:/10.233.66.7:9042 - R:/10.233.65.7:48742]
io.netty.channel.unix.Errors$NativeIoException: readAddress() failed: Connection timed out
at io.netty.channel.unix.Errors.newIOException(Errors.java:117) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.unix.Errors.ioResult(Errors.java:138) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.unix.FileDescriptor.readAddress(FileDescriptor.java:175) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.epoll.AbstractEpollChannel.doReadBytes(AbstractEpollChannel.java:238) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:926) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:397
@sunng87
sunng87 / Cargo.lock.diff
Created November 9, 2016 06:20
Diff for Cargo lock
diff --git a/Cargo.lock b/Cargo.lock
index a2e127d..d593db6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,119 +2,191 @@
name = "cargo-release"
version = "0.6.1-pre"
dependencies = [
- "clap 2.2.5 (registry+git://crates.mirrors.ustc.edu.cn/index)",
- "quick-error 0.1.4 (registry+git://crates.mirrors.ustc.edu.cn/index)",
@sunng87
sunng87 / InfQueue.java
Created April 24, 2016 02:53
A file base blocking queue
import com.squareup.tape.FileObjectQueue;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;