This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Remove next lines if you don't have HTTPS | |
<IfModule mod_headers.c> | |
Header always set Content-Security-Policy: upgrade-insecure-requests | |
</IfModule> | |
# BEGIN Cache-Control/Deflate/GZIP Compression | |
<IfModule pagespeed_module> | |
ModPagespeed on | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// A helper class to manipulate INI configuration files (*.ini, *.cfg, *.conf, or even *.txt) | |
/// | |
/// Usage of values: | |
/// (Name of setting)=(string value) | |
/// | |
/// Sections (optional) may be used to group values under it | |
/// Section names are in between brackets [ and ]. | |
/// | |
/// References: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
/// <summary> | |
/// Performs a bicubic interpolation over the given matrix to produce a | |
/// [<paramref name="newHeight"/>, <paramref name="newWidth"/>] matrix. | |
/// </summary> | |
/// <remarks> | |
/// Note, dimensions of the input and output matrices are in | |
/// conventional matrix order, like [matrix_height, matrix_width], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Minimax AI of TicTacToe based on MatthewSteel's | |
# C Implementation: https://gist.github.com/MatthewSteel/3158579 | |
def gridChar(i): | |
if (i == -1): return 'X' | |
if (i == 1): return 'O' | |
return ' ' | |
def draw(board): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image # pip install Pillow | |
from send2trash import send2trash # pip install Send2Trash | |
import glob | |
import imagehash # pip install imagehash | |
import os, os.path | |
import sys | |
rootDir = input("Directory: ") | |
cutoff = 3 # 1 to 5, higher value lesser sensitive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SmtpHelper { | |
private const int Timeout = 180000; | |
public string Host { get; set; } | |
public int Port { get; set; } = 587; | |
public bool IsSecured { get; set; } = true; | |
public string Sender { get; set; } | |
public string SenderDisplayName { get; set; } | |
public string Password { get; set; } | |
public List<MailAddress> Recipients { get; set; } = new List<MailAddress> { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Time-based One-time Password (TOTP using HOTP key based on a timestamp and window size) | |
/// Note: needs reference to Base32 from https://stackoverflow.com/a/641437/4469947 | |
/// | |
/// Usage: | |
/// Otp::generateSecret(); <- this will be your user's secret key (save it to your db) | |
/// Optionally, you can display the QR code for user's authenticator app using Otp::generateQr(...) | |
/// | |
/// To verify an OTP code provided during login, use VerifyPasscode(...) | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Time-based One-time Password (TOTP using HOTP key based on a timestamp and window size) | |
* | |
* Usage: | |
* 1) Otp::generateSecret(); <- this will be your user's secret key (save it to your db) | |
* Optionally, you can display the QR code for user's authenticator app using Otp::generateQr(...) | |
* 2) You can call Otp::generatePasscode(...) === $userInputOtp to check if provided OTP is valid. | |
* | |
* If you need a simple random 6-digit OTP, you can call Otp::generateSimple(). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class PasswordDecipher | |
{ | |
// Example: 3d3c1fd887fec9d1f9a3ecb0bad1f070d677e2cff6ef632acb417be4a8bbea1e:23ae04889a7d1ef9 is qwerty1234 | |
/// <summary> | |
/// Checks if a plain password matches the hashed password with salting | |
/// </summary> | |
/// <param name="hashedpassword">SHA256-Hashed password + random salt</param> | |
public static bool IsValid(string hashedpassword, string plainpassword) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Requires the following packages: | |
/// Newtonsoft.Json | |
/// System.ValueTuple | |
/// Also requires HttpQueryStringBuilder class. | |
/// Example use: | |
/// HttpHelper.Get("https://api.example.com/status", new { userId = "1234" }); | |
/// will result to https://api.example.com/status?userId=1234 | |
/// </summary> |
NewerOlder