Skip to content

Instantly share code, notes, and snippets.

@num8er
num8er / Warehouse_and_Products_example1.cpp
Created June 6, 2024 20:51
Experimenting with Object (Product) storage (Warehouse) of fixed size and smart pointers
#include <iostream>
struct Product {
Product(const std::string& name): name(name) {
std::cout << "Named Product constructor for \"" + name + "\"" << std::endl;
}
Product(): name("") {
std::cout << "Draft Product constructor" << std::endl;
}
~Product() {
@num8er
num8er / Program.cs
Created April 3, 2024 03:59
C# WebSocketEventEmitter
using System;
class Program
{
static async Task Main(string[] args)
{
var webSocketEventEmitter = new WebSocketEventEmitter();
webSocketEventEmitter.MessageReceived += (sender, message) =>
{
Console.WriteLine("Received message: " + message);
@num8er
num8er / Execution example.sql
Last active February 10, 2024 15:28
MySQL stored function to convert formula to list of numbers
# Given alphanumeric string that includes two special characters + and -.
# Dash "-" means range, "+" (plus) means inclusion of number to list.
# Please execute RangeFormulaToList.sql to create function before running test below.
# Examples:
DROP TABLE IF EXISTS `tests_formulas`;
CREATE TABLE `tests_formulas` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`formula` text DEFAULT NULL,
@num8er
num8er / main.odin
Last active January 16, 2024 01:27
client variable created in for loop is replacing previous one in previous thread
package main
import "core:fmt"
import "core:net"
import "core:io"
import "core:thread"
import "core:time"
import "core:strings"
Client :: struct {
const net = require("net");
const server = net.createServer();
server.on("connection", (clientToProxySocket) => {
//console.log("Client connected to proxy");
clientToProxySocket.once("data", (data) => {
let isTLSConnection = data.toString().indexOf("CONNECT") !== -1;
let serverPort = 8008;
let serverAddress = '127.0.0.1';
const crypto = require('crypto');
class Crypter {
constructor (secretKey, secretKeySalt) {
this._keychain = {
key: this.createKey(secretKey, secretKeySalt),
iv: this.createIV(secretKey, secretKeySalt)
};
}
from flask import request
from flask.logging import default_handler
class RequestFormatter(logging.Formatter):
def format(self, record):
record.url = request.url
record.remote_addr = request.remote_addr
if 'X-Forwarded-For' in request.headers:
proxy_data = request.headers['X-Forwarded-For']
ip_list = proxy_data.split(',')
[$USER]
user = $USER
group = $USER
listen = /run/php/fpm-$USER.sock
listen.owner = $USER
listen.group = $USER
listen.mode = 0666
pm = dynamic
@num8er
num8er / polyfills.php
Last active September 13, 2023 14:33
PHP 5.3 to 7.x migration polyfill collection.
<?php
namespace Polyfills
{
final class Ereg
{
public static function ereg($pattern, $string, &$regs = null)
{
if ($pattern === '' || $pattern === null) {
trigger_error('ereg(): REG_EMPTY', E_USER_WARNING);
@num8er
num8er / fpm-pool.conf
Created March 3, 2020 15:12
Copy of php fpm pool config with comments
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[num8er]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unum8ersocket)
; - 'chroot'