Skip to content

Instantly share code, notes, and snippets.

@programaths
programaths / creates_cycles.gd
Created August 23, 2024 15:34
Detect a cycle in a GraphEdit in Godot.
#Attach to GraphEdit
func creates_cycle(from_node: StringName, to_node: StringName):
var from:GraphNode=get_node(NodePath(from_node))
var to:GraphNode=get_node(NodePath(to_node))
var links:={from_node:{to_node:true}}
for con in get_connection_list():
var list:Dictionary=links.get_or_add(con.from_node,{})
list[con.to_node]=true
var stack=[]
var visited={}
@programaths
programaths / index.html
Created January 1, 2024 11:09
Tax calculator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tax Calculator</title>
<script type="module" src="tax-calculator.js"></script>
<script type="module" src="main.js"></script>
</head>
<body>
<div>
@programaths
programaths / index.html
Created December 23, 2023 17:18
Dumb lookups
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Power Search</title>
<link rel="stylesheet" href="style.css">
<script type="module" src="main.js"></script>
@programaths
programaths / tuto.md
Created May 10, 2023 19:50
Tilengine

​Your cmake file should be like this:​

cmake_minimum_required(VERSION 3.25)
project(MyGame)
set(CMAKE_CXX_STANDARD 17)
set(TILENGINE_PATH "tilengine")
include_directories(${TILENGINE_PATH}/include)
link_directories(${TILENGINE_PATH}/lib/x64)
add_executable(MyGame main.cpp)
@programaths
programaths / matrix.py
Created October 8, 2022 12:12
Code pour générer une vidéo sur la multiplication de matrices
from manim import *
class CreateCircle(Scene):
def construct(self):
mat1_data = [[1, 3, 5], [7, 9, 11], [13, 15, 17]]
mat1 = Matrix(mat1_data, left_bracket="(",
right_bracket=")")
mat2_data = [[2, 4, 6], [8, 10, 12], [14, 16, 18]]
mat2 = Matrix(mat2_data, left_bracket="(",
@programaths
programaths / firstNonRepeating.go
Created August 2, 2021 15:43
firstNonRepeating
package main
import "container/heap"
// Mind that this is slower than doing one pass to count occurances of each letter then a second pass to get the first non repeating letter
// This one does something else though, it will take the first least repeated letter. So, with any permutation of "aaaabbbcc" it would yield "c"
type indexedChar struct {
index int
rune rune
@programaths
programaths / overlapping-rectangles.frag
Created September 7, 2019 19:02
Very simple shader showing how to compose a figure and have layers
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
vec2 rotate(vec2 v, float a) {
float s = sin(a);
@programaths
programaths / auth.js
Created November 27, 2018 07:52
Working case of connection
const fetch = require('node-fetch');
const {ApolloClient,gql} = require('apollo-boost');
const {createHttpLink} =require('apollo-link-http');
const {WebSocketLink} =require('apollo-link-ws');
const WebSocket = require('ws');
const {InMemoryCache} = require('apollo-cache-inmemory');
const TEST_EMAIL = 'test-email';
const TEST_PWD = 'test-password';
@programaths
programaths / fixing-roles-users.js
Last active November 19, 2018 14:13
fixing roles & Users
/**
*
* @param {Array<{name:string}>} schema
*/
function fixSchema(schema) {
let fixedSchema = [];
let hasUser = false;
let hasSysRole = false;
let hasRole = false;
@programaths
programaths / testing-system-classes.js
Created November 19, 2018 10:20
Mocha test for REALM showing that if a class name is "ROLE" or "USER", it overrides "__ROLE" and "__USER" detection and leads duplicate or missing classes
const Realm = require('realm');
const LOGIN_URL = `http://localhost:9080/`;
const SYS_UNAME = '';
const SYS_PWD = '';
async function loginSysUser29(){
return Realm.Sync.User.login(LOGIN_URL,Realm.Sync.Credentials.usernamePassword(SYS_UNAME,SYS_PWD));
}