Skip to content

Instantly share code, notes, and snippets.

View jamescrowley's full-sized avatar

James Crowley jamescrowley

View GitHub Profile
@jamescrowley
jamescrowley / main.js
Last active March 31, 2020 03:18
Repro for Jest issue
'use strict';
const firebase = require("firebase-admin");
const serviceAccount = require('./serviceAccountKey.json');
firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`
});
admin
.auth()
.listUsers()
.then(listUsersResult => {
const selectedUser = listUsersResult.users.filter(
usr => usr.email.toLocaleLowerCase() === testUserEmail
);
if (selectedUser.length > 0) {
return Promise.resolve();
@jamescrowley
jamescrowley / SharedKeyDictionary.cs
Last active August 18, 2019 20:32
SharedKeyDictionary.cs
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace MemoryOptimisations
{
public sealed class SharedKeyDictionary<TKey, TValue> : IReadOnlyDictionary<TKey, TValue> where TValue : class
{
@jamescrowley
jamescrowley / migrate.ps1
Created July 14, 2018 20:47
Migrate to new CS Project format
function Extract-ProjectReferences ($projectFile) {
[regex]::matches((Get-Content $projectFile), '<ProjectReference Include=\"([^"]*)\"') | ForEach-Object { $_.Groups[1].Value }
}
function Extract-NuGetReferences ($nugetFile) {
[regex]::matches((Get-Content $nugetFile), '<package id=\"([^"]*)\" version=\"([^"]*)\"') | ForEach-Object { @{ Name = $_.Groups[1].Value; Version = $_.Groups[2].Value } }
}
function Get-UpgradedProjectFile ($projectFile) {
@jamescrowley
jamescrowley / ZenDeskResponseHandler.py
Last active November 12, 2015 18:47
ZenDesk event handler in Splunk using rest
class ZenDeskEventHandler:
def __init__(self,**args):
pass
#process the received JSON array
def process_automatic_response(self,data):
output = json.loads(data)

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@jamescrowley
jamescrowley / Costs (tab separated).tsv
Last active August 29, 2015 14:13
AWS/Rackspace/Azure SQL Server Licensing
Description Cores Windows VM USD/hr SQL VM USD/hr SQL License USD/hr SQL License USD/mo SQL License USD/core/mo
4 cores
Rackspace - General1-4 (4 cores, 4GB RAM) 4 0.168 0.768 0.600 438.00 109.50
Rackspace - io1-15 (4 cores, 15GB RAM) 4 0.600 1.150 0.550 401.50 100.38
Rackspace - Memory1-30 (4 cores, 30GB RAM) 4 0.480 1.080 0.600 438.00 109.50
Azure - D12 (4 cores, 28 GB RAM) 4 0.732 1.160 0.428 312.51 78.13
AWS - m3.xlarge (4 cores, 15GB RAM) 4 0.532 1.280 0.748 546.04 136.51
AWS - r3.xlarge (4 cores, 30.5gb ram) 4 0.600 1.395 0.795 580.35 145.09
AWS - c4.xlarge (4 cores, 7.5GB RAM) 4 0.430 1.727 1.297 946.81 236.70
8 cores
@jamescrowley
jamescrowley / BlockingPerDbObject.sql
Last active August 29, 2015 14:10
SQL Server Diagnostics
SELECT DB_NAME([database_id]) AS [Database]
,iops.[object_id] AS [ObjectID]
,QUOTENAME(OBJECT_SCHEMA_NAME(iops.[object_id], [database_id])) + N'.' + QUOTENAME(OBJECT_NAME(iops.[object_id], [database_id])) AS [ObjectName]
,i.[index_id] AS [IndexID]
,i.[name] AS [IndexName]
,i.[fill_factor] AS [IndexFillFactor]
,iops.[partition_number] AS [PartitionNumber]
,CASE
WHEN i.[is_unique] = 1
@jamescrowley
jamescrowley / EnumerableExtensions.cs
Created October 30, 2014 08:33
Passes in C# fails in Mono - looks like different behaviour in Linq rather than Iterator blocks
public static IEnumerable<T> HandleExceptions<T>(this IEnumerable<T> values, Func<Exception, T> onException)
{
using (var enumerator = values.GetEnumerator())
{
bool next = true;
Exception lastException = null;
while (next)
{
try
<system.diagnostics>
<switches>
<add name="Microsoft.Owin" value="Verbose" />
</switches>
<trace autoflush="true"></trace>
<sharedListeners>
<add name="file" type="System.Diagnostics.TextWriterTraceListener" initializeData="debug.log" />
</sharedListeners>