Skip to content

Instantly share code, notes, and snippets.

View IonutCicio's full-sized avatar

Ionuț Cicio IonutCicio

View GitHub Profile
@IonutCicio
IonutCicio / lib.rs
Created February 13, 2026 20:03
shunting yard algorithm
use std::collections::VecDeque;
#[derive(Debug)]
enum Associativity {
Left,
Right,
}
#[derive(Debug, Clone, Copy)]
pub enum Operator {
use std::ops::Sub;
fn two_sum<'a, T>(numbers: &'a [T], target: &'a T) -> Option<(usize, usize)>
where
T: Ord,
&'a T: Sub<Output = T>,
{
let mut indexed_numbers: Vec<_> = numbers.iter().enumerate().collect();
indexed_numbers.sort_unstable_by_key(|&(_, number)| number);
const LINE_SIZE: usize = 5;
fn hexdump<T>(reference: &T) {
let ptr = reference as *const T as *const u8;
let type_size = size_of::<T>();
for line in (0..type_size).step_by(LINE_SIZE) {
for byte_offset in line..(line + LINE_SIZE).min(type_size) {
print!("{:02X} ", unsafe { *ptr.add(byte_offset) });
}
@IonutCicio
IonutCicio / main.c
Last active July 24, 2025 18:15
Vigenère
#include "vigenere.h"
#include <stdio.h>
#include <stdlib.h>
int main() {
struct vig_key_t *key = key_from_string("XMWUJBVYHXZ");
if (key == NULL) {
fprintf(stderr, "key_from_string() error");
return EXIT_FAILURE;
}
use std::time::Instant;
mod hundred {
pub fn solve(size: usize) -> Option<Matrix> {
let goal = size.pow(2);
// The matrix is linearized for better cache-efficiency
let mut matrix = vec![0; goal];
let mut moves = vec![];
// Initial position in the center, the first move assigns the number 1
# -*- coding: utf-8 -*-
from timeit import Timer
# from program01 import dumbothello
# from chonji import dumbothello as chonji
# from dangun import dumbothello as dangun
# from dosan import dumbothello as dosan
# from wonhyo import dumbothello as wonhyo
# from yulgok import dumbothello as yulgok
from joonggun import dumbothello as joonggun

Creating a Linux service

Create .service file

cd /etc/systemd/system
sudo touch <name>.service
sudo vim <name>.service # Use your editor of choice

Edit service

async function load(sources, callback) {
for (const src of sources)
await new Promise(
resolve => {
const image = new Image();
image.onload = _ => resolve(src);
image.src = src
}
).then(src => callback(src));
}
@IonutCicio
IonutCicio / main.cpp
Created February 21, 2020 17:35
turn bit on cpp
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
int memory;
cout << "Insert a value between 0 and 255: ";
cin >> memory;
@IonutCicio
IonutCicio / main.cpp
Created February 21, 2020 17:34
turn bit off cpp
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
int memory;
cout << "Insert a value between 0 and 255: ";
cin >> memory;