Skip to content

Instantly share code, notes, and snippets.

@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));
}
@programaths
programaths / array-rotate-rl.php
Created September 22, 2017 17:13
Rotate an array left and right
<?php
function matMul( $a, $b ) {
$countI = count( $a );
$countJ = count( $b[0] );
$countK = count( $b );
$c = [];
for ( $i = 0; $i < $countI; $i ++ ) {
for ( $j = 0; $j < $countJ; $j ++ ) {
$sum = 0;
for ( $k = 0; $k < $countK; $k ++ ) {