Skip to content

Instantly share code, notes, and snippets.

View jvergeldedios's full-sized avatar

Julian Vergel de Dios jvergeldedios

View GitHub Profile
public static final String PREFS_NAME = "MyPrefsFile";
public static final String IMAGE_TEMP_PATH = "ImageTempPath";
public static final int REQUEST_CAMERA = 1;
protected void launchCamera()
{
// Setup a temporary storage path for the image and save it in SharedPreferences
String imageTempPath = "image_" + UUID.randomUUID() + ".jpg";
getSharedPreferences(PREFS_NAME, 0).edit().putString(IMAGE_TEMP_PATH, imageTempPath).commit();
File dir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
@jvergeldedios
jvergeldedios / gist:a5b4b83f574e330c51cf
Created September 19, 2014 05:48
Simple example of Dagger in Android
public class MyApp extends Application {
private ObjectGraph objectGraph;
public void onCreate() {
super.onCreate();
objectGraph = ObjectGraph.create(new AppModule(this));
}
public static void inject(Context context, Object toInject) {
@jvergeldedios
jvergeldedios / keybase.md
Last active December 5, 2017 22:40
keybase.md

Keybase proof

I hereby claim:

  • I am jvergeldedios on github.
  • I am jvergeldedios (https://keybase.io/jvergeldedios) on keybase.
  • I have a public key ASDbicAEpaEZfyAYn6MGeIg3olcQwFQU_zNX_5mWdnlDdAo

To claim this, I am signing this object:

import React from 'react';
import { connect } from 'react-redux';
import { Route, Redirect } from 'react-router-dom';
const PrivateRoute = ({component: Component, session, ...rest}) => {
return (
<Route
{...rest}
render={(props) => session ?
<Component {...props} /> :
//useSomethingAsync.js
export default () => {
const [thing, setThing] = useState(null);
useEffect(() => {
doAsyncThing().then(result => setThing(result));
}, []);
return thing;