Skip to content

Instantly share code, notes, and snippets.

View fancn21th's full-sized avatar
😜
coding and meditation

Fan, Yi-Jie fancn21th

😜
coding and meditation
View GitHub Profile
@fancn21th
fancn21th / dev-server-with-open-ai-recorder.js
Created May 24, 2024 03:22 — forked from unstubbable/dev-server-with-open-ai-recorder.js
How to quickly and cost-efficiently iterate when working with the OpenAI API in Node.js
import path from 'path';
import talkback from 'talkback';
// If dev server is started with:
// OPENAI_BASE_URL=http://localhost:3001/v1/ npm start
if (process.env.OPENAI_BASE_URL?.startsWith('http://localhost')) {
const {port} = new URL(process.env.OPENAI_BASE_URL);
const talkbackServer = talkback({
host: 'https://api.openai.com',
@fancn21th
fancn21th / OneDevMinute.md
Created September 5, 2022 05:42 — forked from ahmadawais/OneDevMinute.md
[OneDevMinute]: Delete a Git branch both locally and remotely [Shell aliases + functions]
title category date
Delete a Git branch both locally and remotely [Shell aliases + functions]
Shell, Git
2018-09-24

OneDevMinute

Deleting a git branch locally is pretty easy, just do a git branch -D branch_name and you're done. But when you have pushed that branch to remote, it becomes a bit more complex. You can't just delete the local branch and do a git push. Instead you have to do a git push origin --delete branch_name to delete it from the remote.

@fancn21th
fancn21th / Classes.js
Created July 9, 2022 04:00 — forked from gaearon/Classes.js
Beneath Classes: Prototypes
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
@fancn21th
fancn21th / get-watchers.js
Created September 24, 2019 02:25 — forked from kentcdodds/get-watchers.js
Get Watchers of element and its children
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));