Skip to content

Instantly share code, notes, and snippets.

View flakey-bit's full-sized avatar

Eddie Stanley flakey-bit

  • Xero
  • Vancouver, Canada
View GitHub Profile
@flakey-bit
flakey-bit / MSBuild arguments for VSTS
Last active June 4, 2018 00:42
Create WebDeploy package which includes transform file (Web.Release.config) - don't apply transform. Also keeps the transform file as dependent so that the "preview-transform" functionality in Visual Studio works.
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
@flakey-bit
flakey-bit / deepEqualMatcher.ts
Created June 20, 2018 00:39
Jasmine toBeDeepEqual w/ TypeScript bindings
import { diff } from "deep-object-diff"; // Available on NPM, includes its own TypeScript bindings
const deepEqualMatcher: jasmine.CustomMatcher = {
compare: function(actual: any, expected: any) {
let diffObj = diff(expected, actual);
let result: jasmine.CustomMatcherResult;
if (Object.keys(diffObj).length > 0) {
result = {
pass: false,
message: "Expected the objects to be deep-equal but they were not:\n" + JSON.stringify(diffObj, null, 2)
@flakey-bit
flakey-bit / QuestionaireNodeConverter.cs
Last active July 19, 2018 03:44
Deserialize recursive subclasses via enum w/ Json.NET (Newtownsoft.JSON)
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Questionaire
{
internal class QuestionaireNodeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
@flakey-bit
flakey-bit / load_jurisdiction_data.ps1
Last active August 30, 2018 05:59
PowerShell script to load Jurisdiction data into GNAF
Param(
[string]$serverName,
[string]$databaseName,
[string]$jurisdictionFilesPath,
[string]$jurisdictionName
)
$filter = $jurisdictionName+"_*.psv"
Get-ChildItem $jurisdictionFilesPath -Filter $filter |
@flakey-bit
flakey-bit / load_authority_codes.ps1
Created August 30, 2018 05:12
PowerShell script to load AuthorityCode data into GNAF
Param(
[string]$serverName,
[string]$databaseName,
[string]$authorityCodeFilesPath
)
Get-ChildItem $authorityCodeFilesPath -Filter *.psv |
Foreach-Object {
$tableName = $_.name.Replace("Authority_Code_", "").Replace("_psv.psv", "")
write-host "Procesing" $_.Name "into table" $tableName
@flakey-bit
flakey-bit / NumericField.tsx
Last active January 6, 2019 04:03
React numeric input field w/ draft functionality
import * as React from 'react';
import TextField from 'react-md/lib/TextFields';
interface Props {
id: string;
label: React.ReactNode;
clearOnFocus: boolean;
step: number;
min?: number;
max?: number;
@flakey-bit
flakey-bit / SomeRepository.cs
Last active May 29, 2019 22:45
EntityFramework Upsert parent and children
public void Upsert(ParentEntity parentEntity) {
ParentEntity existing = DB.Parents.Find(parentEntity.Id);
if (existing == null) {
DB.Parents.Add(parentEntity);
} else {
var newChildKeys = new HashSet<int>(parentEntity.Children.Select(m => m.Id));
var existingChildren = DB.Children.Where(m => m.ParentId == parentEntity.Id).ToArray();
var existingChildrenKeys = new HashSet<int>(existingChildren.Select(m => m.Id));
@flakey-bit
flakey-bit / pulseaudio.service
Created September 11, 2019 02:12
Systemd PulseAudio service for Ubuntu + Kodi HTPC
[Unit]
Description=PulseAudio system server
After=avahi-daemon.service network.target
[Service]
Type=forking
ExecStart=/usr/bin/pulseaudio --realtime --no-cpu-limit --system --disallow-exit --daemon
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
@flakey-bit
flakey-bit / MySQLInstall.ps1
Created October 23, 2019 22:02
Install MySQL 5.7.27 & Workbench on Windows unassisted
Write-Host "Installing MySQL"
$mySqlInstaller = DownloadTempFile -Url "https://downloads.mysql.com/archives/get/file/mysql-installer-community-5.7.27.0.msi" -Filename "mysql-installer-community-5.7.27.0.msi"
Invoke-Process "msiexec" "/i $mySqlInstaller /qb"
Invoke-Process "${env:ProgramFiles(x86)}\MySQL\MySQL Installer for Windows\MySQLInstallerConsole.exe" "community install server;5.7.27;X64:*:servertype=Server;passwd=password -Silent"
Write-Host "Installing MySQL Workbench 8.0.16"
Invoke-Process "${env:ProgramFiles(x86)}\MySQL\MySQL Installer for Windows\MySQLInstallerConsole.exe" "community install workbench;8.0.16;X64:* -Silent"
@flakey-bit
flakey-bit / ComposeRequestUri.cs
Last active November 7, 2019 22:00
Build request URI with query parameters from base Uri and suffix (.NET) - encodes URI components
public static Uri ComposeRequestUri(string baseUri, string pathSuffix=null, IDictionary<string, object> queryParameters=null)
{
if (string.IsNullOrEmpty(baseUri))
{
throw new ArgumentException($"{nameof(baseUri)} is required", nameof(baseUri));
}
var uri = new Uri(baseUri);
if (!string.IsNullOrEmpty(pathSuffix))