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
(write-with [this type user-space-id history] | |
(sql/with-connection {:datasource this} | |
(let [table :history2 | |
where-params ["type = ? and user_space_id = ?" type user-space-id] | |
record {:user_space_id user-space-id, :type type, :history history}] | |
(sql/transaction | |
(let [result (sql/update-values table where-params record)] | |
(if (zero? (first result)) | |
(locking this | |
(sql/insert-values table (keys record) (vals record)) |
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
(write-with [this type user-space-id history] | |
(sql/with-connection {:datasource this} | |
(let [table :history2 | |
where-params ["type = ? and user_space_id = ?" type user-space-id] | |
record {:user_space_id user-space-id, :type type, :history history}] | |
(sql/transaction | |
(let [result (sql/update-values table where-params record)] | |
(if (zero? (first result)) | |
(locking this | |
(sql/insert-values table (keys record) (vals record)) |
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
package com.farpost; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.AtomicLong; | |
import java.util.concurrent.locks.Lock; | |
import java.util.concurrent.locks.ReentrantLock; | |
import static java.lang.System.nanoTime; | |
public class Main { |
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
package com.farpost; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.InvocationTargetException; | |
import java.util.*; | |
final public class Bla { | |
private Bla() { | |
} |
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
package com.farpost.search.statbuilder.termset; | |
import com.farpost.search.statbuilder.util.OrderedSource; | |
import com.farpost.search.statbuilder.util.Source; | |
import com.sun.istack.Nullable; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.io.IOException; | |
import java.util.List; |
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
package com.farpost.search.statbuilder.termset; | |
import com.farpost.search.statbuilder.util.OrderedSource; | |
import com.farpost.search.statbuilder.util.Source; | |
import com.sun.istack.Nullable; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.io.IOException; | |
import java.util.List; |
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
@Test | |
public void test() throws IOException { | |
//BufferedImage bi = bytesToBufferedImage(readBytesFromFile(this, "1401403088318_default.png")); | |
//pls change readBytesFromFile if not storing file in /resources | |
BufferedImage bi = ImageIO.read(new ByteArrayInputStream(readBytesFromFile(this, "1401403088318_default.png"))); | |
System.out.println(bi.getColorModel().getColorSpace().getType()); | |
if (bi.getType() == BufferedImage.TYPE_USHORT_GRAY) { |
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
-- The idea is to have Clojure threading macro '->>' in Haskell: | |
-- (->> 1 repeat (map (* 2)) (take 10) (map (* 2)) (map (+ 40)) (foldl + 0)) | |
-- where (->> x f1 f2 f3 f4) means literally this: "f4 (f3 (f2 (f1 x)))" | |
-- Same in Haskell: "f4 . f3 . f2 . f1 $ x" | |
-- Let's try to implement it | |
data Apply a b = Apply { x :: a, f :: a -> b } | |
(->>) :: a -> (a -> b) -> Apply a b | |
(->>) x f = Apply x f |
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
package com.farpost.imagestorage; | |
import com.farpost.imagestorage.duplicate.index.mongo.MongoDbIndex; | |
import com.mongodb.MongoClient; | |
import org.bson.types.Binary; | |
import java.io.*; | |
import java.math.BigInteger; | |
import java.net.UnknownHostException; | |
import java.util.List; |
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
package anton.logvinenko; | |
import javafx.util.Pair; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.concurrent.atomic.AtomicReference; | |
import java.util.function.Function; | |
public class Parser<S> { |
OlderNewer