Let's examine the type for Entity
.
export interface Model {};
export type Entity<
TModels extends Model[],
> = {
id?: string,
creatorId?: string,
createTimeMs?: number,
@Log4j2 | |
public class ImageUtility { | |
public MultipartFile removeExifAndApplyOrientation(MultipartFile file, String mimeType) throws Exception { | |
final BufferedImage image = ImageIO.read(file.getInputStream()); | |
final Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); | |
final Path originalFile = Files.createTempFile(tempDir, "original-image-", ""); | |
final String originalPath = originalFile.toAbsolutePath().toString(); | |
final ByteArrayOutputStream originalBytes = new ByteArrayOutputStream(); | |
// jpg is lossy, and in this case when we try to write the file out, |
import { calcDist, canReachCorner, getRectIntersections, intersectsCircle, intersectsRect, isPointWithinBounds, solutionsForY, solutionsForX, getCircleIntersections } from "./leet"; | |
describe('leet', () => { | |
describe('calcDist', () => { | |
it('calcs dist', () => { | |
expect(calcDist([0, 0], [0, 1])).toEqual(1); | |
}); |
function compareSemver(a: string, b: string) { | |
const aSemver = a.split('-')[1].split('.'); | |
const bSember = b.split('-')[1].split('.'); | |
for (let i = 0; i < 3; i++) { | |
const aPart = parseInt(aSemver[i], 10); | |
const bPart = parseInt(bSember[i], 10); | |
if (aPart > bPart) { |
#!/usr/bin/env ts-node | |
import { spawn } from 'node:child_process'; | |
import * as fs from "node:fs"; | |
// This script generates test output | |
// files for each jest test so | |
// you can view the diffs in an external | |
// diff viewer | |
function sortByKey(obj: any): any { |
// ==UserScript== | |
// @name Alt Click Copy | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1.0 | |
// @description Alt click an HTML element on the page to copy it to your clipboard. | |
// @author mchpatr | |
// @match *://*/* | |
// @icon https://github.com/prmichaelsen/alt-click-copy/releases/download/alt-click-copy/save.icon.png | |
// @run-at document-start | |
// ==/UserScript== |
import { Readable, Writable } from "node:stream"; | |
import { spawn } from "node:child_process"; | |
export const execCommand = async (cmd: string) => { | |
const ps = spawn("sh", { env: process.env }); | |
const data: string[] = []; | |
const outputStream = new Writable({ | |
write(chunk, encoding, callback) { |
rmrf () { | |
trash="$HOME/.trash" | |
mkdir -p $trash | |
if [ -z "$1" ]; then | |
echo "Usage: rmrf <dir>"; | |
return 1 | |
else | |
while [ -n "$1" ] | |
do | |
dir="$PWD/$1" |
gitf () | |
{ | |
prefix="dev/$USER/" | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
if [[ "$branch" = $prefix* ]]; then | |
echo "[INFO]: Force pushing to branch '$branch'..." | |
git push origin ":$branch" ; git push origin -u "$branch" | |
else | |
echo "[INFO]: Cannot push to branch '$branch' because it does not match prefix '$prefix'." | |
} |
Let's examine the type for Entity
.
export interface Model {};
export type Entity<
TModels extends Model[],
> = {
id?: string,
creatorId?: string,
createTimeMs?: number,
import { NonObject } from "./core-types"; | |
export type DeepComplete<T> = T extends NonObject | |
? Exclude<T, undefined> | |
: T extends Array<infer U> | |
? DeepCompleteArray<U> | |
: T extends Map<infer K, infer V> | |
? DeepCompleteMap<K, V> | |
: DeepCompleteObject<T>; |