Skip to content

Instantly share code, notes, and snippets.

@janily
janily / prompt.js
Created November 24, 2023 09:15 — forked from zckly/prompt.js
gpt-4-v skateboarding coach prompt
// model: gpt-4-vision-preview
const input = 'can you help me land this skateboarding trick?'
const frames = [
// Frames should be a list of image URLs or bytes
]
const messages = [
...messages,
@janily
janily / ChatGPT-Translate-Long-Text.js
Created October 11, 2023 12:03 — forked from JimLiu/ChatGPT-Translate-Long-Text.js
使用ChatGPT自动分页翻译长文
// WARNING:此脚本仅做学习和演示用途,在不了解其用途前不建议使用
// 本脚本的用途是将输入内容分页,每次提取一页内容,编辑第二条消息,发送,然后收集结果
// 使用前,需要有两条消息,参考模板 https://chat.openai.com/share/17195108-30c2-4c62-8d59-980ca645f111
// 演示视频: https://www.bilibili.com/video/BV1tp4y1c7ME/?vd_source=e71f65cbc40a72fce570b20ffcb28b22
//
(function (fullText) {
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const groupSentences = (fullText, maxCharecters = 2800) => {
const sentences = fullText.split("\n").filter((line) => line.trim().length > 0);
@janily
janily / GLSL-Noise.md
Created February 10, 2023 09:58 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@janily
janily / persistentCamera.js
Created October 14, 2022 10:11 — forked from selimbat/persistentCamera.js
This is a quick setup to get a camera in Three.js to persist its position when the website hot-reloads
// When creating the camera
const storedCamera = JSON.parse(localStorage.getItem('camera'));
if (storedCamera) {
camera.position.set(
storedCamera.position.x,
storedCamera.position.y,
storedCamera.position.z,
);
controls.target.set(
storedCamera.target.x,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vanilla Boilerplate / threejs + gsap</title>
<style>
html,
body {
@janily
janily / javascript-proxy-as-rest-client.js
Created February 9, 2022 01:30 — forked from DavidWells/javascript-proxy-as-rest-client.js
Using a javascript proxy as low code REST client
/* Using a JavaScript proxy for a super low code REST client */
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3
// also see https://github.com/fastify/manifetch
// also see https://github.com/flash-oss/allserver
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {
return async function(id = "") {
const response = await fetch(`${url}/${key}/${id}`)
@janily
janily / getJSONFromFigmaFile.js
Created January 4, 2022 11:13 — forked from souporserious/getJSONFromFigmaFile.js
Generates JSON from Figma file
import request from 'request'
const api_endpoint = 'https://api.figma.com/v1'
const personal_access_token = 'FIGMA_ACCESS_TOKEN_HERE' // https://www.figma.com/developers/docs#auth-dev-token
function downloadSvgFromAWS(url) {
return new Promise((resolve, reject) => {
request.get(
url,
{
@janily
janily / encode.sh
Created August 8, 2021 15:24 — forked from jeffpamer/encode.sh
Smooth Scrubbing Web Video FFMPEG Mega Command
ffmpeg -i input.mp4 -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3 -an -vf "scale=-1:1440, reverse" -preset veryslow -g 2 output.mp4
// -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3
// Encode for web with a good balance of browser compatibility and compression ratio
// -an
// Strip audio tracks
// -vf "scale=-1:1440, reverse"
// Scale video to 1440px wide, maintaining aspect ratio
const sketch = require("sketch");
function onDocumentChanged(context) {
var changes = context.actionContext;
for (i = 0; i < changes.length; i++) {
var change = changes[i];
var path = change.fullPath();
var type = change.type();
switch (type) {
@janily
janily / Frame.js
Created November 17, 2020 09:14 — forked from robertgonzales/Frame.js
Use React portals to render inside shadow dom and iframes
class Frame extends Component {
componentDidMount() {
this.iframeHead = this.node.contentDocument.head
this.iframeRoot = this.node.contentDocument.body
this.forceUpdate()
}
render() {
const { children, head, ...rest } = this.props
return (