Skip to content

Instantly share code, notes, and snippets.

View Aitozi's full-sized avatar
🐢
Happy coding

Aitozi Aitozi

🐢
Happy coding
  • 11:42 (UTC +08:00)
View GitHub Profile
@Aitozi
Aitozi / git_toturial
Last active September 25, 2017 01:26 — forked from guweigang/git_toturial
git命令大全
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库
@Aitozi
Aitozi / 0_reuse_code.js
Created August 15, 2017 06:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Aitozi
Aitozi / Threadlocal.java
Last active September 5, 2017 08:15
Threadlocal的用法
/**
*
*当我们调用get方法的时候,其实每个当前线程中都有一个ThreadLocal。每次获取或者设置都是对该ThreadLocal进行的操作,是与其他线程分开的
*应用场景:当很多线程需要多次使用同一个对象,并且需要该对象具有相同初始化值的时候最适合使用ThreadLocal
*/
public class ConnectionUtil {
private static ThreadLocal<Connection> tl = new ThreadLocal<Connection>();
private static Connection initConn = null;
static {
try {
@Aitozi
Aitozi / MeterView.java
Last active September 25, 2017 01:46
计算Meter,每个一个UPDATE_INTERVAL_SECONDS调用一次update方法
package org.apache.flink.metrics;
public class MeterView implements Meter, View {
/** The underlying counter maintaining the count */
private final Counter counter;
/** The time-span over which the average is calculated */
private final int timeSpanInSeconds;
/** Circular array containing the history of values */
private final long[] values;
/** The index in the array for the current time */
@Aitozi
Aitozi / ClusterClient.java
Created October 24, 2017 16:00
Flink job启动分析
try {
// invoke main method
prog.invokeInteractiveModeForExecution();
if (lastJobExecutionResult == null && factory.getLastEnvCreated() == null) {
throw new ProgramMissingJobException();
}
if (isDetached()) {
// in detached mode, we execute the whole user code to extract the Flink job, afterwards we run it here
return ((DetachedEnvironment) factory.getLastEnvCreated()).finalizeExecute();
}
@Aitozi
Aitozi / 惰性求值
Created November 13, 2017 01:21
scala惰性求值
def exists(p: A=> Boolean): Boolean = this match {
case Cons(h, t) => p(h()) || t().exists(p)
case _ => false
}
@Aitozi
Aitozi / gist:298f0f2464bb04d6df6bf312c8cf09dd
Created November 13, 2017 02:11 — forked from jessitron/gist:8376139
scala: print all URLs on classpath
def urlses(cl: ClassLoader): Array[java.net.URL] = cl match {
case null => Array()
case u: java.net.URLClassLoader => u.getURLs() ++ urlses(cl.getParent)
case _ => urlses(cl.getParent)
}
val urls = urlses(getClass.getClassLoader)
println(urls.filterNot(_.toString.contains("ivy")).mkString("\n")
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@Aitozi
Aitozi / ContinuousEventTimeTrigger.java
Created April 1, 2018 15:16
ReducingState usage in ContinuousEventTimeTrigger.java
private final ReducingStateDescriptor<Long> stateDesc =
new ReducingStateDescriptor<>("fire-time", new Min(), LongSerializer.INSTANCE);
@Aitozi
Aitozi / SharedBuffer.java
Created April 2, 2018 05:13
这个清理为什么遇到比pruningTimestamp大的时间就停止清理了呢
public void prune(long pruningTimestamp, List<SharedBufferEntry<K, V>> prunedEntries) {
Iterator<Map.Entry<ValueTimeWrapper<V>, SharedBufferEntry<K, V>>> iterator = entries.entrySet().iterator();
boolean continuePruning = true;
while (iterator.hasNext() && continuePruning) {
SharedBufferEntry<K, V> entry = iterator.next().getValue();
if (entry.getValueTime().getTimestamp() <= pruningTimestamp) {
prunedEntries.add(entry);
iterator.remove();