This file contains 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 <dirent.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
/* | |
* This is example of getting PID of process by name. Returns first matched PID or -1. | |
* */ | |
int getPidByName(const char *name) | |
{ |
This file contains 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
CFLAGS += -O2 -pipe -Wall -Wextra | |
LDFLAGS += -lm | |
HEADERS = $(wildcard *.h) | |
SOURCES = $(wildcard *.c) | |
TARGETS := $(SOURCES:.c=) | |
all: $(TARGETS) |
This file contains 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 <errno.h> | |
#define __USE_GNU | |
#include <unistd.h> | |
#include <sys/wait.h> | |
int main(int argc, char **argv) | |
{ | |
pid_t child; |
This file contains 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
/******************************************************************************* | |
Copyright (c) 2013 Pavel Roschin (aka RPG) <[email protected]> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to | |
deal in the Software without restriction, including without limitation the | |
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
sell copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: The above |
This file contains 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
// a - your string (char *), i - iterator (uint), c - output character (uint) | |
#define UTF8_TO_UINT(a, i) \ | |
if((a[i] & 0b10000000) == 0) { \ | |
c = (unsigned)a[i++]; \ | |
} \ | |
else if (((unsigned)a[i] & 0b11100000) == 0b11000000) { \ | |
c = ((unsigned)a[i++] & 0b00011111) << 6; \ | |
c |= (unsigned)a[i++] & 0b00111111; \ | |
} \ | |
else if (((unsigned)a[i] & 0b11110000) == 0b11100000) { \ |
This file contains 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
#define _CAIRO_HASH_INIT_VALUE 5381 | |
unsigned long _cairo_hash_string (const char *c) | |
{ | |
/* This is the djb2 hash. */ | |
unsigned long hash = _CAIRO_HASH_INIT_VALUE; | |
while (c && *c) | |
hash = ((hash << 5) + hash) + *c++; | |
return hash; | |
} |
This file contains 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
$ make | |
/usr/bin/time -f "Time:\t%e\nMemory:\t%M" php test.php | |
Time: 0.59 | |
Memory: 655984 | |
/usr/bin/time -f "Time:\t%e\nMemory:\t%M" perl test.pl | |
Time: 0.64 | |
Memory: 353456 | |
/usr/bin/time -f "Time:\t%e\nMemory:\t%M" python test.py | |
Time: 0.92 | |
Memory: 544240 |
This file contains 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
char *itoa(int i) | |
{ | |
static char buf[12]; | |
int j = 11; | |
int sign = 0; | |
buf[j] = '\0'; | |
if(i < 0) | |
{ | |
i = -i; | |
sign = 1; |
This file contains 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
G_SLICE=always-malloc G_DEBUG=gc-friendly:resident-modules valgrind --tool=memcheck --leak-check=full --log-file=vgdump --suppressions=gtk.suppression --show-possibly-lost=no src/geany |
This file contains 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
from OpenGL.GL import*;from OpenGL.GLUT import*;from OpenGL.GL.shaders import*;from time import*;t=time();glutInit();glutInitDisplayMode(2);glutInitWindowSize(640,480);glutCreateWindow('');glOrtho(0,1,0,1,0,1);glMatrixMode(5888);p=compileProgram(compileShader('<SHADER>',35632)); | |
def d():glUseProgram(p);glUniform1f(0,time()-t);glBegin(7);glVertex2i(0,1);glVertex2i(1,1);glVertex2i(1,0);glVertex2i(0,0);glEnd();glutSwapBuffers() | |
glutIdleFunc(d);glutMainLoop() |
OlderNewer