This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension=midgard2.so | |
extension=gettext.so | |
extension=mbstring.so | |
extension=posix.so | |
extension=pcntl.so | |
extension=xdebug.so | |
display_errors=On |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.PriorityBlockingQueue | |
import java.util.concurrent.ArrayBlockingQueue | |
public class SlidingWindowMap | |
{ | |
def queue | |
def periodMs | |
public SlidingWindowMap(Set<String> keys, int maxCount, long periodMs) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://beust.com/weblog/2012/09/02/coding-challenge-a-sliding-window-map/ | |
import java.util.concurrent.PriorityBlockingQueue | |
public class SlidingWindowMap | |
{ | |
def queue | |
def windowWidthMillis | |
public SlidingWindowMap(Set<String> keys, int maxCount, long periodMs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
import java.util.Set; | |
public class School { | |
private final String name; | |
private final String nickname; // Nicks are not unique. How many Aggies are there? | |
public School(String name, String nickname) { | |
this.name = name; | |
this.nickname = nickname; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.HashMap; | |
import java.util.IdentityHashMap; | |
import java.util.Iterator; | |
import java.util.Map; | |
import java.util.Set; | |
// Here's a generalized answer to Cedric's School Challenge. | |
// Object identity is the transitive closure of all objects where any key is equal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; My first bit of Clojure. | |
;; https://code.google.com/codejam/contest/2270488/dashboard#s=p3 | |
(def test_chests '({:name 1 :opener 1 :contents ()} {:name 2 :opener 1 :contents (1 3)} {:name 3 :opener 2 :contents ()} {:name 4 :opener 3 :contents (2)})) | |
(defn remove-first [pred lst] | |
(if (pred (first lst)) (rest lst) (cons (first lst) (remove-first pred (rest lst))))) | |
;; Return sequence of chest names to open all the chests starting with the given list (multiset) of keys. | |
;; Return nil if there is no combination that opens all the chests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Something extends BuilderSupport | |
{ | |
// Convenience build method. | |
// Alternatively you can construct the builder then use it: | |
// def something = new Something().something { ... } | |
static def build(Closure cl) { | |
cl.delegate = new Something() | |
cl.call() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.swing.SwingBuilder | |
import javax.swing.JTable | |
import javax.swing.table.AbstractTableModel | |
import javax.swing.table.TableModel | |
class MyTableModel extends AbstractTableModel { | |
List<List> queryResult | |
int getRowCount() { queryResult.size() } | |
int getColumnCount() { queryResult[0].size() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test | |
import javax.script.Bindings | |
class Tests | |
{ | |
@Test | |
def void testSP() | |
{ | |
def p = new Foo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
@Grab(group='org.apache.lucene', module='lucene-analyzers-common', version='4.5.1') | |
import org.apache.lucene.analysis.standard.StandardAnalyzer | |
import org.apache.lucene.document.Document | |
import org.apache.lucene.document.Field | |
import org.apache.lucene.index.DirectoryReader | |
import org.apache.lucene.index.IndexWriter | |
import org.apache.lucene.index.IndexWriterConfig |
OlderNewer