Skip to content

Instantly share code, notes, and snippets.

@bradleykronson
bradleykronson / shrink-database.sql
Created February 29, 2024 13:06
Shink SQL Database
USE DatabaseName;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DatabaseName
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (DatabaseName_Log, 1);
GO
-- Reset the database recovery model.
@bradleykronson
bradleykronson / SessionStorageCalc.js
Created October 25, 2021 10:46
Calculate size of object in session storage
var count = 0;
for (const property in app) {
try {
var l = JSON.stringify(app[property]).length;
count += l;
console.log(`${property}: ${l}`);
} catch(e) {
// meh
}
};
@bradleykronson
bradleykronson / umbraco.gitignore
Created August 4, 2021 13:29 — forked from amogram/umbraco.gitignore
A .gitignore file for Umbraco projects
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
@bradleykronson
bradleykronson / get-macro-param.cs
Last active July 17, 2017 06:21
Get Macro Parameter
public TType GetMacroParam<TType>(PartialViewMacroModel model, string key, Func<string, TType> convert, TType fallback)
{
if(!model.MacroParameters.ContainsKey(key))
{
return fallback;
}
var value = model.MacroParameters[key];
if(value == null || value.ToString().Trim() == "")
@bradleykronson
bradleykronson / gitignore
Created March 31, 2017 06:59
Removes a file from the git cache so .gitignore kicks in. List of .gitignore starter files https://github.com/github/gitignore
Git features a ‘remove’ command, git rm. You can use it to remove files from git’s tracking cache, like so:
git rm --cached <filename>
1
git rm --cached <filename>
The above command is for a specific file. It will take effect with your next commit. It’s a good idea for you to commit any pending changes you have before you start this process. If you have many files and/or folders (for instance, your /bin and /obj folders in a .NET project) that you need to clean up from your repository, you can use the following commands to remove them from the index (cache):
git rm -r --cached .
1
@bradleykronson
bradleykronson / media-image-processor.cs
Last active July 17, 2017 06:21
Media service event that prebuilds for imageprocessor.web (from http://24days.in/umbraco-cms/2014/all-your-images-are-belong-to-umbraco/)
public class ApplicationEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
// Tap into the Saving event
MediaService.Saving += (sender, args) =>
{
MediaFileSystem mediaFileSystem = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
IContentSection contentSection = UmbracoConfig.For.UmbracoSettings().Content;
IEnumerable<string> supportedTypes = contentSection.ImageFileTypes.ToList();
@bradleykronson
bradleykronson / delete-empty-folders.bat
Created December 8, 2016 19:57
Delete empty folders in DOS
ROBOCOPY folder1 folder1 /S /MOVE
@bradleykronson
bradleykronson / bcp-data.sql
Created February 8, 2016 14:23
Use BCP OUT and BULK INSERT to move large amounts of data> NB Script out just schema to start off on destination server!
/************************************************************************************************************************************************
Author : KIN SHAH *********************************************************************************************************************
Purpose : Move data from one server to another*********************************************************************************************
DATE : 05-28-2013 *********************************************************************************************************************
Version : 1.0.0 *************************************************************************************************************************
RDBMS : MS SQL Server 2008R2 and 2012 *************************************************************************************************
*************************************************************************************************************************************************/
@bradleykronson
bradleykronson / Pending-Umbraco-Documents-4.11.8.sql
Last active August 30, 2015 08:38 — forked from danlister/4.11.8.sql
Retrieve a list of Umbraco Documents which have pending changes
DECLARE @NodeId INT
DECLARE my_cursor CURSOR local static read_only forward_only FOR
SELECT DISTINCT nodeid
FROM cmsdocument
OPEN my_cursor
FETCH next FROM my_cursor INTO @NodeId
WHILE @@FETCH_STATUS = 0
@bradleykronson
bradleykronson / doc-type-all-properties.sql
Last active August 29, 2015 14:16
Get all property values of all items of a particular document type
SELECT n.id AS nodeid ,
n.text ,
pt.Alias ,
pd.dataInt ,
pd.dataDate ,
pd.dataNvarchar ,
pd.dataNtext
FROM cmsPropertyData AS pd
INNER JOIN cmsPropertyType AS pt ON pt.id = pd.propertytypeid
INNER JOIN umbracoNode AS n ON n.id = pd.contentNodeId