public static <T> Function<T, IndexedItem<T>> indexed() {
AtomicInteger count = new AtomicInteger();
return (t) -> new IndexedItem<T>(count.getAndIncrement(), t);
}
public static class IndexedItem<T> {
public final Integer index;
public final T item;
This file contains hidden or 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
| /** | |
| * Highly influenced by: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java | |
| * Copyright (c) Rich Hickey. All rights reserved. | |
| * The use and distribution terms for this software are covered by the | |
| * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
| * which can be found in the file epl-v10.html at the root of this distribution. | |
| * By using this software in any fashion, you are agreeing to be bound by | |
| * the terms of this license. | |
| * You must not remove this notice, or any other, from this software. | |
| **/ |
This file contains hidden or 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 org.junit.runner.RunWith; | |
| import static org.mockito.Mockito.*; | |
| import org.mockito.runners.MockitoJUnitRunner; | |
| @RunWith(MockitoJUnitRunner.class) | |
| public class MockitoSpyTest { |
This file contains hidden or 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/ruby | |
| dirty = ARGV.include? "-d" | |
| change_dir = ARGV.include? "-cd" | |
| search = ARGV.find{|x| ! x.start_with? "-"} | |
| repos = Dir.glob("/home/alee/workspaces/**/.git/").collect() | |
| class String | |
| def brown; "\033[33m#{self.strip! || self}\033[0m" end |
This file contains hidden or 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
| (ns diamond.core | |
| (:gen-class)) | |
| (defn letter-index [char] (- (+ 1 (int char)) (int \a))) | |
| (def letter-seq (map char (range (int \a) (+ 1 (int \z))))) | |
| (defn format-line [[char indent inner-space]] | |
| (let [whitespace (fn [i] (apply str (repeat i " "))) | |
| last-char (if (not= char \a) char "")] |
This file contains hidden or 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
| (ns test-client.core | |
| (:gen-class) | |
| (:require [thrift-clj.core :as thrift] | |
| [environ.core :refer [env]])) | |
| (thrift/import | |
| (:types [github.thrift.mongo.core.api Commit] | |
| [github.thrift.mongo.core.api Push]) | |
| (:clients github.thrift.mongo.core.api.PushService)) |
This file contains hidden or 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
| #/bin/bash | |
| NAME="thrift-server" | |
| VERSION="0.1.0" | |
| LOCATION="/opt/$NAME" | |
| JAR_NAME="server-0.1.0-SNAPSHOT-standalone.jar" | |
| DEB_NAME="${NAME}_${VERSION}_amd64.deb" | |
| lein clean && lein uberjar; |
This file contains hidden or 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 test; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.function.Predicate; | |
| import java.util.stream.Collectors; | |
| public class Main { | |
| public static void main(String[] args) { |
This file contains hidden or 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 uk.co.optimisticpanda.spring.proxy; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import org.springframework.aop.Advisor; | |
| import org.springframework.aop.framework.ProxyFactory; | |
| import org.springframework.aop.support.DefaultIntroductionAdvisor; | |
| import org.springframework.aop.support.DelegatingIntroductionInterceptor; | |
This file contains hidden or 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
| (ns fizzbuzz.core | |
| (:gen-class)) | |
| (defn fizzbuzzify[x] | |
| "Get fizzbuzz result for a specific number." | |
| (cond | |
| (zero? (mod x 15)) "fizzbuzz" | |
| (zero? (mod x 3 )) "fizz" | |
| (zero? (mod x 5 )) "buzz" | |
| :else (str x ))) |