This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* gcd.c | |
| * run `make gcd` */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| long gcd (long a, long b) { | |
| ldiv_t qr; | |
| while (b != 0) { | |
| qr = ldiv(a, b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $("canvas").each(function(i,elem) { var ctx = elem.getContext('2d'); var ratio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1); elem.width *= ratio; elem.height *= ratio; ctx.scale(ratio,ratio); }); void(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "stack.h" | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| static void stack_grow(struct stack *s, int addition); | |
| struct stack *stack_new(int maxsize) | |
| { | |
| struct stack *s; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "llist.h" | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| struct llist *llist_new(void) | |
| { | |
| struct llist *ll; | |
| if ((ll = malloc(sizeof(*ll))) == NULL) { | |
| fprintf(stderr, "%s: could not create list\n", __func__); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* validate 2sat input data */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define abs(x) ((x) < 0 ? -(x) : (x)) | |
| int main(int argc, char *argv[]) | |
| { | |
| if (argc < 2) { | |
| printf("usage: %s [file]\n", argv[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* gendata.c | |
| * generate random 2sat data | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| if (argc < 4) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "queue.h" | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| struct queue *queue_new(void) | |
| { | |
| struct queue *q; | |
| q = malloc(sizeof(struct queue)); | |
| q->base = NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <pthread.h> | |
| #include <sys/sysinfo.h> | |
| #define UBOUND 1000000000 | |
| void *tfunc(void *arg); | |
| int main(int argc, char *argv[]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # makefile for glfw | |
| CFLAGS=$(shell pkg-config --cflags glfw3) | |
| LDFLAGS=$(shell pkg-config --libs glfw3) -lGL -lm | |
| all: | |
| $(CC) $(CFLAGS) glfwtest.c -o glfw_test $(LDFLAGS) | |
| clean: | |
| $(RM) glfw_test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # put this in .bashrc or /etc/bashrc | |
| function fsize() { | |
| kB=1000 | |
| val=$(stat --printf="%s" $1) | |
| if [ $val -lt $kB ]; then | |
| printf "$val B\n" | |
| elif [ $val -lt $(($kB*$kB)) ]; then | |
| printf "%0.2lf KB\n" $(bc -l <<< "$val/$kB") |