Skip to content

Instantly share code, notes, and snippets.

View mtavkhelidze's full-sized avatar
🇬🇪
OOP is an exceptionally bad idea which could only have originated in California.

Misha Tavkhelidze mtavkhelidze

🇬🇪
OOP is an exceptionally bad idea which could only have originated in California.
View GitHub Profile
@mtavkhelidze
mtavkhelidze / Protected.tsx
Last active November 17, 2024 05:43
A component for protection of routes, for example when using `wouter`
import React, { type PropsWithChildren } from "react";
type Props = {
with: () => boolean;
} & PropsWithChildren
const Protected: React.FC<Props> = props =>
props.with() ? <>{props.children}</> : <UserLogin />;
@mtavkhelidze
mtavkhelidze / CMakeLists.txt
Last active September 5, 2024 13:22
Template CMakeLists with GoogleTest
cmake_minimum_required(VERSION 3.30)
project(project_cpp VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror" CACHE PATH "" FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/lib)
@mtavkhelidze
mtavkhelidze / build.sbt
Last active March 17, 2024 07:44
Dot build.sbt
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "3.4.0"
lazy val fpsCode = (project in file("."))
.settings(
name := "fps-code",
idePackagePrefix := Some("ge.zgharbi.study.fps"),
libraryDependencies ++= Seq(
"org.scalameta" %% "munit" % "0.7.29" % Test,
@mtavkhelidze
mtavkhelidze / .scalafmt.conf
Last active March 17, 2024 07:42
Dot scalafmt.conf
align.preset = none
# From https://scalameta.org/scalafmt/docs/configuration.html
#
# Keep in mind that 80 characters fit perfectly on a split laptop
# screen with regular resolution.
#
# GitHub mobile view only shows 80 characters and sometimes you might
# review code on your phone.
#
# Consider refactoring your code before choosing a value above 100.
FROM alpine:3.10
ARG SPARK_VERSION=3.0.0-preview
ARG HADOOP_VERSION_SHORT=3.2
ARG HADOOP_VERSION=3.2.0
ARG AWS_SDK_VERSION=1.11.375
RUN apk add --no-cache bash openjdk8-jre python3
# Download and extract Spark
@mtavkhelidze
mtavkhelidze / match_case.py
Last active June 1, 2023 05:05
Scala-like case class pattern matching in Python >= 3.10
import math
from dataclasses import dataclass
from math import sqrt
"""
Scala-like case class pattern mathing in python >= 3.10
"""
@dataclass(frozen=True)
@mtavkhelidze
mtavkhelidze / MapReduce.scala
Created February 14, 2023 11:26 — forked from iravid/MapReduce.scala
Map-Reduce with ZIO
import $ivy.`dev.zio::zio:1.0.0-RC8-12`
import $ivy.`dev.zio::zio-streams:1.0.0-RC8-12`
import zio._, zio.stream._
object Step1 {
import java.nio.file.{Files, Paths, Path}
import scala.collection.JavaConverters._
import zio.blocking._
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame
from pandas.io.common import urlopen
import numpy as np
URL = "https://covidtracking.com/api/v1/states/daily.json"
ALPHA = 0.1
LOGARITHMIC = False
@mtavkhelidze
mtavkhelidze / ru_veterans.py
Last active April 9, 2020 19:28
Number of veterans in Russia (blue) with annual change (red).
# Number of veterans in Russia
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.axes import Axes
from matplotlib.figure import Figure
raw_data_source = "https://twower.livejournal.com/2408991.html"
@mtavkhelidze
mtavkhelidze / vm.sh
Created October 31, 2019 10:36
Start/Stop VirtualBox VM in headless mode
#!/usr/bin/env bash
vmm=VBoxManage
function usage {
echo "Usage:" $(basename $0) "start|stop" "hostname" >/dev/stderr
}
function get_ip {
VBoxManage guestproperty enumerate $1 \