Skip to content

Instantly share code, notes, and snippets.

View caprica's full-sized avatar
🇬🇧
In the Lands Between

Mark Lee caprica

🇬🇧
In the Lands Between
View GitHub Profile
@caprica
caprica / generic-react-component.ts
Created November 20, 2022 07:38
Example of a React component using Typescript with generics
/*
* An outline example of how to create a generic component using Typescript and
* React.
*
* This is NOT the only way to do something like this.
*/
// === Generic component ===
/**
@caprica
caprica / rita-markov.ts
Created September 19, 2022 16:57
Rita, Markov and Typescript
/*
* No Typescript types for Rita, so:
*
* 1. Add module declaration, e.g. in a file called "decls.d.ts":
*
* declare module 'rita';
*
* 2. adjust include path in tsconfig.json:
*
* "include": ["src", "decls.d.ts"],
@caprica
caprica / application.properties
Created June 21, 2022 09:34
Banish Spring Boot HATEOAS ugly responses
# Instead of returning JSON with "_embedded" HATEOAS structures (e.g. when returning PagedModel), use a nicer format
# with "links", "content" and "page".
#
# The media type on the controller method should be "application/json", NOT "application/hal+json".
spring.hateoas.use-hal-as-default-json-media-type=false
@caprica
caprica / cors.sh
Created June 15, 2022 07:42
Testing CORS headers with curl
curl -H "Access-Control-Request-Method: GET" -H "Origin: http://localhost:3000" --head http://my.api.com/whatever
curl -H "Access-Control-Request-Method: GET" -H "Origin: http://localhost:3000" --head http://my.api.com/whatever | grep "<"
curl -H "Access-Control-Request-Method: GET" -H "Origin: http://localhost:3000" --head http://my.api.com/whatever | grep "Access-Control"
@caprica
caprica / rebase.txt
Created May 15, 2022 09:26
git rebase preference when resolving conflicts
git rebase -Xtheirs master
git rebase -Xours master
@caprica
caprica / traffic.sh
Created May 13, 2022 19:15
Dump network traffic when running local web servers
sudo tcpflow -p -c -i lo port 8080
@caprica
caprica / vue-typescript-vscode-volar.txt
Last active May 11, 2022 14:04
vue.js, Typescript, VS Code and Volar
Creating a brand new vue.js application with Typescript was working, but there were errors reported by VS Code when trying to import modules, it would complain that the module or type definitions could not be found.
- make sure obsolete vue.js extensions like Vetur are no longer installed
- install Vue Language Features (Volar) and nothing else
- in the extensions tab in VS Code, type "@builtin typescript"
- choose TypeScript and JavaScript Language Features
- in the editor content pane, find the gear icon to enable/disable the extension
- choose Disable (workspace)
- restart VS Code
@caprica
caprica / build-win64.sh
Last active June 19, 2022 11:19
Building VLC/LibVLC 4.x on Win64
# Mostly but not completely works...
git clone https://gitlab.com/garfvl/denv.git
export PATH=`pwd`/denv/bin:$PATH
git clone https://code.videolan.org/videolan/vlc.git
cd vlc
denv list
denv compile-vlc-win64
cd vlc
./extras/package/win32/build.sh -l -a x86_64 -i n
@caprica
caprica / update-package-json.sh
Created April 16, 2022 13:44
Update package.json with latest versions
npx npm-check-updates -u && npm i
@caprica
caprica / git-amend-date.sh
Created October 10, 2021 18:49
Amend date of latest commit to current date
git commit --amend --date=now