Skip to content

Instantly share code, notes, and snippets.

View victorstein's full-sized avatar
🧪
Experimenting with JS!

Alfonso Emilio Gomez Selva victorstein

🧪
Experimenting with JS!
  • CleverTech
  • Nicaragua
View GitHub Profile
import { createContext, useReducer, FC } from 'react'
import { MainStoreContext } from './types'
import { Reducer } from 'react'
import { Action, ActionTypes, MainStoreContext } from '../types'
const reducer: Reducer<MainStoreContext, Action> = ({ state, ...rest }, action) => {
switch (action.type) {
case ActionTypes.OPEN_SIDEBAR:
return { state: { ...state, sidebarOpen: true }, ...rest }
case ActionTypes.CLOSE_SIDEBAR:
@victorstein
victorstein / swagFetcher.js
Last active August 21, 2023 15:45
Swag fetcher
const fetch = require('node-fetch');
let url = 'https://shop.clevertech.biz/products.json?limit=250';
let options = {
method: 'GET',
headers: {
cookie: 'storefront_digest=941a23011fdef8c43f4add54afd393479c090a530667631bc48e35745eb58b9d; '
}
};
{
"data": {
"findAllCreditsForUser": {
"orderItems": [
{
"id": "8f6af825-cfe6-4849-acdc-67f0f8028a2f",
"orderId": "8f6af825-cfe6-4849-acdc-67f0f8028a2f",
"productVariationId": "1c6fa2e9-f7ae-4212-a854-1648c8b2ef18",
"quantity": 1,
"order": {
@victorstein
victorstein / apollo.config.js
Created May 27, 2022 22:14
Configure apollo plugin for VSCode to do Intellisense with local gql schema
module.exports = {
client: {
includes: ["./components/**/**.{queries,mutations}.ts"],
service: {
name: "peoplehood",
localSchemaFile: "./schema.gql"
}
}
};
@victorstein
victorstein / sum3.js
Created February 5, 2020 15:27
Sum 3 (not optimized)
const threeSum = function (nums) {
const result = []
let index = 0
let secondaryIterator = 1
let iterator = 2
const dictionary = {}
while (index < nums.length) {