Skip to content

Instantly share code, notes, and snippets.

using System;
[Serializable]
public struct Score {
public string Name;
public int LevelCompleted;
public int Time;
public DateTime Date;
public bool Current;
using UnityEngine;
using UnityEngine.SceneManagement;
using GoogleMobileAds.Api;
using System;
public class AdManager : MonoBehaviour {
private InterstitialAd interstitial;
public void PrepareAd()
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class CharacterBehavior : MonoBehaviour {
/// <summary>
/// Vitesse de déplacement du personnage
/// </summary>
public float speed = 2.0f;
// String literal type
type Role =
| "Capitaine"
| "Matrose"
| "Charpentier"
// Create a list
const crew: { name: string; role: Role }[] = [
{ name: "Jack", role: "Capitaine" },
{ name: "Barbossa", role: "Matrose" },
@TheShinriel
TheShinriel / CodeWithError.vue
Created March 9, 2023 16:33
VueJS - Rules Trap
<template>
<v-form class="d-flex flex-column px-2" @submit.prevent="validate">
<v-text-field
outlined
v-model="amountTotal"
label="Prix TTC"
type="number"
:rules="[() => amountTotal >= 0 || 'Le champ ne peut pas être négatif']"
></v-text-field>
<v-text-field
const acceptedAmmunition = [
"boulet",
"chaîne",
"couverts",
"boulet enflammé",
"pot de poudre à canon",
] as const
if (acceptedAmmunition.includes(ammunitionType)) {
// Do something
@TheShinriel
TheShinriel / array functions.ts
Created August 1, 2023 08:23
List des fonctions de tableau avec exemple pour typescripe
// 🔍 Fonction concat() :
const arr1: number[] = [1, 2];
const arr2: number[] = [3, 4];
const result = arr1.concat(arr2);
// 👉 Résultat : [1, 2, 3, 4]
// 🔍 Fonction filter() :
const numbers: number[] = [1, 2, 3, 4, 5];
const evenNumbers = numbers.filter(num => num % 2 === 0);
// 👉 Résultat : [2, 4]
@TheShinriel
TheShinriel / set-functions.ts
Created August 2, 2023 23:26
Présentation des fonctions disponibles avec Set
// 🔍 Créer un nouvel ensemble (Set)
const mySet = new Set();
// 👉 Résultat : Set {}
// 🔍 Ajouter des éléments à l'ensemble
mySet.add('🍎');
mySet.add('🍌');
mySet.add('🍊').add('🥑').add('🥝');
// 👉 Résultat : Set { '🍎', '🍌', '🍊', '🥑', '🥝' }
// 🔍 Test basique avec expect().toBe()
test('Vérifier si deux nombres sont égaux', () => {
const a = 10;
const b = 10;
// 👉 Résultat attendu : true
expect(a).toBe(b);
});
// 🔍 Test avec expect().not.toBe()
test('Vérifier si deux nombres sont différents', () => {
// 🔍 Fonctions de Parsing en TypeScript
// 🔍 parseInt() : Convertir une chaîne de caractères en un entier
const numString: string = '42';
const parsedInt: number = parseInt(numString);
// 👉 Résultat : 42 (typeof parsedInt est number)
// 🔍 parseFloat() : Convertir une chaîne de caractères en un nombre à virgule flottante
const floatString: string = '3.14';
const parsedFloat: number = parseFloat(floatString);