Skip to content

Instantly share code, notes, and snippets.

Dave Ceddia dceddia

Block or report user

Report or block dceddia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dceddia
dceddia / new-post.sh
Created Feb 1, 2019
Create a new post based in Gatsby. (make sure to create a new-post-template.md file)
View new-post.sh
#!/bin/bash
# Print usage if args are missing
if [ -z $1 ]; then
echo "Usage: new-post <slug>"
exit
fi
SLUG=$1
DAY=$(date +%Y-%m-%d)
@dceddia
dceddia / App.js
Created Jun 15, 2018
Initialize Autoshoot's state
View App.js
class Autoshoot extends React.Component {
state = {
photo: null
}
...
}
@dceddia
dceddia / App.js
Created Jun 15, 2018
Asking for permission to use the camera.
View App.js
export default class App extends React.Component {
...
componentDidMount() {
Permissions.askAsync(Permissions.CAMERA)
.then(({ status }) =>
this.setState({
cameraPermission: status === 'granted'
})
);
@dceddia
dceddia / App.js
Created Jun 15, 2018
Render the Camera, or the last photo.
View App.js
render() {
const { photo } = this.state;
return (
<View style={{ flex: 1, width: '100%' }}>
{photo ? (
<ImageBackground
style={{ flex: 1 }}
source={{ uri: photo.uri }} />
) : (
@dceddia
dceddia / App.js
Created Jun 15, 2018
Using Autoshoot inside App
View App.js
render() {
const { cameraPermission } = this.state;
// Render one of 3 things depending on permissions
return (
<View style={styles.container}>
{cameraPermission === null ? (
<Text>Waiting for permission...</Text>
) : cameraPermission === false ? (
<Text>Permission denied</Text>
@dceddia
dceddia / App.js
Created Jun 15, 2018
Importing Camera and rendering based on permissions.
View App.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
// add this:
import { Camera, Permissions } from 'expo';
export default class App extends React.Component {
// initialize state
state = {
cameraPermission: null
@dceddia
dceddia / App.js
Created Jun 15, 2018
Upload each picture as it is taken
View App.js
// Here's the timer code, lifted from takePicture:
queuePhoto = () => {
// In 27 seconds, turn the camera back on
setTimeout(() => {
this.setState({ photo: null });
}, PHOTO_INTERVAL - FOCUS_TIME);
// In 30 seconds, take the next picture
setTimeout(this.takePicture, PHOTO_INTERVAL);
}
@dceddia
dceddia / App.js
Created Jun 15, 2018
Add the takePicture method
View App.js
takePicture = () => {
this.camera.takePictureAsync({
quality: 0.1,
base64: true,
exif: false
}).then(photo => {
this.setState({ photo });
})
}
@dceddia
dceddia / App.js
Created Jun 15, 2018
Expo-generated App.js file
View App.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
);
@dceddia
dceddia / App.js
Created Jun 15, 2018
Creating the Autoshoot component to render the Camera.
View App.js
class Autoshoot extends React.Component {
render() {
return (
<View style={{ flex: 1, width: '100%' }}>
<Camera
style={{ flex: 1 }}
type={Camera.Constants.Type.back}
ref={cam => this.camera = cam}>
</Camera>
</View>
You can’t perform that action at this time.