Skip to content

Instantly share code, notes, and snippets.

View synesthesia's full-sized avatar
💭
I may be slow to respond.

Julian Elve synesthesia

💭
I may be slow to respond.
View GitHub Profile
@synesthesia
synesthesia / Blockchain
Created January 4, 2016 20:48
Blockchain
Verifying that +julianelve is my blockchain ID. https://onename.com/julianelve
@synesthesia
synesthesia / RealClean.ps1
Created January 19, 2017 08:32
RealClean.ps1
gci -include debug,release -recurse |
% {gci -path $_.PSPath -File |
% {
Write-Host $_.Name
$_.Delete()
}
}
@synesthesia
synesthesia / legacy-setstaterequest.cs
Last active February 3, 2017 09:59
CRM entity status weirdness - the old way
// issue invoice
var setStateRequest = new SetStateRequest
{
EntityMoniker = new EntityReference(Invoice.EntityLogicalName, invoice.Id),
State = new OptionSetValue((int)InvoiceState.Active),
Status = new OptionSetValue((int)invoice_statuscode.ReadyToIssue)
};
Service.Execute(setStateRequest);
@synesthesia
synesthesia / NaiveEntityStateUpdateApproach.cs
Created February 3, 2017 10:03
Workarounds for CRM set state weirdness - C#
var invoiceEntity = new Entity(Invoice.EntityLogicalName) { Id = invoiceRef.Id };
invoiceEntity["statecode"] = new OptionSetValue((int)InvoiceState.Active);
invoiceEntity["statuscode"] = new OptionSetValue((int)invoice_statuscode.ReadyToIssue);
tracingService.Trace("Update invoice status to Ready To Issue, Id:{0}", invoiceEntity.Id);
service.Update(invoiceEntity);
var invoiceEntity = new Entity(Invoice.EntityLogicalName) { Id = invoiceRef.Id };
// do not attempt to set the statecode - if you do this code will fire workflows twice
// invoiceEntity["statecode"] = new OptionSetValue((int)InvoiceState.Active);
invoiceEntity["statuscode"] = new OptionSetValue((int)invoice_statuscode.ReadyToIssue);
tracingService.Trace("Update invoice status to Ready To Issue, Id:{0}", invoiceEntity.Id);
service.Update(invoiceEntity);
@synesthesia
synesthesia / RevisedEntityStateUpdate.js
Last active February 3, 2017 10:42
Original attempt to change invoice status from Javascript using the REST API
var setStateToIssued = function(invoiceId) {
window.console.log('setStateToIssued(' + invoiceId + ')');
invoiceId = invoiceId.replace(/[{}]/g, "");
var url = Xrm.Page.context.getClientUrl() + "/api/data/v8.2/invoices(" + invoiceId + ")";
var entity = {};
//entity.statecode = 0; //commenting because we think setting state AND status causes workflows to fire twice
entity.statuscode = 293750003; // Ready To Issue
var req = new XMLHttpRequest();
req.open("PATCH", url, true);
req.setRequestHeader("OData-Version", "4.0");
@synesthesia
synesthesia / DiscourseController.cs
Last active October 4, 2018 15:00
Enabling SSO for Discourse with IdentityServer3 - extended
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Security;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Security;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web;
@synesthesia
synesthesia / .gitignore
Created June 13, 2019 11:55
Publishing a Hugo site to both Netlify and GitHub Pages
public/
@synesthesia
synesthesia / Export-Drafts-to-Foam.md
Last active July 16, 2020 07:28
Drafts - post note to Foam inbox