Skip to content

Instantly share code, notes, and snippets.

View kgabis's full-sized avatar

Krzysztof Gabis kgabis

View GitHub Profile
@kgabis
kgabis / markov_strings.c
Created October 18, 2012 21:37
Markov string generator
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define to_index(a) (a - 97)
#define to_char(a) (a + 97)
int main(int argc, const char *argv[]) {
char letters[26][2048];
@kgabis
kgabis / nonograms.py
Created August 8, 2012 22:23
Nonogram solver for nonograms.net
#!/usr/bin/python
# This script solves encoded nonograms from site nonograms.net.
# When you create a nonogram and click encode, you are given an url
# with encoded nonogram (for instance http://nonograms.net?CxOuiPURF7Ii1ERa7u4AACuyNVVFqsi9VRa6uwAA).
# To solve it, you must pass a string after ? as an argument (CxOuiPURF7Ii1ERa7u4AACuyNVVFqsi9VRa6uwAA).
import base64
import sys
@kgabis
kgabis / hack.sh
Created April 11, 2012 15:58 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@kgabis
kgabis / cshuffle.c
Created September 22, 2011 11:22
stdin shuffle
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define START_SIZE 64
char * shuffle(char * array, int seed, int index, int len);
char * unshuffle(char * array, int seed, int index, int len);
void swap(char * a, char * b);
@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)
@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 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 / 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 / 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 / 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};