Skip to content

Instantly share code, notes, and snippets.

View eriksimonic's full-sized avatar

Erik Simonič eriksimonic

  • Business Solutions d.o.o.
  • Slovenia
View GitHub Profile
@eriksimonic
eriksimonic / FixPublishedContentTemplates.cs
Created March 14, 2019 13:12
Fix documnet that are missing default TEmplate in umbraco. Startup Event Handler
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
namespace FixDocumentTypeFuckUP
@eriksimonic
eriksimonic / cmsLanguageText.sql
Created March 10, 2019 15:38
Clean duplicate cmsLanguageText if duplication occurs.
with c (UniqueId) as
(
select UniqueId from cmsLanguageText
group by UniqueId
having count(1) > 2
)
select
'delete from cmsLanguageText where UniqueId = ''' +cast( l.UniqueId as varchar(max)) + ''' and pk != '+cast( min(l.pk) as varchar(max)) +' and languageId = '+ cast(l.languageId as varchar(max)) +';',
l.UniqueId, l.value,l.languageId, min(l.pk) as pk, count(1) as Count
from cmsLanguageText l
@eriksimonic
eriksimonic / order.cs
Created December 14, 2018 09:39
Reorder array based on DateTime.
private static int GetArrayIndexFromUtc(int length, int frameTimeout)
{
var slides = length;
var slideDuration = frameTimeout;
var frameSegment = slideDuration * slides;
var currentDateTime = DateTime.Now;
var baseDateTime = new DateTime(currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, 0, 0, 0, 0);
var ticks = (currentDateTime - baseDateTime).TotalMilliseconds;
@eriksimonic
eriksimonic / script.sh
Last active December 28, 2017 11:01
Remove Folders from Git Commits
#!/bin/sh
#Remove all folders that you need to remove.
git filter-branch -f --tree-filter "rm -fr */App_Data/*" --prune-empty --tag-name-filter cat HEAD
#Run GC cleanup of references.
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
#Force push to origin
git push origin --force
@eriksimonic
eriksimonic / tt.sh
Created June 7, 2017 10:50
Find Modified Files on linex.
find . -type f -mtime -10 -ls | grep -v ".lock\|.jpg\|.cache\|report\|.pdf\|.png\|.txt\|.sql\|proc\|newrelic\|.map\|udev\|kernel\|sys/\|.log\|run/\|/apt"
void Main()
{
var locaTime = DateTime.Now;
IServiceSyncedTime ts = new SyncDateTime(new NAVTimeService());
locaTime.Dump();
Thread.Sleep(5000);
@eriksimonic
eriksimonic / gist:23cd52af07faddd3089fd56cb54d53b6
Created January 3, 2017 09:17
Create git commit archive.
git archive -o .zip [id] $(git diff-tree --no-commit-id --name-only -r [id])
@eriksimonic
eriksimonic / DeleteAllVersions.sql
Last active October 23, 2016 10:41 — forked from Hendy/DeleteAllVersions.sql
Umbraco - delete version history for all content , Umbraco 7.5+
TRUNCATE TABLE umbracoLog
GO
TRUNCATE TABLE umbracoUser2NodePermission
GO
-- Create a temporary table for all documents which are published and not in the recycle bin
CREATE TABLE #Nodes (id int)
-- Delete all rows if the table exists before
TRUNCATE TABLE #Nodes
@eriksimonic
eriksimonic / README.MD
Last active September 22, 2016 12:55
Include adition folder in publish process, for all Build processes

#Include folder on publish#

the folder is not included in the main project Source for this snipset is Umbraco Deplyment .target file.

@eriksimonic
eriksimonic / file.sh
Created September 7, 2016 06:51
Remove all history from git.
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D master # Deletes the master branch
git branch -m master # Rename the current branch to master
git push -f origin master # Force push master branch to github