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 Foundation | |
import FoundationNetworking | |
// URL session provides async and callback API to upload Data | |
// Use continuations to convert existing callback API into an async | |
// https://developer.apple.com/documentation/foundation/url_loading_system/uploading_data_to_a_website | |
// You can POST to the /register endpoint of this API https://movie-api-ybwl.koyeb.app/api-docs/ | |
enum HttpError: Error { |
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
struct ToDoTask { | |
var description: String | |
var completed: Bool | |
} | |
let task1 = ToDoTask(description: "Practice ping-pong.", completed: false) | |
let toDoList = [ | |
task1, | |
ToDoTask(description: "Buy a pirate costume.", completed: true), | |
ToDoTask(description: "Visit Boston in the Fall.", completed: false), |
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
func computeMax<T: Comparable>(a: T, b: T) -> T{ | |
return if a > b { | |
a | |
} else { | |
b | |
} | |
} | |
// Here, swift inferred that T is Float (or Double ?) | |
print(computeMax(a: 100, b: 20.0)) |
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
const x = 10; | |
const y = 20; | |
function add(x: number, y: number): number { | |
return x + y; | |
} | |
console.log(add(x, y)); |
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
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>JSP - Hello World</title> | |
</head> | |
<body> | |
<h1><%= "Hello World!" %> | |
</h1> | |
<p/> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Client mqtt</title> | |
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script> | |
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> |
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 paho.mqtt.client as mqtt | |
def on_connect_mqtt(client, userdata, flags, rc): | |
print(f"rc : {rc}, {userdata}") | |
client.publish("chambre1/ordi", "Ah !") | |
res = client.subscribe("chambre1/tv") | |
print(f"subscribe res : {res}") | |
res = client.subscribe("chambre1/tv2") | |
print(f"subscribe res : {res}") |
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
const int pin = 13; | |
const int pin2 = 10; | |
const int pin3 = 2; | |
void setup() | |
{ | |
pinMode(pin, OUTPUT); | |
pinMode(pin2, OUTPUT); | |
pinMode(pin3, OUTPUT); | |
} |
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
"use strict"; | |
const http = require("http"); | |
// Cet exercice utilise le module http de nodejs | |
// documentation: https://nodejs.org/api/http.html et https://www.w3schools.com/nodejs/nodejs_http.asp | |
/** | |
* créer un serveur nodejs qui affiche dans la console les champs suivants de la requête client: url, headers, method | |
* Le serveur répond au client avec une réponse http dont le coprs contient la date à laquelle il a reçu la requete | |
* Documentation: https://nodejs.org/api/http.html#http_class_http_incomingmessage |
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
// source: https://www.w3resource.com/csharp-exercises/for-loop/csharp-for-loop-exercise-38.php | |
int num, r, sum = 0, t; | |
Console.Write("\n\n"); | |
Console.Write("Check whether a number is a palindrome or not:\n"); | |
Console.Write("------------------------------------------------"); | |
Console.Write("\n\n"); | |
Console.Write("Input a number: "); | |
num = 123115; |
NewerOlder