Skip to content

Instantly share code, notes, and snippets.

Avatar

Philip Schiffer hameno

View GitHub Profile
@Fbalashov
Fbalashov / InvalidatesView.kt
Last active Feb 16, 2018
A property delegate to remove boilerplate when updating views
View InvalidatesView.kt
package *****
import android.view.View
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
/**
* Copyright 6/24/2017 Fuad Balashov
*
* Licensed under the Apache License, Version 2.0 (the "License");
View BaseDao.kt
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@PurpleBooth
PurpleBooth / Dockerfile
Last active Oct 20, 2020
Create a static binary in go and put it in a from scratch docker container
View Dockerfile
FROM golang:1.9
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@vidia
vidia / nginx-unificontroller.conf
Last active Oct 19, 2020
Example, working, NGINX config for proxying to Unifi Controller software and using letsencrypt. Includes websocket fix.
View nginx-unificontroller.conf
# I had a bit of trouble getting my unifi controller (hosted offsite) to use a proxy/letsencrypt. So here are the fruits of my labor.
# The unifi default port is 8443 running on localhost.
# License: CC0 (Public Domain)
server {
# SSL configuration
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
@mryan43
mryan43 / gist:f160fb29cbad0da169fe007735c7307b
Created Aug 14, 2017
Nexus 3 script delete images not downloaded since X months.
View gist:f160fb29cbad0da169fe007735c7307b
import groovy.time.TimeCategory
import org.sonatype.nexus.repository.storage.Asset
import org.sonatype.nexus.repository.storage.Component
import org.sonatype.nexus.repository.storage.Query
import org.sonatype.nexus.repository.storage.StorageFacet
def repo = repository.repositoryManager.get("sq-docker")
StorageFacet storageFacet = repo.facet(StorageFacet)
def tx = storageFacet.txSupplier().get()
@STAR-ZERO
STAR-ZERO / AsyncLiveData.kt
Created Jun 19, 2017
LiveData + Kotlin Coroutine
View AsyncLiveData.kt
// compile "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.16"
// compile "android.arch.lifecycle:runtime:1.0.0-alpha3"
// compile "android.arch.lifecycle:extensions:1.0.0-alpha3"
// kapt "android.arch.lifecycle:compiler:1.0.0-alpha3"
class AsyncLiveData<T> private constructor(private val exec: suspend () -> T) : LiveData<T>() {
private var observer: Observer<T>? = null
private var job: Job? = null
View DisposeOnDestroy.kt
import android.app.Activity
import android.app.Application
import android.os.Bundle
import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer
fun Activity.disposeOnDestroy() = Consumer<Disposable> { disposable ->
application.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
override fun onActivityDestroyed(activity: Activity) {
@Robyer
Robyer / maven-publish-helper-usage.gradle
Last active Oct 25, 2020
Gradle script for publishing Android library with sources and javadoc to Maven repository using maven-publish plugin.
View maven-publish-helper-usage.gradle
// You can use maven-publish-helper.gradle script without changes and even share it between multiple
// modules. Just place the maven-publish-helper.gradle file in the root directory of your project,
// then apply it at the bottom of your module's build.gradle file like this:
// ...content of module's build.gradle file...
apply from: '../maven-publish-helper.gradle'
publishing {
publications {
@klingerf
klingerf / blue-green.groovy
Created Nov 4, 2016
Jenkins pipeline script to perform blue-green deploys to a Kubernetes cluster running linkerd and namerd
View blue-green.groovy
node {
def currentVersion = getCurrentVersion()
def newVersion = getNextVersion(currentVersion)
def frontendIp = kubectl("get svc l5d -o jsonpath=\"{.status.loadBalancer.ingress[0].ip}\"").trim()
def originalDst = getDst(getDtab())
stage("clone") {
git url: gitRepo + '.git', branch: gitBranch
}
@NikolaDespotoski
NikolaDespotoski / CursorCallback.java
Last active Mar 21, 2020
Cursor Diff Util callback.
View CursorCallback.java
import android.database.Cursor;
import android.support.annotation.Nullable;
import android.support.v7.util.DiffUtil;
/**
* Created by Nikola on 9/29/2016.
*/
public abstract class CursorCallback<C extends Cursor> extends DiffUtil.Callback {
private final C newCursor;
You can’t perform that action at this time.