Skip to content

Instantly share code, notes, and snippets.

@technomaz
technomaz / gist:b3c1de31f68541f550c0
Created December 30, 2014 22:26
Use winscp in cfexecute to upload file to linux server
<cfexecute name="C:\download\WinScp\winscp.com" arguments="/command ""open sftp://user:pass@yourserver.com"" ""put c:\full\path\to\file.txt /usr/local/remote/dir/"" ""exit""" variable="result" errorvariable="errorv" timeout="10"></cfexecute>
<cfoutput>
<cfif len(errorv)>
<h1>Error</h1>
<pre>#errorv#</pre>
<cfelse>
<h1>Result</h1>
<pre>#result#</pre>
</cfif>
</cfoutput>
@technomaz
technomaz / gist:dad88cf55fb62c335b7a
Created December 31, 2014 18:18
Add Bootstrap icon to all PDF links that do not have the btn class
jQuery("a[href$='.pdf']:not(.btn)").after(" <i class=\"icon-file-text-alt\"></i>");
@technomaz
technomaz / gist:24ee35868e533c8ba5b2
Created December 31, 2014 18:18
Add Bootstrap icon to all links with /Secure/ in the path that do not have the btn class
jQuery("a[href*='/Secure/']:not(.btn)").after(" <i class=\"icon-lock\"></i>");
@technomaz
technomaz / gist:bd3382b0de36a0d5c48b
Created December 31, 2014 18:19
jQuery on DOM ready
jQuery().ready(function() {
// content here
});
@technomaz
technomaz / Restore-Sitecore-items.ps1
Last active August 2, 2018 01:42
Sitecore Powershell script to restore items from recycle bin archived after a certain date (e.g. recently deleted)
[datetime]$archivedDate = [datetime]::Today.AddDays(-1)
Write-Host "Restoring items recycled after $($archivedDate.ToShortDateString())"
foreach($archive in Get-Archive -Name "recyclebin") {
Write-Host " - Found $($archive.GetEntryCount()) entries"
$entries = $archive.GetEntries(0, $archive.GetEntryCount())
foreach($entry in $entries) {
if($entry.ArchiveLocalDate -ge $archivedDate) {
Write-Host "Restoring item: $($entry.OriginalLocation) {$($entry.ArchivalId)}on date $($entry.ArchiveLocalDate)"
$archive.RestoreItem($entry.ArchivalId)
@technomaz
technomaz / Import from file system.ps1
Created August 2, 2018 13:45
Sitecore Powershell import from file system
$folders = Get-ChildItem "C:\data\sites\test.local\Data\serializationps\master\sitecore\media library\Images" -recurse | ?{ $_.PSIsContainer }
$folders | Import-Item -root "C:\data\sites\test.local\Data\serializationps\" -DisableEvents
@technomaz
technomaz / sitecore-in-editing-mode-check.js
Created November 9, 2018 18:01
Sitecore JS to check if currently in Experience Editor editing mode
// note this works for Sitecore 8.2 Experience Editor edit mode; no other versions or variations tested
// highly inspired and updated from https://mattneil.co.uk/2016/12/08/detect-sitecore-page-modes/
var isSitecoreEditing = function() { return !!(Sitecore && Sitecore.WebEditSettings && Sitecore.WebEditSettings.editing); };
if (isSitecoreEditing()) {
// in Sitecore editing mode
} else {
// not in Sitecore editing mode
}
@technomaz
technomaz / list-recent-files.sh
Created December 7, 2018 21:21
Run this from a linux command line to list all the files in subfolders ordered by date. Add an "r" to the sort -n command to place the newest files at the top of the result set. Based on code from https://hamwaves.com/find/en/index.html
find . -type f -not -path '*/\.*' -printf '%TY.%Tm.%Td %THh%TM %Ta %p\n' |sort -n|less
@technomaz
technomaz / CuSitefinityHelper.cs
Last active March 6, 2019 21:02
When using a list view to show only a single entry, such as an academic program, use the following code to grab the first item in the list of items returned.
public static ItemViewModel GetFirstItemViewModel(this DynamicContentListViewModel listModel)
{
ItemViewModel item = null;
if (listModel.Items.Any())
{
item = listModel.Items.First();
}
return item;
}
@technomaz
technomaz / sf-change-news-date.cs
Last active March 6, 2019 21:03
Change the publication date and associated URL for a Sitefinity News article.
using Telerik.Sitefinity.Modules.News;
using Telerik.Sitefinity.News.Model;
public void ChangeNewsDate()
{
// https://www.progress.com/blogs/how_to_publish_content_items_in_the_past
// https://www.progress.com/documentation/sitefinity-cms/for-developers-modify-news-items
var pubDate = new DateTime(2019, 02, 25);
var manager = NewsManager.GetManager();
//var item = manager.GetNewsItem(new Guid("6aa1dc9a-58ad-45e5-b624-fe5e8267728a"));