Skip to content

Instantly share code, notes, and snippets.

View ProNotion's full-sized avatar

ProNotion

  • Prolific Notion Ltd
  • Plymouth, UK
View GitHub Profile
@DanDiplo
DanDiplo / BlockListCreatorService.cs
Last active July 26, 2024 05:58
Create Blocklist JSON programmatically in Umbraco
/// <summary>
/// Helper service for creating JSON necessary for creating block list items programatically using Umbraco <see cref="ContentService"/>
/// </summary>
/// <remarks>
/// Based of this: https://github.com/umbraco/UmbracoDocs/blob/e64ec0e5b28b4e5a37b7865691621e45dd82701f/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Block-List-Editor/index.md
/// It's intended for simple content
/// </remarks>
public class BlockListCreatorService
{
/// <summary>
@ststeiger
ststeiger / RSAKeys.cs
Created October 25, 2018 11:29 — forked from therightstuff/RSAKeys.cs
Import and export RSA Keys between C# and PEM format using BouncyCastle
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{
@bcnzer
bcnzer / postman-pre-request.js
Last active July 22, 2024 10:59
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@firatkucuk
firatkucuk / delete-slack-messages.js
Last active November 5, 2024 13:15
Deletes slack public/private channel messages, private chat messages and channel thread replies.
#!/usr/bin/env node
// Channel ID is on the the browser URL.: https://mycompany.slack.com/messages/MYCHANNELID/
// Pass it as a parameter: node ./delete-slack-messages.js CHANNEL_ID
// CONFIGURATION #######################################################################################################
const token = 'SLACK TOKEN';
// Legacy tokens are no more supported.
// Please create an app or use an existing Slack App
@secretorange
secretorange / ConditionalAnchorTagHelper.cs
Last active February 17, 2019 16:23
ASP.NET 5 Conditional Anchor Tag Helper. This tag helper will omit the anchor tag if the href is null or empty.
namespace SecretOrange
{
[HtmlTargetElement("a", Attributes = "asp-conditional")]
public class ConditionalAnchorTagHelper : TagHelper
{
public override async void Process(TagHelperContext context, TagHelperOutput output)
{
var href = context.AllAttributes["href"]?.Value.ToString();
if (String.IsNullOrWhiteSpace(href))
@mirsaeedi
mirsaeedi / AspnetWebApiUploadFile.cs
Created October 6, 2016 08:37
Helps you to save uploaded files to disk in ASP.Net Web API. The SaveFile method works with Request object directly.
public async Task<IHttpActionResult> SaveFile(string diskFolderPath)
{
var path = Path.GetTempPath();
if (!Request.Content.IsMimeMultipartContent("form-data"))
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
}
MultipartFormDataStreamProvider streamProvider = new MultipartFormDataStreamProvider(path);
@timruffles
timruffles / google-sheets-formula.vb
Last active January 25, 2022 11:24
google sheets - uk stamp duty calculator, new rate (2015)
// put this into a cell and then name a range 'housePrice'
=MIN(MAX(0,housePrice-250000),250000-125000)*0.02 + MIN(MAX(0,housePrice - 250000), 925000-250000) * 0.05 + MIN(MAX(0,housePrice - 9250000), 1500000-925000) * 0.1
@JimBobSquarePants
JimBobSquarePants / ImageProcessorPreProcessor.cs
Created July 23, 2015 15:40
Demonstration code for Preprocessing uploaded images with Umbraco
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ImageProcessorPreProcessor.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Attaches ImageProcessor to the Media.Saving event to ensure that uploaded files do not exceed
// a maximum size.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
@robert-claypool
robert-claypool / app_offline.htm
Created July 21, 2015 20:11
A simple "app offline" template for ASP.NET
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Offline</title>
</head>
<body style="margin:3em;font-family:sans-serif">
<h2>Offline</h2>
<p>This site is offline for maintenance.</p>
<!--
@TimGeyssens
TimGeyssens / Contour send email workflow
Created May 11, 2015 13:17
Contour send email workflow
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Web;
using Umbraco.Forms.Core.Enums;
using System.Text.RegularExpressions;
using Umbraco.Forms.Data.Storage;
using System.Xml;