Skip to content

Instantly share code, notes, and snippets.

@duane
duane / gist:9841277
Last active August 29, 2015 13:57
Duane, no! You'll make god cry!
val (unseenItems, changedItems, unchangedItems, status) = items.getData.grouped(3).map(_.toList).
foldLeft[(List[MediaFeedData], List[MediaFeedData], List[MediaFeedData], Map[String, Long])]((Nil, Nil, Nil, Map.empty))({
case ((unseenSoFar, changedSoFar, unchangedSoFar, statusMap), unseen :: changed :: unchanged :: Nil) => {
(
unseen :: unseenSoFar,
changed :: changedSoFar,
unchanged :: unchangedSoFar,
statusMap ++ Map(unseen.getId -> 0L,
changed.getId -> (changed.getComments.getCount.toLong - 1L),
unchanged.getId -> unchanged.getComments.getCount.toLong))
@duane
duane / gist:11187444
Created April 22, 2014 17:21
Scalac compiler problem
[error] /Users/duane/pinsights/pinsights-utils/src/main/scala/com/getpinsights/utils/WorkerAuditor.scala:70: unsupported pattern: (_: Exception) (a class scala.reflect.internal.Trees$Typed).
[error] This is a scalac bug. Tree diagnostics: (_: Exception){<null>}.
[error] case e: Exception => {
[error] ^
while compiling: /Users/duane/pinsights/pinsights-utils/src/main/scala/com/getpinsights/utils/WorkerAuditor.scala
during phase: patmat
library version: version 2.10.4
compiler version: version 2.10.4
reconstructed args: -classpath /Users/duane/pinsights/pinsights-utils/target/classes:/Users/duane/.m2/repository/com/typesafe/akka/akka-actor/2.0.5/akka-actor-2.0.5.jar:/Users/duane/.m2/repository/com/typesafe/config/0.3.1/config-0.3.1.jar:/Users/duane/.m2/repository/org/apache/curator/curator-recipes/2.2.0-incubating/curator-recipes-2.2.0-incubating.jar:/Users/duane/.m2/repository/org/apache/curator/curator-framework/2.2.0-incubating/curator-framework-2.2.0-i
@duane
duane / crash.scala
Created April 22, 2014 17:25
Scalac crash
def run() {
Thread.sleep(60000)
while (true) {
val start = System.currentTimeMillis()
val next = start + 60000
val numJobsToReport = numJobs
if (numJobsToReport != 0) {
val totalJobTimeToReport = totalJobTime
fn parse_term<'i>(input: &'i mut ParserStream<'i>) -> Result<Option<LinearExpression>, String> {
let coef = Parser::parse_scalar(input).unwrap();
input.skip_whitespace();
let var = Parser::parse_identifier(input).unwrap();
match (coef, var) {
(Some(scalar), Some(var)) => Ok(Some(LinearExpression::term(var, scalar))),
(Some(scalar), None) => Ok(Some(LinearExpression::from(scalar))),
(None, Some(var)) => Ok(Some(LinearExpression::from(var))),
(None, None) => Ok(None)
}
@duane
duane / bls.js
Last active April 13, 2016 01:48
$(".greenbar").removeClass("greenbar");
$('#cps_eeann_mwe_ft_det_occu tbody tr').each(function(i, el) {
var rows = $(el).find("td");
if (rows.length !== 6) {
return;
}
var stripAndParse = function(td){return parseFloat($(td).text().replace(/[$,]/g,''));},
men = stripAndParse(rows[3]),
women = stripAndParse(rows[5]);
if (!isNaN(men) && !isNaN(women)) {

Keybase proof

I hereby claim:

  • I am duane on github.
  • I am drb (https://keybase.io/drb) on keybase.
  • I have a public key ASCYmQaidv-55raLIZDpt0uEeowdLoUG_gNrIhO_St-1Owo

To claim this, I am signing this object:

# Prints out a tree like this (branches_height = 5) with a pedestal:
#
# x
# xxx
# xxxxx
# xxxxxxx
# xxxxxxxxx
# |
# ===
def render_tree(branches_height)