Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@szehnder
szehnder / DataProvider.swift
Last active December 23, 2019 12:13
Pattern for async callback between a view controller and a dataprovider singleton
typealias ServiceResponse = (NSDictionary?, NSError?) -> Void
class DataProvider: NSObject {
var client:AFHTTPRequestOperationManager?
let LOGIN_URL = "/api/v1/login"
class var sharedInstance:DataProvider {
struct Singleton {
static let instance = DataProvider()
@jpotts18
jpotts18 / Alamofire-JSON-Serialization.md
Last active August 17, 2020 15:44
Alamofire JSON Serialization of Objects, Collections, Nesting

Alamofire JSON Serialization of Objects and Collections

Alamofire is a great Swift library developed by the creator of AFNetworking @mattt. The purpose of this gist is to explain how to use the built-in power of Alamofire to serialize your JSON. In this example we will be serializing a simple blog API. First we will start with serializing a single JSON object and add complexity as we go along.

Warning: This was written before Swift 1.2

A Single JSON Serialization

This is the first JSON object that we will be serializing.

@deargle
deargle / _island.byu.edu-conf.md
Last active August 21, 2020 22:21
island.byu.edu configs and scripts

how to start from scratch

Deprecated: see https://github.com/deargle/island-vNext instead


  • set up the nginx-proxy docker-compose. pull down nginx.tmpl.
    • This will give auto letsencrypt
  • git clone discourse into /home/deargle/island, drop in the two container config files below. Build them using the discourse launcher
  • git clone the discourse-cas repo, up that.
@brescia123
brescia123 / ViewVisibilityExtensions.kt
Last active May 10, 2023 12:28
Useful Android Kotlin Extension functions to easily change the visibility of a View
/** Set the View visibility to VISIBLE and eventually animate the View alpha till 100% */
fun View.visible(animate: Boolean = true) {
if (animate) {
animate().alpha(1f).setDuration(300).setListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator) {
super.onAnimationStart(animation)
visibility = View.VISIBLE
}
})
} else {
@ericksli
ericksli / ReactNativeExtensions.kt
Last active March 20, 2024 19:51
React Native Kotlin extension functions for creating WritableMap and WritableArray #android #react-native #kotlin
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
fun writableMapOf(vararg values: Pair<String, *>): WritableMap {
val map = Arguments.createMap()
for ((key, value) in values) {
when (value) {
null -> map.putNull(key)
is Boolean -> map.putBoolean(key, value)