Skip to content

Instantly share code, notes, and snippets.

View PatrickJS's full-sized avatar

PatrickJS PatrickJS

View GitHub Profile
@PatrickJS
PatrickJS / method-missing-proxy.js
Created March 11, 2024 01:59 — forked from torgeir/method-missing-proxy.js
es6 proxies method missing example
/*
What happens?
- `new Type().what` is looked up with a call to `get` on the proxy
- a function is returned that will look up `METHOD_NAME` when called
- `METHOD_NAME` is called because of the `()` behind `new Type().what`
- if `METHOD_NAME` exists on you object, your own function is called
- if not, because of prototypal inheritance, `get` is called again
- `name` is now `METHOD_NAME` and we can throw as we know `METHOD_NAME` is not implemented on the type
credits http://soft.vub.ac.be/~tvcutsem/proxies/
@PatrickJS
PatrickJS / gource.sh
Created January 31, 2024 00:41 — forked from peterjmag/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@PatrickJS
PatrickJS / run.js
Created November 8, 2023 05:21 — forked from thdxr/run.js
Remove all linkedin connections
// Run on https://www.linkedin.com/mynetwork/invite-connect/connections/
while(true) {
document.querySelector('.mn-connection-card__dropdown-trigger').click()
await new Promise(resolve => setTimeout(resolve, 500))
document.querySelector(".artdeco-dropdown__content-inner button").click()
await new Promise(resolve => setTimeout(resolve, 500))
document.querySelector("[data-test-dialog-primary-btn]").click()
await new Promise(resolve => setTimeout(resolve, 500))
}
import { z } from "zod";
import { zodToTs, printNode } from "zod-to-ts";
// Replace with your `openai` thing
import { openai } from "../openai.server";
import endent from "endent";
function createJSONCompletion<T extends z.ZodType>({
prompt,
schema_name,
# STEP 1: Load
# Load documents using LangChain's DocumentLoaders
# This is from https://langchain.readthedocs.io/en/latest/modules/document_loaders/examples/csv.html
from langchain.document_loaders.csv_loader import CSVLoader
loader = CSVLoader(file_path='./example_data/mlb_teams_2012.csv')
data = loader.load()
{
"environment": "staging"
}
/*
Makes your remote containers low level API accessible via:
import accessFederatedContainer from "access-federated-containers";
accessFederatedContainer("app2")
*/
/** @typedef {import("webpack").Compiler} Compiler */
/** @typedef {import("webpack").Compilation} Compilation */
@PatrickJS
PatrickJS / emit-all-plugin.js
Created February 28, 2022 23:20 — forked from DrewML/emit-all-plugin.js
Output every file in a webpack build to the specified dist directory in the webpack config. Each file is output after having each loader run against it, but before the webpack module wrapper is added.
const path = require('path');
module.exports = class EmitAllPlugin {
constructor(opts = {}) {
this.ignorePattern = opts.ignorePattern || /node_modules/;
}
shouldIgnore(path) {
return this.ignorePattern.test(path);
}
@PatrickJS
PatrickJS / getOrLoadRemote.js
Created February 27, 2022 09:38 — forked from ScriptedAlchemy/getOrLoadRemote.js
The Right Way to Load Dynamic Remotes
/**
*
* @param {string} remote - the remote global name
* @param {object | string} shareScope - the shareScope Object OR scope key
* @param {string} remoteFallbackUrl - fallback url for remote module
* @returns {Promise<object>} - Federated Module Container
*/
const getOrLoadRemote = (remote, shareScope, remoteFallbackUrl = undefined) =>
new Promise((resolve, reject) => {
// check if remote exists on window
@PatrickJS
PatrickJS / BrowserDeviceInfo.js
Created January 30, 2022 02:21 — forked from TrevorJTClarke/BrowserDeviceInfo.js
A quick list of browsers and devices for use in testing. Chrome is used for all devices that need simulation.
var devices = [
{ name: 'Desktop - Huge', width: 2880, height: 1800, ratio: 2, type: 'desktop' },
{ name: 'Desktop - Extra Large', width: 1920, height: 1080, ratio: 1, type: 'desktop' },
{ name: 'Desktop - Large', width: 1440, height: 900, ratio: 1, type: 'desktop' },
{ name: 'Desktop - HiDPI', width: 1366, height: 768, ratio: 1, type: 'desktop' },
{ name: 'Desktop - MDPI', width: 1280, height: 800, ratio: 1, type: 'desktop' },
{ name: 'Laptop with HiDPI screen', width: 1440, height: 900, ratio: 2, type: 'desktop' },
{ name: 'Laptop with MDPI screen', width: 1280, height: 800, ratio: 1, type: 'desktop' },
{ name: 'Laptop with touch', width: 1280, height: 950, ratio: 1, type: 'desktop' },
{ name: 'Tablet - Portrait', width: 768, height: 1024, ratio: 1, type: 'tablet' },