Skip to content

Instantly share code, notes, and snippets.

View darekmydlarz's full-sized avatar
👨‍💻
Senior Software Engineer

Dariusz Mydlarz darekmydlarz

👨‍💻
Senior Software Engineer
View GitHub Profile
@darekmydlarz
darekmydlarz / bahs_quotes.sh
Created March 25, 2016 09:34
show bash quotes in your console
# install fortune
brew install fortune
# backup current fortunes
mv -r /usr/local/Cellar/fortune/9708/share/games/fortunes /usr/local/Cellar/fortune/9708/share/games/fortunes.bak
# download bash.org.pl quotes
curl -s http://bash.org.pl/text > bash_text
# create random access file
@darekmydlarz
darekmydlarz / jupyter_notebook_config.py
Last active March 29, 2016 12:05
jupyter pyspark configuration file
# jupyter notebook --generate-config
# vim .jupyter/jupyter_notebook_config.py
import os
import sys
spark_home = os.environ.get('SPARK_HOME', None)
sys.path.insert(0, spark_home + "/python")
# FIXME make sure you have got correct py4j version
sys.path.insert(0, os.path.join(spark_home, 'python/lib/py4j-0.9-src.zip'))
@darekmydlarz
darekmydlarz / Task.java
Last active March 30, 2016 10:54
How to test time dependent code in Java? [czystykod.pl]
public class Task {
public String getAction() {...}
public LocalDateTime getDueDate() {...}
public boolean isOverdue(Clock clock) {
return LocalDateTime.now(clock).isAfter(getDueDate());
}
}
@darekmydlarz
darekmydlarz / Java8vsPre8.java
Created July 5, 2016 08:45
Java 8 vs Java pre-8
void prejava8() throws MalformedUrlException {
Map<String, Cluster> clusters = Maps.newHashMap();
for (final Map<String, Object> clusterYml : clustersListYml) {
Cluster cluster = new HystrixCluster(clusterAdapter.fromMap(clusterYml));
clusters.put(cluster.name(), cluster);
}
return clusters;
}
void java8() {

Keybase proof

I hereby claim:

  • I am dmydlarz on github.
  • I am dmydlarz (https://keybase.io/dmydlarz) on keybase.
  • I have a public key ASBWpjF_o-mj0hbfz92oU83e6FFunYYPIqsqjljk5sCUIwo

To claim this, I am signing this object:

@darekmydlarz
darekmydlarz / latency.markdown
Created November 10, 2016 12:55 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@darekmydlarz
darekmydlarz / introrx.md
Created December 12, 2016 10:00 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@darekmydlarz
darekmydlarz / javaslang.java
Last active June 28, 2017 07:27
javaslang vs java8
// vavr (aka javaslang)
public Set<Integer> usersIds() {
return managerNode.descendants()
.flatMap(Node::userIds);
}
// (POJ8) Plain Old Java 8
public java.util.Set<Integer> usersIds() {
return managerNode.descendants()
.stream()
@darekmydlarz
darekmydlarz / server.py
Created September 21, 2017 12:48 — forked from raelmax/server.py
Python SimpleHTTPServer com sleep
import SimpleHTTPServer
import SocketServer
from time import sleep
PORT = 5000
SLEEP_TIME = 6
class SlowHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):