Skip to content

Instantly share code, notes, and snippets.

View kgabis's full-sized avatar

Krzysztof Gabis kgabis

View GitHub Profile
@kgabis
kgabis / itob.c
Created July 19, 2011 20:15
n int to b base string in C
void itob(int n, char s[], int b)
{
int i = 0, temp;
n = n > 0 ? n : -n;
do {
temp = n % b;
if(temp < 10)
s[i++] = '0' + temp;
@kgabis
kgabis / Program.cs
Created July 25, 2011 23:22
RemRaw raw file remover
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace remraw
{
class Program
{
@kgabis
kgabis / about.md
Created August 9, 2011 19:01 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@kgabis
kgabis / strtoint.c
Created September 6, 2011 13:25
String to long unsigned int
long unsigned int strToInt(char * str)
{
long unsigned int result = 0;
while(*str)
{
result *= 10;
result += *str - '0';
str++;
}
return result;
@kgabis
kgabis / arrayshuffle.c
Created September 8, 2011 18:07
Array shuffle and unshuffle
#include <stdio.h>
int * shuffle(int * array, int seed, int index, int len);
int * unshuffle(int * array, int seed, int index, int len);
void swap(int * num1, int * num2);
void printArray(int * array, int len);
int main()
{
int vec[5] = {1, 2, 3, 4, 5};
@kgabis
kgabis / genarrayshuffle.c
Created September 8, 2011 18:10
Generic array shuffle and unshuffle
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define Shuffle(A, B, C) shuffle(A, B, 0, C, sizeof(*A))
#define Unshuffle(A, B, C) unshuffle(A, B, 0, C, sizeof(*A))
typedef struct
{
int x;
@kgabis
kgabis / hw.c
Created September 11, 2011 17:30
Hello world x5 in C, assembly (-O0) and optimized assembly (-O3) from gcc
#include <stdio.h>
void hello(int i);
int main(int argc, char * argv[])
{
hello(5);
}
void hello(int i)
@kgabis
kgabis / stack.c
Created September 14, 2011 16:17
Linked stack in C
#include "..\Header\stack.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
void stackinit(Stack * stack)
{
stack->top = NULL;
stack->top->next = NULL;
stack->isempty = true;
@kgabis
kgabis / stack.c
Created September 14, 2011 17:47 — forked from mbelicki/stack.c
Linked stack in C
#include "stack.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
void stackpush(Stack ** stack, int value)
{
assert(stack != NULL);
@kgabis
kgabis / stack.c
Created September 14, 2011 18:30
Linked stack in C
#include "..\Header\stack.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
void stackpush(Stack * stack, int value)
{
assert(stack != NULL);
if(stack->top == NULL)