Skip to content

Instantly share code, notes, and snippets.

View rlemon's full-sized avatar
🍋
Hanging around.

Robert Lemon rlemon

🍋
Hanging around.
  • Dryer Moisture Systems Inc.
  • Kitchener, Ontario. Canada.
View GitHub Profile
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@gigaherz
gigaherz / 00 Explanation.md
Last active April 16, 2024 09:52
Custom shader rendertype mini-howto example (forge 37.0.15+)

Making a custom render type with a custom shader requires a number of things to exist at once:

  1. A ShaderInstance which references your shader json. The RegisterShadersEvent lets you define a ShaderInstance, and has a callback for when the shader is fully loaded from disk.
  2. A ShaderStateShard with a supplier that returns the ShaderInstance. The supplier exists so that shaders can reload themselves when you change resourcepacks or do a F3+T reload.
  3. A RenderType which uses the ShaderStateShard as its shader state.
  4. A shader json, which declares the shader properties and points to the shader programs (vsh and fsh).
  5. A vertex shader program, which describes how the vertex data is transformed before passing into the rasterizer and being turned into pixels.
  6. A fragment shader program, which describes how the interpolated values from the vertices get turned into color values before being passed into the output blending stage.

Note: The vanilla logic does not normally allow namespaces in the shader

@ChampionAsh5357
ChampionAsh5357 / 1194-120-primer.md
Last active April 13, 2024 15:36
Minecraft 1.19.4 -> 1.20 Mod Migration Primer

Minecraft 1.19.4 -> 1.20 Mod Migration Primer

This is a high level, non-exhaustive overview on how to migrate your mod from 1.19.4 to 1.20 using Forge.

This primer is licensed under the Creative Commons Attribution 4.0 International, so feel free to use it as a reference and leave a link so that other readers can consume the primer.

If there's any incorrect or missing information, please leave a comment below. Thanks!

Pack Changes

@zackthehuman
zackthehuman / hexagons.js
Created February 20, 2012 03:46
Drawing a hexagonal grid with HTML canvas
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Canvas Hexagonal Map</title>
<style type="text/css">
canvas {
border:0;
display:block;
margin:0 auto;
@Raynos
Raynos / starred-gists.md
Created February 27, 2012 00:33
My starred gists
  • [Why you don't need Meteor][20]
  • [Shim status of ES6][1]
  • [unshimmable subset of ES5][2]
  • [Host objects][3]
  • [Why you don't need jQuery][4]
  • [All the DOM recursion you'll ever need][5]
  • [The heart of pd][6]
  • [jQuery library critique][7]
  • [klass][8]
  • [tiny select][9]
@rlemon
rlemon / demo.markdown
Created March 1, 2012 14:23
Ubuntu Keyboard with KBD tags and CSS
@Raynos
Raynos / select.js
Created December 10, 2011 16:01
tiny select. Selecting has never been so awesome \o/
// Pretty fast - http://jsperf.com/select-vs-natives-vs-jquery
/*
By, shortcuts for getting elements.
*/
var By = {
id: function (id) { return document.getElementById(id) },
tag: function (tag, context) {
return (context || document).getElementsByTagName(tag)
},
"class": function (klass, context) {
@lakenen
lakenen / detectanimation.js
Created June 28, 2012 17:17
JavaScript animated GIF detection!
function isAnimatedGif(src, cb) {
var request = new XMLHttpRequest();
request.open('GET', src, true);
request.responseType = 'arraybuffer';
request.addEventListener('load', function () {
var arr = new Uint8Array(request.response),
i, len, length = arr.length, frames = 0;
// make sure it's a gif (GIF8)
if (arr[0] !== 0x47 || arr[1] !== 0x49 ||
@Zirak
Zirak / gist:1677020
Created January 25, 2012 16:15
Visibility API
//http://www.w3.org/TR/2011/WD-page-visibility-20110602/
(function () {
"use strict";
//no need to shim if it's already there
if ( 'hidden' in document && 'onvisibilitychange' in document ) {
return;
}
//fail silently if the browser sux

These examples are presented in an attempt to show how each coding styles attempts to or does not attempt to isolate side-effects. There are only 2 semantic elements in a barebone "Hello World" implementation:

  • Invocation of console.log
  • Declaration of HELLO_WORLD

Since every coding style can abstract away data into a parameter or variable, there is no point for us to show that. All implementations assume HELLO_WORLD is a constant that is always inlined. This way it reduces the variations we need to present. (To make an anology, if we were to implement incrementByOne, would we need to inline the number 1 or pass it in as parameter?)

CAVEAT/LIMITATION: All implementations also assume console is static global. In case of functional programming, console.log is asumed to be a function that can be passed around without further modification. (This is not the case in the browser, but that can be resolved with console.log.bind(console))

Declarative