Skip to content

Instantly share code, notes, and snippets.

@Harrison-M
Created July 12, 2013 22:39
Show Gist options
  • Save Harrison-M/5988386 to your computer and use it in GitHub Desktop.
Save Harrison-M/5988386 to your computer and use it in GitHub Desktop.
Notes from the Friday #TXDevFest talks I attended
TX Dev Fest
Mastering <canvas>
@johnathanhebert
Skitch
It's just pixels
Immediate mode graphics surface
No DOM
Grid size independent from css size
General process
clear()
draw()
repeat()
Coordinate system
The Great Fixed Coordinate System in the Sky
The initial <canvas> coordinate system is your friend
Translate - moves origin
Rotate - rotates canvas and coordinate system around origin
Linear algebra - lets you change coordinate system with matrices
3 things:
Scale it
Translate
[1 0 tx [x [x+tx
0 1 ty y = y+ty
0 0 1 ] 1] 1 ]
Homogeneous coordinates - transformation cannot be represented in 2D
Transform method: context.transform(a,b,c,d,e,f)
[a c e
b d f
0 0 1]
transform() changes the coordinate system
setTransform is *relative to the initial coordinate system*
Translate point to origin, scale, then translate back to zoom in on point
but backward
Operations have to be in reverse order because the vector has to be on the right for the vector math to work
Spin: translate(100,100).rotate(3).translate(-100,-100);
NFC
"The future is already here -- it's just not very evenly distributed"
Crossing the Chasm by Geoffery A. Moore
NFC sitting in a niche right now
History
RADAR - 1935
Leon Theremin invents first passively-powered "bug" for espionage - 1945
RFID implementations continue - 1950's
1960's - identifiying remote objects
1970's - preventing retail theft
2003 - NFC grows out of RFID, recognized specification
Previously "wild west" of protocols
Ugly logo
Frequency vs distance
NFC is in HF range - 13.56 MHz
2004 - NFC forum created
NDEF
NFC Data Exchange Format
2005 - NFC capable "shells"
Mostly used as id chip
2006 - First NFC built in
2010 - Galaxy Nexus S first NFC-enabled Android device
Moral: Technology has a long evolution, window of opportunity not missed
Most devices with NFC are Android phones
Embedded Android surging
What's different now than a few years ago
More computing power
Cheaper hardware
User-friendly OS's/apps
Better API's
Write custom tags
Launch apps
Change settings
BT pairing
Peer-to-peer data
Book chapter: Professional Android Sensor Programming - Chapter 11
Sample code: github.com/pchen/nfc-starter-apps
Docs: nfc.android.com
Four supported types of tag
Broadcom Topaz and MIFARE ultra light most common/cheapest, good for playing
Sony FeliCa and NXP DESFire/SmartFX have more storage space, features
MIFARE Classic has partial support, removed from Google phones as of Nexus 4
Forms
Stickers
Sewable
Keychain
Plastic
Made for putting on metal
More stickers
Passcard
Presto card
Uses
Read and write NFC tags
Simple URL's
URL-based triggers
Launch application from URI
Sample intent filter shown in slides, probably in above Github URL
Example: NFC tag sticker with simple label deep-linked to specific Evernote entry for recipies
Moo beta testing NFC business cards
Task automation
tagstand.com
snapguide.com/guides/enhance-a-phone-slip-case-with-nfc-part-2-1
Slip in the phone one direction, ringer loud, flip other direction, sets to quiet
NFC-enabled phones
Bluetooth pairing
Do not revolve experience around NFC - should make tech disappear, simple, passive
Pandemic 1.0 by Lance Weiler
Transmedia project
50 Nexus S devices at Sundance, NFC tag scavenger hunt
Case for NFC
Create low friction interactions
Augments physical objects (internet not required)
Apps/tech more tangible
Increase viralness of your app
Possibility to be platform agnostic
Location Services on Android
Android GPS is awesome
3m accuracy
1s updates
Most devices have GNSS hardware
Not silver bullet
Not all devices have
Eats battery (~135 mA according to "studies")
Takes a long time to get initial position fix (Most in 1s-5s range according to mapmyfitness data, ~18% 5s-10s)
Can retrieve quality of fix and # of satellites
GPS will sometimes return junk coordinates
Time, lat/lng, or accuracy == 0
Accuracy numbers in meters
TTFF tricks
Read source com.android.server.location.GpsLocationProvider
No guarantees, use at your own risk, but cool stuff
Don't use in production app
Code in slides to re-bootstrap GPS chip
Android LocationManager
provides API to allow use of multiple sources
Pros
Control of provider: gps or cell/wifi
Does not require Play Store (Kindle, CM)
Backward compatible to API 1 (wheee)
Cons:
Requires requesting updates from individual location providers
Need to examine multiple factors for "best estimate"
Fused location provider
Uses all of above + sensor data
Pros:
No complicated strategies
Uses sensor data for indoor position
Battery optimized
Cons:
Limited control
Doesn't work on devices w/o Play Store
Code: checkGooglePlayServiceAvailability
Recheck for onResume to make sure update in place
Fewer outliers than GPS, but slower and slightly less accurate
Accuracy vs power
getLastLocation() vs LocationRequest
Priority options
LocationRequest
setExpirationDuration(millis)
setNumUpdates(numUpdates) (1 for one very accurate location)
setSmallestDisplacement(meters)
LocationRequest.create(), chainable
Checking Providers
Can't do that with Fused, use LocationManager to check if location services enabled
WiFi Proximity Demo
Custom provider
Sometimes all you need is WiFi proximity
Geofencing API maybe better fit
Code
Sticky service
Runs until explicitly stopped
Can start with click or on BOOT_COMPLETED intent
WakeLock makes sure CPU doesn't sleep until we're done
Partial wake lock for CPU, full wake lock for screen
Release in finally block to make sure CPU doesn't keep running on failure
Useful references at end of presentation
Presentation: http://t.co/kz3qjWq5lP
Code: https://t.co/5Yd1IAeN8g
Opera & Blink
Chromium is whole package, Blink is rendering engine
Chrome Packaged Apps
Sandboxed client-side applications
User-approved access to local resources
Full window control
Filesystem
Local and synced storage
Networking
Background processing
Bluetooth
Devices
HTML/CSS/(JS|DART)
MVC structure
Files
manifest.json
background.js
Create window
index.html
Angularisms
Requires ng-csp on html tag
Distribute through Chrome web store
Using Enyo to Make Chrome Apps
@unwiredben
Came out of work Palm did a while ago on HP TouchPad
www.enyojs.com
Javascript/CSS framework
Reusable components
Cross-platform strong
Designed for single-page apps
UI widgets
Apache 2.0
Bought by LG Electronics recently
TV's
Enyo Bootplate
http://github.com/enyojs/bootplate
Template with Enyo and common libs
Clone, rename, push
Includes minifier to make enyo.js and app.js
http://enyojs.com/api
App restriction
CSP
document.write
*no inline event handlers
no eval()
no Function() constructors
no strings for setTimeout/setInterval (same as eval)
no inline <script> tags
Openings
XHR fetches will work in app bundle, unlike normal file://XHRs
Request permission to do things like USB port handling (Arduino)
background.js
Can use boilerplate for most apps
Hardest decision is default window size
Links to other sites
No default handling of off-app links
_blank pushes to main browser window
Testing
Go to chrome://extensions page
Developer tools checkbox
Load unpacked extension
Submit to store
Zip, not .crx
Must have manifest.json at root
Must NOT contain any other manifest.json files
Required images
128x128 icon
640x400 screenshot
something else went too fast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment