Skip to content

Instantly share code, notes, and snippets.

View andrew-wilkes's full-sized avatar

Andrew Wilkes andrew-wilkes

View GitHub Profile
@andrew-wilkes
andrew-wilkes / grid
Last active November 22, 2022 11:18
Grid Shader for Godot
shader_type canvas_item;
uniform float cell_size = 16;
uniform float cell_spacing = 2;
uniform vec4 line_color : hint_color; //Now called source_color in Godot 4
varying vec2 v;
void vertex() {
v = VERTEX;
@andrew-wilkes
andrew-wilkes / track.scad
Created April 13, 2019 07:55
Straight and curved railway rail track OpenScad code
/* Track */
module track(num_sleepers = 10)
{
SPACING = 8;
RAIL_PITCH = 16.5;
RAIL_LENGTH = num_sleepers * SPACING;
RAIL_SIZE = [RAIL_LENGTH, 0.5, 0.8];
SLEEPER_SIZE = [2, RAIL_PITCH * 1.2, 0.4];
CURVE_ANGLE = 160;
@andrew-wilkes
andrew-wilkes / code.php
Created February 27, 2019 11:27
PHP Code to replace a token with injected content
<?php
class Code
{
private static $langs = array(
"gd" => "gdscript",
"cpp" => "C++"
);
public static function insert($content)
{
@andrew-wilkes
andrew-wilkes / gdscript-keywords-stripper.php
Created February 27, 2019 10:01
GDScript Keywords Extractor Script
<?php
$txt = "if See if/else/elif.
elif See if/else/elif.
else See if/else/elif.
for See for.
while See while.
match See match.
break Exits the execution of the current for or while loop.
continue Immediately skips to the next iteration of the for or while loop.
@andrew-wilkes
andrew-wilkes / gist:83b80fac1fd9ae21f2da064f7164bdf0
Created February 27, 2019 09:56
GDScript support for prism.js
/* PrismJS 1.15.0
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+c+csharp+cpp+python+typescript */
var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-([\w-]+)\b/i,t=0,n=_self.Prism={manual:_self.Prism&&_self.Prism.manual,disableWorkerMessageHandler:_self.Prism&&_self.Prism.disableWorkerMessageHandler,util:{encode:function(e){return e instanceof a?new a(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++t}),e.__id},clone:function(e,t){var a=n.util.type(e);switch(t=t||{},a){case"Object":if(t[n.util.objId(e)])return t[n.util.objId(e)];var r={};t[n.util.objId(e)]=r;for(var l in e)e.hasOwnProperty(l)&&(r[l]=n.ut
@andrew-wilkes
andrew-wilkes / obfuscation-test.gd
Created February 9, 2019 07:45
Test code for text obfuscation methods
extends Node2D
func _ready():
var test_bytes = generate_test_bytes()
var processed_bytes = flip_bytes(flip_bytes(test_bytes))
print(compare_bytes(test_bytes, processed_bytes))
func generate_test_bytes() -> PoolByteArray:
var bytes = [] as PoolByteArray
for i in range(256):
@andrew-wilkes
andrew-wilkes / enc.gd
Created February 8, 2019 14:26
Godot simple text file obfuscation
var d = File.new()
if d.file_exists(DIALOG_FILE):
encode_dialog()
d.open(ENC_DIALOG_FILE, File.READ)
dialog = flip_bytes(d.get_buffer(d.get_len())).get_string_from_utf8().split("###")
d.close()
func encode_dialog():
var file = File.new()
file.open(DIALOG_FILE, File.READ)