Skip to content

Instantly share code, notes, and snippets.

View realKfiros's full-sized avatar
🇮🇱
Bring them home

Kfir Nevo realKfiros

🇮🇱
Bring them home
View GitHub Profile
@realKfiros
realKfiros / full_table_based_simulation.py
Last active December 10, 2025 17:16
UEFA Swiss Model - simulate how many points will be enough for a team to reach each position in a league stage
import random
import math
from collections import Counter, defaultdict
# ----- Configuration -----
N_TEAMS = 36 # number of teams in the league phase
ROUNDS = 8 # number of games per team (for reference only)
MAX_POINTS = ROUNDS * 3 # 8 * 3 = 24
@realKfiros
realKfiros / OfflineQueue.tsx
Last active January 8, 2025 07:40
Post requests queue in expo - useful when the signal is weak
import React from "react";
import {View, Button, Text} from "react-native";
import {useOfflineQueue} from "@/hooks/useOfflineQueue";
export const OfflineQueue = () =>
{
const {connected, queue, postData} = useOfflineQueue();
const sendData = async () =>
{
@realKfiros
realKfiros / scrapepool.userscript.js
Created December 10, 2024 04:23
Scrapepool - A userscript that helps you win the "refresh game" and buy a ticket for a Liverpool game
// ==UserScript==
// @name Scrapepool
// @namespace https://kfiros.com/
// @version 0.1
// @description try to win the refresh game in order to get Liverpool tickets!
// @author realKfiros
// @match https://ticketing.liverpoolfc.com/en-GB/events/*/*/*?*hallmap
// @icon https://www.google.com/s2/favicons?sz=64&domain=liverpoolfc.com
// @grant none
// ==/UserScript==
@realKfiros
realKfiros / run_me.js
Last active September 15, 2024 08:30
The greatest JavaScript code of all time
[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]][([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(+(!+[]+!+[]+!+[]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([]+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(!
@realKfiros
realKfiros / computed_interval.js
Created August 26, 2024 16:38
Mobx computed interval
import {observable, action, runInAction} from 'mobx';
/**
* @typedef {object} Descriptor - The descriptor object for a property
* @property {boolean} enumerable - whether the property is enumerable
* @property {boolean} configurable - whether the property can be deleted or changed
* @property {function} get - the getter function
* @property {Map} [_intervals] - a map of intervals created by the @computedInterval decorator (no need to manually set this)
*/
@realKfiros
realKfiros / ImageSizeObserver.js
Last active March 19, 2024 16:00
A react hook used to observe changing size of an image and get the new ratio and use that on absolute positioned elements wrapped together with the image.
import {useState, useCallback} from "react";
/**
* @typedef {object} Size
* @property {number} width
* @property {number} height
*/
/**
* @typedef {object} ImageSizeObserver - A hook that observe an image size and provide some useful methods in order to work with its new size relatively
@realKfiros
realKfiros / countdown.jsx
Created March 3, 2021 10:55
useCountdown hook
import React, { useState, useMemo, useEffect } from "react";
import { intervalToDuration, subSeconds } from 'date-fns';
const useCountdown = ({ finishTime, format }) => {
const [time, setTime] = useState(new Date());
const countdown = useMemo(
() =>
intervalToDuration({
start: finishTime,
end: new Date(),
import Foundation
import UserNotifications
class NotificationsService: NSObject {
// the function that checks if user gave a permission to send notifications and if it didn't it awaits an answer from the user
@available(iOS 10.0, *) // available only on iOS 10 and newer iOS versions
func requestPermission() -> Void {
let notificationCenter = UNUserNotificationCenter.current()
let options: UNAuthorizationOptions = [.alert, .sound, .badge]
notificationCenter.requestAuthorization(options: options) {
@realKfiros
realKfiros / passport_local_w_sequelize.js
Last active October 21, 2019 17:57
Passport.js local strategy base configuration with Sequelize ORM, based on Express
const express = require('express');
const cors = require('cors');
const { sequelize } = require('./configurations');
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const session = require('express-session');
const uuid = require('uuid/v4');
const bodyParser = require('body-parser');
const models = {
# Created by realKfiros on 09/10/2017
import random
class TicTacToe:
winning_positions = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[7,5,3]]
def __init__(self):
self.board = {
1: " ", 2: " ", 3: " ",