Skip to content

Instantly share code, notes, and snippets.

@EIREXE
EIREXE / RangeDownloader.gd
Last active July 19, 2022 21:41
Godot HTTP "Range" based file downloader
class_name HBHTTPRangeDownloader
signal download_finished
enum STATE {
STATE_READY,
STATE_BUSY
}
var download_url := ""
@sjvnnings
sjvnnings / better_jumping_character_example.gd
Last active June 25, 2024 21:37
An easy to work with jump in Godot
extends KinematicBody2D
export var move_speed = 200.0
var velocity := Vector2.ZERO
export var jump_height : float
export var jump_time_to_peak : float
export var jump_time_to_descent : float

Everything I Know About UI Routing

Definitions

  1. Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
    1. pathname - The "file/directory" portion of the URL, like invoices/123
    2. search - The stuff after ? in a URL like /assignments?showGrades=1.
    3. query - A parsed version of search, usually an object but not a standard browser feature.
    4. hash - The # portion of the URL. This is not available to servers in request.url so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things.
    5. state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
@developit
developit / *state-machine-component.md
Last active February 6, 2021 00:44
265b lib for building pure functional state machine components. https://github.com/developit/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

@jaredpalmer
jaredpalmer / ReducerComponent.js
Last active July 27, 2019 15:59
React.ReducerComponent
import React from 'react';
class ReducerComponent extends React.Component {
constructor(props) {
super(props);
}
reducer = (state, action) => state;
dispatch = action => this.setState(state => this.reducer(state, action));
@XANOZOID
XANOZOID / KinematicPlatformer2d.gd
Last active February 7, 2022 02:59
Godot easy and composable slopes platformer code (DEMO: https://media.giphy.com/media/iPQssOxSZ61Zm/giphy.gif )
# Please credit "Ghouly The Ghost" out of your kind heart! Check my gist page for a license.
# Includes: No slip inclines, variable angle climbing, shape agnostic implementation, slope climb up/down, smooth old school vertical collisions
# WARNING! IMPORTANT!: Relies on " Scene >> Projects Settings >> Physics 2D >> motion_fixed_enabled[x] __ on[x]"
extends KinematicBody2D
const floorCheckVector = Vector2( 0, 1 )
const normalCheckVector = Vector2( 0, -1 )
var angleThreshold = 1.39 setget set_angle_threshold
var slopeScale = tan( angleThreshold )
// see also https://www.npmjs.com/package/subtractiontype.ts
// for literal unions
type Sub0<
O extends string,
D extends string,
> = {[K in O]: (Record<D, never> & Record<string, K>)[K]}
type Sub<
@Xananax
Xananax / drake.js
Created April 25, 2016 12:12
Drake Equation Calculator
/**
A little bare-bones drake calculator whipped together in ten minutes just to test some values and have fun.
Should work in all modern browsers.
**/
function createDrake(element){
if(!element){element = document.body;}
const container = document.createElement('div');
container.id = 'drake';
// ==UserScript==
// @version 1.4.1
// @name Hide watched videos on YouTube
// @icon https://www.youtube.com/favicon.ico
// @match https://www.youtube.com/*
// @exclude https://www.youtube.com/embed/*
// @exclude https://www.youtube.com/api/*
// @namespace https://gist.github.com/xPaw/6324624
// @updateURL https://gist.github.com/xPaw/6324624/raw/YoutubeHideWatched.user.js
// @downloadURL https://gist.github.com/xPaw/6324624/raw/YoutubeHideWatched.user.js