Skip to content

Instantly share code, notes, and snippets.

View ajermakovics's full-sized avatar
🎯
Focusing

Andrejs Jermakovics ajermakovics

🎯
Focusing
View GitHub Profile
@amaembo
amaembo / Test.java
Created May 19, 2020 15:12
Reified generics in Java
import java.util.*;
@SuppressWarnings("ALL")
class Test {
static class ReifiedList<T> extends AbstractList<T> {
private final List<T> delegate = new ArrayList<>();
private final Class<?> type;
@SafeVarargs
ReifiedList(@Deprecated T... unused) {
@janhoy
janhoy / jvm-mon.rb
Created March 27, 2017 11:25
jvm-mon brew formulae
# Documentation: http://docs.brew.sh/Formula-Cookbook.html
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
class JvmMon < Formula
desc "Console based JVM monitoring"
homepage "https://github.com/ajermakovics/jvm-mon"
url "https://github.com/ajermakovics/jvm-mon/releases/download/0.2/jvm-mon-0.2.tar.gz"
sha256 "3f85e8fec42449d8af831657ede96c9b7a5d12e80b35dbbc14f2e00eae301f28"
depends_on :java => "1.8+"

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o

@ajermakovics
ajermakovics / java_web_frameworks.md
Last active June 16, 2023 08:33
A list of Java web frameworks and toolkits
@dpryden
dpryden / ClassLoaderLeakExample.java
Created October 20, 2014 00:01
Example of a ClassLoader leak in Java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,
Development Cycle:
By starting today we're switching to a pull-request based development. Instead of pushing directly to main repo (github.com/hazelcast/hazelcast), everybody should push his bugfix/improvement/feature to his own git fork and send a pull request to merge with main repo. There will be no direct push to main repo branches.
This requires everybody to work two separate remote repositories. First of all, everybody should have a fork of main repo in their own account (I guess nearly everybody has already a fork at the moment). If not, go to github.com/hazelcast/hazelcast and press the fork button (top rlght of the page). There may be lots of ways of working with multiple remote repos. I'll try to explain how I work, you can find an easier/comfortable way of your own..
Currently I (and most of you) already have a default remote named 'origin' for main repo. Add your own repo as another remote (You can list current remotes using: git remote -v);
git remote add mdogan git@github.com:mdogan/hazelca

Consul Consistency

As Kyle brought up, Consul at the moment has a single known case of a potential inconsistency (Could be unknown cases lurking). Currently Consul works by electing a leader, who "leases" the position for LeaderLeaseTimeout interval. At each interval, it checks that a quorum of nodes still believes it to be the leader. At the same time, if a follower does not hear from the leader within randomInterva(HeartbeatTimeout, 2 * HeartbeatTimeout), it will start a new election.

@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t
@noctarius
noctarius / gist:7784770
Created December 4, 2013 09:29
Hazelcast MapReduce Avg Example
package com.hazelcast.mapred.test;
import com.hazelcast.core.CompletableFuture;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.mapred.*;
import java.util.List;
import java.util.Map;
@ms-tg
ms-tg / jdk8_optional_monad_laws.java
Created November 11, 2013 21:14
Does JDK8's Optional class satisfy the Monad laws? Yes, it does.
/**
* ```
* Does JDK8's Optional class satisfy the Monad laws?
* =================================================
* 1. Left identity: true
* 2. Right identity: true
* 3. Associativity: true
*
* Yes, it does.
* ```