Skip to content

Instantly share code, notes, and snippets.

View SeanTAllen's full-sized avatar
🐴
Seriouspony

Sean T Allen SeanTAllen

🐴
Seriouspony
View GitHub Profile
// WHY DOES PATTERN MATCH EXHAUSTIVENESS CHECK ONLY WORK WHEN
// THE CASE CLASS IS SEALED?
case class Foo(a: Option[String])
sealed case class Bar(a: Option[String])
sealed trait Zed
case class Alpha(a: Option[String]) extends Zed
// This causes a scala matchError at runtime
Foo(None) match {
case Foo(Some(x)) => x
case class Foo(a: Option[String])
Foo(Some("string")) match {
case Foo(None) => "compiles w/o warning"
}
val z: Option[String] = None
z match {
case None => "doesn't compile w/o warning"
@SeanTAllen
SeanTAllen / gist:24be2bb89ad4a05bf702
Last active August 29, 2015 14:08
When settings aren't used
➜ apache-storm-0.9.2-incubating ag "topology.enable.message.timeouts"
conf/defaults.yaml
122:topology.enable.message.timeouts: true
storm-core/src/jvm/backtype/storm/Config.java
512: public static final String TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS = "topology.enable.message.timeouts";
➜ apache-storm-0.9.2-incubating ag TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS
storm-core/src/jvm/backtype/storm/Config.java
512: public static final String TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS = "topology.enable.message.timeouts";
@SeanTAllen
SeanTAllen / gist:83d2e442c52feaf1dcb2
Last active August 29, 2015 14:07
Books looking for a home
HELP! I have too many programming books. Time to find some a home. What follows is a list of ones that are currently not in storage that are looking for a home. Perhaps someday the ones in storage will end up looking for a home as well.
You need to be able to come get any that you want in Williamsburg, Brooklyn or maybe Soho.
I can ship some to you if you pay for shipping ahead of time.
If you are interested in when a particular one is from (some might be rather old), ask.
The EXIM SMTP Mail Server - 2nd edition
Hardening Apache
Hardening Linux
GNU Emacs Manual v 22
@SeanTAllen
SeanTAllen / gist:c61d1b1431169cefaad7
Created August 16, 2014 14:01
What exactly is going on here?
(defn mk-executor-transfer-fn [batch-transfer->worker]
(fn this
([task tuple block? ^List overflow-buffer]
(if (and overflow-buffer (not (.isEmpty overflow-buffer)))
(.add overflow-buffer [task tuple])
(try-cause
(disruptor/publish batch-transfer->worker [task tuple] block?)
(catch InsufficientCapacityException e
(if overflow-buffer
(.add overflow-buffer [task tuple])
@SeanTAllen
SeanTAllen / gist:70ace1159f5e1448b07b
Last active August 29, 2015 14:05
An answer to your question from yesterday...
All memory for the ring buffer is pre-allocated on start up. A ring-buffer can store either
an array of pointers to entries or an array of structures representing the entries.
The limitations of the Java language mean that entries are associated with the ring-buffer
as pointers to objects. Each of these entries is typically not the data being passed itself,
but a container for it. This pre-allocation of entries eliminates issues in languages that
support garbage collection, since the entries will be re- used and live for the duration of
the Disruptor instance. The memory for these entries is allocated at the same time and it is
highly likely that it will be laid out contiguously in main memory and so support cache striding.
There is a proposal by John Rose to introduce “value types”5 to the Java language which would allow
arrays of tuples, like other languages such as C, and so ensure that memory would be allocated
@SeanTAllen
SeanTAllen / gist:48fabdd93ff465329898
Last active August 29, 2015 14:05
Having an "ummm" moments with this Storm code
;; max-buffer-size which is a configuration option is no longer used as of 0.9.2 but is still in method signature. bug?
(defn- mk-receive-thread [context storm-id port transfer-local-fn daemon kill-fn priority socket max-buffer-size thread-id]
(async-loop
(fn []
(log-message "Starting receive-thread: [stormId: " storm-id ", port: " port ", thread-id: " thread-id " ]")
(fn []
(let [batched (ArrayList.)
^Iterator iter (.recv ^IConnection socket 0 thread-id)
closed (atom false)]
2014-05-28T18:26:14.382-0400: 17664.570: [CMS-concurrent-mark-start]
2014-05-28T18:26:17.605-0400: 17667.793: [CMS-concurrent-mark: 3.223/3.223 secs] [Times: user=16.49 sys=2.03, real=3.23 secs]
2014-05-28T18:26:17.605-0400: 17667.793: [CMS-concurrent-preclean-start]
2014-05-28T18:26:17.678-0400: 17667.866: [CMS-concurrent-preclean: 0.070/0.073 secs] [Times: user=0.08 sys=0.00, real=0.07 secs]
2014-05-28T18:26:17.678-0400: 17667.866: [CMS-concurrent-abortable-preclean-start]
CMS: abort preclean due to time 2014-05-28T18:26:23.351-0400: 17673.539: [CMS-concurrent-abortable-preclean: 5.658/5.673 secs] [Times: user=9.37 sys=1.23, real=5.67 secs]
2014-05-28T18:26:23.855-0400: 17674.043: [CMS-concurrent-sweep-start]
2014-05-28T18:26:30.855-0400: 17681.043: [CMS-concurrent-sweep: 7.000/7.000 secs] [Times: user=17.07 sys=4.41, real=6.99 secs]
2014-05-28T18:26:30.858-0400: 17681.046: [CMS-concurrent-reset-start]
2014-05-28T18:26:30.885-0400: 17681.073: [CMS-concurrent-reset: 0.027/0.027 secs] [Times: user=0.04 s
-Xms7973m -Xmx7973m -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC
-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError
-Xmn2g -XX:+PrintGCTimeStamps -XX:+PrintGCDetails
-Xloggc:/opt/es-debug/gc.log -XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=1M -XX:+PrintGCDateStamps
-XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintSafepointStatistics
@SeanTAllen
SeanTAllen / gist:9780447
Created March 26, 2014 10:29
Live in production...
<dependency>
<groupId>com.basho.riak</groupId>
<artifactId>riak-client</artifactId>
<version>2.0.0-DEVELOP-LADDERS-1</version>
</dependency>