Skip to content

Instantly share code, notes, and snippets.

View Gelio's full-sized avatar

Grzegorz Rozdzialik Gelio

View GitHub Profile
function putPixel(x: number, y: number) {
const textureVectorWithLightColor = textureVectorsWithLightColor[x][y];
const distortedNormalVector = distortedNormalVectors[x][y];
// cos theta = v1 * v2 / (norm(v1) * norm(v2))
// Since lightDirectionVersor and distortedNormalVector are unit vectors, cos theta is just
// a dot product
const cosTheta = Vector3.dotProduct(lightDirectionVersor, distortedNormalVector);
const clampedCosTheta = Math.max(0, Math.min(1, cosTheta));
onmessage = (e: MessageEvent) => {
const messageType: FillWorkerMessageType = e.data.type;
switch (messageType) {
case FillWorkerMessageType.InitialData:
appFillData = e.data.appFillData;
canvasWidth = e.data.width;
canvasHeight = e.data.height;
break;
@Gelio
Gelio / allocate-customers-procedure.sql
Last active May 25, 2017 12:36
Databases DDL laboratory task preparation
USE Northwind;
GO
CREATE PROCEDURE AllocateEmployees
AS
DECLARE @UnallocatedStayID int
DECLARE @HotelID int
DECLARE UnallocatedRooms CURSOR LOCAL FOR SELECT StayID, HotelID FROM HotelStays WHERE EndDate IS NULL AND RoomID IS NULL ORDER BY NEWID()
OPEN UnallocatedRooms
FETCH NEXT FROM UnallocatedRooms INTO @UnallocatedStayID, @HotelID
WHILE @@FETCH_STATUS = 0
@Gelio
Gelio / Lab11_Main.cs
Created May 20, 2017 11:47
ASD2 laboratory task 11 main file with custom tests and performance metrics
using System;
using System.Diagnostics;
using ASD.Graphs;
namespace ASD
{
#region Types
public class SmurfphoneFactoryTestCase : TestCase
{
@Gelio
Gelio / Lab10_Main.cs
Created May 11, 2017 09:28
ASD2 laboratory task 10 main file with custom tests and performance metrics
using System;
using System.Linq;
using System.Collections.Generic;
using ASD;
using ASD.Graphs;
namespace lab10
{
class MatchingTestCase : TestCase
@Gelio
Gelio / Lab09_Main.cs
Last active April 26, 2017 17:05
ASD2 laboratory task 9 main file with custom tests and performance metrics
using System;
using System.Linq;
using ASD;
using ASD.Graphs;
namespace Lab9
{
class MuseumTestCase : TestCase
{
public static bool NumberOnly;
@Gelio
Gelio / socket-udp-task-scheduler-client.c
Created April 10, 2017 15:10
UDP task scheduler with client-server architecture created in C for the Operating Systems class
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
@Gelio
Gelio / Lab07_Main.cs
Last active April 5, 2017 07:58
ASD2 laboratory task 7 main file with custom tests and performance metrics
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ASD
{
class BridgeCrossingTestCase : TestCase
@Gelio
Gelio / socket-communicator-client-local.c
Last active April 3, 2017 20:03
Socker communicator with server-client architecture created in C
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <errno.h>
#include <sys/un.h>
#include <pthread.h>
#include <sys/time.h>
#include <stdint.h>
@Gelio
Gelio / Makefile
Created March 30, 2017 08:38
Pseudo numer computing in a cluster created with POSIX message queues in C for an Operating Systems course
CC=gcc
CFLAGS=-Wall -std=gnu99
LDLIBS=-lrt