Skip to content

Instantly share code, notes, and snippets.

@jamescoxhead
jamescoxhead / NodeDocumentTypes.sql
Created April 16, 2019 14:54
Lists Umbraco content and media nodes and their corresponding document type alias
SELECT C.nodeId, CT.alias, N.text FROM cmsContent C
INNER JOIN cmsContentType CT ON C.contentType = CT.nodeId
INNER JOIN umbracoNode N ON C.nodeId = N.id
@jamescoxhead
jamescoxhead / .editorconfig
Last active October 7, 2019 13:01
Sample editor config
root = true
[*]
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
charset = utf-8
[*.{xml,proj,nuspec}]
@jamescoxhead
jamescoxhead / PurgeCloudflare.ps1
Created November 15, 2017 12:04
Purges the Cloudflare cache. Assumes variables are stored as environment variables
# Get parameters
$cloudflareApiKey = $Env:CloudflareApiKey
$cloudflareEmail = $Env:CloudflareEmail
$cloudflareZoneId = $Env:CloudflareZoneId
# Build the request
$endpoint = "https://api.cloudflare.com/client/v4/zones/$cloudflareZoneId/purge_cache"
$headers = @{"X-Auth-Key" = $cloudflareApiKey; "X-Auth-Email" = $cloudflareEmail; "Content-Type" = "application/json"}
$body = "{'purge_everything': true}"
@jamescoxhead
jamescoxhead / Regex.txt
Created March 16, 2016 17:05
Common Regexes
Vimeo URL - ^https?:\/\/(?:www\.|player\.)?vimeo\.com/(\d+)$
@jamescoxhead
jamescoxhead / HMACSHA1-Encode.linq
Created February 26, 2016 17:19
Linqpad Queries
<Query Kind="Statements">
<Reference>&lt;RuntimeDirectory&gt;\System.Security.dll</Reference>
<Namespace>System.Security.Cryptography</Namespace>
</Query>
string unhashed = "password";
HMACSHA1 hash = new HMACSHA1();
hash.Key = Encoding.Unicode.GetBytes(unhashed);
@jamescoxhead
jamescoxhead / DeleteNodeModules.cmd
Last active February 17, 2016 16:52
Force delete the node_modules folder and contents (from https://github.com/CrumpledDog/SkriftBuildingBlocks)
mkdir temp
robocopy temp node_modules /MIR
rd temp
rd node_modules
@jamescoxhead
jamescoxhead / applicationHost.config.xml
Created February 8, 2016 10:49
IIS URL Compression for SVG and fonts (under C:\Windows\System32\inetsrv\config)
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
@jamescoxhead
jamescoxhead / uCommerceDeleteProduct.sql
Created January 11, 2016 09:55
Hard deletes a uCommerce product. When a product is deleted from the back office it is only soft deleted, there is no way to hard-delete a product from the back office.
BEGIN TRANSACTION
BEGIN TRY
DECLARE @ProductId int;
SET @ProductId = 142;
DELETE FROM uCommerce_PriceGroupPrice
where ProductId = @ProductId
@jamescoxhead
jamescoxhead / UmbracoUnusedDatatypes.sql
Last active November 23, 2016 12:59
Lists Umbraco datatypes which haven't been used on document types. Care is needed if using packages like Archetype as this script will show datatypes as unused if they are only used on an archetype.
SELECT distinct [nodeId]
FROM [cmsDataType]
EXCEPT
SELECT distinct dataTypeId
FROM [cmsPropertyType]
@jamescoxhead
jamescoxhead / RolesOwnedByUser.sql
Created January 11, 2016 09:49
Lists any roles associated with a SQL Server user
select DBPrincipal_2.name as role, DBPrincipal_1.name as owner
from sys.database_principals as DBPrincipal_1 inner join sys.database_principals as DBPrincipal_2
on DBPrincipal_1.principal_id = DBPrincipal_2.owning_principal_id
where DBPrincipal_1.name = 'USER_NAME'