Skip to content

Instantly share code, notes, and snippets.

View eastlondoner's full-sized avatar

Andrew Jefferson eastlondoner

View GitHub Profile
To create a valid eBay UK listing using the Trading API, the `<ShippingDetails>` XML element is essential. It specifies shipping-related information for the item, including domestic and international shipping options, costs, and policies. Below is an example of a valid `<ShippingDetails>` XML structure for a listing on eBay UK:
```xml
<ShippingDetails>
<ShippingType>Flat</ShippingType>
<ShippingServiceOptions>
<ShippingServicePriority>1</ShippingServicePriority>
<ShippingService>UK_RoyalMailFirstClassStandard</ShippingService>
<ShippingServiceCost currencyID="GBP">3.99</ShippingServiceCost>
<FreeShipping>false</FreeShipping>
@eastlondoner
eastlondoner / Chat.txt
Created January 20, 2025 15:43
Distillation
Yes, very much so. Model distillation—often referred to as knowledge distillation—is a technique where a large, complex model (often called the “teacher”) is used to guide the training of a smaller, more efficient model (the “student”). The goal is to achieve comparable performance to the teacher model but with far fewer parameters or lower computational cost.
Here’s a quick summary of how knowledge distillation typically works:
1. Teacher Model: A large neural network (e.g., a deep Transformer model or a wide CNN) is trained on a given task until it achieves strong accuracy or other performance metrics.
2. Soft Targets or Logits: Rather than just using the final hard labels (like one-hot vectors in classification tasks), we use the teacher’s soft outputs. These are essentially the raw logits or the probabilities the teacher assigns to each class before making a hard decision. These “soft targets” carry more nuanced information about how the teacher model generalizes and how it “thinks” about different cla
@eastlondoner
eastlondoner / ask_gemini.sh
Last active January 10, 2025 07:59
Ask Gemini
#!/usr/bin/env bash
# make bash play nice
set -euo pipefail
# Load environment variables
source .env
# Check required environment variables
check_env_var() {
if [ -z "${!1:-}" ]; then
@eastlondoner
eastlondoner / swift_concurrency.md
Created January 3, 2025 14:03
Swift Concurrency Notes

In Swift’s concurrency model, you can handle multiple concurrent streams of work using async let or the TaskGroup API. Both approaches allow you to perform concurrent tasks and wait for their results.

Option 1: Using async let

async let is a concise way to launch multiple tasks concurrently and wait for their results.

func fetchData() async throws -> (String, Int, Bool) { async let stringResult = doSomethingAsync() async let intResult = somethingElseAsync() async let boolResult = thirdThingAsync()

@eastlondoner
eastlondoner / ConcurrentQueue.ts
Created March 27, 2023 11:26
Process Tasks using a Concurrent Queue in javascript
import { Readable } from 'node:stream';
export type ConcurrentQueueTask<T> = {
maxRetries: number;
getPromise: () => Promise<T>;
};
export type CreateConcurrentQueueParams = {
/*
* Max concurrency sets the maximum number of tasks that can be running at the same time.
@eastlondoner
eastlondoner / AsyncExample.java
Created February 3, 2021 13:20
Running independent async queries using neo4j java driver
/**
* Creates a disposable async session and uses it to perform the provided unit of work.
* Ensures that the provided work is committed successfully and the async session has been closed before the returned completion stage completes.
* @param driver Driver to use
* @param sessionConfig Session Config to use when creating the async session (can be used to pass in a bookmark)
* @param isWrite Is this a write transaction (will be sent as a read transaction if false)
* @param work Unit of transaction work
* @param <U> Type returned by the transaction work
* @return A completion stage that is completed successfully when the session has been closed - either with an error or with the result of the UoW
*/
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.junit.platform.commons.logging.Logger;
import org.junit.platform.commons.logging.LoggerFactory;
import java.net.URI;
import java.util.HashSet;
@eastlondoner
eastlondoner / pom.xml
Created December 14, 2020 19:34
create a neo4j driver fat / uber jar
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.neo4j.driver</groupId>
<artifactId>fat-jar</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
@eastlondoner
eastlondoner / publish-dir-with-ngrok.sh
Created May 26, 2019 10:40
Publish a local directory to ngrok.io using ngrok and python
#!/usr/bin/env bash
# Bail on errors
set -e
# Default to using port 8080 if PORT is not set
PORT="${PORT:-8080}"
echo >&2 "Using port ${PORT}"
@eastlondoner
eastlondoner / generate_numbers.py
Last active May 22, 2019 15:44
Generates a csv of the numbers one to a million as both an integer and representation as English words
import math
def num2words(num):
nums_20_90 = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']
nums_0_19 = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', "Nine", 'Ten', 'Eleven',
'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen']
nums_dict = {100: 'hundred', 1000: 'thousand', 1000000: 'million'}
if num < 20:
return nums_0_19[num]