Skip to content

Instantly share code, notes, and snippets.

View imclint21's full-sized avatar

clint21.eth ⚡️ imclint21

View GitHub Profile
@imclint21
imclint21 / DeployNetCoreApp.sh
Created October 22, 2018 01:03
Install all .Net Core required depencies.
sudo apt update && apt upgrade -y
sudo apt install -y nginx git tmux iftop multitail nmap apt-transport-https certbot python-certbot-nginx curl
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/9/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y dotnet-sdk-2.1 libgdiplus
@imclint21
imclint21 / QrCodeView.cs
Created October 17, 2018 18:48
.NetCore make QrCode for bitcoin/cryptos address
[Route("qr/{value}")]
public IActionResult Qr(string value)
{
var memoryStream = new MemoryStream();
var qrGenerator = new QRCodeGenerator();
var qrCodeData = qrGenerator.CreateQrCode(value, QRCodeGenerator.ECCLevel.L);
var qrCode = new QRCode(qrCodeData);
qrCode.GetGraphic(20).Save(memoryStream, ImageFormat.Png);
return File(memoryStream.ToArray(), "image/png");
}
@imclint21
imclint21 / SendInBlue_ConfirmationEmail.cs
Created September 28, 2018 17:18
Use SendInBlue to send confirmation mail with an activation link (use a SendInBlue template ID)
public static bool SendConfirmationEmail(string emailAddress, string activationLink)
{
var client = new RestClient("https://api.sendinblue.com/v3/smtp/email");
var sendInBlueRequest = new RestRequest(Method.POST);
sendInBlueRequest.AddHeader("api-key", "SENDINBLUE_API_KEY");
sendInBlueRequest.AddHeader("Accept", "application/json");
sendInBlueRequest.AddHeader("Content-Type", "application/json");
sendInBlueRequest.AddParameter("undefined", $"{{\"tags\":[\"Activate account for {{emailAddress}}\"],\"sender\":{{\"email\":\"[email protected]\",\"name\":\"You\"}},\"htmlContent\":\"\",\"replyTo\":{{\"email\":\"[email protected]\",\"name\":\"You\"}},\"templateId\":2,\"to\":[{{\"email\":\"{emailAddress}\",\"name\":\"{emailAddress}\"}}],\"params\":{{\"ActivationLink\":\"{activationLink}\"}}}}", ParameterType.RequestBody);
var sendInBlueResponse = client.Execute(sendInBlueRequest);
return sendInBlueResponse.IsSuccessful;
@imclint21
imclint21 / CreateCryptographicallySecureGuid.cs
Created September 18, 2018 14:56
Making a Cryptographically Secure Guid
public static Guid CreateCryptographicallySecureGuid()
{
using (var provider = new RNGCryptoServiceProvider())
{
var bytes = new byte[16];
provider.GetBytes(bytes);
return new Guid(bytes);
}
}
public static Guid CreateCryptographicallySecureGuid()
{
using (var provider = new RNGCryptoServiceProvider())
{
var bytes = new byte[16];
provider.GetBytes(bytes);
return new Guid(bytes);
}
}
rm -rf quentin/chambre/*