Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Duarte Monteiro du5rte

🏠
Working from home
View GitHub Profile
View transformSvgsToUniversalSupport.js
const fs = require('fs')
const path = require('path')
const iconsPath = path.join(__dirname, 'src/icons')
function transform(input) {
const replacements = {
'svgs': 'Svg',
'circle': 'Circle',
@du5rte
du5rte / layout-challenge.md
Last active Apr 7, 2020
Layout Challenge
View layout-challenge.md

Layout Challenge

Create the layout attached below, using your preferred styling method (React or React Native). It does not need to be functional, rather concentrate on getting it as close to the design as possible.

layout

Branding

Branding guides, colors and icons, can be downloaded here

Font:

@du5rte
du5rte / signin-challenge.md
Created Apr 3, 2020
GraphQL Sign In Challenge 💫
View signin-challenge.md
@du5rte
du5rte / paths.js
Created Feb 25, 2019
Add support for lerna and/or yarn workspaces to react-scripts
View paths.js
// HACK:
// https://github.com/facebook/create-react-app/issues/1333#issuecomment-347970625
module.exports.appLernaModules = []
function searchModules(dir) {
fs.readdirSync(dir).forEach(folderName => {
if (folderName === 'react-scripts') return
if (folderName[0] === '.') return
View popup.js
export default function popup(url, {name='', width=500, height=500}={}) {
// References
// https://developer.mozilla.org/en-US/docs/Web/API/Window/open
let options = `
width=${width},
height=${height},
left=${window.screenX + ((window.outerWidth - width) / 2)},
top=${window.screenY + ((window.outerHeight - height) / 2)}
`
@du5rte
du5rte / ratios.js
Last active Jul 25, 2018
Expand Ratios
View ratios.js
// https://stackoverflow.com/questions/14224535/scaling-between-two-number-ranges
function withinRange(val, { min, max }) {
return (
val > max
? max
: val < min
? min
: val
);
@du5rte
du5rte / booleanTest.js
Created Sep 13, 2017
test multiple booleans
View booleanTest.js
const tests = [true, false, true]
const finalTest = tests.reduce((acc, val) => {
return acc && val
}, true);
console.log(finalTest)
@du5rte
du5rte / unionAndInterface.js
Created Aug 31, 2017
GraphlQL UnionType and InterfaceType
View unionAndInterface.js
import {
GraphQLID,
GraphQLInt,
GraphQLString,
GraphQLObjectType,
GraphQLList,
GraphQLNonNull,
OrderTypeEnum,
GraphQLUnionType,
GraphQLInterfaceType,
@du5rte
du5rte / distanceBetweenPoints.js
Created Jul 14, 2017
Distance between two Points(x,y) Pythagorean Theorem
View distanceBetweenPoints.js
function distanceBetweenPoints(p1, p2) {
// http://www.mathwarehouse.com/algebra/distance_formula/index.php
// https://stackoverflow.com/questions/20916953/get-distance-between-two-points-in-canvas
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot
// or
// Math.sqr((p2.x - p1.x) + (p2.y - p1.y))
return Math.hypot(p2.x - p1.x, p2.y - p1.y)
}
View handleNestedChange.jsx
import React, { Component } from "react";
import _ from "lodash";
export default class Example extends Component {
constructor(props) {
super(props);
this.state = {
uid: "",