Skip to content

Instantly share code, notes, and snippets.

@naezith
naezith / background.js
Created September 18, 2023 14:51
mm2 service worker
import init, {
LogLevel,
Mm2MainErr,
Mm2RpcErr,
mm2_main,
mm2_main_status,
mm2_rpc,
mm2_version,
} from "./src/mm2/mm2lib.js";
@naezith
naezith / spiral.cpp
Last active September 1, 2022 13:18
Spiral animation in Terminal, a bit dirty
#include <iostream>
#include <vector>
#include <string>
#include <unistd.h>
using namespace std;
const string CSI{"\x1b["};
const string CYAN{CSI + "36m"};
const string RED{CSI + "31m"};
@naezith
naezith / SwapMacKeys.ahk
Last active November 23, 2019 07:58
Swap Mac keyboard with Windows
; Swaps buttons for Mac keyboards
; Disable with Ctrl+F6 when you use a Windows keyboard.
; Option<->Command (Alt<->Win)
; RCommand<->RAlt (RWin<->RAlt)
; ROption<->RCtrl (RAlt<->RCtrl)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#InstallKeybdHook
@naezith
naezith / socket_stress.cpp
Last active May 17, 2019 10:41
Socket Stress using SFML
#include <SFML/Network.hpp>
#include <iostream>
#include <chrono>
#include <future>
#include <cstring>
int main() {
// Parameters
const auto ip = "111.111.111.111";
const auto port = 7777;
@naezith
naezith / read_matrix.cpp
Created September 19, 2018 23:27
Read matrix with unknown sizes into vectors
#include <iostream>
#include <vector>
#include <fstream>
int main() {
std::ifstream file("data.txt");
if(!file) {
std::cerr << "Failed to open the file";
return 1;
}
@naezith
naezith / http-stream.py
Last active June 26, 2018 23:14
picamera mjpeg stream, view on HTML page. Camera closes if noone watches.
import io
import picamera
import logging
import socketserver
from threading import Condition
from http import server
PAGE="""\
<html>
<head>
@naezith
naezith / 64bin_lbp.cpp
Created December 26, 2016 21:21
Image Search with 64 Bin and Local Binary Pattern techniques
#include <opencv2/opencv.hpp>
#include <iostream>
const int IMG_COUNT = 50;
const std::string file_prefix = "Dataset/";
const std::string file_folder[2] = {"Color/", "Texture/"};
const std::string file_suffix = ".jpg";
typedef std::vector<int> HIST;
typedef std::pair<int, double> DIST;
@naezith
naezith / genetic_algo.cpp
Created November 20, 2016 20:28
Genetic Algorithm Solution for Expression Finding
#include <iostream>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <memory>
int MAX_GENERATION = 10000;
int POPULATION_SIZE;
int TARGET_NUM;
@naezith
naezith / caesar_cipher.c
Last active November 12, 2016 12:56
Caesar Cipher
#include <stdio.h>
#include <stdlib.h>
char cap(char c) {
if(c >= 'a' && c <= 'z') c -= 32;
return c;
}
void addToSet(char* set, int* len, char c) {
int i = 0;
@naezith
naezith / derivation.java
Last active December 21, 2016 17:27
Derivation and Percent Error calculation, http://imgur.com/a/r7n0z
import java.text.DecimalFormat;
import java.text.NumberFormat;
// Solution for the question here -> http://imgur.com/a/r7n0z
public class Demo {
public static void main(String[] args) {
NumberFormat formatter = new DecimalFormat("#0.00000");
final double T = 70;
final double L = 1;