Skip to content

Instantly share code, notes, and snippets.

View monday8am's full-sized avatar
🙃
meehh

Angel Anton monday8am

🙃
meehh
View GitHub Profile
@monday8am
monday8am / sample_json.json
Created October 3, 2017 19:30
Sample JSON
{
"title": {
"en": "English",
"es": "Spanish"
},
"description": "Description"
}
# run fastlane
# pass 'patch', 'minor' or 'major' as parameter
fastlane ios beta bump:patch
desc "Deploy a new version to the Fabric."
lane :fabric do
# upload to Beta by Crashlytics
crashlytics(
api_token: ENV['FABRIC_API_TOKEN'],
build_secret: ENV['FABRIC_BUILD_SECRET']
)
end
export FABRIC_API_TOKEN=1111
export FABRIC_BUILD_SECRET=x1x1x1x1x1
export GITHUB_TOKEN=11xx1x1x1x1
@monday8am
monday8am / network_middleware.kt
Last active April 1, 2018 11:58
Network Middleware fragment for Unidirectional Flow post.
// This middleware executes the async requests related with the Rest API
internal val networkMiddleware: Middleware<AppState> = { dispatch, state ->
{ next ->
{ action ->
when (action) {
// an async operation is called
is SetDeviceInfo -> { getDeviceDescription(deviceId = action.deviceId,
deviceInfo = action.payload,
dispatch = dispatch) }
@monday8am
monday8am / delivery_state.kt
Created April 1, 2018 12:31
Delivery state described in Kotlin
sealed class DeliveryState: StateType {
object NotStarted: DeliveryState()
data class SettingUp (val appId: AppId,
val serviceId: ServiceId,
val description: ServiceDescription? = null): DeliveryState()
data class Going (val progress: DeliveryProgress): DeliveryState()
data class IsIdle (val reason: Idle): DeliveryState()
data class Failed (val error: Throwable): DeliveryState()
data class Finished (val status: ServiceStatus): DeliveryState()
@monday8am
monday8am / delivery_state.swift
Created April 1, 2018 12:37
Delivery state described in Swift
enum DeliveryState: StateType {
case notStarted
case settingUp(appId: AppId,
serviceId: ServiceId,
description: ServiceDescription? = null)
case going(progres: DeliveryProgress)
case idle(reason: Idle)
case failed(error: Error)
case finished(status: ServiceStatus)
@monday8am
monday8am / result.kt
Created April 15, 2018 20:37
Result variant of Either pattern
sealed class Result <out V, out E> {
// Idle state
object Loading : Result<Nothing, Nothing>()
// Operation finished correctly with result saved on value
data class Ok <out V > constructor (val value: V): Result<V, Nothing>()
// Operation finished with error
data class Err <out E> constructor (val error: E): Result<Nothing, E>()
@monday8am
monday8am / typeHierarchy.kt
Last active April 17, 2018 20:10
TypeHierarchy adapter demostration
val gson = GsonBuilder()
.registerTypeHierarchyAdapter(Result::class.java, ResultSerializer())
.create()
@monday8am
monday8am / resultSerializer.kt
Last active April 20, 2018 16:49
Result serializer empty
class ResultSerializer : JsonSerializer<Result<*, *>>, JsonDeserializer<Result<*, *>> {
override fun serialize(src: Result<*, *>?,
typeOfSrc: Type?,
context: JsonSerializationContext?): JsonElement? {
// TODO
}
override fun deserialize(json: JsonElement?,
typeOfT: Type?,