Skip to content

Instantly share code, notes, and snippets.

View samidalouche's full-sized avatar

Sami Dalouche samidalouche

View GitHub Profile
/**
* Semi-automatic derivation done similarly to how Kittens does it
*
* @see https://github.com/typelevel/kittens/blob/master/core/src/main/scala/cats/derived/package.scala
* */
final object generic {
final object semi {
def deriveSchema[A](implicit ev: MkAvroSchema[A]): HasAvroSchema[A] = ev
}
@samidalouche
samidalouche / ListenForChanges.scala
Last active May 16, 2017 18:08
Subscription doesn't get notified of new elements when reconnecting too early on EventStore
package esplayground
import akka.Done
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Sink, Source}
import eventstore.Content.Json
import eventstore.{EventData, EventNumber, EventStoreExtension, EventStream, WriteEvents}
public func streamMessages(from startOffset: Offset = Offset(value: 0), toExclusive endOffsetOpt : Offset? = .None,
includeTransient: Bool = true) -> SignalProducer<Message, NoError> {
func streamMessagesChunk(from: Offset) -> SignalProducer<Message, NoError> {
func waitForNewMessageAvailable(from: Offset) -> SignalProducer<Offset?, NoError> {
return self.lastOffsetIncludingTransient(includeTransient).producer
.filter{ offsetOpt in offsetOpt.map {offset in offset >= from } ?? false }
.take(1)
}
kpi.video_downloads.requested.tic,videoId=0cd8a04b-61a4-4bb3-8e1c-faf8be10bb2f,accountId=0291e400-62c1-4709-bfbb-fdeec06c54c4,partnerId=OM,isExternal=true value=1 1432258851872
kpi.video_downloads.requested.tic,videoId=0cd8a04b-61a4-4bb3-8e1c-faf8be10bb2f,accountId=0291e400-62c1-4709-bfbb-fdeec06c54c4,partnerId=OM,isExternal=true value=1 1432326384353
kpi.video_downloads.requested.tic,videoId=0cd8a04b-61a4-4bb3-8e1c-faf8be10bb2f,accountId=0291e400-62c1-4709-bfbb-fdeec06c54c4,partnerId=OM,isExternal=true value=1 1432253103199
kpi.video_downloads.requested.tic,videoId=0cd8a04b-61a4-4bb3-8e1c-faf8be10bb2f,accountId=0291e400-62c1-4709-bfbb-fdeec06c54c4,partnerId=OM,isExternal=true value=1 1432296867591
kpi.video_downloads.requested.tic,videoId=0cd8a04b-61a4-4bb3-8e1c-faf8be10bb2f,accountId=0291e400-62c1-4709-bfbb-fdeec06c54c4,partnerId=OM,isExternal=true value=1 1432318511360
kpi.video_downloads.requested.tic,videoId=0cd8a04b-61a4-4bb3-8e1c-faf8be10bb2f,accountId=0291e400-62c1-4709-bfbb-fdeec06c54c4,partner
#!/bin/bash
USERS=10
DAYS=30
MAX_USAGE_SECONDS=$((120*60))
START_TIME=1388534400000
MILLIS_PER_DAY=$((1000*60*60*24))
COLLECTION="kpi.weartime.sync.allaccounts.seconds"
generateUserData()
@samidalouche
samidalouche / gist:5c6bdd2bb8a10609cfb9
Last active August 29, 2015 14:10
OMsignal Full Stack Software Engineer [REMOTE or LOCAL]
OMsignal, Montreal | http://www.omsignal.com -
Full Stack Scala/iOS/NodeJS/Machine Learning/etc Software Engineer [REMOTE or LOCAL]
OMsignal is made possible by the expertise of Smart Textile experts,
Data/Bio Scientists, Hardware, Firmware and
Software Engineers. Please note that this offer is mostly focused on
Full Stack Engineers, but we are also looking to
hire smart Data Scientists who have an interest in biodata and possibly
people who could help bridging BLE/MSP firmware and driver development.
case class SdkSignInCommand(accountId: UUID, appId: String, deviceId: String)
case class SdkSignInConfirmation(
accountId: UUID,
firstName: String,
lastName: String,
email: String,
pairingKey: Int,
sdkId: UUID,
isSdkLinkedToAccount: Boolean,
boxLink: Option[DisplayableBoxLink]
____ _ _
| _ \ ___ ___ ___(_) __| | ___ _ __
| |_) / _ \/ __|/ _ \ |/ _` |/ _ \| '_ \
| __/ (_) \__ \ __/ | (_| | (_) | | | |
|_| \___/|___/\___|_|\__,_|\___/|_| |_|
def bucketHourOpenClosed : joda.Interval = {
val hourTruncated = dateTime.withTime(dateTime.getHourOfDay, 0, 0, 0)
if(dateTime == hourTruncated){
new joda.Interval(dateTime.minusHours(1),dateTime)
} else {
new joda.Interval(hourTruncated,hourTruncated.plusHours(1))
}
}
{"inhalationStartedEvents":[{"volume":5000.5,"name":"InhalationStartedEvent","timestamp":"2013-10-03 18:40:52 +0000"}],"breathingCycleDetectedEvents":[{"volumeOnInhalationStart":2000,"inhalationEnd":"2013-10-03 18:40:53 +0000","name":"BreathingCycleDetectedEvent","exhalationEnd":"2013-10-03 18:41:01 +0000","volumeOnExhalationStart":500,"inhalationStart":"2013-10-03 18:40:52 +0000","exhalationStart":"2013-10-03 18:40:55 +0000"}],"breathingQualitySampledEvents":[{"end":"2013-10-03 18:40:53 +0000","ok":true,"noisyAbdominalBelt":false,"abdominalBeltBaselineShift":false,"name":"BreathingQualitySampledEvent","abdominalBeltDisconnected":false,"thoracicBeltBaselineShift":true,"thoracicBeltDisconnected":true,"start":"2013-10-03 18:40:52 +0000","noisyThoracicBelt":true}],"stepDetectedEvents":[{"name":"StepDetectedEvent","timestamp":"2013-10-03 18:40:52 +0000"},{"name":"StepDetectedEvent","timestamp":"2013-10-03 18:40:53 +0000"}],"sessionStartedEvents":[{"hexoskinSerialNumber":"XV1","hexoskinHardwareVersion":"V23","shir