Skip to content

Instantly share code, notes, and snippets.

View gioiliop7's full-sized avatar
:octocat:
Hello

Giorgos Iliopoulos gioiliop7

:octocat:
Hello
View GitHub Profile

Development and Enhancement of the Cloud-Based FOSSBot Platform - GSOC 2024

This is the final report of the work which was done as part of development of the Fossbot Platform @ GSOC24.

Google Summer of Code logo

Name: Giorgos Iliopoulos

Mentor: Christos Chronis

@gioiliop7
gioiliop7 / functions.php
Created September 18, 2023 16:36
[WORDPRESS][DOKAN] Create shortcode and display html with given id
<?php
// Define the custom shortcode function
function get_vendor_info_shortcode($atts)
{
// Extract the attributes from the shortcode
$atts = shortcode_atts(
array(
'id' => 0, // Default ID if not provided
),
$atts,
@gioiliop7
gioiliop7 / Loading.tsx
Created August 27, 2023 08:35
Loading component with tailwind css (typescript)
const Loading: React.FC = () => {
return (
<>
<div className="min-h-screen bg-gray-200 flex items-center justify-center" role="status">
<svg
aria-hidden="true"
className="w-29 h-20 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-black"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
@gioiliop7
gioiliop7 / DigitalClock.tsx
Created August 27, 2023 08:34
Create digital-clock in React typescript using tailwind.css
import React, { useState, useEffect } from "react";
const DigitalClock: React.FC = () => {
const [time, setTime] = useState(new Date());
useEffect(() => {
const interval = setInterval(() => {
setTime(new Date());
}, 1000);
@gioiliop7
gioiliop7 / Weather.jsx
Created August 27, 2023 08:29
[React][Javascript][Tailwind] Weather component with Open weather map api
import React, { useState, useEffect } from 'react';
const Weather = () => {
const [weatherData, setWeatherData] = useState(null);
useEffect(() => {
const fetchWeatherData = async () => {
const apiKey = 'API_KEY';
const place = 'Your Place';
const apiUrl = `https://api.openweathermap.org/data/2.5/weather?q=${place}&units=metric&appid=${apiKey}`;
@gioiliop7
gioiliop7 / createNavigationLink.ts
Created August 27, 2023 08:21
[Typescript] Create navigation link for Google Maps
@gioiliop7
gioiliop7 / accents.js
Created May 24, 2023 06:09
Remove accents in greek string and make it capitalize
export function removeAccents(str) {
const upperCaseSeriousString = str.toUpperCase();
const greekLetters = {
Ά: "Α",
Έ: "Ε",
Ή: "Η",
Ί: "Ι",
Ϊ: "Ι",
Ό: "Ο",
Ύ: "Υ",
@gioiliop7
gioiliop7 / enisximeni_analogiki.js
Created May 23, 2023 22:56
Calculate parliament seats with "Enisxymeni analogiki" system
function calculateSeats(percentages) {
const totalSeats = 300; // Total number of seats
const threshold = 3; // Percentage threshold for proportional allocation
const totalVotes = percentages.reduce((sum, percentage) => sum + percentage, 0);
const allocatedSeats = [];
// Calculate seats for proportional allocation
const proportionalSeats = totalSeats - 50; // Remaining seats after allocating 50 for the first party
for (let i = 0; i < percentages.length; i++) {
@gioiliop7
gioiliop7 / apli_analogiki.js
Last active May 23, 2023 22:20
Calculate the seats in "Apli Analogiki" elections format, in greek elections
function distributeSeats(percentages, totalSeats, threshold) {
const validParties = percentages.filter((percentage) => percentage >= threshold);
const totalValidPercentages = validParties.reduce((a, b) => a + b, 0);
const seatDistribution = [];
validParties.forEach((percentage) => {
const seats = Math.floor((percentage / totalValidPercentages) * totalSeats);
seatDistribution.push(seats);
});
@gioiliop7
gioiliop7 / timezone.php
Created January 5, 2023 16:00
[PHP] Get current date or time of specific timezone
// If our server has a timezone out of Greece as an example , we can use this function to get the time of that timezone
// Supported timezones https://www.php.net/manual/en/timezones.php
// Supported time & date formats https://www.php.net/manual/en/datetime.format.php
function GetCityTimeDate($format,$timezone)
{
$tz = $timezone;
$timestamp = time();
$dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string
$dt->setTimestamp($timestamp); //adjust the object to correct timestamp