Skip to content

Instantly share code, notes, and snippets.

# Bash best practices and style-guide
Just simple methods to keep the code clean.
Inspired by [progrium/bashstyle](https://github.com/progrium/bashstyle) and [Kfir Lavi post](http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/).
## Quick big rules
* All code goes in a function
* Always double quote variables
@nwrox
nwrox / ubuntu_1804.ipxe
Created July 11, 2021 15:28 — forked from robinsmidsrod/ubuntu_1804.ipxe
iPXE script entries for booting Ubuntu 18.04 in different ways
# boot-url points to an nfs URL
# sanboot-url points to an http URL
# ubuntu-version contains 18.04.3
# ubuntu-release contains bionic
:ubuntu
echo Booting Ubuntu from iSCSI for ${initiator-iqn}
set root-path ${base-iscsi}:${hostname}.boot.ubuntu
sanboot ${root-path} || goto failed
goto start
public byte[] Unprotect(byte[] protectedData)
{
if (protectedData?.Length < 1)
{
return null;
}
var keyId = new byte[16];
var magicHeader = new byte[4];
var purposes = _appOptions.CookieAadPurposes;
var appOptions = _conf.GetSection("AppOptions");
var purposes = appOptions.GetSection("CookieAadPurposes")
.GetChildren();
services.AddCors(options =>
{
options.AddPolicy(CorsPolicyName,
//.AllowCredentials()
builder => builder.AllowAnyHeader()
.AllowAnyMethod()
@nwrox
nwrox / ManagedAuthenticatedEncryptor
Created January 25, 2020 19:50 — forked from badcommandorfilename/ManagedAuthenticatedEncryptor
Standalone (mostly) SP800_108_CTR_HMACSHA512 Key Derivation Function for ASPNetCore cookie sharing
///This is a Frankenstein class that can extract the AES key from a KDK as described in:
/// https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/subkeyderivation?view=aspnetcore-2.2
///With a bit of luck, this should let an ASP.NET app decrypt cookies generated by an ASPNETCore app
///Still consult https://docs.microsoft.com/en-us/aspnet/core/security/cookie-sharing?view=aspnetcore-2.2 to share cookies
///Credit for most of the code is from various parts of https://github.com/aspnet/AspNetCore/tree/master/src/DataProtection/DataProtection/src
public unsafe class CookieDataProtector : IDataProtector
{
readonly string _base64MasterKey;
{
"comments": [
{
"x": "2019/06/05",
"y": "4"
},
{
"x": "2019/05/29",
"y": "6"
},
@nwrox
nwrox / credits.txt
Last active June 18, 2019 12:56
Share memory or session storage in a multi tab environment
https://blog.guya.net/2015/06/12/sharing-sessionstorage-between-tabs-for-secure-multi-tab-authentication/
{
"a": 1
}
const m1 = Array.from({ length: 11 }, (k, v) => v)
.reverse()
.slice(0, 9)
const m2 = Array.from({ length: 12 }, (k, v) => v)
.reverse()
.slice(0, 10)
let tempCpf;
let digito;
let soma;
# initialization file (not found)