Skip to content

Instantly share code, notes, and snippets.

@naezith
naezith / sfml_interp.cpp
Last active September 1, 2019 01:23
Minimal SFML and Interpolation example
#include <SFML/Graphics.hpp>
#include <chrono>
using namespace std::chrono_literals;
int main() {
sf::RenderWindow window(sf::VideoMode(1280, 720), "Stutter");
sf::Event event;
const float dt = 0.008f;
@naezith
naezith / battleships.c
Last active January 8, 2016 20:16
Battleships Game against AI
// There are 5 ships for you and your enemy and their sizes are 1, 2, 3, 4, 5. Map is 10x10
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#define GRID_SIZE 10
typedef struct POINT{ int i, j; } POINT; // Coordinate holder
@naezith
naezith / snake_n_mouse.c
Created January 4, 2016 13:09
Snake and Mouse game and this time, you're the mouse! Full C Source Code
// Snake and Mouse game, you're the mouse. Eat cheese to get points and watch out for the snake!
// Written by naezith, you can use/change the code however you want.
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <math.h>
#include <time.h>
#define MAP_WIDTH 20
@naezith
naezith / maze.c
Created January 4, 2016 12:52
Find Path in Maze using Depth First Search, DFS
#include <stdio.h>
#include <conio.h>
#define SIZE_X 6
#define SIZE_Y 6
// Visibility and Walls around
typedef struct CELL { char mid, N, E, S, W; } CELL;
CELL maze[SIZE_X][SIZE_X];
@naezith
naezith / course_catalog_1.dtd
Created January 4, 2016 12:50
Course Catalog DTD examples
<!DOCTYPE Course_Catalog [
<!ELEMENT Course_Catalog (Department+)>
<!ELEMENT Department (Title,Course*,Professor*,Lecturer*)>
<!ELEMENT Professor (First_Name,Middle_Initial?,Last_Name)>
<!ELEMENT Lecturer (First_Name,Middle_Initial?,Last_Name)>
<!ELEMENT Course (Title,Description?)>
<!ELEMENT Description (#PCDATA | Courseref)*>
<!ELEMENT Courseref EMPTY>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT First_Name (#PCDATA)>
@naezith
naezith / search_engine_hash_tables.c
Created January 4, 2016 12:48
Search Engine using Hash Tables
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct ht_entry_s { char* a; char* b; } ht_entry_t;
typedef struct ht_s { ht_entry_t* table; int size; } ht_t;
ht_t* ht_create(int size);
void ht_set(ht_t* ht, char* a, char* b); // Sets key a, value b
char* ht_get(ht_t* ht, char* a); // Gets the value b with the key a
char* strapp(char* old_str, char* add_str); // Safely appends the second string to first one
@naezith
naezith / text_justify.c
Last active January 4, 2016 12:44
Text Justify
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
int main(){
char words[100][100];
int word_count = 0, line_length;
@naezith
naezith / round_robin.c
Last active January 4, 2016 12:35
Round Robin process scheduling simulation
#include <stdio.h>
#include <stdlib.h>
typedef struct Process {
unsigned int id;
int cpu_time;
int last_start_time;
int preemption_count;
} Process;
@naezith
naezith / quicksort.c
Created January 4, 2016 12:33
Benchmark of Quicksort implementations
// You need to uncomment and comment some blocks in order to benchmark, it is not full automatic.
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
// Inputs
#define ARRAY_SIZE 1000
#define LOGS_ON 0
@naezith
naezith / filter_list.sh
Created January 4, 2016 12:30
Filter a list of data
inf="input_list.txt" # this file has lines like [201504695,ASLI,ASLAN,[email protected],CS101,89,2]
outf="list.txt"
sep=',' #define seperator
#filter the list
list=$(cat $inf `
`| egrep "2015.*(CS101|CS102),([6-9][0-9]|100).*" ` # filter with CS101 OR CS102, 2015 and 60 <= mark
`| sed 's/-//1' ` # remove - from the number
`| awk -F $sep 'int($7)==2' ` # second time they take the lesson
`| awk -F $sep 'int($6)<90' ` # mark < 90