Skip to content

Instantly share code, notes, and snippets.

View ericnograles's full-sized avatar

Eric Nograles ericnograles

View GitHub Profile
@ericnograles
ericnograles / infix-prefix.md
Last active September 17, 2020 13:30 — forked from ohbadiah/infix-prefix
Infix-prefix coding problem

We have some expressions, represented as a list where every term is either:

  • A variable (e.g. A, B, C)
  • A boolean operator (AND or OR)
  • A nested expression (list)

You're presented an expression with infix operators, like:

[A AND [B OR C]]

Can you transform these expressions so the operators are in prefix order? The output for this case is:

@ericnograles
ericnograles / graphql_types_assembler.js
Created January 18, 2018 15:01
Dynamic construction of .graphql files as one schema text file to load to makeExecutableSchema
const path = require('path');
const fs = require('fs');
const topLevelQuery = fs.readFileSync(
path.resolve(__dirname, 'Query.graphql'),
{ encoding: 'UTF-8' }
);
let types = fs
.readdirSync(__dirname)
.filter(fileName => {
@ericnograles
ericnograles / IconButton.js
Last active December 28, 2020 07:31
Signature Pad Implementation for React Native
'use strict';
import React from 'react';
import {
StyleSheet,
View,
TouchableOpacity,
} from 'react-native';
@ericnograles
ericnograles / SignatureView.js
Created December 20, 2017 13:47
SignatureView for React Native utilizing react-native-svg
import React from 'react';
import { View, PanResponder, StyleSheet } from 'react-native';
import Svg, { G, Surface, Path } from 'react-native-svg';
export default class SignatureView extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
currentMax: 1,
@ericnograles
ericnograles / open_ios_simulator.sh
Created February 19, 2017 16:56
Allows you to open multiple iOS Simulators
#!/usr/bin/env bash
# The command below will fire an empty iOS simulator. You will initially get an error.
# To actually launch it, click on Hardware -> Device -> iOS [some version] -> [device]
cd /Applications/Xcode.app/Contents/Developer/Applications
open -n Simulator.app
@ericnograles
ericnograles / ButtonWithActivityIndicator.js
Last active January 2, 2017 23:39
A Generic React Native component that allows for a button with an ActivityIndicator when the attached loading prop is true
import React from 'react';
import { View, Text, ActivityIndicator, TouchableOpacity } from 'react-native';
export default class ButtonWithActivityIndicator extends React.Component {
render() {
const { buttonStyle, textStyle, label, onPress, activityIndicatorSize, activityIndicatorColor, loading } = this.props;
return (
<TouchableOpacity style={buttonStyle} onPress={() => {
if (!loading) {
return onPress();
@ericnograles
ericnograles / LoadingView.js
Last active January 2, 2017 21:34
A Generic React Native Higher Order Component for a Loading Screen
import React from 'react';
import { View, ActivityIndicator, Dimensions } from 'react-native'
import * as Animatable from 'react-native-animatable'; // TODO: Please install react-native-animatable as a dependency
const window = Dimensions.get('window');
export default class LoadingView extends React.Component {
componentWillUpdate(nextProps) {
const { loading } = this.props;
if (this.refs.view && loading !== nextProps.loading) {