Skip to content

Instantly share code, notes, and snippets.

View arinto's full-sized avatar

Arinto Murdopo arinto

View GitHub Profile
@arinto
arinto / spam.py
Last active January 13, 2016 04:27
Spam in Python
def printSpam():
print 'Spam!'
printSpam()
@arinto
arinto / all-options.elasticsearch.yml
Last active September 26, 2018 18:12
`elasticsearch.yml` with all options
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
@arinto
arinto / java-numbers.md
Last active August 29, 2015 14:01
Numbers that every Java programmers and developers should know!

Java numbers..

that every Java programmers/developers should know. Feel free to contribute by forking and pull requests! :bowtie:

###Size of primitive data types

  • byte: 1 byte, 8-bit signed two's complement, default 0
  • short: 2 bytes, 16-bit signed two's complement, default 0
  • int: 4 bytes, 32-bit signed two's complement, default 0
  • long: 8 bytes, 64-bit signed two's complement, default 0L
  • float: 4 bytes, 32-bit, default 0.0f
@arinto
arinto / StaticMethodReference.java
Created April 7, 2014 16:39
Static method reference example.
public class StaticMethodReference {
public static void main(String[] args) {
Random random = new Random();
Set<Integer> theIntSet = new HashSet<>();
for(int i = 0; i < 10;i++) {
theIntSet.add(Integer.valueOf(random.nextInt(100)));
}
@arinto
arinto / TargetTyping.java
Last active April 7, 2017 05:49
A target-typing example in Java 8
public class TargetTyping {
public static void main(String[] args) throws IOException {
String value = System.getProperty("user.dir");
File f = new File(value);
//without target typing
System.out.println("Without target typing example, to find file that ends with xml");
for(File resFile: f.listFiles((File sf) -> sf.getName().endsWith(".xml"))) {
@arinto
arinto / ParallelStreamExample.java
Last active August 29, 2015 13:58
A parallel stream example
public class ParallelStreamExample {
public static void main(String[] args) {
Collection<Student> students = initStudents();
students.parallelStream()
.filter(s -> year == s.getGradYear() && s.getGrade() > 90)
.forEach(s -> System.out.println(s));
@arinto
arinto / StreamExample.java
Last active August 29, 2015 13:58
A stream example in Java 8
public class StreamExample {
public static void main(String[] args) {
Collection<Student> students = initStudents();
students.stream()
.filter(s -> year == s.getGradYear() && s.getGrade() > 90)
.forEach(s -> System.out.println(s));
}
@arinto
arinto / Awesome.java
Last active August 29, 2015 13:58
Awesome interface with its default method
public interface Awesome {
/**
* say hello!
*/
void sayHello();
/**
* eat something!
* @param something thing to be eaten
@arinto
arinto / Awesome.java
Last active August 29, 2015 13:58
A very simple Awesome interface
public interface Awesome {
/**
* say hello!
*/
void sayHello();
}
@arinto
arinto / FindMaxLambda.java
Last active August 29, 2015 13:58
Finding max grade using lambda expression in Java
public class FindMaxLambda {
public static void main(String[] args) {
Set<Student> aSetOfStudent = initStudents();
OptionalInt maxGrade =
aSetOfStudents
.stream().filter(s -> 2014 == s.getGraduationYear())
.map(s -> s.getScore())
.max();