Recent Blog Posts

C – forking a child process using fork()

Creates a child process using fork(). The child increments a global variable (glob) and a local one (var) and returns the corresponding process id of each process. With fork() the child DOES NOT USE the same variables as the parent, so if the child changes these values, the parent still keeps his./* creates a child process using fork(). the child increments a global variable (glob) * and a local one (var) and returns the corresponding...

Read More

C – file type

Takes one or more files as arguments on the command line and returns the type of the file(s) (normal file, directory, etc.)/* reports the type of a file or of multiple files * that are given as arguments on the command line * it works too */ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> int main (int argc, char *argv[]) /* In ISO C you can define `main’ either to take no arguments, or to *...

Read More

C – cut file to zero length

Modify a file without changing it’s access and modification times. This is old code, all this was done in school, many years ago, no idea if it still works on modern systems./* should open a file, truncate it to length 0 but keep the old acces and modification time */#include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<utime.h> #include<stdio.h> int main(int argc, char *argv[]) /* In ISO...

Read More

C – echo server

According to the comments this is supposed to be a very basic echo server. It was written for school many years ago and I didn’t turn out to be a C coder after all, though I remember this being fun, so for anyone stumbling upon this: DISCLAIMER – apparently it was six in the morning and looks like I was a bit drunk too, so, seriously, don’t try it if you don’t know what it does. You shouldn’t run unknown code on your system, specially...

Read More

Backup files on Google Drive using Google Apps Script

My ideea was to set up a script running on Google’s servers that would automatically get files from my site and back them up on Google Drive. I would have gotten a free off-site backup. Unsurprisingly, it’s not working due to limits imposed by Google, even though I did manage to cheat on the 10MB limit for UrlFetchApp and file creation. Instead it now fails either because it’s execution takes too long, or because it tries to write to Drive...

Read More