Skip to content

Instantly share code, notes, and snippets.

Avatar

Tomasz Czajęcki tchayen

View GitHub Profile
@tchayen
tchayen / script-calculator.js
Last active Sep 10, 2021
Javascript calculator using Reverse Polish notation and Shunting-yard algorithm
View script-calculator.js
// function connecting algorithm with outer world
function updateCalculator(event) {
var expression = document.getElementById("calculator").value;
var result = calculate(expression);
document.getElementById('calculatorResult').innerHTML = result;
}
function calculate(expression) {
View opengl_setup_test.cpp
#include <cstdio>
#include <cstdlib>
#include "glew.h"
#include "glfw3.h"
typedef short int16;
typedef int int32;
typedef unsigned short uint16;
typedef unsigned int uint32;
View gaussian_blur.cpp
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include "gl3w\gl3w.h"
#include "glfw-3.2\glfw3.h"
#include "soil-1.16\SOIL.h"
// not necessary but makes my life much easier when I can just see the number of
// bits and I dont have to write 'unsigned' as a separate word
View solution1.java
import java.util.*;
public class Solution {
private static boolean isPrime(int n) {
if (n < 2) return false;
for (int i = 2; i * i <= n; i++)
if (n % i == 0 || n % (n - i) == 0)
return false;
return true;
View solution2.java
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
public class Solution {
private static boolean shouldUserBeAsked(List<String> dates) {
Collections.reverse(dates);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
View example1.js
document.documentElement.style.overflow = 'hidden'
const vertices = new Float32Array([-1.0, -1.0, 1.0, -1.0, 0.0, 1.0])
const vertex = `
attribute vec2 a_position;
void main() {
gl_Position = vec4(a_position, 0, 1);
}`
View example2.js
document.documentElement.style.overflow = 'hidden'
const vertices = new Float32Array([0.0, 0.0, 0.0, 300.0, 200.0, 300.0])
const vertex = `
attribute vec2 a_position;
uniform mat3 u_matrix;
void main() {
gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1);
}`
View example3.js
document.documentElement.style.overflow = 'hidden'
const vertices = new Float32Array([
-1, -1, -1,
1, -1, -1,
-1, -1, 1,
-1, -1, 1,
1, -1, -1,
1, -1, 1,
View example4.js
document.documentElement.style.overflow = 'hidden'
const obj = `
v 0.5 -0.12 -0.26
v 0.5 -0.12 -0.12
v -0.5 -0.12 -0.26
v -0.5 -0.12 -0.26
v 0.5 -0.12 -0.12
v -0.5 -0.12 -0.12
v -0.5 -0.5 -0.12
View barycentric.js
const vertex = `
attribute vec2 a_position;
attribute vec3 a_barycentric;
uniform mat3 u_matrix;
varying vec3 vbc;
void main() {
vbc = a_barycentric;
gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1);
}`