Skip to content

Instantly share code, notes, and snippets.

@irineu
irineu / EchoClient.java
Created August 27, 2022 17:55 — forked from ochinchina/EchoClient.java
Async socket demo in java
package asyncsocket;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;
import java.util.concurrent.atomic.AtomicInteger;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@irineu
irineu / heartbeat.js
Last active November 27, 2016 15:06
d3 heartbeat
var myApp = angular.module("myApp",[]);
myApp.directive('heartbeat', function($interval, $window) {
return {
restrict: 'E',
scope: {},
templateUrl: 'directives/heartbeat.html',
link: function(scope, element, attr) {
var el = $(element).find(".heartbeat").get(0);
@irineu
irineu / Checksum
Created July 14, 2015 18:26
Java checksum MD5
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
public class Main {
public static byte[] getMD5Checksum(String filename) throws Exception {
InputStream fis = new FileInputStream(filename);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] buffer = new byte[1024];