Skip to content

Instantly share code, notes, and snippets.

View Iftimie's full-sized avatar
🐒

Iftimie Florentin Alexandru Iftimie

🐒
  • Bucharest, Romania
View GitHub Profile
@Iftimie
Iftimie / common.js
Last active January 30, 2022 12:02
WebRTC 2
export const CHAT_CHANNEL = "chat"
export function waitForAllICE(peerConnection) {
return waitForEvent((fulfill) => {
peerConnection.onicecandidate = (iceEvent) => {
if (iceEvent.candidate === null)
fulfill()
}
})
<html>
<head>
<title>WebRTC</title>
<script type="module">
import * as common from './common.js';
async function start() {
const peerConnection = initializeBeforeReceivingOffer()
await receiveOfferSDP(peerConnection)
await sendAnswerSDP(peerConnection)
from concurrent.futures import process
import os
from typing import Iterable, Iterator
import time
from dask.distributed import Client
def main():
folder_path = "data"
filepaths = get_filepaths(folder_path)
lines = get_lines(filepaths)
@Iftimie
Iftimie / index.css
Last active July 4, 2024 22:32
Resume
/* Fonts */
/* Family */
h1 {
font-family: 'Julius Sans One', sans-serif;
}
h2 { /* Contact, Skills, Education, About me, Work Experience */
font-family: 'Archivo Narrow', sans-serif;
}
@Iftimie
Iftimie / index.html
Created January 19, 2022 13:48
Main formatting
<!DOCTYPE html>
<html>
<head>
<style>
body {
background: rgb(204,204,204);
width: 21cm;
height: 29.7cm;
margin: 0 auto;
}
import redis
DISTRIBUTED_CACHE_TOP_PHRASES_KEY = 'top-phrases:'
class Frontend:
def __init__(self):
self._distributed_cache = redis.Redis(host=os.getenv("DISTRIBUTED_CACHE_HOST"), port=6379, db=0)
# Using Cache Aside Pattern
def top_phrases_for_prefix(self, prefix):
min_lexicographic_char = chr(0)
max_lexicographic_char = chr(255)
PARTITIONS = (min_lexicographic_char, 'mod'), ('mod', max_lexicographic_char)
class Backend:
def __init__(self):
self.backend_number = self.find_self_partition()
def _attempt_to_join_target(self, target_id):
if (not target_id or self._zk.exists(f'/phrases/distributor/{target_id}') is None):
...
class Backend:
def __init__(self):
self._trie = Trie()
self.partition_index = self.find_self_partition()
def find_self_partition(self):
cli = docker.Client(base_url='unix://var/run/docker.sock')
all_containers = cli.containers()
# filter out ourself by HOSTNAME
...
min_lexicographic_char = chr(0)
max_lexicographic_char = chr(255)
PARTITIONS = (min_lexicographic_char, 'mod'), ('mod', max_lexicographic_char)
...
class TrieBuilder:
def build(self, target_id):
for start, end in PARTITIONS:
...
from hdfs import InsecureClient
from hdfs.ext.avro import AvroReader
class HdfsClient:
def __init__(self, namenode_host, datanode_host):
self._namenode_host = namenode_host
self._datanode_host = datanode_host
self._client = InsecureClient(f'http://{self._namenode_host}:9870')