Skip to content

Instantly share code, notes, and snippets.

View GraemeF's full-sized avatar

Graeme Foster GraemeF

View GitHub Profile
@liamwh
liamwh / +page.svelte
Last active May 3, 2024 13:37
SvelteKit Otel
<script lang="ts">
import type { UserView } from '$lib/stubs/auth';
import { getContext, onMount } from 'svelte';
import { goto } from '$app/navigation';
import { getContacts } from '$lib/repositories/contacts';
import { browser } from '$app/environment';
import { CONTACTS_STORE_KEY, USER_STORE_KEY } from '$lib/store-keys';
import type { Writable } from 'svelte/store';
import AddContactButton from '$lib/components/Contacts/AddContact/AddContactButton.svelte';
import { db } from '$lib/surrealdb';
@andersonba
andersonba / executor.ts
Last active July 26, 2022 07:35
An Nx executor to run a target in parallel across all project dependencies, also forwarding the args to the commands.
import { ExecutorContext, readCachedProjectGraph } from '@nrwl/devkit'
import runCommandsExecutor from 'nx/src/executors/run-commands/run-commands.impl'
import { RunDepsExecutorSchema } from './schema'
function getForwardedArgs(): string[] {
try {
const nxCommandArg = JSON.parse(process.argv[2] || '{}') as {
overrides?: {
__overrides_unparsed__?: string[]
@davidfowl
davidfowl / Example1.cs
Last active March 28, 2024 20:36
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)
@ToJans
ToJans / 99bottles.js
Last active August 29, 2015 14:14
99 bottles of beer as short as possible in ECMAScript 6 - currently 142 characters
x=""
b=r=>`${c||"No more"} bottle${c-1?"s":""} of beer${r&&c--||" on the wall"}
`
for(c=99;c;)x+=b()+b(1)+`Take one down, pass it around
`+b()
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
//child catalog is a filtered catalog that contains only parts that should appear in the child (including TPart)
private TPart ComposePartWith<TPart>(ComposablePartCatalog childCatalog, CompositionContainer parentContainer, out IDisposable disposable, params object[] imports)
{
var childContainer = new CompositionContainer(childCatalog, parentContainer);
childContainer.ComposeParts(imports);
disposable = childContainer;
return childContainer.GetExportedValue<TPart>();
}