Skip to content

Instantly share code, notes, and snippets.

View gruvw's full-sized avatar
💻
Coding as always

Lucas Jung gruvw

💻
Coding as always
View GitHub Profile
@gruvw
gruvw / merge_riverpod_providers.dart
Created September 13, 2024 06:31
Dart Riverpod: merging two providers of the same type to emit the latest value
import 'package:riverpod/riverpod.dart';
/// Dart Riverpod merging two providers of the same type
/// https://stackoverflow.com/questions/78978863/dart-riverpod-merging-two-providers-of-the-same-type
// Example StateNotifier for a simple counter.
class Counter extends Notifier<int> {
@override
int build() => 0;
void increment() => state++;
@gruvw
gruvw / fix_submission.py
Created January 7, 2024 11:29
Fix MP2 submission
import os
import sys
import glob
def main():
if len(sys.argv) < 2:
print("Usage: python fix_submission.py <SCIPER1-SCIPER2>")
sys.exit(1)
PROJECT = sys.argv[1]
def max_from(l, s=0):
return max((s := s + e, i) for i, e in enumerate(l))
def max_crossing(l1, l2):
s1, i = max_from(reversed(l1))
s2, j = max_from(iter(l2))
return s1 + s2, (i, len(l1) + j)
@gruvw
gruvw / lexoRank.py
Last active August 3, 2022 09:48
LexoRank Python
import math
def _pad(s, n):
p = _alphabet[0] * (n - len(s))
return s + p
def _debase(s):
val = 0
@gruvw
gruvw / decipher_vigenere.py
Last active March 24, 2022 16:25
Decipher Vigenère from partial plaintext
# Alphabet
a = "abcdefghijklmnopqrstuvwxyz"
# Given data
cipher = "ebgrycxgbghitursyneavcgbgryv"
partial_text = "t*****************u**i**i***" # supposed valid and not empty (only *)
# Function (single char) that does C,T -> K or C,K -> T
clear = lambda c, tk: (i := (a.find(c)-a.find(tk)) % len(a), a[i]) # (index, letter)
@gruvw
gruvw / .hyper.js
Last active January 9, 2022 10:15
Hyper Terminal Settings
// ~/.hyper.js
"use strict"
module.exports = {
config: {
updateChannel: 'stable',
fontSize: 13,
fontFamily: '"Fira Code", monospace',
fontWeight: 'normal',
fontWeightBold: 'bold',
@gruvw
gruvw / best_meeting_point.py
Created May 27, 2021 10:28
Meeting point from GPS coordinates
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
multi = 1e3 # Precision
# GPS coords: (°N, °E)
pers = [
(, ),
(, ),
{
"basics": {
"name": "Lucas Jung",
"label": "EPFL Computer Science Student / Software Developer",
"picture": "https://avatars1.githubusercontent.com/u/63407038?s=460&u=58879e919dd2613767be454455528db0e469f89b&v=4",
"email": "[email protected]",
"website": "https://gruvw.com",
"summary": "Also known as Gruvw, I was born in 2002 in Switzerland. I started to learn how to code at the age of 10. Since then, I have fallen in love with programming and Computer Science in general. I learned a lot about programming by myself before studying Computer Science at EPFL and I wrote many projects (some OpenSource that you can check out on my GitHub). I try to have as much professional experiences as possible in order to develop my skills further and to better understand professional environments. I am passionate and very curious about everything, never missing out an opportunity to learn.",
"location": {
"countryCode": "Switzerland",