Skip to content

Instantly share code, notes, and snippets.

View R366Y's full-sized avatar
👾

Nicola Muneratto R366Y

👾
  • Oslo (Norway)
  • 12:49 (UTC +01:00)
View GitHub Profile
@R366Y
R366Y / pomo.sh
Created September 10, 2024 07:51
Pomodoro timer for Ubuntu - bash script
while true
do
for i in {1..4}
do
sleep 25m
notify-send "Time to take a short break"
sleep 5m
notify-send "Time to get back to work"
done
notify-send "Time for a long break"
@R366Y
R366Y / simple_todo.rs
Created August 6, 2024 12:40
a simple to-do app written in Rust
use std::io;
#[derive(Debug)]
struct TodoItem {
id: u32,
name: String,
completed: bool,
}
fn complete_item(item: &mut TodoItem){
@R366Y
R366Y / index.html
Created August 25, 2023 13:05
Matrix effect with Javascript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<title>Code rain</title>
<link rel="stylesheet" href="style.css"/>
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
#[derive(Debug, Clone, Copy, PartialEq)]
struct Vec3f {
x: f64,
y: f64,
z: f64,
@R366Y
R366Y / day3.rs
Created August 1, 2023 13:09
advent of code 2020 day 3 (Rust)
use std::fmt;
use std::ops::AddAssign;
#[derive(Debug, Clone, Copy, PartialEq)]
struct Vec2 {
x: i64,
y: i64,
}
@R366Y
R366Y / day2.rs
Last active August 1, 2023 10:05
Advent of code 2020 day 2 (Rust)
use std::error::Error;
use std::ops::RangeInclusive;
use std::fmt;
type MyResult<T> = Result<T, Box<dyn Error>>;
#[derive(Debug)]
enum ParseError {
Expected(&'static str),
}
@R366Y
R366Y / day1.rs
Last active August 1, 2023 09:18
advent of code 2020 day 1
use std::error::Error;
type MyResult<T> = Result<T, Box<dyn Error>>;
fn all_pairs(s: &[i64]) -> Vec<(i64, i64)> {
let mut pairs: Vec<_> = Default::default();
for i in 0..s.len() {
for j in 0..s.len() {
pairs.push((s[i], s[j]))
@R366Y
R366Y / crud.rs
Created July 31, 2023 13:40
a simple crud application I made while learning Rust
#[derive(Debug, PartialEq)]
enum CrudErr{
NotFound
}
#[derive(Debug, Clone, PartialEq)]
struct User {
id: u32,
name: String,
address: String,
@R366Y
R366Y / nuke_regex.py
Created February 16, 2018 14:29
Alphabet wars - nuclear strike
"""
Introduction
There is a war and nobody knows - the alphabet war!
The letters hide in their nuclear shelters. The nuclear strikes hit the battlefield and killed a lot of them.
Task
Write a function that accepts battlefield string and returns letters that survived the nuclear strike.
The battlefield string consists of only small letters, #,[ and ].
@R366Y
R366Y / string_subpatterns1.py
Created February 13, 2018 09:37
Return True or False if a string can be seen as the repetition of a simpler/shorter subpattern or not
"""
you need to build a function to return either true/True or false/False if a string can be seen as the repetition of
a simpler/shorter subpattern or not
For example:
has_subpattern("a") == False #no repeated pattern
has_subpattern("aaaa") == True #created repeating "a"
has_subpattern("abcd") == False #no repeated pattern
has_subpattern("abababab") == True #created repeating "ab"