Skip to content

Instantly share code, notes, and snippets.

View kspalaiologos's full-sized avatar
❤️‍🔥

Kamila Szewczyk kspalaiologos

❤️‍🔥
View GitHub Profile
@kspalaiologos
kspalaiologos / bf.c
Created November 15, 2017 17:14 — forked from maxcountryman/bf.c
A simple brainfuck interpreter in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// initialize the tape with 30,000 zeroes
unsigned char tape[30000] = {0};
// set the pointer to point at the left-most cell of the tape
unsigned char* ptr = tape;
@kspalaiologos
kspalaiologos / TicTacToe.asm
Created March 8, 2018 15:57
TicTacToe game in Assembly. Intel syntax. License: MIT
square:
.byte 48 ;0
.byte 49 ;1
.byte 50 ;2
.byte 51 ;3
.byte 52 ;4
.byte 53 ;5
.byte 54 ;6
.byte 55 ;7
.byte 56 ;8
@kspalaiologos
kspalaiologos / consolepauser.cs
Created March 13, 2018 16:03
Console Pauser application (From Brainfuck Builder 1/2/3).
using System;
using System.Diagnostics;
namespace ConsolePauser
{
internal class Program
{
private static void Main(string[] args)
{
@kspalaiologos
kspalaiologos / sq2gsq.c
Last active March 13, 2018 17:06
From SUBLEQ compiler for GSQ+ architecture.
#include <stdio.h>
#include <stdlib.h>
typedef union {
char bytes[4];
long instruction;
} data_t;
int main(int argc, char ** argv) {
@kspalaiologos
kspalaiologos / MAZE_COM.BF
Created March 17, 2018 16:41
Maze Solver. License:MIT WARN: MAY NOT WORK!
W pamieci jest na poczatku labirynt potem jest tablica gdzie algorytm byl a na koncu jest tablica z wlasciwa sciezka
Dalej sa zmienne takie jak poczatkowy x y koncowy x y x i y i czy labirynt zostal rozwiazany
>+<+[
Inicjalizacja poczatkowego x
start >[>[-]+<-]>[<+
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-]
Inicjalizacja poczatkowego y
start <[-]
Inicjalizacja zmiennej czy rozwiazano
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]
@kspalaiologos
kspalaiologos / MAZE.BF
Created March 17, 2018 16:42
Maze solver, minified version using Brainfuck Builder 3. License: MIT.
>+<+[>[>[-]+<-]>[<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>[-]<[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>>
[-]++++++++++<[-]++++++++++<<<<<<<<<<<[-]<[-]<<<<<<<<<+++++++++++[>+++++++>+++++
++++>+++++++++++>+++>++++<<<<<-]>.>--.>+.<++++.>>-.<<++.--.+++++++++.---------.>
--------.<----.>++.<++++++++.>-----.-.>.<<.>.>.<<<-----------.>>++++.<--------.+
+++++++.>----.<---.>+++++++.<---.++++++++.>>>++.[-]<[-]<[-]<[-]<[-]<++++++++++.[
-]+++++++++++++++++[>++++>+++++++>++>++++++>+++++>+++<<<<<<-]>--.>++.>--.<<+++++
++++.>-------.++++++++.-.------.+++++++.------.-----.>>.<.>>--.<<<+++++++++++.>>
-.<<---.>>--.<<+++.-.>>++++++++.<.>-----.+++++++++.+++.<.<<++.>>>>++++++++++++++
.<.>++++.++++++.<<.<<----------.>>>>---.<---.>+.<-.+++++.>++.--.>-----.[-]<[-]<[
@kspalaiologos
kspalaiologos / CvsCppBenchmark.txt
Created March 18, 2018 09:48
C vs C++ size/speed benchmark
GCC-generated code for searching 1000 first primes:
.LC0:
.string "2 "
.LC1:
.string "%d "
.LC2:
.string "Time elapsed: %d"
primes:
pushq %rbp
@kspalaiologos
kspalaiologos / BRAINFUCK.ASM
Created April 11, 2018 06:33
Tiny assembly brainfuck interpreter
.program:
.string ",[.,]"
main:
push r12 ; Function entry point
or r12d, -1 ; Setting up parameters in registers
push rbp
mov ebp, OFFSET FLAT:l
push rbx
xor ebx, ebx
.mainloop:
@kspalaiologos
kspalaiologos / C-OOP-Tutorial.MD
Last active December 4, 2019 08:46
Small OOP tutorial for C.

C OOP tutorial

This small file was made to help beginners with OOP in C. I hope it will be helpful. All code included in this file is released to public domain, while this document itself is released under terms of MIT license. This file contains C99 code, so please adjust your compiler to use it. For gcc pass: -std=c99

Creating new class

To create new class, we have to create new two files first. First will be named 'simple.c' and second will be named 'simple.h'.

simple.h:

%&pdfLaTeX
% !TEX encoding = UTF-8 Unicode
\documentclass{article}
\usepackage{ifxetex}
\usepackage{listings}
\ifxetex
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{STIXGeneral}
\else
\usepackage[T1]{fontenc}