Skip to content

Instantly share code, notes, and snippets.

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

Andru Menangen menangen

🏠
Working from home
  • Russia
View GitHub Profile
@menangen
menangen / main.cpp
Created November 4, 2023 12:19
Modern C++ class based Stack Iterator
#include <iostream>
struct AdditionModule {
const char * name = "ADD";
void print() {
std::cout << name << "\n";
};
};
@menangen
menangen / hash_16_bit.cpp
Last active March 13, 2023 16:29
Speck 32 Block 64 Key - C / C ++
#include <stdio.h>
#include <inttypes.h>
#define ROUNDS 32
static inline void
speck_hash(
uint8_t& x, uint8_t& y,
const uint8_t key)
{
@menangen
menangen / main.cpp
Created December 7, 2022 16:24
C++ class like union
#include <iostream>
struct User {
enum { AGE, NAME } tag;
union {
int age;
char * nik;
};
@menangen
menangen / main.cpp
Created October 5, 2022 17:21
Hello c++ Queue structure
#include <cassert>
#include <iostream>
#define STREAM std::ostream&
struct Player {
int score;
Player (int s) { this -> score = s; }
Player () { this -> score = 0; }
@menangen
menangen / AtomicStorage.swift
Last active December 27, 2021 20:16
Dispatch Timer
//
// main.swift
// runLoop
//
// Created by menangen on 27.12.2021.
//
import Foundation
extension Thread {
@menangen
menangen / client.c
Last active December 18, 2021 22:23
UNIX C TCP socket: server and client
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#define MAX 80
@menangen
menangen / Shader.metal
Created October 3, 2021 21:41
Apple Metal Square rotation with Aspect ratio
//
// Shaders.metal
// metal2Mac
//
// Created by menangen on 02.11.2018.
// Copyright © 2018 menangen. All rights reserved.
//
// File for Metal kernel and shader functions
@menangen
menangen / main.swift
Created September 24, 2021 14:43
Swift 5 GCD
//
// main.swift
// dispatcher
//
// Created by menangen on 24.09.2021.
//
import Foundation
import Dispatch
@menangen
menangen / main.swift
Created September 4, 2021 18:28
Swift 5.5 Concurrency
//
// Created by menangen on 04.09.2021.
//
import Foundation
print("Hello, World!")
let t = Task(priority: .background, operation: { return 2 } )
let handle = Task {
@menangen
menangen / index.js
Last active December 24, 2020 17:18
Node.js 14 Promise example in JavaScript
function timeHandler(ok, bad) {
if (Math.random() > 0.5)
ok("Anna")
else
bad("Andre")
}
function
setUp(ok, bad) {
setTimeout(timeHandler, 1000, ok, bad)