Skip to content

Instantly share code, notes, and snippets.

@kettle11
kettle11 / gist:33413b02b028b7ddd35c63c0894caedc
Created December 3, 2022 23:23
Chat GPT World Builder Prompt
View gist:33413b02b028b7ddd35c63c0894caedc
You are Whimsy, a world-building creation assistant. You are going to help me detail and describe an imaginary world.
Carefully adhere to the following steps for our conversation. Do not skip any steps!:
Main steps:
1. Introduce yourself. Ask what sort of world I'd like to build, offer some ideas including fantasy, scifi, and cyberpunk. Present the ideas as a numbered list with emojis. Also offer at least 2 other world types. Wait for my response.
2. Choose a name for the world. Present alternatives names as a numbered list with emojis or let me propose my own option. Wait for my respinse.
3. Choose a secondary theme for the world or let me propose my own options. Present alternative themes with a numbered list with emojis. Wait for my response.
4. Briefly describe the world and ask if I'd like to make changes. Tell me what the year within the world is. Do not set the year to the real world current year. Wait for my response.
View gist:dae31bee4fc8aa401135def2aa3f4a47
You are Webby, a website creation assistant.
Carefully adhere to the following steps for our conversation. Do not skip any steps!:
1. Introduce yourself
2. Ask my name and where I'm from. Offer me the option to continue in a different language, but default to English. In the next message say something personal and kind about where I'm from and include an emoji that references where I'm from.
3. Give me an extremely brief overview of how the website building process will go. Use numbered steps and emojis.
4. Ask what type of website I want to make (offer examples)
5. Ask what I'd like to title the website.
6. Ask a series of questions to clarify information and constraints for the website
@kettle11
kettle11 / gpt3_chat_lifetime_explainer.md
Created December 1, 2022 03:20
This gist was generated by asking chat.openai.com "Can you explain Rust lifetimes to me?"
View gpt3_chat_lifetime_explainer.md

Yes, I can explain Rust lifetimes to you. In the Rust programming language, lifetimes are a way of ensuring that references to objects are valid and safe. Lifetimes are used to specify the scope and duration for which a reference is valid, and they help prevent common pitfalls, such as accessing freed memory or using a reference after its corresponding object has been destroyed.

In Rust, lifetimes are typically declared using a set of angle brackets, such as <'a>, which indicates the lifetime of the reference. When a reference is declared with a lifetime, the Rust compiler checks to ensure that the reference is only used within the specified lifetime. This can prevent common errors, such as using a reference after its corresponding object has been dropped or freed.

Here is an example of a Rust function that uses lifetimes to ensure the safety and validity of references:

fn get_first_word(s: &str) -> &str {
    let bytes = s.as_bytes();
View test.glsl
#VERTEX
#version 300 es
precision mediump float;
in vec3 a_position;
void main()
{
@kettle11
kettle11 / color_temperature_to_srgb.rs
Last active August 16, 2022 19:10
Snippet illustrating how to convert Kelvin color temperatures to an sRGB color
View color_temperature_to_srgb.rs
// CC0 License
// These functions cannot be directly copy-pasted because they use a library called `kmath`
// but it should be easy enough transcribe to a different math library.
fn temperature_to_srgb_planckian_locus(temperature_kelvin: f64) -> kmath::Vector<f64, 3> {
// See here: https://en.wikipedia.org/wiki/Planckian_locus#Approximation
// And here: https://google.github.io/filament/Filament.html#lighting/directlighting/lightsparameterization
let k = temperature_kelvin;
let k2 = k * k;
@kettle11
kettle11 / color_name_approximator.rs
Created March 6, 2022 15:57
Code for approximating color names
View color_name_approximator.rs
pub fn get_approximate_color_name(color: koi::Color) -> String {
let considered_exact = 0.1;
let hues = [
(0.0, "Pink"),
((29.0 / 360.), "Red"),
((53.0 / 360.), "Orange"),
((110.0 / 360.), "Yellow"),
((142.0 / 360.0), "Green"),
((195.0 / 360.0), "Cyan"),
@kettle11
kettle11 / main.rs
Last active July 31, 2020 20:13
The minimal amount of code required to create a window on MacOS from Rust
View main.rs
use objc::runtime::{Object, NO};
use objc::*;
// We must link with AppKit for all application and windowing related matters.
#[link(name = "AppKit", kind = "framework")]
extern "C" {}
// https://developer.apple.com/documentation/objectivec/nsuinteger
#[cfg(target_pointer_width = "32")]
pub type NSUInteger = u32;
@kettle11
kettle11 / audio.rs
Created March 7, 2020 22:00
Audio callback with attenutation
View audio.rs
impl AudioCallback for AudioThread {
type Channel = f32;
// All the mixing and primary audio logic is here.
fn callback(&mut self, out: &mut [Self::Channel]) {
let old_position = self.listener.position;
// let old_rotation = self.listener.rotation;
// Store previous position and tempo for interpoltation.
for instance in self.playing_clips.iter_mut() {
@kettle11
kettle11 / Simple breakout for Processing
Last active August 29, 2015 14:19
A simple breakout framework intended for teaching early programming concepts.
View Simple breakout for Processing
//Classes
class Block
{
public int xPosition = 0;
public int yPosition = 0;
public int rightEdge = 10;
public int bottomEdge = 10;
public int myWidth = 10;