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
| /** | |
| * Copyright (c) 2017-present, Wonday (@wonday.org) | |
| * All rights reserved. | |
| * | |
| * This source code is licensed under the MIT-style license found in the | |
| * LICENSE file in the root directory of this source tree. | |
| */ | |
| #import "RCTPdfView.h" |
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 array = [0, 1, 2, 4, 5 ] | |
| const update = (array, index, newItem) => | |
| Object.assign([], array, { [index]: newItem }); | |
| const update2 = (array, index, newItem) => [ | |
| ...array.slice(0, index), | |
| newItem, | |
| ...array.slice(index + 1) | |
| ]; |
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
| let input = { | |
| name: { | |
| firstName: "Toto", | |
| lastName: "Smith", | |
| toJSON() { | |
| return `${this.firstName} ${this.lastName}`; | |
| } | |
| }, | |
| email: "email@email.com" | |
| }; |
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 from "react"; | |
| type CustomInputProps = { | |
| inputRef: (el: HTMLInputElement) => void; | |
| }; | |
| const CustomInput: React.FC<CustomInputProps> = ({ inputRef }) => { | |
| return ( | |
| <div> | |
| <input ref={inputRef} /> |
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
| /** | |
| * Update item at index with new item | |
| * Slice method | |
| * @param array | |
| * @param index | |
| * @param newItem | |
| */ | |
| export function update<T>(array: T[], index: number, newItem: T) { | |
| return [ | |
| ...array.slice(0, index), |
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
| /** | |
| * Update item at index with new item | |
| * Slice method | |
| * @param index | |
| * @param newItem | |
| */ | |
| export function update<T>(index: number, newItem: T) { | |
| return (array: T[]) => [ | |
| ...array.slice(0, index), | |
| newItem, |
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
| /** | |
| * Remove duplicate elements in array | |
| * @param array | |
| */ | |
| export const unique = <T>(array: T[]) => [...new Set(array)]; | |
| console.log(unique([0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5])); |
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
| // @ts-ignore | |
| import process from 'process' | |
| /** | |
| * Measure code execution time with date method | |
| * Can be used in both environments (Browser & Node.js) | |
| * @param label | |
| * @param fn | |
| */ | |
| export const execTime = (label: string, fn: () => void): void => { |
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
| /** | |
| * Generate random hex color | |
| * #ffffff | |
| */ | |
| export const random = (): string => { | |
| return `#${Math.floor(Math.random() * 0xFFFFFF).toString(16)}`; | |
| }; |
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
| # !/usr/bin/python | |
| # coding=utf-8 | |
| def init_board(n): | |
| # Insertion des boules blanches | |
| game = list(map(lambda x: "☺", range(n))) | |
| # Insertion de l'espace | |
| game += " " |