This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
takePicture = () => { | |
this.camera.takePictureAsync({ | |
quality: 0.1, | |
base64: true, | |
exif: false | |
}).then(photo => { | |
this.setState({ photo }); | |
// In 27 seconds, turn the camera back on | |
setTimeout(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// View latest image | |
app.get('/', (req, res) => { | |
// Does this session have an image yet? | |
if(!latestPhoto) { | |
return res.status(404).send("Nothing here yet"); | |
} | |
console.log('sending photo'); | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
// If your phone has a modern camera (unlike my iPhone 4S) | |
// you might wanna make this bigger. | |
app.use(bodyParser.json({ limit: '10mb' })); | |
// TODO: handle requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uploadPicture = () => { | |
return fetch(SERVER_URL, { | |
body: JSON.stringify({ | |
image: this.state.photo.base64 | |
}), | |
headers: { | |
'content-type': 'application/json' | |
}, | |
method: 'POST' | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
const { photo } = this.state; | |
return ( | |
<Camera | |
style={{ flex: 1 }} | |
type={Camera.Constants.Type.back} | |
ref={cam => this.camera = cam}> | |
<TouchableOpacity | |
style={{ flex: 1 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Store the single image in memory. | |
let latestPhoto = null; | |
// Upload the latest photo for this session | |
app.post('/', (req, res) => { | |
// Very light error handling | |
if(!req.body) return res.sendStatus(400); | |
console.log('got photo') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PHOTO_INTERVAL = 30000; | |
const FOCUS_TIME = 3000; | |
class Autoshoot extends React.Component { | |
componentDidMount() { | |
this.countdown = setTimeout( | |
this.takePicture, | |
PHOTO_INTERVAL | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class App extends React.Component { | |
... | |
componentDidMount() { | |
Permissions.askAsync(Permissions.CAMERA) | |
.then(({ status }) => | |
this.setState({ | |
cameraPermission: status === 'granted' | |
}) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Insert a function": { | |
"prefix": "f", | |
"body": [ | |
"function $1($2) {\n $0\n}\n" | |
], | |
"description": "Insert a function" | |
}, | |
"const arrow": { | |
"prefix": "c>", |