A Pen by oluwasusi david damilola on CodePen.
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 removeInstance = (array=[], val=null) => { | |
| if(!Array.isArray(array)) return 0; | |
| if(!val) return array.length; | |
| let currIndex = array.indexOf(val); | |
| while(currIndex !== -1){ | |
| array.splice(currIndex, 1) | |
| currIndex = array.indexOf(val); | |
| } | |
| return array.length | |
| } |
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
| export default function usePromise(api) { | |
| const [state, dispatch] = useReducer( | |
| (state, action) => { | |
| switch (action.type) { | |
| case 'LOADING': | |
| return { ...state, loading: true } | |
| case 'RESOLVED': | |
| return { ...state, loading: false, response: action.response, error: null } | |
| case 'ERROR': | |
| return { ...state, loading: false, response: null, error: action.error } |
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
| def bitStr(n, s): | |
| if n == 1: return s | |
| return [ digit + bits for digit in bitStr(1,s) for bits in bitStr(n- 1,s)] | |
| print (bitStr(3,'abc')) |
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
| export const getUniqueItemsFromArray = (array=[]) => { | |
| return Array.from(new Set(array)).length() | |
| } |
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, { useRef } from "react"; | |
| import "./FileInput.scss"; | |
| import { greyTrash} from "assets/images/svg"; | |
| interface InputProps { | |
| id?: string; | |
| type: string; | |
| handleChange?: any; | |
| disabled?: boolean; |
Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
| Commit type | Emoji |
|---|---|
| Initial commit | 🎉 :tada: |
| Version tag | 🔖 :bookmark: |
| New feature | ✨ :sparkles: |
| Bugfix | 🐛 :bug: |
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
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions |
NewerOlder