This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Context, Effect, pipe } from 'effect'; | |
import { either } from 'fp-ts'; | |
import { ReaderTaskEither } from 'fp-ts/ReaderTaskEither'; | |
import { TaskEither } from 'fp-ts/TaskEither'; | |
export const effectFromEither = either.matchW(Effect.fail, Effect.succeed); | |
export const effectFromTaskEither = <E, A>( | |
program: TaskEither<E, A>, | |
): Effect.Effect<never, E, A> => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const binomialCoefficient = (n: number, k: number): number => { | |
if (k < 0 || k > n) { | |
return 0; | |
} | |
if (k === 0 || k === n) { | |
return 1; | |
} | |
if (k === 1 || k === n - 1) { | |
return n; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Number with 2 decimals maxi | |
const regex = /^[0-9]*(\.[0-9]{1,2})?$/ | |
"1.12".match(regex) // true | |
".1".match(regex) // true | |
".".match(regex) // false | |
".123".match(regex) // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This hook has the same behavior of useState, but takes a method as second parameter | |
// to be called with the state value on component unmount. | |
const useStateOnUnmount = <StateType>( | |
initialState: ?StateType, | |
onUnmount: (?StateType) => any, | |
) => { | |
const stateRef = useRef(initialState); | |
/* eslint-disable no-unused-vars */ | |
const [_, setState] = useState(stateRef.current); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { compose } from 'recompose'; | |
import { connect } from 'react-redux'; | |
import { fetchTasks } from 'redux/entities/tasks/actions'; | |
import { selectTasksByProjectId } from 'redux/entities/tasks/selectors'; | |
import ProjectTasksTab from './ProjectTasksTab'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
export const deepUndefinedSearch = (obj: any): boolean => | |
obj instanceof Object && obj.constructor === Object | |
? Object.keys(obj) | |
.map(key => { | |
if (obj[key] instanceof Array) { | |
return ( | |
obj[key].map(o => deepUndefinedSearch(o)).filter(o => !o) | |
.length === 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function PercentageNumber(props) { | |
const { value, inputRef, onChange, fieldName, ...other } = props; | |
return ( | |
<NumberFormat | |
{...other} | |
value={value * 100} | |
decimalScale={2} | |
getInputRef={inputRef} | |
onValueChange={values => { | |
onChange(values.value / 100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, Blueprint | |
from flask_cors import CORS | |
from flask_restplus import Resource, Api, fields | |
from flask_restplus.reqparse import Argument | |
from werkzeug.contrib.fixers import ProxyFix | |
app = Flask(__name__) | |
CORS(app) | |
app.wsgi_app = ProxyFix(app.wsgi_app) | |
blueprint = Blueprint('api', __name__, url_prefix='/api') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import { Formik, FastField, ErrorMessage } from "formik"; | |
import * as Yup from "yup"; | |
const schemaForm1 = Yup.object().shape({ | |
email: Yup.string() | |
.email("Invalid email") | |
.required("Required"), | |
password: Yup.string() | |
.min(2, "Too Short!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -ss 30 -i input.mp4 -an -filter:v "setpts=0.09*PTS" result.mkv |
NewerOlder