Skip to content

Instantly share code, notes, and snippets.

graph LR
A[Square Rect] -- Link text --> B((Circle))
A --> C(Round Rect)
B --> D{Rhombus}
C --> D
// source: https://www.youtube.com/watch?v=Wim9WJeDTHQ
// Python implementation: https://gist.github.com/ilotoki0804/fcec5d437354e5094b620b1450986299
// Not using threading: https://gist.github.com/ilotoki0804/2fa26d0e3ba4cb34eae76615f9070080
use std::fmt::{Display, Debug};
use std::thread;
struct DigitsGenerator(u64, Option<Vec<u8>>);
impl DigitsGenerator {
@ilotoki0804
ilotoki0804 / multiplicative_persistence.rs
Last active January 28, 2024 01:28
multiplicative persistence implementation in Rust.
// source: https://www.youtube.com/watch?v=Wim9WJeDTHQ
// Python implementation: https://gist.github.com/ilotoki0804/fcec5d437354e5094b620b1450986299
// Using threading: https://gist.github.com/ilotoki0804/34f8331a23eb28a693149fb8c0314d7f
use std::fmt::{Display, Debug};
struct DigitsGenerator(u64, Option<Vec<u8>>);
impl DigitsGenerator {
fn new(i: u64) -> Self {
# https://velog.io/@gil0127/%EA%B0%9C%EB%B0%9C%EC%9E%90%EA%B0%80-%EB%A6%AC%EB%88%85%EC%8A%A4%EB%82%98-Mac%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%B4%EC%95%BC-%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0
from pathlib import Path
import pandas as pd
from collections import Counter
total_df = pd.read_csv("survey_results_public.csv") # from https://insights.stackoverflow.com/survey
frontend_df = total_df[total_df["DevType"].map(lambda value: not isinstance(value, float) and "front-end" in value)]
result = Counter([os for oses in frontend_df["OpSysProfessional use"]
if not isinstance(oses, float)
@ilotoki0804
ilotoki0804 / with_decorator.py
Created September 28, 2023 10:42
Using Decorator Instead With Statement
def with_role_decorator(f):
def wrapper(filename: str):
connection = open(filename, 'rb')
try:
return f(connection)
finally:
connection.close()
return wrapper
@ilotoki0804
ilotoki0804 / make_tuple.py
Created August 31, 2023 08:09
make tuple with growing size
def add_at_tuple(n):
tuple_ = ()
for i in range(n):
tuple_ = tuple_ + (i,)
return tuple_
def use_list(n):
list_ = []
for i in range(n):
@ilotoki0804
ilotoki0804 / multiplicative_persistence.py
Last active January 28, 2024 01:29
Finding multiplicative persistence number
# source: https://www.youtube.com/watch?v=Wim9WJeDTHQ
# Rust implementation: https://gist.github.com/ilotoki0804/34f8331a23eb28a693149fb8c0314d7f
from itertools import count, combinations_with_replacement
from functools import reduce
from operator import mul
import sys
sys.set_int_max_str_digits(0)