Skip to content

Instantly share code, notes, and snippets.

@arkadijs
arkadijs / Container.java
Created April 19, 2012 09:54
Java VM Type Erasure
package te;
import java.util.ArrayList;
import java.util.List;
public class Container<T> {
public List<T> elems = new ArrayList<T>();
public Container(T arg) {
this.elems.add(arg);
@arkadijs
arkadijs / ArabicNumeralsTest.groovy
Created July 22, 2012 23:01
LDN Coding Dojo: Groovy
class ArabicNumeralsTest extends GroovyTestCase {
def converter = new RomanNumerals()
void testOne() {
assert 1 == converter.toArabic("I")
}
void testDigit() {
assert 4 == converter.toArabic("IV")
import Test.Hspec
import Data.List
anagrams :: [String] -> String -> [String]
anagrams lwords checkword = filter (wordsAreAnagrams checkword) lwords
wordsAreAnagrams :: String -> String -> Bool
wordsAreAnagrams a b = (a /= b) && (sort a == sort b)
allAnagrams :: [String] -> [[String]]
@arkadijs
arkadijs / cron.scala
Last active December 10, 2015 12:48
TreSQL usage examples
transactional {
val delta = event.days // 7 days
val q =
"""
|construction_merchants [status = :active] {id}
|-
| construction_merchants merchant
|[merchant.prn_id = official_list.prn_id] official_list
|[official_list.child_id = member.prn_id] construction_merchants member
|[merchant.status = :active & member.status = :active & official_list.date_to = null & official_list.typ = :org]
@arkadijs
arkadijs / README.md
Last active December 17, 2015 00:09
Homework for LDN event Workshop: Clojure http://ldn.lv/events/113852292/

Immutant primer

Homework for LDN event [Workshop: Clojure][event].

Task

Follow [Immutant Tutorials][tutorials] and install [Leiningen][leiningen] and [Immutant][install].

  1. Create [web handler][deploy] for /?counter=some-name
  2. Create [queue][messaging] to enqueue some-name
  3. Create [cache][caching]
  4. Read from queue and increment cache(some-name)
@arkadijs
arkadijs / gameoflife1.py
Created December 24, 2013 22:52
Coderetreat: Java 8 vs Scala http://ldn.lv/events/138303652/ (Python quietly sneaks in)
import time
def cell_transition(alive, neighbour_count):
return neighbour_count in (2, 3) if alive else neighbour_count == 3
class RectField(object):
def __init__(self, size, cells):
self.size = size
@arkadijs
arkadijs / Week1.md
Last active January 4, 2016 09:39
Groovy Grails life

The Origin

I'm here not to teach you - see me as a guiding friend, a facilitator. We'll go together through a journey of getting better at some particular, non-hype, well understood yet sometimes problematic, still modern technology for developing web- and service-oriented applications. Hopefully it will give you a new perspective on how such things could be built.

It's up to you to choose what it'll be for you - an epic or a walk in the park. Most of the value will be to stay till the end, though.

To do the homework I expect about 5 hours of commitment per week -- similar to [Coursera]. Some colleagues already demonstrated that it could be done. But, compared to consuming nicely prepared material, we're on raw side this time -- you'll be setting your own tactical learning plan and digging for materials instead.

Last but not least, my opinion and judgments are always subjective.

object Main {
def main(args: Array[String]) {
val date = new Deserializer().deserialize[java.util.Date]("2014-02-15")
val ints = new Deserializer().deserialize2[Int]("[1, 2, 3]")
}
}
class Deserializer {
import scala.reflect.{ ClassTag, Manifest }