Skip to content

Instantly share code, notes, and snippets.

@sihugh
sihugh / GOV.UK API cheat sheet.md
Last active January 9, 2023 09:59
This is a quick start for working with GOV.UK's APIs
@sihugh
sihugh / abridged_organisation_content_item.json
Created August 22, 2019 09:35
An abridged content item for the Prime Minister's Office page on GOV.UK. I've removed some fields for clarity.
{
"base_path": "/government/organisations/prime-ministers-office-10-downing-street",
"content_id": "705dbea4-8bd7-422e-ba9c-254557f77f81",
"document_type": "organisation",
"first_published_at": "2013-03-12T14:15:18.000+00:00",
"locale": "en",
"public_updated_at": "2019-08-12T09:29:33.000+00:00",
"publishing_app": "whitehall",
"rendering_app": "collections",
"schema_name": "organisation",
@sihugh
sihugh / abridged_organisation_content_item.json
Created August 22, 2019 09:35
An abridged content item for the Prime Minister's Office page on GOV.UK. I've removed some fields for clarity.
{
"base_path": "/government/organisations/prime-ministers-office-10-downing-street",
"content_id": "705dbea4-8bd7-422e-ba9c-254557f77f81",
"document_type": "organisation",
"first_published_at": "2013-03-12T14:15:18.000+00:00",
"locale": "en",
"public_updated_at": "2019-08-12T09:29:33.000+00:00",
"publishing_app": "whitehall",
"rendering_app": "collections",
"schema_name": "organisation",
@sihugh
sihugh / build_analysis_csvs.rb
Last active November 15, 2017 10:57 — forked from whoojemaflip/build_analysis_csvs.rb
Gather benchmarking stats
# yes, it's a pile of hacks
require 'set'
require 'csv'
require 'pry'
require 'rugged'
require 'time'
filename = 'deployments.csv'
release_regex = /^release_[\d]+$/
@sihugh
sihugh / successerror
Created May 29, 2015 11:10
Handle SharePoint Errors in JQuery Success Handler
$.ajax({
headers: { "X-RequestDigest": formDigestValue },
url: url,
method: "POST",
contentType: "application/json",
data: submitData,
success: function(data){
if(data.indexOf("<meta name=\"SharePointError\"") > 0){
// oh noes!
// error handling
@sihugh
sihugh / stringify
Created May 29, 2015 11:03
Stringify Before POSTing
var data = {
name: "dave",
age: 35,
height: 188};
var submitData = JSON.stringify(data);
$.ajax({
headers: { "X-RequestDigest": formDigestValue },
url: url,
@sihugh
sihugh / requestdigest
Created May 29, 2015 10:57
CRSF Token in SharePoint Web Service Request
var formDigestValue = $("#__REQUESTDIGEST").val();
$.ajax({
headers: { "X-RequestDigest": formDigestValue },
url: url,
method: "POST",
contentType: "application/json",
data: JSON.stringify(data),
success: success,
error: error
@sihugh
sihugh / Fingerprint
Created May 13, 2015 14:22
A version of http://madskristensen.net/post/cache-busting-in-aspnet for when you can't easily mess with URL rewriting
using System.IO;
using System.Web;
using System.Web.Hosting;
using System.Web.Caching;
namespace Hughesdon.Cache {
public static class Fingerprint
{
public static string Tag(string path)
{
@sihugh
sihugh / CreateWSP
Created May 13, 2015 13:07
Build target example to build a WSP using an MSBuild target
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Include this step after the current build "depends on" list -->
<BuildDependsOn>
$(BuildDependsOn);
CreateWSP;
</BuildDependsOn>
<BinStash>$(SolutionDir)Bin\</BinStash>
<PostBuildEvent></PostBuildEvent>
@sihugh
sihugh / StashOutput
Last active August 29, 2015 14:21
Build target example to copy built assembly to a stash area "BinStash"
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildDependsOn>
$(BuildDependsOn);
StashOutput;
</BuildDependsOn>
<BinStash>$(SolutionDir)Bin\</BinStash>
<PostBuildEvent></PostBuildEvent>
</PropertyGroup>