This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
import java.util.stream.Collector; | |
import java.util.stream.LongStream; | |
/** | |
* Stats of a stream of objects, including `count`, `min`, and `max`. | |
* Note that `min` and `max` are undefined if `count==0`. | |
* <p> | |
* This is intended to be used with `Stream.collect()`, for example | |
* </p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
import java.util.TreeMap; | |
import java.util.concurrent.locks.LockSupport; | |
public class UnfairSemaphore | |
{ | |
TreeMap<Integer, LinkedList<Thread>> waitingThreads = new TreeMap<>(); | |
void storeWaitingThread(Integer priority, Thread thread) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bayou.async.*; | |
import bayou.http.*; | |
import java.time.Duration; | |
import java.time.Instant; | |
import java.util.concurrent.ConcurrentHashMap; | |
import java.util.concurrent.atomic.AtomicLong; | |
// see question https://groups.google.com/forum/#!topic/bayou-io/9Mqtcl3OoWM | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bayou.async.Async; | |
import bayou.bytes.ByteSource; | |
import bayou.gzip.GunzipByteSource; | |
import bayou.http.*; | |
import bayou.mime.Headers; | |
import bayou.ssl.SslConf; | |
import bayou.text.TextHttpEntity; | |
import bayou.util.function.ConsumerX; | |
import javax.net.ssl.SSLEngine; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SunRiseSetAlgo | |
{ | |
static double calcSunrise(int dayOfYear, double localOffset, double latitude, double longitude) | |
{ | |
return calc(dayOfYear, localOffset, latitude, longitude, true); | |
} | |
static double calcSunset(int dayOfYear, double localOffset, double latitude, double longitude) | |
{ | |
return calc(dayOfYear, localOffset, latitude, longitude, false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.awt.Font#getAttributes -> java.util.Map<java.awt.font.TextAttribute, ?> | |
java.awt.Toolkit#mapInputMethodHighlight -> java.util.Map<java.awt.font.TextAttribute, ?> | |
java.awt.datatransfer.DataFlavor#getDefaultRepresentationClass -> java.lang.Class<?> | |
java.awt.datatransfer.DataFlavor#getRepresentationClass -> java.lang.Class<?> | |
java.awt.im.InputMethodHighlight#getStyle -> java.util.Map<java.awt.font.TextAttribute, ?> | |
java.beans.BeanDescriptor#getBeanClass -> java.lang.Class<?> | |
java.beans.BeanDescriptor#getCustomizerClass -> java.lang.Class<?> | |
java.beans.EventSetDescriptor#getListenerType -> java.lang.Class<?> | |
java.beans.IndexedPropertyDescriptor#getIndexedPropertyType -> java.lang.Class<?> | |
java.beans.PropertyDescriptor#getPropertyEditorClass -> java.lang.Class<?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bayou.util; | |
import javax.crypto.Cipher; | |
import javax.crypto.spec.SecretKeySpec; | |
import java.nio.charset.StandardCharsets; | |
import java.security.GeneralSecurityException; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.Base64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package _bayou; | |
import bayou.bytes.ByteSource; | |
import bayou.http.*; | |
import bayou.util.End; | |
import java.nio.ByteBuffer; | |
// simple demo of proxy, log response bodies | |
public class HttpProxyX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bayou; | |
import bayou.http.HttpClient; | |
import bayou.http.HttpClientConf; | |
import bayou.http.HttpResponse; | |
import bayou.ssl.SslConf; | |
import javax.imageio.ImageIO; | |
import javax.net.ssl.SSLEngine; | |
import javax.net.ssl.SSLParameters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bayou.util; | |
import java.util.*; | |
/** | |
* Mutable Map implementation with small memory footprint. | |
* <p> | |
* This class is suitable for maps with small number of entries. | |
* The implementation stores keys and values in an array; | |
* searching a key will be a linear operation. |