Skip to content

Instantly share code, notes, and snippets.

View FreeCX's full-sized avatar
:shipit:
Detective Squirrel

Alexey Golubev FreeCX

:shipit:
Detective Squirrel
View GitHub Profile
@FreeCX
FreeCX / serialize_demo.rs
Created August 29, 2022 10:57
rust struct serialize-deserialize demo
use std::convert::TryInto;
trait Serialize {
fn to_bytes(&self) -> ObjectData;
}
trait Deserialize {
fn from_bytes(data: ObjectData) -> Self
where
Self: Sized;
@FreeCX
FreeCX / two_input_nn.py
Created May 26, 2022 08:00
Two input neural network demo
import keras.layers as L
import keras.models as M
import numpy as np
import sklearn.metrics as sk
import matplotlib.pyplot as plt
def create_model():
input_a = L.Input(shape=(1,))
input_b = L.Input(shape=(1,))
@FreeCX
FreeCX / idiot_proof_code.py
Last active April 22, 2022 17:52
Finally! Idiot-proof code!
from uuid import uuid4
import pickle
class IdiotProof:
def __init__(self, local):
self.vars = []
self.local = local
def track(self, variable):
@FreeCX
FreeCX / Makefile
Created April 14, 2021 16:31
Код к статье про поиск кота
CXX := g++
FLAGS := -O3
all:
$(CXX) $(FLAGS) find_a_cat_v1.cpp -o find_a_cat_v1
$(CXX) $(FLAGS) find_a_cat_v2.cpp -o find_a_cat_v2
$(CXX) $(FLAGS) prove_xorshift.cpp -o prove_xorshift
clean:
$(RM) find_a_cat_v1 find_a_cat_v2 prove_xorshift
@FreeCX
FreeCX / encode.hs
Last active December 26, 2021 11:58
Encode/Decode input string
module Main where
import Data.Maybe (fromJust)
import Data.List (elemIndex)
import Data.Char (ord, chr)
import Text.Printf (printf)
alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#@"
-- добавление паддинга до размера size
@FreeCX
FreeCX / draw-ffmpeg.py
Last active December 26, 2021 11:58
L-System
from copy import deepcopy
from pathlib import Path
import subprocess as sp
import argparse
import json
import math
from PIL import Image, ImageDraw
@FreeCX
FreeCX / fake_repo.py
Created September 4, 2020 14:31
Fake Git Repo Server
from datetime import datetime as dt
from hashlib import sha1
import zlib
from flask import Flask, Response
app = Flask(__name__)
@FreeCX
FreeCX / Makefile
Last active March 28, 2026 20:58
Реализация клеточного автомата на N языках
all: build_rust build_cpp build_nim build_haskell build_zig
build_rust:
@echo "> build rust code"
@rustc -C opt-level=3 cellmachine.rs -o cellmachine_rs
build_cpp:
@echo "> build c++ code"
@g++ -O3 -std=c++20 cellmachine.cpp -o cellmachine_cpp
build_nim:
@echo "> build nim"
@nim compile -d:release -o:cellmachine_nim cellmachine.nim > /dev/null 2>&1
@FreeCX
FreeCX / crates_bigint_fib.rs
Last active February 23, 2020 08:30
Расчёт чисел Фибонначи с помощью больших чисел
// [dependencies]
// num-bigint = "*"
extern crate num_bigint;
// num-traits = "*"
extern crate num_traits;
use num_bigint::BigUint;
use num_traits::{One, Zero};
use std::env;
use std::mem::replace;
@FreeCX
FreeCX / build.rs
Last active November 2, 2020 10:57
build info code generator for rust
#[cfg(windows)]
extern crate winres;
extern crate chrono;
use std::collections::HashMap;
use std::process::Command;
use std::{fs::read_to_string, fs::File, io::Write};
use chrono::Utc;
fn execute(cmd: &str) -> String {
match Command::new(cmd).arg("-vV").output() {