Skip to content

Instantly share code, notes, and snippets.

View vporton's full-sized avatar

mathematician vporton

View GitHub Profile
@vporton
vporton / my-ufw.py
Created June 7, 2025 15:16
Protect from DoS attacks: Script to allow (by UFW firewall) your server HTTPS (port 443) to be accessed only from CloudFront
#!/usr/bin/env python3
import re
import subprocess
import json
import urllib.request
import shutil
import os
import sys
@vporton
vporton / safe.sh
Last active April 9, 2021 12:51
Script to run a shell command without breaching security of anything except of your home dir
#!/bin/sh
# Script to run a shell command without breaching security of your home dir:
# safe cat /home/me/VERY-SECRET-FILE
# cat: /home/me/VERY-SECRET-FILE: No such file or directory
# Requires `firejail`, `expect`, `xserver-xorg-video-dummy`.
# The file /etc/X11/xorg.conf.d/dummy-1920x1080.conf is to be taken from
# https://techoverflow.net/2019/02/23/how-to-run-x-server-using-xserver-xorg-video-dummy-driver-on-ubuntu/

Response to a security audit

Trusted courts

Chain of trust is interntional. It has (at least) the following usages:

  • District courts may trust supreme courts. This trust is unconditional.
  • A court may trust an automated exchange. If no absolute trust, it could not function.

So, in my opinion, your response to trusted courts is invalid. If you have any response, please respond.

@vporton
vporton / open-source.md
Last active February 5, 2020 08:33
The future of open source monetization

The future of open source is to reward open source developers with minted crypto money (instead of current inefficient or not working ways to monetize). It can be done with my Ethereum Reward Courts software.

Open source usually benefits the entire world, but only a small number of people or companies provide reward for an open source product. Instead we should mint money creating inflation in the entire world spread approximately equally between all and reward open source with those minted money. It means that open source will be both free and paid: free for users, paid by the entire world (the entity who benefits).

This way we could turn most of the closed source software into open source, because open source will become more profitable than closed source, due to a more just spreading of spents.

Keybase proof

I hereby claim:

  • I am vporton on github.
  • I am porton (https://keybase.io/porton) on keybase.
  • I have a public key ASBwvejjmaetGkkHF7QxxH9oTLzl4_eYwHfJizu5jq8rYAo

To claim this, I am signing this object:

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace BravoDB.Models.Tables
{
[Table("AdvShows")]
public class AdvShowsTable
{
[Key]
public int AdvOrderID { get; set; }
        private static void ProcessTable(ModelBuilder modelBuilder, PropertyInfo contextMember)
        {
            Type tableType = contextMember.PropertyType.GetGenericArguments()[0];

            PropertyInfo[] members2 = tableType.GetProperties();

            foreach (var m in members2)
            {
                object[] attrs = m.GetCustomAttributes(typeof(KeyAttribute), true);

Pure Dependency Injection in D

Dependency injection

A little modified quote from Wikipedia, Dependency injection article (This quote is licensed under CC BY-SA 3.0):

In software engineering, dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it. The service is made part of the client's state. Passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern.

The intent behind dependency injection is to achieve Separation of Concerns of construction and use of objects.

In D language we cannot construct an object of a template argument type in a template, as shown by the following example:

class Constructor(Result, Params...) {
    const(Result) create(Params params) {
        return new Result(params);
    }
}

void main() {
    class X { }

Modify tuple modifiers

The problem

In the standard D library it seems missing a function to modify tuple modifiers.

Consider the following:

alias t = AliasSeq!(int, float); // create tuple (int, float) of two types
alias tc = addTupleModifiers!("const shared", t);