Skip to content

Instantly share code, notes, and snippets.

View samstewart's full-sized avatar

Sam Stewart samstewart

  • New York, New York
View GitHub Profile
@samstewart
samstewart / UIImage+CompatibleImage.m
Created August 30, 2013 19:09
Loads iPad and iPhone images according to Apple's naming convention. Nice for retina displays
//
// UIImage+CompatibleImage.m
// Notescast 3.6
//
// Created by Sam Stewart on 8/25/13.
//
//
#import "UIImage+CompatibleImage.h"
<ul id="form_templates" class="fields hidden">
<li class="name">
<label class="field_name">Name</label>
<input type="text" name="name"></input>
<span class="error_message"></span>
</li>
<li class="email">
<label class="field_name">Email</label>
<input type="email" name="email" class="email" novalidate></input>
<span class="error_message"></span>
@samstewart
samstewart / dump_dom.js
Created May 28, 2013 04:22
Nice script to dump all the visible elements of the DOM to JSON.
/* Dump the DOM as a javascript object in the new window.
Possibly useful links:
https://developer.mozilla.org/en-US/docs/Web/API/document.elementFromPoint
*/
function dump_dom ()
{
@samstewart
samstewart / changes_diagnostic_app.md
Last active December 17, 2015 12:29
changes I made to the playhaven diagnostic app

Compatibility with UI Tests for Diagnostic App

I added a contentDescription to the major UI components for the SDK so that my UI tests of DiagnosticApp could discern when the main view was being shown.

Logging Fix

Currently, the SDK allows system log level to override the log level set in code in the Playhaven SDK. The idea is to allow support developers to "turn on" the verbose logs when debugging an app that is "mute" in production and the flag can be set via adb setprop log.tag.[APP NAME] [LOG LEVEL]. Unfortunately, this flag defaults to INFO even if the support developer never calls setprop. This means that the code level setting can never restrict the logs below a level of INFO because the device setting takes precedence.

The system property concept as a whole seemed problematic and unreliable so I switched to a small configuration file placed in /sdcard/loglevel.prop that simply listed the appropriate log level. If this file does not exist, the SDK defaults to the code level setting but

@samstewart
samstewart / gist:5588542
Created May 16, 2013 00:27
Way to start diagnostic app for playhaven
mvn -Dmaven.test.skip=true -am -pl diagnostic install android:deploy
@samstewart
samstewart / telephone_digitis.py
Created July 17, 2012 18:24
Solution for combinatorics problem
# simple python script for cs106b assignment
import subprocess
words = list()
SYSTEM_DICT_LOOKUP = "egrep -i \"^%s\" /usr/share/dict/words"
class Lexicon:
def __init__(self):
self.word_dict = {}
@samstewart
samstewart / glu_null_fix.java
Created May 27, 2012 01:03
Fix for Glu's crashes
// Fix for PHPublisherContentRequest null pointer exception in Playhaven's SDK. Open up PHPublisherContentRequest and find handleRequestSuccess (should be around line 332). Remove the following line:
delegate.requestFailed(this, new JSONException("Couldn't parse respone into PHContent"));
// and replace it with to guard against null delegates
if (delegate != null) delegate.requestFailed(this, new JSONException("Couldn't parse respone into PHContent"));
// if you want extra security, make sure to use a "dummy" delegate as well with blank method stubs instead of passing null.
@samstewart
samstewart / annoying_bug
Created May 10, 2012 01:20
Paste from odd bug in Unity framework for Android
05-09 17:22:44.539 24771 24771 I [Playhaven-1.10.2]: Parsing initial content request: true
05-09 17:22:44.539 24771 24771 D PlayHavenFacade: willDisplayContent
05-09 17:22:44.539 24771 24771 D PhoneWindow: couldn't save which view has focus because the focused view com.unity3d.player.UnityPlayer$17@405664f0 has no id.
05-09 17:22:44.539 24771 24771 D Unity : NativeActivity save instance state: 0x2c6910
05-09 17:22:44.539 24771 24771 D Unity : NativeActivity pause: 0x2c6910
05-09 17:22:44.539 505 737 I ActivityManager: Starting: Intent { cmp=com.bitwisedesign.pong2012/com.playhaven.src.publishersdk.content.PHContentView } from pid 24771
05-09 17:22:45.039 505 520 W ActivityManager: Activity pause timeout for HistoryRecord{405a1100 com.bitwisedesign.pong2012/com.unity3d.player.UnityPlayerNativeActivity}
05-09 17:22:45.062 505 520 D MotDevicePolicyManagerService: isPasswordSetEnforced false
05-09 17:22:45.078 24771 24771 I Unity : onPause
05-09 17:22:45.226 505 794 D MotDevicePolicyManagerS
@samstewart
samstewart / macos_x_ios_gitignore
Created December 9, 2011 02:34
.gitignore file for Mac OS X and iOS applications
# Exclude the build directory
build/*
# Exclude temp nibs and swap files
*~.nib
*.swp
# Exclude OS X folder attributes
.DS_Store
@samstewart
samstewart / osx_ios_hgignore
Created December 9, 2011 02:33
.hgignore file for Mac OS X and iOS applicaitons
syntax: glob
build
*.swp
*.mode1
*.mode1v3
*.mode2
*.mode2v3
*.pbxuser
*.perspective