Skip to content

Instantly share code, notes, and snippets.

// private static String MATRIX_NON_NULL_AND_ACTIVE_NON_NULL = "matrix non null and active non null";
// private static String MATRIX_NULL_AND_ACTIVE_NON_NULL = "matrix null and active non null";
// private static String MATRIX_NULL_AND_ACTIVE_NULL = "matrix null and active null";
// private static String EXCEPTION = "Add a value for active or leave empty matrix too";
// public String searchForUserAndRole(String matrix, String active) {
// String response = "";
// if (matrix != null && active != null) {
// response = MATRIX_NON_NULL_AND_ACTIVE_NON_NULL;
@sebassdc
sebassdc / config.yml
Created October 7, 2020 20:30
Automatic build with CRA and aws s3
version: 2.1
jobs:
deploy:
docker:
- image: cimg/node:12.18.4
steps:
- checkout
- node/install-packages
- run: npm run build
import { useState, useRef, useEffect } from 'react'
export const useTimer = ({ initialStartTime = 0, shouldStartOnMount = false }) => {
const [milliseconds, setMilliSeconds] = useState(0)
const intervalRef = useRef()
const startTime = useRef()
const play = () => {
if (intervalRef.current) return
if (!startTime.current) {
startTime.current = new Date().getTime()
import * as Yup from 'yup'
import { handleErrorCode } from './auth'
import { makeRequest } from '../services/requests'
import getCurrentPosition from '../../utils/getCurrentPosition'
import log from '../../utils/log'
const requestSchema = Yup.object().shape( {
endpoint: Yup.string().required(),
method: Yup.string().default( 'GET' ),
query: Yup.object().default( {} ),
// https://www.reddit.com/r/learnprogramming/comments/3456xv/convert_rgb_color_to_wavelengthfrequency/
// https://www.alanzucconi.com/2015/09/30/colour-sorting/
const WHITE_STRING = parseInt( 'FFFFFF', 16 )
const NUMBER_OF_COLORS = 50
const genRandomInt = (min, max) => Math.floor(Math.random() * (max - min)) + min
const getHueFromRGB = ({ red, green, blue }) => {
const min = Math.min(Math.min(red, green), blue);
@sebassdc
sebassdc / smooth_behavior.jsx
Created October 9, 2018 01:25
Smooth behavior
export default class extends Component {
constructor (props) {
super(props)
this.element = null
}
componentDidMount = () => {
this.element = document.getElementById(this.props.className)
}
changeHeight = () => {
this.element.scrollIntoView({behavior: 'smooth'})
const degToRad = deg => (deg / 180) * Math.PI
const radToDeg = rad => rad * 180 / Math.PI;
class Turtle {
constructor(ctx) {
this.ctx = ctx
// Set initial orientation and position
this.orientation = 0;
this.position = {x: 0, y: 0}
}
export default (initialState, actionHandlers) =>
(state = initialState, action) =>
actionHandlers.hasOwnProperty(action.type)
? actionHandlers[action.type](state, action)
: state
import React, { Component } from 'react'
import CLink from '../General/CLink'
import Logo from '../../assets/Logo.svg'
import LogoResponsive from '../../assets/Responsive-logo.png'
import instLogo from '../../assets/Instagram-white.svg'
import HamburgerImg from '../../assets/hamburguer.svg'
import './NavBar.css'
const StyledLink = ({className, ...props}) =>
<CLink
@sebassdc
sebassdc / progresive_bar.js
Last active December 13, 2017 05:07
[Progresive Bar] This is a port to javascript from https://gist.github.com/rougier/c0d31f5cbdaac27b876c#file-progress_bar-py #Javascript
//@ts-check
const progress = ({
value,
length=40,
title = " ",
vmin=0.0,
vmax=1.0,
progressive = false
}) => {