Skip to content

Instantly share code, notes, and snippets.

@Kilowhisky
Kilowhisky / newrelic.ts
Created October 17, 2024 15:16
NewRelic EventAPI NodeJs RecordCustomEvent
export async function recordCustomEvent(type: string, event: Record<string, string | number>) {
try {
const ACCOUNT_ID = process.env.NEW_RELIC_ACCOUNT_ID;
const LICENSE_KEY = process.env.NEW_RELIC_LICENSE_KEY;
const APP_NAME = process.env.NEW_RELIC_APP_NAME;
if (!ACCOUNT_ID || !LICENSE_KEY || !APP_NAME) {
console.warn("NEW_RELIC_ACCOUNT_ID or NEW_RELIC_LICENSE_KEY or NEW_RELIC_APP_NAME not found in ENV");
return;
}
@Kilowhisky
Kilowhisky / newRelic.ts
Last active October 29, 2024 19:27
NewRelic instrumentation for AWS CDK NodeJS function
import { Stack } from "aws-cdk-lib"
import { Runtime, Architecture, ILayerVersion, LayerVersion, CfnFunction } from "aws-cdk-lib/aws-lambda"
import { NodejsFunction, NodejsFunctionProps } from "aws-cdk-lib/aws-lambda-nodejs"
import { Secret } from "aws-cdk-lib/aws-secretsmanager"
import { Construct } from "constructs"
/**
* A NodejsFunction with New Relic instrumentation.
* @see https://forum.newrelic.com/s/hubtopic/aAX8W0000008d3MWAQ/setting-up-new-relic-with-cdk
*/
@Kilowhisky
Kilowhisky / DebounceAction.cs
Last active August 16, 2023 15:54
C# Class that debounces an action denoted by a given key
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Threading;
namespace Utils
{
@Kilowhisky
Kilowhisky / raw-geo.geojson
Created December 7, 2022 05:24
Raw geoJSON that is to be simplified
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kilowhisky
Kilowhisky / simply-destroyer.geojson
Last active December 7, 2022 05:17
A GeoJSON file that turf.simplify will explode on (6.5.0)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kilowhisky
Kilowhisky / DataUrlConverter.cs
Last active July 19, 2021 16:22
DataUrl to Binary Converter
private (string type, byte[] data) DataUrlToBinary(string dataUrl)
{
var match = Regex.Match(dataUrl, @"data:(?<type>.+?);base64,(?<data>.+)");
var type = match.Groups["type"].Value;
var base64Data = match.Groups["data"].Value;
var binData = Convert.FromBase64String(base64Data);
return (type, binData);
}
@Kilowhisky
Kilowhisky / controllers.application\.js
Last active February 3, 2021 06:11
Issue with ObjectPromiseProxy
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { ObjectPromiseProxy, resolvingPromise, resultObject } from '../utils/object-proxy';
export default class ApplicationController extends Controller {
regularObject = resultObject;
//@computed() // uncomment this to get it to work 'somehow'
get promiseObj() {
return ObjectPromiseProxy.create({
@Kilowhisky
Kilowhisky / c_sharp_rockpaperscissors.c
Created January 22, 2021 23:06
Rock Paper Scissors program build in C#
using System;
using System.Collections.Generic;
public class Program
{
public static List<WinEnum> PlayerStats = new List<WinEnum>();
public static void Main()
{
Console.WriteLine("Welcome to my great game");
@Kilowhisky
Kilowhisky / adapters.application.js
Last active August 29, 2018 15:27
Reload Record Hell
import DS from 'ember-data';
import Ember from 'ember';
export default DS.RESTAdapter.extend({
namespace: 'api'
});
@Kilowhisky
Kilowhisky / adapters.application.js
Last active July 26, 2018 23:17
HasMany Explosion
import DS from 'ember-data';
export default DS.RESTAdapter.extend({});