Skip to content

Instantly share code, notes, and snippets.

View mgp's full-sized avatar
🤗

Michael Parker mgp

🤗
View GitHub Profile
@mgp
mgp / signpost-okhttp.markdown
Created December 2, 2015 18:04
signpost-okhttp-blog

5. Consider Signpost for OAuth 1.0a

We initially turned to Scribe for our OAuth 1.0a needs, but it has its own Request class that uses java.net.HttpURLConnection to send and receive data. Therefore we could not use Stetho to inspect the data. Later we migrated to Signpost, which is a lightweight OAuth 1.0a library that allows using whatever networking layer you already have. All you must do is adapt instances of your request and response classes to the HttpRequest and HttpResponse interfaces defined by Signpost.

Our OkHttpOAuthRequest class adapts a com.squareup.okhttp.Request instance to the HttpRequest interface of Signpost. The implementation is quite straightforward. You can read OkHttpOAuthRequest.java in its entirety here, but here is an excerpt:

``

As I mentioned earlier, I feel like the interface that I've sketched out for loading more and more search results from the server isn't very RAC-friendly. Its design doesn't step beyond that of a delegate, honestly.

To start, here's my current representation for a single search result, and for a sublist of the total search results:

struct SearchResultItem {
  let contentItem: ContentItem
  let topicTreePath: TopicTreePath

 var domain: KAContentDomain {
@mgp
mgp / gist:9af5efb6399472e32c89
Created November 3, 2015 18:44
visible thumbnail tracker
//
// Blehhhh.swift
// Khan Academy
//
// Created by Mike Parker on 11/2/15.
// Copyright © 2015 Khan Academy. All rights reserved.
//
import UIKit
import KHACore
@mgp
mgp / gist:5d8805d4f7c7b78637e2
Last active September 17, 2015 20:59
reconciliation
DownloadReconciliation{
initialState=InitialState{
pendingResourceKeys=[
Key{
type=VIDEO_MP4, contentItemIdentifier=ContentItemIdentifier{
itemKind=VIDEO,
contentId=x6a16bad3
}
}
],
@mgp
mgp / gist:089cebff550a162db330
Created September 17, 2015 18:55
FullSubjectContentFragment leak
09-17 11:53:31.457 32425-2176/org.khanacademy.android.debug D/LeakCanary﹕ In org.khanacademy.android.debug:0.9:56.
09-17 11:53:31.457 32425-2176/org.khanacademy.android.debug D/LeakCanary﹕ * LEAK CAN BE IGNORED.
09-17 11:53:31.457 32425-2176/org.khanacademy.android.debug D/LeakCanary﹕ * org.khanacademy.android.ui.library.tablet.FullSubjectContentFragment has leaked:
09-17 11:53:31.457 32425-2176/org.khanacademy.android.debug D/LeakCanary﹕ * GC ROOT android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper.mParentInputMethodManager
09-17 11:53:31.457 32425-2176/org.khanacademy.android.debug D/LeakCanary﹕ * references android.view.inputmethod.InputMethodManager.mNextServedView
09-17 11:53:31.457 32425-2176/org.khanacademy.android.debug D/LeakCanary﹕ * references android.support.v7.widget.RecyclerView.mOnItemTouchListeners
09-17 11:53:31.457 32425-2176/org.khanacademy.android.debug D/LeakCanary﹕ * references java.util.ArrayList.array
09-17 11:53:31.457 32425-2176/org.khanacadem
@mgp
mgp / gist:531b162e860f65d886b9
Created September 10, 2015 21:20
ffmpeg.h264.decoder error
09-10 17:14:13.097 17759-17759/org.khanacademy.android.debug I/VideoViewActivity﹕ onResume
09-10 17:14:13.097 17759-17759/org.khanacademy.android.debug I/VideoSubtitlesFragment﹕ onResume
09-10 17:14:13.112 17759-18686/org.khanacademy.android.debug I/OMXClient﹕ Using client-side OMX mux.
09-10 17:14:13.113 17759-18686/org.khanacademy.android.debug W/linker﹕ libswscale.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
09-10 17:14:13.113 17759-18686/org.khanacademy.android.debug D/SoftFFmpegVideo﹕ SoftFFmpegVideo component: OMX.ffmpeg.h264.decoder mMode: 0 appData: 0x9e08e480
09-10 17:14:13.116 17759-18686/org.khanacademy.android.debug W/OMXNodeInstance﹕ [1:ffmpeg.h264.decoder] component does not support metadata mode; using fallback
09-10 17:14:13.116 17759-18686/org.khanacademy.android.debug E/ACodec﹕ [OMX.ffmpeg.h264.decoder] storeMetaDataInBuffers failed w/ err -1010
09-10 17:14:13.118 17759-18686/org.khanacademy.android.debug V/SoftFFmpegVideo﹕ got OMX_Inde
@mgp
mgp / gist:943bcdc4825194fed116
Created August 31, 2015 18:46
Android WebView leak
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug D/LeakCanary﹕ In org.khanacademy.android.debug:0.7:38.
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug D/LeakCanary﹕ * org.khanacademy.android.ui.articles.ArticleViewActivity has leaked:
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug D/LeakCanary﹕ * GC ROOT org.khanacademy.android.Application.mComponentCallbacks
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug D/LeakCanary﹕ * references java.util.ArrayList.array
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug D/LeakCanary﹕ * references array java.lang.Object[].[3]
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug D/LeakCanary﹕ * references com.android.org.chromium.android_webview.AwContents$AwComponentCallbacks.this$0
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug D/LeakCanary﹕ * references com.android.org.chromium.android_webview.AwContents.mContainerView
08-31 14:32:27.428 2080-2232/org.khanacademy.android.debug
@mgp
mgp / styles.xml
Created August 26, 2015 16:03
Action button styles
<style name="Widget.Material.ActionButton" parent="Widget.ActionButton">
<item name="minWidth">@dimen/action_button_min_width_material</item>
<item name="minHeight">@dimen/action_button_min_height_material</item>
<item name="gravity">center</item>
<item name="scaleType">center</item>
<item name="maxLines">2</item>
<item name="paddingStart">12dp</item>
<item name="paddingEnd">12dp</item>
</style>
public Toolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// Need to use getContext() here so that we use the themed context
final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
R.styleable.Toolbar, defStyleAttr, 0);
mTitleTextAppearance = a.getResourceId(R.styleable.Toolbar_titleTextAppearance, 0);
mSubtitleTextAppearance = a.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, 0);
mGravity = a.getInteger(R.styleable.Toolbar_android_gravity, mGravity);
package org.khanacademy.android.prefs;
import org.khanacademy.core.util.ObservableUtils;
import rx.Observable;
import rx.subjects.PublishSubject;
import android.content.SharedPreferences;
/**