Skip to content

Instantly share code, notes, and snippets.

View manduks's full-sized avatar
🥷
Working from home

Armando Gonzalez manduks

🥷
Working from home
View GitHub Profile
'use client';
import { useRef, useState } from 'react';
// create a function that takes an operator and two numbers and returns the result
const calculate = (op: string, a: number, b: number): number => {
switch (op) {
case '+':
return a + b;
case '-':
import { useState, useEffect, useRef } from "react";
import {
PinchGestureHandler,
PinchGestureHandlerGestureEvent,
State,
} from "react-native-gesture-handler";
import {
StyleSheet,
Text,
View,

Keybase proof

I hereby claim:

  • I am manduks on github.
  • I am manduks (https://keybase.io/manduks) on keybase.
  • I have a public key ASDQirxaOh2Y3_CaK1e4kMWKHtS_pDCeVmFrJoueoKSBHQo

To claim this, I am signing this object:

@manduks
manduks / lowestCommonAncestor.js
Last active July 1, 2023 12:05
Lowest Common Ancestor in a Binary Tree in Javascript
/*
Taking this tree as an example the output for
lowestCommonAncestor('k', 'j') => e
a
/ \
b c
/ \
d e
/ \
f g
@manduks
manduks / ReactContext.js
Created September 16, 2020 19:56
Context example
const CounterContext = React.createContext();
function useCount() {
const context = React.useContext(CounterContext)
if (!context) {
throw new Error(`useCount must be used within a CountProvider`)
}
return context;
}
import { getAvailiableActuators, getFigureByKey } from './editor';
const DEFAULT_ACTIONS = {
led: 'turnOff()',
motor: 'turnOff()',
servo: 'turnOff()'
};
const TOI_MAPPINGS = {
led: 'LED',
distance: 'DSensor',
@manduks
manduks / flatten.js
Created March 5, 2019 00:30
flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
/**
* flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
* e.g. [[1,2,[3]],4] -> [1,2,3,4].
**/
const isInteger = (n) => {
if(Number.isInteger(n)) {
return n;
};
throw "An item inside the array is not integer";
const admin = require('firebase-admin');
var serviceAccount = require('path/to/serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
db.collection('locations').get()
.then((snapshot) => {
@manduks
manduks / assessment-report.json
Created October 5, 2017 16:33
Assessment report response.
{
"@context": "/api/contexts/Report",
"@id": "/api/assessments/1161940/report",
"@type": "Report",
"id": "1161940",
"assessment": {
"@id": "/api/assessments/1161940",
"@type": "Assessment",
"id": "1161940",
"createdAt": "2017-10-05T16:02:52+00:00",
@manduks
manduks / finished-assessment.json
Last active October 5, 2017 16:28
Finished assessment response
{
"@context": "/api/contexts/Assessment",
"@id": "/api/assessments/1161940",
"@type": "Assessment",
"id": "1161940",
"createdAt": "2017-10-05T16:02:52+00:00",
"updatedAt": "2017-10-05T16:02:52+00:00",
"completedAt": null,
"productConfiguration": {
"@id": "/api/product_configurations/101",