Skip to content

Instantly share code, notes, and snippets.

Avatar

James Crowley jamescrowley

View GitHub Profile
@jamescrowley
jamescrowley / main.js
Last active Mar 31, 2020
Repro for Jest issue
View main.js
'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`
});
View import-data-less-nesting.js
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 Aug 18, 2019
SharedKeyDictionary.cs
View 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 Jul 14, 2018
Migrate to new CS Project format
View migrate.ps1
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 Nov 12, 2015
ZenDesk event handler in Splunk using rest
View ZenDeskResponseHandler.py
class ZenDeskEventHandler:
def __init__(self,**args):
pass
#process the received JSON array
def process_automatic_response(self,data):
output = json.loads(data)
View gist:69266b31d9799ce1fff4

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 Aug 29, 2015
AWS/Rackspace/Azure SQL Server Licensing
View Costs (tab separated).tsv
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
View BlockingPerDbObject.sql
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 Oct 30, 2014
Passes in C# fails in Mono - looks like different behaviour in Linq rather than Iterator blocks
View EnumerableExtensions.cs
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
View gist:82e888a5fa6ecd429b5d
<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>
You can’t perform that action at this time.