Skip to content

Instantly share code, notes, and snippets.

@rnewman
rnewman / gist:f7f0d6740f9a2ee5a613
Created April 29, 2014 19:42
How to get the label for a resource ID
package android.content.res;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class AssetManagerSnooper {
/**
* Use reflection to find the resource name for the given ID.
*/
public static final String getNameForID(AssetManager assets, int id) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
01-06 03:02:32.800 W/MemoSwitchView( 705): current view = com.huawei.android.myrichpad.MemoSwitchView@406413d8
01-06 03:02:34.700 D/GeckoApp( 952): Enabling Android StrictMode
01-06 03:02:35.060 D/GeckoScreenOrientation( 952): updating to new orientation PORTRAIT_PRIMARY
01-06 03:02:35.330 D/libEGL ( 952): loaded /system/lib/egl/libGLES_android.so
01-06 03:02:35.370 D/libEGL ( 952): loaded /system/lib/egl/libEGL_adreno200.so
01-06 03:02:35.760 D/libEGL ( 952): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
01-06 03:02:35.770 D/libEGL ( 952): loaded /system/lib/egl/libGLESv2_adreno200.so
01-06 03:02:36.060 I/ListView( 952): maxScrollFactorString = null
01-06 03:02:36.130 D/GeckoSharedPrefs( 952): Current version = 0, prefs version = 1
01-06 03:02:36.130 D/GeckoSharedPrefs( 952): Performing migration
@rnewman
rnewman / gist:4fc8ef4b944b0fc3808b
Created May 12, 2014 20:13
Successful history and tabs sync taking 17 seconds
1399924895573 Sync.ErrorHandler DEBUG Flushing file log.
1399924895574 Sync.ErrorHandler TRACE Beginning stream copy to success-1399924895574.txt: 1399924895574
1399924895583 Sync.Tracker.Passwords DEBUG Saving changed IDs to passwords
1399924895718 Sync.ErrorHandler TRACE Notifying weave:ui:sync:finish. Status.login is success.login. Status.sync is success.sync
1399924895719 Sync.Status DEBUG Status.service: success.status_ok => success.status_ok
1399924895720 Sync.Status DEBUG Status.service: success.status_ok => success.status_ok
1399924895722 Sync.Status DEBUG Status.service: success.status_ok => success.status_ok
1399924895723 Sync.Status DEBUG Status.service: success.status_ok => success.status_ok
1399924895725 Sync.Status DEBUG Status.service: success.status_ok => success.status_ok
1399924895726 Sync.Status DEBUG Status.service: success.status_ok => success.status_ok
17:17:45 < jasonmchristos> Youns need to just pack up and head off.
17:17:57 < ckitching> jasonmchristos: Are those like nouns?
17:17:57 < jasonmchristos> I am the internet.
17:18:01 < Guest1> ckitching: as I understand, it's because they got rid of the font inflation checkbox
17:18:14 < jasonmchristos> And theres nothing but a bunch of idiots coded to complain about what I do.
17:18:21 < rnewman> dbaron: would you be so kind? ^
17:18:37 < jasonmchristos> debate party fools
17:18:43 < ckitching> Guest1, What even was font inflation?
17:18:50 < jasonmchristos> everythings a debate
17:18:52 < ckitching> I managed to miss that party, too.
spec resource 0x7f020000 org.mozilla.fennec_rnewman:drawable/ab_add_search_engine: flags=0x00000000
spec resource 0x7f020001 org.mozilla.fennec_rnewman:drawable/ab_copy: flags=0x00000000
spec resource 0x7f020002 org.mozilla.fennec_rnewman:drawable/ab_cut: flags=0x00000000
spec resource 0x7f020003 org.mozilla.fennec_rnewman:drawable/ab_done: flags=0x00000000
spec resource 0x7f020004 org.mozilla.fennec_rnewman:drawable/ab_paste: flags=0x00000000
spec resource 0x7f020005 org.mozilla.fennec_rnewman:drawable/ab_search: flags=0x00000000
spec resource 0x7f020006 org.mozilla.fennec_rnewman:drawable/ab_select_all: flags=0x00000000
spec resource 0x7f020007 org.mozilla.fennec_rnewman:drawable/ab_stacked_transparent_light_holo: flags=0x00000000
spec resource 0x7f020008 org.mozilla.fennec_rnewman:drawable/action_bar_button: flags=0x00000000
spec resource 0x7f020009 org.mozilla.fennec_rnewman:drawable/action_bar_button_inverse: flags=0x00000000
@rnewman
rnewman / inherited.playground
Created December 19, 2014 19:30
Inherited protocol methods issue
import Foundation
protocol Profile {
func localName() -> String
}
protocol AccountProfile: Profile {
var accountName: String { get }
}
@rnewman
rnewman / gist:57bc73e6f6afd4e624e3
Created December 19, 2014 19:38
Bizarre log output
class TestAccountManager : AccountProfileManager {
override func login(username: String, password: String, error: ((error: RequestError) -> ())) {
let credential = NSURLCredential(user: username, password: password, persistence: .None)
let account = MockAccountProfile()
self.loginCallback(account: account)
return
...
let am = TestAccountManager(loginCallback: { (profile: Profile) -> Void in
@rnewman
rnewman / gist:2f6e99c15edafa9bee7b
Created January 12, 2015 18:26
Error when running Robocop from Eclipse
01-12 10:26:02.447 I/TestRunner( 4085): started: testClearPrivateData(org.mozilla.gecko.tests.testClearPrivateData)
01-12 10:26:02.453 W/Robocop ( 4085): Did not find deviceroot in arguments; falling back to: /mnt/sdcard/tests
01-12 10:26:02.465 I/TestRunner( 4085): failed: testClearPrivateData(org.mozilla.gecko.tests.testClearPrivateData)
01-12 10:26:02.465 I/TestRunner( 4085): ----- begin exception -----
01-12 10:26:02.466 I/TestRunner( 4085):
01-12 10:26:02.466 I/TestRunner( 4085): java.lang.RuntimeException: No log file specified!
01-12 10:26:02.466 I/TestRunner( 4085): at org.mozilla.gecko.FennecNativeDriver.log(FennecNativeDriver.java:354)
01-12 10:26:02.466 I/TestRunner( 4085): at org.mozilla.gecko.FennecNativeDriver.log(FennecNativeDriver.java:349)
01-12 10:26:02.466 I/TestRunner( 4085): at org.mozilla.gecko.FennecNativeDriver.getFile(FennecNativeDriver.java:287)
01-12 10:26:02.466 I/TestRunner( 4085): at org.mozilla.gecko.tests.BaseRobocopTest.setUp(BaseRobocopTest.java:109)
/**
* Map a function over the values of a map, returning only entries
* for which the function returns non-nil. Works seamlessly with a
* function that has a non-optional type signature, too.
*/
public func mapValues<K, T, U>(source: [K: T], f: (T -> U?)) -> [K: U] {
var m = [K: U]()
for (k, v) in source {
if let u = f(v) {
m[k] = u
@rnewman
rnewman / gist:5d5e6a30558743d0cde7
Created March 25, 2015 16:26
Non-localized strings
Account/FxAClient10.swift:68: let errorString = error.error ?? "Missing error"
Account/FxAClient10.swift:69: let messageString = error.message ?? "Missing message"
Client/Application/AppDelegate.swift:108: let alert = UIAlertView(title: "New version available", message: "There is a new version available of Firefox Aurora. Tap OK to go to the download page.", delegate: self, cancelButtonTitle: "Not Now", otherButtonTitles: "OK")
Client/Application/AppDelegate.swift:159: mailComposer.setSubject("Feedback on iOS client version v\(appVersion) (\(buildNumber))")
Client/Frontend/Browser/BrowserViewController.swift:948: var openNewTabAction = UIAlertAction(title: "Open In New Tab", style: UIAlertActionStyle.Default) { (action: UIAlertAction!) in
Client/Frontend/Browser/BrowserViewController.swift:954: var copyAction = UIAlertAction(title: "Copy", style: UIAlertActionStyle.Default) { (action: UIAlertAction!) -> Void in
Client/Frontend/