Skip to content

Instantly share code, notes, and snippets.

View ticidesign's full-sized avatar

Ticiana de Andrade ticidesign

View GitHub Profile
@ticidesign
ticidesign / keybase.md
Created July 10, 2023 04:28
Keybase Access

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@ticidesign
ticidesign / recursive-types.ts
Last active October 2, 2021 07:24
Recursive types in TypeScript to defining a type that describes any allowable JSON value.
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#recursive-conditional-types
type Primitive = string | number | boolean | null
type JSONObject = {[k: string] : JSONValue}
type JSONArray = JSONValue[]
type JSONValue =
| Primitive
| JSONObject
| JSONArray
@ticidesign
ticidesign / .gitignore
Created May 3, 2020 01:41
Git Ignore FIle
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
@ticidesign
ticidesign / mongo-use.sh
Created April 26, 2020 01:40
CI for switching MongoDB from v3.4 to latest
# Switching from v3.4 to latest
select_lastest() {
# Stop and unlink 3.4
brew services stop mongodb@3.4
brew unlink mongodb@3.4
# Link last version
brew unlink mongodb && brew link mongodb
# Update mongo logs and database paths
@ticidesign
ticidesign / useRemoteData.js
Created April 7, 2020 08:02
A hook to load data from remote and keep track of the loading state
import { useState, useRef, useEffect } from 'react';
/**
* A hook to load data from remote and keep track of the loading state
*/
function useRemoteData( url, isJson = true, timeout = 3000 ) {
const [ loadingState, setLoadingState ] = useState('loading');
const loadingStateRef = useRef( loadingState );
const [ data, setData ] = useState([]);
.App {
font-family: 'Roboto', sans-serif;
color: #484848;
}
.header__wrapper {
padding: 20px 52px;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
display: flex;
align-items: flex-end;
export const menuData = [
{
emoji: '🍔',
label: 'burger',
name: 'Cheeseburger',
description:
'Cheeseburger with pickles, lettuce, tomato and sauce on a sesame seed bun',
price: 10
},
{
@ticidesign
ticidesign / useScroll.js
Created November 1, 2019 05:14
useScroll Hook
import { useEffect, useState } from 'react';
import ResizeObserver from 'resize-observer-polyfill';
import raf from 'raf-schd';
const LISTENER_OPTIONS = { passive: true }; // we don't call `event.preventDefault()`
export function useScroll(ref, { isPassive = true }) {
// const scrollTarget = ref.current || document.documentElement;
// define setters and getters
import { mockServer, MockList } from 'graphql-tools';
import casual from 'casual-browserify';
// The GraphQL schema. Described in more detail here:
// https://medium.com/apollo-stack/the-apollo-server-bc68762e93b
const schema = `
type User {
id: ID!
name: String
lists: [List]
@ticidesign
ticidesign / customizable-mocking.js
Created July 8, 2019 04:35
Customizable Mocking
// customize mocking per type (i.e. Integer, Float, String)
mockServer(schema, {
Int: () => 6,
Float: () => 22.1,
String: () => 'Hello',
});
// customize mocking per field in the schema (i.e. for Person.name and Person.age)
mockServer(schema, {
Person: () => ({