Skip to content

Instantly share code, notes, and snippets.

View iamrommel's full-sized avatar

Rommel C. Manalo iamrommel

View GitHub Profile
import React from 'react'
import { MapView } from 'expo'
import {
View,
Text,
H3,
variables,
Content,
Icon,
ListItem,
@iamrommel
iamrommel / Object Flatten
Created February 13, 2018 06:25 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@iamrommel
iamrommel / setting-up-babel-nodemon.md
Created September 18, 2018 04:14 — forked from sam-artuso/setting-up-babel-nodemon.md
Setting up Babel and nodemon

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@iamrommel
iamrommel / Mutation
Created November 13, 2018 09:28
Mutation Component
import React from 'react'
import {Mutation as MutationCore} from 'react-apollo'
import {AsyncStorage} from 'react-native'
// Pull serialized mutations from localstorage
const KEY = '@offlineQueueKey'
const getPending = async () => {
const obj = await AsyncStorage.getItem(KEY)
return JSON.parse(obj) || []
@iamrommel
iamrommel / AddUser
Created November 13, 2018 09:30
Add user using the custom component
import React from 'react'
//import {Mutation} from 'react-apollo'
import {Button, Icon} from 'native-base'
import {Mutation} from './Mutation'
import {ADD_USER, GET_USERS, generateId} from './queries'
const update = (cache, {data: {createUser}}) => {
const {allUsers} = cache.readQuery({query: GET_USERS})
cache.writeQuery({
<%
if (s.forceSsl) {
%>
server {
listen 80;
server_name <%-s.publicDomain%>;
# Used by Let's Encrypt
@iamrommel
iamrommel / for...Of
Created January 24, 2019 07:51
Sample of using for ... of loop in javascript to support the async await in sequence order
async function updateAllCustomer(customers) {
for (const customer of customers) {
await update(customer);
}
console.log('Done!');
}
@iamrommel
iamrommel / promise.all async await
Created January 24, 2019 07:59
Sample of using async/await in loops with promise.all
async function updateAllCustomer(customers) {
const mapsPromises = customers.map(update);
//this will wait until all promise is resolved before going to next line
await Promise.all(mapsPromises);
console.log('Done!');
}