Skip to content

Instantly share code, notes, and snippets.

@AssafTzurEl
AssafTzurEl / docker-postgres.bat
Created November 30, 2023 14:35
Deploy Postgres + pgAdmin containers
docker network create pgnet
docker run -d --name postgres-container --network pgnet -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_DB=mydb -v postgres-data:/var/lib/postgresql/data postgres:16.1
docker run -d --name pgadmin-container --network pgnet -e PGADMIN_DEFAULT_EMAIL=admin@email.com -e PGADMIN_DEFAULT_PASSWORD=password -p 5050:80 dpage/pgadmin4:8.0
REM You can now access pgAdmin at http://localhost:50505/
#define DEBUG_MODE
#ifdef UNICODE
#define TCHAR wchar_t
#else
#define TCHAR char
#endif
#ifdef _DEBUG
#define LOG(format, val) printf(format, val)
@AssafTzurEl
AssafTzurEl / const.c
Created June 14, 2019 08:33
Const in C
void main()
{
const int ANSWER = 42;
int i = 0;
//ANSWER = 43; // Can't assign to constant
const int *cp;
cp = &ANSWER;
//*cp = 43; // cp points to a (const int)
cp = &i; // cp's contract allows to modify its contents
@AssafTzurEl
AssafTzurEl / StudentDb.c
Created June 14, 2019 08:23
Memory management
#include <malloc.h>
#define MAX_STUDENTS 30
typedef struct
{
int id;
/* more fields here */
} Student;
@AssafTzurEl
AssafTzurEl / ArrayParams.c
Last active June 7, 2019 10:09
C workshop
#include <stdio.h>
void f(int arr[]) // == void f(int *arr)
{
size_t size = sizeof(arr);
printf("Size in f(): %d\n", size);
}
void main()