Skip to content

Instantly share code, notes, and snippets.

View JonathanTurnock's full-sized avatar

Jonathan Turnock JonathanTurnock

  • Manchester, United Kingdom
View GitHub Profile
@JonathanTurnock
JonathanTurnock / server.ts
Created January 20, 2024 12:19
Electron subprocess
import { randomUUID } from "node:crypto";
import * as os from "os";
import Aigle from "aigle";
import { UtilityProcess, utilityProcess } from "electron";
import { compact, flatten, values } from "lodash";
import { z } from "zod";
import { trpc } from "../trpc";
type ServerEntry = {
id: string;
@JonathanTurnock
JonathanTurnock / App.jsx
Created September 29, 2023 22:04
Mobx simple example
// App.js
import React from "react";
import { observer } from "mobx-react-lite";
import { counterStore } from "./store";
const App = observer(() => {
return (
<div>
<h1>{counterStore.count}</h1>
<button onClick={() => counterStore.increment()}>Increment</button>
@JonathanTurnock
JonathanTurnock / COORDS.md
Created August 7, 2023 09:29
Geo Coordinate Systems

1. Geographic Coordinates

The most recognized method to pinpoint a location. It uses:

  • Latitude (lat): Specifies how far north or south a point is from the Equator.
  • Longitude (lon): Details how far east or west a point is from the Prime Meridian.

2. Cartesian Coordinates

Often employed in computer graphics and mathematics:

  • 2D Cartesian:
    • x: Represents the horizontal axis (often east-west direction).
  • y: Represents the vertical axis (often north-south direction).
@JonathanTurnock
JonathanTurnock / Server.js
Last active July 5, 2023 01:28
Job Scheduler
const express = require('express');
const schedule = require('node-schedule');
const { addMinutes, isValid, parseISO } = require('date-fns');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json()); // for parsing application/json
const port = 3000;
@JonathanTurnock
JonathanTurnock / README.md
Created March 31, 2023 09:25
React Function Component - Live template

React Functional Component Template

Add this to webstorm under Editor > Live Templates

Add a variable

TM_FILENAME_BASE -> capitalize(camelCase(fileNameWithoutExtension()))

@JonathanTurnock
JonathanTurnock / App.jsx
Last active January 22, 2023 13:10
React RXJS Subject State https://playcode.io/1088821
import React from 'react';
import { BehaviorSubject } from 'rxjs';
import { useObservable } from 'react-use';
const subject = new BehaviorSubject(1);
const useSubjectState = (subject) => [useObservable(subject), (value) => subject.next(value)]
const Increment = () => {
const [state, setState] = useSubjectState(subject);
@JonathanTurnock
JonathanTurnock / to-url-string.test.ts
Created January 8, 2023 21:35
Snippet for url conversion
import { toUrlString } from "./to-url-string";
describe("toUrlString", () => {
it("should transform a basic url", () => {
expect(toUrlString({ path: "/people" })).toEqual("/people");
});
it("should transform a colon parameterised url", () => {
expect(toUrlString({ path: "/people/:id", params: { id: 1 } })).toEqual("/people/1");
});
@JonathanTurnock
JonathanTurnock / README.md
Last active August 30, 2021 19:30
JS implementation Dijkstra's Algorithm
@JonathanTurnock
JonathanTurnock / README.md
Last active March 15, 2021 18:48
Centos 8 WS Setup
@JonathanTurnock
JonathanTurnock / README.md
Last active March 7, 2021 12:58
VLC media player Convert & Save DVD Chapters

Intro

How to use VLC media player to export a DVD in a file per chapter format

The command for reference is:

vlc dvdsimple:///G:/#1:1-1:1 --sout "#standard{access=file,mux=ts,dst=T1_CH1.mpg} vlc://quit"

The important part is the addition of a "to" section that the GUI does not allow.