Skip to content

Instantly share code, notes, and snippets.

View jpshelley's full-sized avatar
🔲

John Shelley jpshelley

🔲
View GitHub Profile
@jpshelley
jpshelley / HelloWorldReactFragment.kt
Created June 16, 2017 17:00
react-native-android-fragment-oss-blog-1
var helloWorldFragment = ReactFragment.Builder()
.setComponentName("HelloWorld")
.setLaunchOptions(launchOptions)
.build()
@jpshelley
jpshelley / MyViewModell.kt
Created September 28, 2016 23:10
gql-annotation-viewmodel
class MyViewModel {
var heroNameText: String = getHero().name
var showIsJediImage: Boolean? = getHero().isJedi
@GraphQL(queryDocument = hero_query.graphql)
fun getHero(): Hero {
// . . . MyViewModelGQL could be the generated code after the annotation processor runs
// . . . The property "hero" is created based on the graphql file, and a getter is created.
@jpshelley
jpshelley / AdapterSection.kt
Last active July 21, 2019 12:02
A Sectioned Adapter for Android via Kotlin
/**
* A section to use in Recycler Adapter's.
* It holds a sectioned position for use in determining the offset of the adapter items.
*/
data class AdapterSection(var firstPosition: Int, var title: String, var sectionedPosition: Int = 0)
@jpshelley
jpshelley / SectionedAdapter.kt
Created August 14, 2016 17:48
A Sectioned Adapter for Android via Kotlin
/**
* An adapter that allows a RecyclerView to contain sections or subheaders
* much like the material docs describe.
* https://material.google.com/components/subheaders.html
*/
interface SectionedAdapter {
/**
* A list of sections to display in adapter.
*/

Keybase proof

I hereby claim:

  • I am jpshelley on github.
  • I am johnshelley (https://keybase.io/johnshelley) on keybase.
  • I have a public key ASDAzowTS8HeYIO02o0wFrAasyk6w5z1NLRtZw7ar8CYDQo

To claim this, I am signing this object:

{"title": "The Phantom of the Opera", "author": [{"fullname": "Gaston Leroux", "age": "42", "country": "France"}], "isbn": "9781593082499", "date": {"$date": "1909-09-23T23:32:18Z"}, "country": "France", "pubname": "Pierre Lafitte and Cie", "shortdesc": "The Paris Opera is haunted—everyone knows it. Everyone, that is, except for the new managers, who spark a violent dispute with the Opera Ghost when they refuse to acknowledge his existence or submit to his demands. Sometimes surfacing as a disembodied voice in Box Five or appearing as a gentleman in evening dress with a death’s-head, the phantom is obsessed with Christine Daaé, a lovely and enigmatic novice singer endowed with an amazing voice. But impetuous Viscount Raoul de Chagny is in love with Christine, and he and his brother, Count Philippe, are swept into the phantom’s deadly illusion with horrifying consequences."}
{"title": "Treasure Island", "author": [{"fullname": "Robert Stevenson", "age": "33", "country": "Scotland"}], "isbn": "9781593082475", "
/**
* Created by johnshelley on 4/10/14.
*/
public class CameraHelper {
static final int REQUEST_TAKE_PHOTO = 11111;
public static Uri openImageIntent(Activity activity) {
Uri outputFileUri;
johnshelley-2:/ john.shelley$ brew cask doctor
==> OS X Release:
10.10
==> OS X Release with Patchlevel:
10.10.3
==> Hardware Architecture:
intel-64
==> Ruby Version:
2.0.0-p481
==> Ruby Path:
@jpshelley
jpshelley / kitchen-sublime-issue
Created June 16, 2015 18:57
source "https://rubygems.org" gem "chef", "~> 11.0" gem 'librarian-chef', '~> 0.0.4'
-> Making sure /opt exists and I can write to it
run sudo mkdir -p /opt from "."
run while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null from "."
Password:
run sudo chown -R john.shelley /opt from "."
-> Setting up bundler
identical pt.kitchenplan.Gemfile
run mkdir -p vendor/cache from ".opt.kitchenplan"
run rm -rf vendor/bundle/config from ".opt.kitchenplan"
run ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future bundle install --quiet --binstubs vendor/bin --path vendor/bundle from ".opt.kitchenplan"
@jpshelley
jpshelley / MakeChocalate.java
Created April 6, 2015 20:27
MakeChocalate-iFit
public class MakeChocolate {
/********************************
* We want make a package of goal kilos of chocolate. We have
* small bars (1 kilo each) and big bars (5 kilos each).
* Return the number of small bars to use, assuming we always
* use big bars before small bars. Return -1 if it can't be done.
*
* See the verify lines below for examples of input
* and expected output.