Skip to content

Instantly share code, notes, and snippets.

Avatar

Alain Pellaux gallib

View GitHub Profile
@gallib
gallib / main.dart
Created Jan 26, 2021
Débuter avec Dart, exercice 7
View main.dart
void main() {
var number = 20;
print('fibonacci($number) = ${fibonacci(number)}');
}
int fibonacci(int number) {
return number < 2 ? number : (fibonacci(number - 1) + fibonacci(number - 2));
}
@gallib
gallib / main.dart
Created Jan 26, 2021
Débuter avec Dart, exercice 6
View main.dart
void main() {
Map<String, bool> modules = {
'm105': true,
'm133': false,
'm226': false,
'm213': true
};
modules.forEach((module, done) => done ? print('J\'ai déjà suivi le module $module') : '');
}
@gallib
gallib / main.dart
Last active Jan 26, 2021
Débuter avec Dart, exercice 5
View main.dart
void main() {
transport(6);
transport(18);
transport(20);
transport(32);
transport(55);
transport(75);
}
@gallib
gallib / main.dart
Last active Jan 26, 2021
Débuter avec Dart, exercice 4
View main.dart
void main() {
double kilometers = 3;
print('$kilometers kilomètres est égal à ${kilometersToMiles(kilometers)} miles');
}
double kilometersToMiles(double kilometers) {
return kilometers / 1.609;
}
@gallib
gallib / main.dart
Created Jan 26, 2021
Débuter avec Dart, exercice 3
View main.dart
void main() {
// Dart: Exercice n°3
// Avec une boucle for
for (int i = 0; i <= 100; i++) {
if (i % 2 == 0) {
print('$i est un nombre pair');
}
}
@gallib
gallib / preferences.json
Created Dec 9, 2018
Sublime Text preferences
View preferences.json
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_bottom": 1,
"caret_extra_top": 1,
"caret_extra_width": 1,
"caret_style": "blink",
"color_scheme": "Packages/Materialize/schemes/Material Monokai.tmTheme",
"default_line_ending": "unix",
"fade_fold_buttons": false,
@gallib
gallib / gist.php
Last active Dec 16, 2015
A placer dans functions.php. Utilisation: [gist id="xxx"]
View gist.php
function embed_gist( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'id' => '',
), $atts )
);
// Code
return '<script src="https://gist.github.com/' . $atts['id'] . '.js"></script>';
View robot.js
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(1000);