nardev

nardev.org

Short and simple blog, images, programming and electronics projects....and anything else i want to write about...Sometimes in English sometimes not...

9 February 2018

Micro:bit - Mala Skola

by vedran alajebegovic

mala skola You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.

To add new posts, simply add a file in the _posts directory that follows the convention YYYY-MM-DD-name-of-post.ext and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.

Jekyll also offers powerful support for code snippets:

const char *kmp_search(const char *text, const char *pattern)
{
int *T;
int i, j;
const char *result = NULL;

if (pattern[0] == '\0')
return text;

/* Construct the lookup table */
T = (int*) malloc((strlen(pattern)+1) * sizeof(int) );
T[0] = -1;
for (i=0; pattern[i] != '\0'; i++) {
T[i+1] = T[i] + 1;
while (T[i+1] > 0 && pattern[i] != pattern[T[i+1]-1])
T[i+1] = T[T[i+1]-1] + 1;
}

/* Perform the search */
for (i=j=0; text[i] != '\0'; ) {
if (j < 0 || text[i] == pattern[j]) {
++i, ++j;
if (pattern[j] == '\0') {
result = text+i-j;
break;
}
}
else j = T[j];
}

free(T);
return result;
}
tags: micro:bit / sarajevo / vares
I sell on Tindie micro:bit