Skip to content

Instantly share code, notes, and snippets.

View JonathanTurnock's full-sized avatar

Jonathan Turnock JonathanTurnock

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / client.ts
Last active January 2, 2025 22:15
Miminal Typescript RPC
import { RpcClient } from "./rpc.ts"
import type { RpcAPI } from "./router.ts"
export const client = new RpcClient<RpcAPI>();
const foo = rpcClient.get("foo");
foo.getFoo().then(console.log)