Instantly share code, notes, and snippets.

# Xavier Combelle xcombelle

Created January 17, 2024 18:13
View classes.py
This file contains 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
 print("BEFORE") def creer_classes(eleves_tries): taille_classe = len(eleves_tries)//3 return ( eleves_tries[:taille_classe],eleves_tries[taille_classe:2*taille_classe],eleves_tries[2*taille_classe:]) print(creer_classes([])) print(creer_classes([0])) print(creer_classes([0,1,2]))
Last active July 31, 2023 16:25
une autre manière de faire un template
View example.html
This file contains 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
 [] [] for item in itemlist: [
• {item}
• ] [] []
Last active June 10, 2023 23:10
View risk.py
This file contains 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 itertools import product dices=[range(1,7),range(1,7),range(1,7),range(1,7),range(1,7)] wins={0:0,1:0,2:0} C = 0 for a,b,c,d,e in product(*dices): n=0; d,e =sorted([d,e]) A,B = sorted([a,b,c],reverse=True)[:2] if A>e:
Created May 28, 2023 09:44
View tes.txt
This file contains 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
 // Define the two rotations as quaternions Quaternion rotation1 = Quaternion.Euler(x1, y1, z1); // First rotation Quaternion rotation2 = Quaternion.Euler(x2, y2, z2); // Second rotation // Combine the rotations Quaternion combinedRotation = rotation1 * rotation2; // Apply the combined rotation to the object's transform transform.rotation = combinedRotation;
Last active May 18, 2023 14:53
View asyouprefer.pseudocode
This file contains 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
 # pseudo code de ton traitement ################################ read_record: for line in fichier(): records.append(scanf(line)) partie1: for record in records():
Last active May 8, 2023 07:57
global variable impact
View withmain.py
This file contains 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 main(): from time import time as t t1=t() for i in range(1_000_000_000):
Last active April 13, 2023 14:49
random
View test.js
This file contains 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
 var win=0;for(var i=0;i<10*1000*1000;i++){if(Math.random()*100<=0.01){win++;};};console.log(win/(10*1000*1000));
Created March 22, 2023 11:05
View count.py
This file contains 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 collections import Counter words = "le petit chat est mort le gros chien est rassasié".split() count=Counter(words ) print(count.most_common()) # resultat # [('le', 2), ('est', 2), ('petit', 1), ('chat', 1), ('mort', 1), ('gros', 1), ('chien', 1), ('rassasié', 1)]
Created August 15, 2019 08:20
This vaccum all database in the home directory
View vaccum-maintenance.sh
This file contains 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
 #!/bin/bash set -eu echo "Scanning for sqlite databases..." find \ ~\ -type f '(' -iname '*.sqlite' -o -iname '*.db' ')' \ -print0 | while read -r -d \$'\0' filename; do
Created September 18, 2017 12:31
View mailman_pattern.py
This file contains 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 re import sys def e(arg): return re.escape(arg) def any(arg): return "("+"|".join(map(re.escape,arg.split()))+")" def non_space(): return r"\S+" def spaced(*args): return "\s+".join(args)