Skip to content

Instantly share code, notes, and snippets.

View frozenspider's full-sized avatar

Alex Abdugafarov frozenspider

View GitHub Profile
// Problematic code snippet, `collect` invocation causes compiler to crash with an error below
val cache2 = cache
.withoutPath(quotedAlias)
.withValue("\"" + url + "\"", newConfig(Map(
"lastCheckMs" -> cacheObj.get[Option[Long]]("lastCheckMs").value,
"lastUpdateMs" -> cacheObj.get[Option[Long]]("lastUpdateMs").value
).collect { case (k, Some(v)) => (k, v) }))
/*
[error] java.lang.IllegalArgumentException: Could not find proxy for case val x1: Tuple2 in List(value x1, method applyOrElse, <$anon: Function1>, value cache2, method $anonfun$post-1.3_1$1, value x1, value x$1, method post-1.3_1, class MigrationService, package migration, package checker, package fs, package org, package <root>) (currentOwner= value k )
function debounce(func, wait, immediate) {
let timeout;
return function() {
let context = this, args = arguments;
let later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
let callNow = immediate && !timeout;
clearTimeout(timeout);
package org.newtonpolyhedron.ex;
public class WrongFormatException extends Exception {
private static final long serialVersionUID = 1943547769150295590L;
public WrongFormatException() {}
public WrongFormatException(String msg) {
super(msg);
@frozenspider
frozenspider / self-recursive-type-failure.scala
Last active November 21, 2015 21:24
self-recursive-type-failure.scala
trait Foo { self =>
type SelfType <: Foo {
type SelfType = self.SelfType
}
}
// SelfType points to its child type
trait FooExtLvl1 extends Foo {
type SelfType = FooExtLvl2
}
@frozenspider
frozenspider / gist:b84eba656aea7a077c9b
Last active August 29, 2015 14:18
GORM/Hibernate associations test
import test.*
Parent.withNewSession {
Parent.withNewTransaction {
def parent = new Parent()
.addToChildren(new Child(name: "a"))
.addToChildren(new Child(name: "b"))
.addToChildren(new Child(name: "c"))
.save(failOnError: true)
}
@frozenspider
frozenspider / merge-and-rebase-history.txt
Last active August 29, 2015 14:06
Merge and rebase history
Merge:
z
|\
| g
x | |
| * |
| | f
| * |
| * |
@frozenspider
frozenspider / slick-queries.sql
Created April 11, 2014 12:04
Slow and fast queries
# Generated by Slick (select terms optimized for clarity)
# Takes 47034 ms
SELECT *
FROM (
SELECT x281.id
FROM `comp_proposal_raw_batch_comp_proposal_raw` x282, `comp_proposal_raw` x281
WHERE (x282.`comp_proposal_raw_batch_proposals_id` = 4936) AND (x281.`id` = x282.`comp_proposal_raw_id`)
) x187
INNER JOIN (
SELECT *
@frozenspider
frozenspider / comp-proposal-dao-query3.sql
Last active August 29, 2015 13:58
comp-proposal-dao-query3
SELECT status_temp.id FROM (
SELECT temp_batch.original_id as id, temp_batch.validation_errors, COUNT(temps_enabled.id), COUNT(temps_disabled.id)
FROM comp_proposal_raw_temp_batch temp_batch
LEFT OUTER JOIN comp_proposal_raw temps_enabled
ON temps_enabled.temp_batch_id = temp_batch.id AND temps_enabled.dont_integrate = 0
LEFT OUTER JOIN comp_proposal_raw temps_disabled
ON temps_disabled.temp_batch_id = temp_batch.id AND temps_disabled.dont_integrate = 1
GROUP BY temp_batch.original_id
HAVING (COUNT(temps_enabled.id) = 0 AND COUNT(temps_disabled.id) > 0) OR temp_batch.validation_errors > 0
) status_temp
trait A {
val a: Int
}
trait B extends A {
println(a)
}
trait C extends A {
override val a: Int = 10
@frozenspider
frozenspider / Parsers.scala
Last active August 29, 2015 13:57
trait Parsers
trait Parsers {
type Elem
type Input = Reader[Elem]
sealed abstract class ParseResult[+T] {
...
}
case class Success[+T](result: T, override val next: Input) extends ParseResult[T] {
...
}