Skip to content

Instantly share code, notes, and snippets.

View ardrabczyk's full-sized avatar

Arkadiusz Drabczyk ardrabczyk

View GitHub Profile
@ardrabczyk
ardrabczyk / stack.c
Created September 1, 2015 10:08
C stack implementation
#include <stdio.h>
#include <stdlib.h>
#define _E(msg, args...) \
do{ \
printf( "[ERROR][%s][%d]: ", __FUNCTION__, __LINE__); \
printf( (msg), ##args); \
}while(0)
struct stack
@ardrabczyk
ardrabczyk / bubble-sort.c
Last active March 16, 2022 23:35
Bubble sort implementation in C using do...while loop
#include <stdio.h>
#include <stdlib.h>
void bubble(int arr[], size_t size)
{
int i = 0;
int temp;
int again = 1;
int iter = size - 1;
@ardrabczyk
ardrabczyk / insertion_sort.c
Created September 14, 2015 13:14
Insertion sort implementation in C
#include <stdio.h>
#include <stdlib.h>
void print(int arr[], size_t size)
{
unsigned i = 0;
for (; i < size; ++i)
{
printf("%d ", arr[i]);
}
@ardrabczyk
ardrabczyk / main.c
Created September 30, 2015 13:20
Extract bits from byte stream
#include <stdio.h>
#include <stdlib.h>
/*
Starting at position <position> extract <length> older bits.
Example:
bit number:
7 6 5 4 3 2 1 0 | 15 14 13 12 11 10 9 8 | 23 22 21 20 19 18 17 16
@ardrabczyk
ardrabczyk / vb.sh
Last active September 28, 2020 20:08
vb.sh: create a new virtualbox machine
#!/usr/bin/env sh
# vb.sh: create a new virtualbox machine
#
## (c) 2016-2020, Arkadiusz Drabczyk, arkadiusz@drabczyk.org
if [ "$#" -lt 2 ]
then
echo Usage: "$0" \<MACHINE-NAME\> \<ISO\> [RAM] [DISK] [TYPE]
echo Example:
echo ./vb.sh \"Slackware x64 14.1\" slackware64-14.1-install-dvd.iso
@ardrabczyk
ardrabczyk / linked-list.c
Created January 2, 2017 11:01
Single linked-list implementation in C
/* ## (c) 2017, Arkadiusz Drabczyk, arkadiusz@drabczyk.org */
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
@ardrabczyk
ardrabczyk / test.md
Last active January 15, 2024 18:26
test.md
var user = "string"
var user = "string"
@ardrabczyk
ardrabczyk / triangle.c
Last active January 23, 2019 19:26
Character triangle
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int chars_in_line = 7;
char current_letter = 65; /* ASCII A */
int current_chars_in_line = chars_in_line;
for(int i = 0; i < chars_in_line; i++)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <float.h>
unsigned long long factorial(unsigned num)
{
unsigned int i = 1;
unsigned long long result = 1;
@ardrabczyk
ardrabczyk / Makefile
Last active February 9, 2023 07:28
Shared object with rpath set
all:
cc -shared -fPIC lib_one.c lib_one.h -o libone.so
cc -shared -fPIC lib_two.c lib_two.h -o libtwo.so -L. -lone -Wl,-rpath=libs
mkdir -p libs
mv libone.so libs
cc main.c -o main -L. -ltwo -Wl,-rpath=.
clean:
rm -f libone.so libone.a libtwo.so main