Skip to content

Instantly share code, notes, and snippets.

View ssaurel's full-sized avatar

Sylvain Saurel ssaurel

View GitHub Profile
@ssaurel
ssaurel / tooltip.html
Created January 7, 2024 15:13
India Map Tooltip on SSaurel's Blog
var ids = ['IN-AN', 'IN-AP', 'IN-AR', 'IN-AS', 'IN-BR', 'IN-CH', 'IN-CT', 'IN-DD', 'IN-DL', 'IN-DN', 'IN-GA', 'IN-GJ',
'IN-HP', 'IN-HR', 'IN-JH', 'IN-JK', 'IN-KA', 'IN-KL', 'IN-LD', 'IN-MH', 'IN-ML', 'IN-MN', 'IN-MP',
'IN-MZ', 'IN-NL', 'IN-OR', 'IN-PB', 'IN-PY', 'IN-RJ', 'IN-SK', 'IN-TG', 'IN-TN', 'IN-TR',
'IN-UP', 'IN-UT', 'IN-WB'];
function init(evt) {
if ( window.svgDocument == null ) {
svgDocument = evt.target.ownerDocument;
}
@ssaurel
ssaurel / India_Map_Step_2.html
Created January 7, 2024 14:04
India Map Step 2 on SSaurel's Blog
<!DOCTYPE html>
<html lang="en">
<head>
<title>India Interactive SVG Map on the SSaurel's Blog</title>
<style type="text/css">
#title {
font-size: 25px;
fill: black;
@ssaurel
ssaurel / India_Map_Step_1.html
Created January 7, 2024 13:56
India Map Step 1 on the SSaurel's Blog
<!DOCTYPE html>
<html lang="en">
<head>
<title>India Interactive SVG Map on the SSaurel's Blog</title>
</head>
<body>
<svg height="800" width="1000">
<path
id="IN-AN"
@ssaurel
ssaurel / PongGame.py
Created January 4, 2024 13:35
Classical Pong Game in Python with Tkinter UI for the SSaurel's Blog
import tkinter as tk
import random as rand
import threading
import os
#define some constants
WIDTH = 1000
HEIGHT = 700
MARGIN = 15
@ssaurel
ssaurel / Pong.py
Created January 4, 2024 13:31
Pong Object for a Pong Game on the SSaurel's Blog
# Now, we can define the Pong Game Object
class Pong:
def __init__(self, root, width, height, margin):
paddlewidth = width / 50
paddleheight = height / 12
self.leftpoints = 0
self.lefttxt = None
self.rightpoints = 0
self.righttxt = None
self.render = True # True when we need to render the game on the canvas
@ssaurel
ssaurel / Paddle.py
Created January 4, 2024 13:18
Paddle Object for a Pong Game on the SSaurel's Blog
# Now, it is time to design the Paddle for our Pong Game
class Paddle:
def __init__(self, canvas, topx, topy, width, height, boardheight):
self.topx = topx
self.topy = topy
self.width = width
self.height = height
self.boardheight = boardheight
self.score = 0
self.canvas = canvas
@ssaurel
ssaurel / Ball.py
Created January 4, 2024 13:11
Ball Object for a Pong Game on the SSaurel's Blog
# First, we design the Ball Object
class Ball:
def __init__(self, canvas, width, velocity, boardwidth, boardheight):
self.width = width
self.boardwidth = boardwidth
self.boardheight = boardheight
# we center the ball on the board
self.topx = boardwidth / 2 - width / 2
self.topy = boardheight / 2 - width / 2
self.velocity = velocity
@ssaurel
ssaurel / RomanNumeral.java
Created March 28, 2019 11:20
Roman Numeral TDD Kata on the SSaurel's Channel
public String intToRoman(int arabic) {
StringBuilder roman = new StringBuilder();
if (arabic == 10) {
roman.append("X");
} else {
while (arabic-- > 0) {
roman.append("I");
}
}
@ssaurel
ssaurel / FlippingBitsGame.py
Last active May 8, 2023 14:15
Flipping Bits Game in Python with Tkinter - Tutorial for the SSaurel's Blog
import tkinter as tk
import random
from copy import deepcopy
class FlippingBitsGame:
def __init__(self, level):
self.level = level # Level = size of the square
self.target = [[0] * level for _ in range(level)] # the board to obtain when you play
self.board = [[0] * level for _ in range(level)] # the current board played by the user
self.solved = True
@ssaurel
ssaurel / onclick.py
Created May 8, 2023 14:13
onclick method for a Flipping Bits Game on the SSaurel's Blog
def onclick(self, event):
if self.game.solved:
self.game.newgame()
self.drawboard()
return
# we get coordinates of the user's click
idx = int(event.x)
idy = int(event.y)