Skip to content

Instantly share code, notes, and snippets.

View javafun's full-sized avatar

Vincent javafun

View GitHub Profile
using System.Collections.Generic;
using System.Linq;
using EPiServer.Commerce.Catalog.ContentTypes;
using EPiServer.Core;
using EPiServer.Find;
using EPiServer.Find.Cms;
using EPiServer.PlugIn;
using EPiServer.Scheduler;
using EPiServer.ServiceLocation;
@javafun
javafun / UmbracoMembershipAPI snippets.cs
Created June 16, 2019 06:29
A bunch of Umbraco Membership API snippets
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Security.
using Umbraco.Core.Services;
using Umbraco.Web.Models;
using Umbraco.Web.PublishedCache;
/*
*
@javafun
javafun / rebuild_index.sql
Created June 6, 2019 23:36 — forked from kshimi/rebuild_index.sql
SQLServer rebuild index
DECLARE @SchemaName sysname, @TableName sysname, @IndexName sysname
DECLARE @basesql nvarchar(max), @sql nvarchar(max)
SET @basesql = 'ALTER INDEX @1 On @2 REBUILD WITH ( FILLFACTOR = 50 ) '
DECLARE IXC CURSOR FOR
SELECT
OBJECT_SCHEMA_NAME(i.object_id) As SchemaName
, OBJECT_NAME(i.object_id) AS TableName
, i.name AS IndexName
@javafun
javafun / rebuildIndexes.sql
Created June 6, 2019 23:36 — forked from richardbasile/rebuildIndexes.sql
SQL Server - Rebuild Indexes
BEGIN
set quoted_identifier on
DECLARE @db varchar(max) = 'MyDB'
DECLARE @today VARCHAR(9) = datename(w,sysdatetime())
DECLARE @tableName varchar(max)
DECLARE @indexName varchar(max)
DECLARE @sql Nvarchar(max)
@javafun
javafun / power-query-pagination.m
Created April 4, 2019 04:40 — forked from MarkTiedemann/power-query-pagination.m
Power Query Pagination Example
let
BaseUrl = "https://fake-odata-api.com/v1/Entities?",
Token = "F4K3-T0K3N-D0NT-U5E-L0L",
EntitiesPerPage = 1000,
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData)
in Json,
@javafun
javafun / AsyncHelper.cs
Created April 1, 2019 04:38 — forked from ChrisMcKee/AsyncHelper.cs
AsyncHelpers to simplify calling of Async/Task methods from synchronous context.
namespace My.Common
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
public static class AsyncHelpers
{
/// <summary>
@javafun
javafun / DeleteAllVersions.sql
Created January 5, 2019 12:21 — forked from Hendy/DeleteAllVersions.sql
Umbraco - delete version history for all content
-- 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
-- Insert all nodeIds from all documents which are published and not in the recycle bin
INSERT INTO #Nodes
SELECT N.id
FROM umbracoNode N
INNER JOIN cmsDocument D ON N.ID = D.NodeId
@javafun
javafun / gist:de2d01c8900fb83786467bad98307d52
Created December 31, 2018 05:24 — forked from jbreuer/gist:0a5996e5e6bf881ce847
Archetype and Nested Content as Models Builder properties
[ImplementPropertyType("slider")]
public IEnumerable<HomeSlider> Slider
{
get
{
var archetypeModel = this.GetPropertyValue<ArchetypeModel>("slider");
return archetypeModel.Select(x =>
{
return new HomeSlider()
{
@javafun
javafun / Microsoft.PowerShell_profile.ps1
Created December 23, 2018 01:32 — forked from TomoyukiAota/Microsoft.PowerShell_profile.ps1
PowerShell profile for equivalent command of "rm -rf" in Bash.
function rmrf {
<#
.DESCRIPTION
Deletes the specified file or directory.
.PARAMETER target
Target file or directory to be deleted.
.NOTES
This is an equivalent command of "rm -rf" in Unix-like systems.
@javafun
javafun / NearestValue.php
Created December 17, 2018 12:14 — forked from pepijnolivier/NearestValue.php
Finds the 'nearest value' of a needle in a SORTED numeric array (ascending). Via https://stackoverflow.com/a/22375510/237739
<?php
/**
* Class NearestValue
* Finds the 'nearest value' of a needle in a SORTED numeric array (ascending)
* Via https://stackoverflow.com/a/22375510/237739
*
* Usage:
* $array = [1000,2000,3000,4000,5000];
* $needle = 1337;