Skip to content

Instantly share code, notes, and snippets.

@antcolag
antcolag / di.cc
Last active December 11, 2022 17:49
Possible implementation of a dependency injection framework in C++
#include <iostream>
#include <system_error>
#include <memory>
template<typename T>
class di : public std::shared_ptr<T>
{
static std::shared_ptr<T> ptr;
public:
@antcolag
antcolag / easy-websocker.js
Created November 15, 2021 22:09
easy websocker
import * as crypto from 'crypto';
var SocketHandlerCounter = 0;
export class SocketHandler {
constructor(req, socket) {
this.req = req;
this.socket = socket;
this.id = SocketHandlerCounter++;
this.data = this.parse.bind(this)
}
@antcolag
antcolag / riempitore campi vuoti.js
Last active January 29, 2021 10:45
tool per console, per inserire le ore lavorate, per in una nota agenzia interinale
/*
skip: giorni del mese da skippare
firstDay: primo giorno del mese nella settimana:
*/
lunedy = 1;
martedy = 2;
mercoledy = 3;
giovedy = 4;
venerdy = 5;
sabatdy = 6;
@antcolag
antcolag / index.php
Last active January 8, 2020 10:52
php function for unpack arrays
<?php
$array = [
"Complimenti",
"ora",
"puoi",
[
"inviare",
[
"la tua",
@antcolag
antcolag / cammini-giusti.cs
Last active January 29, 2021 10:54
l'algoritmo della ricerca dei cammini più giusti sugli alberi
public class ProductShotsPattern
{
public string Name { get; set; }
public int Data { get; set; }
public List<string> Pattern { get; set; }
public List<ProductShotsPattern> Overrides { get; set; }
public ProductShotsPattern Find(string search, int depth = 0)
{
var setPseudoStyle = (function() {
document.head.appendChild(document.createElement('style'));
style = document.styleSheets[document.styleSheets.length-1];
return function setPseudoStyle(elm, pseudo, text){
var id = elm.dataset.psudoLinkToStyle
if(void 0 === id){
id = style.rules.length;
style.addRule( '[data-psudo-link-to-style="'+id+'"]:'+pseudo, '', id);
elm.dataset.psudoLinkToStyle = id;