Skip to content

Instantly share code, notes, and snippets.

@muhozi
muhozi / retrieve-from-asynStorage.js
Created April 1, 2019 20:51
Retrieve from AsyncStorage
componentDidMount() {
let images;
AsyncStorage.getItem('images')
.then(data => {
images = JSON.parse(data) || [];
this.setState({
images: images
});
})
.catch(error => {
@muhozi
muhozi / progress-bar.js
Created April 1, 2019 20:28
Progress bar
//...
<Image source={imgSource} style={styles.image} />
{uploading && (
<View
style={[styles.progressBar, { width: `${progress}%` }]}
/>
)}
//...
@muhozi
muhozi / App.js
Created April 1, 2019 20:10
Select image method
/**
* Select image method
*/
pickImage = () => {
ImagePicker.showImagePicker(options, response => {
if (response.didCancel) {
console.log('You cancelled image picker 😟');
} else if (response.error) {
alert('And error occured: ', response.error);
} else {
@muhozi
muhozi / App.js
Created April 1, 2019 19:53
Upload image react native firebase
uploadImage = () => {
const ext = this.state.imageUri.split('.').pop(); // Extract image extension
const filename = `${uuid()}.${ext}`; // Generate unique name
this.setState({ uploading: true });
firebase
.storage()
.ref(`tutorials/images/${filename}`)
.putFile(this.state.imageUri)
.on(
firebase.storage.TaskEvent.STATE_CHANGED,
@muhozi
muhozi / Appfile
Created February 17, 2019 19:39 — forked from mmazzarolo/Appfile
Simple Fastlane setup for React-Native (Android - iOS)
# iOS
app_identifier "com.myapp.app" # The bundle identifier of your app
apple_id "[email protected]" # Your Apple email address
team_id "1234ABCD" # Developer Portal Team ID
# Android
json_key_file "./google-play-api-secret.json" # Path to the json secret file - Follow https://github.com/fastlane/supply#setup to get one
package_name "com.myapp.app" # Your Android app package
@muhozi
muhozi / Fastfile
Created February 16, 2019 14:31 — forked from polbins/Fastfile
Fastlane script for Uploading to Slack and Play Store Alpha
default_platform :android
platform :android do
before_all do
ENV["SLACK_URL"] = "https://hooks.slack.com/services/ABC/123/XYZ"
end
######################### PUBLIC LANES #########################
desc "Deploy a new Prod APK version to Play Store Alpha"
@muhozi
muhozi / ..git-pr.md
Created February 13, 2019 18:59 — forked from gnarf/..git-pr.md
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@muhozi
muhozi / App.js
Last active January 9, 2019 19:59
App.js - Test if image picker works
import React, { Component } from 'react';
import { StyleSheet, Text, View, TouchableOpacity, Image } from 'react-native';
import ImagePicker from 'react-native-image-picker';
const options = {
title: 'Select Image',
storageOptions: {
skipBackup: true,
path: 'images'
}
@muhozi
muhozi / Podfile
Last active March 18, 2019 17:44
RnFirebaseImgUpload Podfile
# The target name is most likely the name of your project.
platform :ios, '9.0'
target 'RnFirebaseImgUpload' do
rn_path = '../node_modules/react-native'
rn_maps_path = '../node_modules/react-native-maps'
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge',
@muhozi
muhozi / Service_to_run_python_application_using_gunicorn.md
Last active November 13, 2018 09:54
Creating a service on linux to run python application
[Unit]
Description=Gunicorn service to run your_application
After=network.target

[Service]
User=user
Group=www-data
WorkingDirectory=/home/user/apps/python/your_application
Environment="PATH=/home/user/apps/python/your_application/env/bin"