Skip to content

Instantly share code, notes, and snippets.

View MAGANER's full-sized avatar
🏠
Working from home

Ian MAGANER

🏠
Working from home
  • Russian Federation
View GitHub Profile
@MAGANER
MAGANER / put_to_cb.py
Created July 7, 2021 20:05
i just need to run several terminals in the same directory, so i wrote this script to get current dir and paste it to clipboard, but also it can put whole file to clipboard.
#for Windows
import pathlib
import sys
import os
curr_path = pathlib.Path().resolve()
def copy2cb(data):
with open(".ts","w") as f:
f.write(str(data))
@MAGANER
MAGANER / GetIP.hpp
Created July 5, 2021 19:04
function to get local, external ip address of your machine under Windows OS.
/*
* This solution works for Windows as well,
* i don't know what about Unix-like, but i think
* it can include different implementations with
* macros as Win32 e.t.c.
* So we save ipconfig result to file get its 13 line
* with ipv4 data, save it, delete file and then return data.
*/
#ifndef GET_IP_H
#define GET_IP_H
@MAGANER
MAGANER / run.py
Created June 19, 2021 13:55
i got different projects in c++, so i always need to type application name and then call, so instead i run this script in build directory.
from os import listdir, system
import pathlib
data = listdir(pathlib.Path().absolute())
data = list(filter(lambda n: n[len(n)-4:] == ".exe",data))
if len(data) != 1:
print("can not find what to run")
else:
programm = data[0]
@MAGANER
MAGANER / btree.hpp
Created April 2, 2021 16:20
common btree in pure c++
template<class T>
class Node
{
private:
T data;
Node* left, * right;
public:
Node()
{
@MAGANER
MAGANER / 2048.cpp
Last active March 30, 2021 15:02
fixed problem, when you win or loose window gets closed and information is being printed to console.
#include"SFML/Graphics.hpp"
#include<vector>
#include<random>
#include<iostream>
using namespace sf;
using namespace std;
const int MAX_X = 4;
@MAGANER
MAGANER / life.cpp
Created March 29, 2021 20:12
short example of Life in C++/sfml
#include"SFML/Graphics.hpp"
#include<random>
#include<vector>
#include<iostream>
using namespace std;
using namespace sf;
const int CELL_SIZE = 16;
@MAGANER
MAGANER / snake.cpp
Created March 29, 2021 08:47
a short snake in C++/sfml
#include "SFML/Graphics.hpp"
#include<random>
#include<vector>
#include<string>
//to print score and wait
#include<iostream>
#include<conio.h>
using namespace std;
@MAGANER
MAGANER / rsa.rs
Last active March 26, 2021 19:15
RSA example in RUST
use rand::prelude::*;
use modinverse::modinverse;
fn is_prime(n: u32) -> bool
{
//checks is number prime
let limit = (n as f64).sqrt() as u32;
for i in 2..=limit {
if n % i == 0 {
@MAGANER
MAGANER / fizzbuzz.py
Created March 22, 2021 20:10
functional solution of FizzBuzz task.
def FizzBuzz(number):
is_mult_of_3 = lambda n: (n % 3) == 0
is_mult_of_5 = lambda n: (n % 5) == 0
if is_mult_of_3(number) and is_mult_of_5(number):
return "FizzBuzz"
elif is_mult_of_3(number):
return "Fizz"
elif is_mult_of_5(number):
return "Buzz"
else:
@MAGANER
MAGANER / clipboard_data_getter.py
Last active October 25, 2021 13:06
get data from windows clipboard, if it's image then you get image close to script, if it's text then just print it.
import ctypes
import time
kernel32 = ctypes.windll.kernel32
user32 = ctypes.windll.user32
#standart clipboard formats used with win32
CF_TEXT = 1
CF_BITMAP = 2