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
/** | |
* Created by smallufo on 2015-02-22. | |
*/ | |
package twitter; | |
import com.squareup.okhttp.*; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import rx.Observable; | |
import rx.Subscriber; |
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
/** | |
* Created by smallufo on 2015-02-22. | |
*/ | |
package twitter; | |
import rx.Observable; | |
import rx.subjects.PublishSubject; | |
import rx.subjects.Subject; | |
import twitter4j.*; | |
import twitter4j.conf.ConfigurationBuilder; |
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
/** | |
* Created by smallufo on 2016-03-21. | |
*/ | |
package destiny.vaadin.components; | |
import com.vaadin.server.FontAwesome; | |
import com.vaadin.ui.Alignment; | |
import com.vaadin.ui.Button; | |
import com.vaadin.ui.Label; | |
import com.vaadin.ui.themes.ValoTheme; |
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
public Observable<Data> toObservable(int batch) { | |
return Observable.create(new Observable.OnSubscribe<Data>() { | |
@Override | |
public void call(Subscriber<? super Data> subscriber) { | |
Session session = ((Session) emp.get().getDelegate()).getSessionFactory().openSession(); | |
Query query = session.createQuery("select d from Data d order by id asc"); | |
query.setFetchSize(batch); | |
query.setReadOnly(true); | |
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY); |
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 Once Read Never | |
Map<Double , Tuple2<Star , StationaryType>> map = stars | |
.stream() | |
.flatMap(star -> { | |
List<Tuple2<Double , StationaryType>> list = getPeriodStationary(star, fromGmt, toGmt, starPositionImpl); | |
return list.stream().map(t -> Tuple.tuple(t.v1() , star , t.v2())); | |
}).collect(Collectors.toMap(Tuple3::v1, t -> Tuple.tuple(t.v2() , t.v3()) , (v1, v2) -> v1 , TreeMap::new)); | |
return map.entrySet().stream() | |
.map(entry -> Tuple.tuple(entry.getKey() , entry.getValue().v1() , entry.getValue().v2())) |
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
public interface IBookService { | |
List<Tuple2<LocalDate , Book>> findBooks(User user , LocalDate from , LocalDate to); | |
} |
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
public interface IBookService { | |
List<Tuple2<LocalDate , Book>> findBooks(User user , LocalDate from , LocalDate to); | |
default List<Tuple3<LocalDate , User , Book>> findUserBooks(List<User> users , LocalDate from , LocalDate to) { | |
Map<LocalDate , Tuple2<User , Book>> map = users.stream() | |
.flatMap(user -> { | |
List<Tuple2<LocalDate , Book>> list = findBooks(user , from , to); | |
return list.stream().map(t -> Tuple.tuple(t.v1 , user , t.v2)); | |
} |
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
interface IBookService { | |
fun findBooks(user: User, from: LocalDate, to: LocalDate): List<Tuple2<LocalDate, Book>> | |
fun findUserBooks(users: List<User>, from: LocalDate, to: LocalDate): List<Tuple3<LocalDate, User, Book>> { | |
val map = users.stream() | |
.flatMap { user -> | |
val list = findBooks(user, from, to) | |
list.stream().map { t -> Tuple.tuple(t.v1, user, t.v2) } | |
}.collect<TreeMap<LocalDate, Tuple2<User, Book>>, Any>(Collectors.toMap( |
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
interface IBookService { | |
fun findBooks(user: User, from: LocalDate, to: LocalDate): List<Tuple2<LocalDate, Book>> | |
fun findUserBooks(users: List<User>, from: LocalDate, to: LocalDate): List<Tuple3<LocalDate, User, Book>> { | |
return users.flatMap { user -> | |
findBooks(user , from , to).map { it -> Tuple3(it.v1 , user , it.v2) } | |
}.sortedBy { triple -> triple.v1 } | |
} | |
} |
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
fun getNextFullMoon(from: LocalDateTime): LocalDateTime | |
fun getYearlyFullMoons(year: Int): List<LocalDateTime> { | |
val startOfYear = LocalDateTime.of(year, 1, 1, 0, 0) | |
return generateSequence (getNextFullMoon(startOfYear)) { | |
getNextFullMoon(it.plusDays(1)) | |
}.takeWhile { it.year == year } | |
.toList() | |
} |
OlderNewer