Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Elegance, grandeur in code. Simplicity first.

Don Cadavona doncadavona

💭
Elegance, grandeur in code. Simplicity first.
View GitHub Profile
@doncadavona
doncadavona / weight-utility.php
Last active Nov 18, 2020 — forked from irazasyed/weight-utility.php
PHP: Utility function for getting random values with weighting.
View weight-utility.php
<?php
/**
* Utility function for getting random values with weighting.
* Pass in an associative array, such as ['A'=> 5, 'B'=> 45, 'C'=> 50].
* An array like this means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%.
* The return value is the array key, A, B, or C in this case. Note that the values assigned
* do not have to be percentages. The values are simply relative to each other. If one value
* weight was 2, and the other weight of 1, the value with the weight of 2 has about a 66%
* chance of being selected. Also note that weights should be integers.
@doncadavona
doncadavona / Aes256CbcEncrypterApp.cs
Last active Jun 28, 2021
A sample C# class to encrypt and decrypt texts using the cipher AES-256-CBC used in Laravel.
View Aes256CbcEncrypterApp.cs
using System;
using System.Text;
using System.Security.Cryptography;
using System.Web.Script.Serialization;
using System.Collections.Generic;
namespace Aes256CbcEncrypterApp
{
class MainClass
{
@doncadavona
doncadavona / 0_introduction.md
Created Jul 28, 2021 — forked from justinhartman/0_introduction.md
Setup Azure Ubuntu 18.04 LEMP VM
View 0_introduction.md

How To Install Nginx, MySQL, PHP, SFTP on an Ubuntu Azure Virtual Machine

This series of documents will configure and setup a Nginx, MySQL, and PHP (LEMP) server on a basic Standard B1s (1 vcpus, 1 GiB memory) Ubuntu 16.04 or 18.04 LTS Virtual Machine on Microsoft Azure.

This will also install other useful packages and configurations for SFTP and a fully automated SSL service using certbot for Let's Encrypt.

The B1s is Azure's entry level Linux VM and only comes with 1 GiB memory so

@doncadavona
doncadavona / Aes256CbcEncrypterApp.cs
Last active Nov 27, 2021
A sample C# class to encrypt and decrypt strings using the cipher AES-256-CBC used in Laravel.
View Aes256CbcEncrypterApp.cs
using System;
using System.Text;
using System.Security.Cryptography;
using System.Web.Script.Serialization;
using System.Collections.Generic;
namespace Aes256CbcEncrypterApp
{
class MainClass
{