Skip to content

Instantly share code, notes, and snippets.

View bvodola's full-sized avatar

Brunno Vodola Martins bvodola

View GitHub Profile
@bvodola
bvodola / get-recipe-schema.js
Created December 17, 2020 16:54
Get Recipe Schema from Website
function getRecipeSchema(schema) {
if(!schema) {
const nodes = document.querySelectorAll('script[type="application/ld+json"]');
let returnData;
nodes.forEach(n => {
const childSchema = JSON.parse(n.innerText);
const data = getRecipeSchema(childSchema);
if(data) returnData = data;
});
return returnData;
import React from "react";
import { Modal } from "src/components";
const CrudPanel = ({ key, data, tableFields, entryFields, operations }) => {
const [isModalVisible, setIsModalVisible] = React.useState(false);
const openModal = () => setIsModalVisible(true);
const closeModal = () => setIsModalVisible(false);
return (
@bvodola
bvodola / FirebasePhoneAuth.js
Created June 25, 2020 22:02
Firebase Phone Authentication Example
import React from "react";
import firebase, { auth } from "src/firebase";
const App = () => {
const [phoneNumber, setPhoneNumber] = React.useState("");
const [code, setCode] = React.useState("");
const [user, setUser] = React.useState(null);
React.useEffect(() => {
// =======
// App.js
const App = () =>
<Context.Provider value={this.state.context}>
<AppBar onPressLogoutButton={this.logout} />
<View style={{paddingTop: 64}}>
<Router>
<Route exact path="/" exact component={Home} />
</Router>
</View>
import React from 'react';
import globals from '../../globals';
import axios from 'axios';
import Loading from '../Loading/Loading';
import VMasker from 'vanilla-masker';
class Form extends React.Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
// Some random page example
import Pixel from '../components/Pixel'
export default () =>
<div>
<Pixel name='FACEBOOK_PIXEL_1' />
</div>
import React from 'react'
export default () =>
<React.Fragment>
<script dangerouslySetInnerHTML={{ __html: `!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
@bvodola
bvodola / facebook-pixel-example.html
Created October 16, 2018 16:08
Facebook Pixel Example
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
@bvodola
bvodola / index.js
Created October 16, 2018 16:01
Pixel/index.js
import React from 'react'
import Head from 'next/head'
import FACEBOOK_PIXEL_1 from './facebook/pixel-1'
export default ({name}) => {
return(
<Head>
{name === 'FACEBOOK_PIXEL_1' && <FACEBOOK_PIXEL_1 />}
<View style={{display: this.state.visible?'flex':'none', backgroundColor: 'rgba(0,0,0,0.5)', position: 'absolute', top: 0, left: 0, height, width}}>
<Modal animationType={'slide'} transparent={true} visible={this.state.visible}>
<TouchableWithoutFeedback onPress={() => this.toggleActionSheet()}>
<View>
<TouchableWithoutFeedback>
<View style={{backgroundColor: '#fff', padding: 16, marginTop: '100%', height: '50%'}}>
<Text style={{height: 20}}>Title</Text>
// Content goes here...
</View>
</TouchableWithoutFeedback>