Skip to content

Instantly share code, notes, and snippets.

View rasmuseeg's full-sized avatar
💭
Coding ofc.

Rasmus Eeg Møller rasmuseeg

💭
Coding ofc.
View GitHub Profile
@rasmuseeg
rasmuseeg / Pagination.cshtml
Created August 8, 2017 11:33
Propperly the best way to navigate
@{
int offsetLeft = 1;
int offsetRight = 1;
int offset = offsetLeft + offsetRight + 1;
int minPage = Math.Max(Math.Min(Model.Page - offsetLeft, Model.TotalPages - offset), 1);
int maxRange = Math.Min(Model.Page + offsetRight, Model.TotalPages);
}
<ol class="nav-pagination">
@if(minPage > 1)
{
@rasmuseeg
rasmuseeg / CreateAndExportCert.ps1
Created May 15, 2017 10:56
Remote Desktop Connection Manager PowerShell Scripts
#Create and Export Certificate
$PlainPassword = "Pa$$w0rd"
$ExportFolder = "S:\Remote Desktop Connection Manager"
$Subject = "RDCMan"
$YEARS = 1
$CertificateFileName = "RDCManCertificate.pfx"
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
$RDCManCertificate = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -Subject $Subject -KeyExportPolicy Exportable -KeySpec KeyExchange -NotAfter $(Get-date).AddYears($YEARS)
Export-PfxCertificate -Cert $RDCManCertificate -FilePath "$ExportFolder\$CertificateFileName" -Password $SecurePassword
$RDCManCertificate | Remove-Item
$AutoUpdateNotificationLevels = @{0 = "Not configured"; 1 = "Disabled" ; 2 = "Notify before download";
3 = "Notify before installation"; 4 = "Scheduled installation"
}
$AutoUpdateDays = @{0 = "Every Day"; 1 = "Every Sunday"; 2 = "Every Monday"; 3 = "Every Tuesday"; 4 = "Every Wednesday";
5 = "Every Thursday"; 6 = "Every Friday"; 7 = "EverySaturday"
}
Function Set-WindowsUpdateConfig {
@rasmuseeg
rasmuseeg / default.pubxml
Last active January 16, 2018 08:20
Default WebDeploy Publish profile
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- ACL will be handled by the server -->
<IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
<!-- Invalidate files by checksum, and not change date -->
<MSDeployUseChecksum>True</MSDeployUseChecksum>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
</PropertyGroup>
</Project>
function FizzBuzz(){
for(var i = 0; i <= 100; i++){
if(i % 3 == 0 && i % 5 == 0){
console.log("FizzBuzz");
continue;
}else if(i % 3 == 0){
console.log("Fizz");
continue;
}else if(i % 5 == 0){
console.log("Buzz");
@rasmuseeg
rasmuseeg / ExamineIndex.config
Created February 4, 2017 11:40
Custom Examine SimpleDataService
<ExamineLuceneIndexSets>
<IndexSet SetName="ClinicIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/{machinename}/Clinics/">
<IndexUserFields>
<add Name="Id" />
<add Name="Name" />
<add Name="Address" />
<add Name="ZipCode" />
<add Name="City" />
<add Name="PhoneNumber" />
<add Name="CellPhoneNumber" />
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Xml.Linq;
@using umbraco.cms.businesslogic.web;
@using System.Web.Configuration;
@using System.Text;
@using System.Globalization;
@{
Layout = null;
List<string> contentTypes = new List<string>() { };
@rasmuseeg
rasmuseeg / web.Release.config
Last active January 4, 2017 07:44
Force media files to use client domain
<system.webServer>
<rewrite>
<rules>
<rule name="Force Media" enabled="true"
xdt:Transform="Remove()" xdt:Locator="Match(name)">
</rule>
</rules>
</rewrite>
</system.webServer>
@rasmuseeg
rasmuseeg / 1040_CreateTables.cs
Last active June 12, 2019 09:59
Umbraco V7 Migration Runner and Configuration
using Umbraco.Core;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Migrations;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Logging;
using LadyChamber.Core.Persistence.Models;
namespace $rootnamespace$.Core.Persistence.Migrations
{
// SemVersion: major.minor.revsion+build
@rasmuseeg
rasmuseeg / Generic Umbraco Repository
Last active March 10, 2020 08:32
Generic Repository for umbraco
public abstract class GenericRepository<TKey, TEntity>
{
public DatabaseContext context;
public GenericRepository(DatabaseContext context)
{
this.context = context;
}
public virtual IEnumerable<TEntity> Get()