Skip to content

Instantly share code, notes, and snippets.

@raheelahmad
raheelahmad / gist:3f48bc5fc83a4a611904
Last active August 29, 2015 14:06
Core Data stack in Swift
//
// PersistenceStack.swift
import CoreData
public class PersistenceStack: NSObject {
let mainContext: NSManagedObjectContext = {
let context = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
context.undoManager = nil
context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
@Rcureton
Rcureton / The Technical Interview Cheat Sheet.md
Created June 28, 2016 17:31 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@macsystems
macsystems / AndroidFontFamiliesByVersion.mk
Last active August 15, 2017 20:28
Font Families on Android Versions
Added in Android Jelly Bean (4.1) - API 16 :
Regular (default):
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
Italic:
<item name="android:fontFamily">sans-serif</item>
@Reyurnible
Reyurnible / Variable.kt
Last active March 28, 2018 05:30
RxSwift's Variable.swfit convert to Kotlin
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject
/**
* Wrapping Rx BehaviorSubject defaultValue object.
* RxSwfit Variable.swfit https://github.com/jspahrsummers/RxSwift/blob/master/RxSwift/SpinLock.swift
*/
class Variable<T> private constructor(defaultValue: T?) {
companion object {
fun <T> create(): Variable<T> = Variable(null)

Registration Flow - iOS

A crucial type in the app is the CognitoStore. There's only ever one instance of this type that lives throughout the life-cycle of the app. Everywhere in our app, a dev has access to this one instance through the sharedInstance static stored property on the CognitoStore.

Important to note is the init function on this type. It sets everything up, most imporantly the userPool stored property of type AWSCognitoIdentityUserPool. This in turn will provide access to the AWSCognitoIdentityUser that exists on the AWSCognitoIdentityUserPool. This is done by calling currentUser() on the AWSCognitoIdentityUserPool instance.

We expose the AWSCognitoIdentityUser in the form of a computed property named currentUser.

Here's how accessing this currentUser looks like throughout the app:

package rx.playground;
import rx.Observable;
import rx.subjects.BehaviorSubject;
import rx.subjects.SerializedSubject;
public class Variable<T> {
private T value;
private final SerializedSubject<T, T> serializedSubject;
@ZacSweers
ZacSweers / RxJava.md
Last active September 3, 2018 18:52 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@kpgalligan
kpgalligan / gist:8595c2522164ab316f9c
Last active November 16, 2018 13:15
Bad Activity
public class MistakesActivity extends ActionBarActivity
{
public static final String TABLE_NAME = "names";
ExecutorService executorService = Executors.newFixedThreadPool(4);
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mistakes);
@rakshakhegde
rakshakhegde / fragment_utility.kt
Last active January 19, 2023 09:26
Handy Idiom: Pass Arguments to Android Fragment using Kotlin + Anko
import android.support.v4.app.Fragment
import org.jetbrains.anko.bundleOf
/**
* Pass arguments to a Fragment without the hassle of
* creating a static newInstance() method for every Fragment.
*
* Declared outside any class to have full access in any
* part of your package.
*
@cassiozen
cassiozen / pixelbook-dev-setup.md
Last active October 22, 2023 12:06 — forked from denolfe/pixelbook-linux-setup.md
Notes on setting up Pixelbook for development

Pixelbook Setup

Change your channel

Some of the features mentioned in this document only work on the beta or Dev channel. To change your channel:

  1. chrome://help in a browser window
  2. Click Detailed Build Information
  3. Change Channel
  4. Select Beta (Or Dev, if you're feeling adventurous)