Skip to content

Instantly share code, notes, and snippets.

View t-harison's full-sized avatar
🏆
Positive mindset

Tolotra Raharison t-harison

🏆
Positive mindset
  • Lévis, Québec
View GitHub Profile
/**
* 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"
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)
];
let input = {
name: {
firstName: "Toto",
lastName: "Smith",
toJSON() {
return `${this.firstName} ${this.lastName}`;
}
},
email: "email@email.com"
};
import React from "react";
type CustomInputProps = {
inputRef: (el: HTMLInputElement) => void;
};
const CustomInput: React.FC<CustomInputProps> = ({ inputRef }) => {
return (
<div>
<input ref={inputRef} />
/**
* 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),
/**
* 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,
/**
* 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]));
// @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 => {
/**
* Generate random hex color
* #ffffff
*/
export const random = (): string => {
return `#${Math.floor(Math.random() * 0xFFFFFF).toString(16)}`;
};
# !/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 += " "