JetCracker

Life-time learner's blog

Tag Archives: Source code

[MPI] Solving the advection equation in parallel

In chemistry, engineering and earth sciences, advection is a transport mechanism of a substance or conserved property by a fluid due to the fluid’s bulk motion.

Mathematics describes the process of advection with the advection equation:

\frac{\partial\psi}{\partial t}+\nabla\cdot\left(\psi{\bold u}\right)=0

In my course on Parallel programming, I had to implement a solution to a particular advection equation, with  the initial and boundary conditions defined. Read more of this post

PHP: Syntax highlighting with GeSHi

One day I needed to add some source code examples to the web-site. But there was no features for highlighting syntax. I decided to create my own tool for highlighting source code. Here I will show you how to do it using PHP with GeSHi. Read more of this post

MPI: Calculating sum 1/n! in parallel

Hello.
I’ve spend several hours to understand how to programme in MPI and how to calculate the sum of 1/n! in parallel (it’s my task from university). (By the way, why do I have study this shit? I don’t think I will be working in the field of parallel/distributed computing.)

But finally I wrote a decent programme, which showed not bad results. And I am very excited to share with you! Read more of this post

[My old trash] Resizing images in Delphi.

Hello!

A hundred years ago I was working on a PHP web site. I needed to place there a lot of images but all of them have different resolutions and sizes. For example, pictures from photo camera were very heavy (~ 5 Mb) and maximum file size that was allowed on the hosting was 3 Mb. So, before placing those photos to my hosting I needed to scale them down so that they met the limits.

You might have suggested using a PhotoShop or anything like that to get this job done. But I didn’t have the money to use this software (actually, I still don’t have). There were also a lot of free photo editors, which provided the function to scale images in bulk, but they were too overloaded and not so handy. Besides, I was very curious about how to make such a tool that would solve my problem.

Here I’m going to show you how to create a tool in Delphi that will automatically scale all images (only jpeg) in the directory that you specify. Why Delphi? Simply because it was the only programming language I was good enough at. Read more of this post

[Unix C] ID implementation

Hello.

Last time I posted my implementation of linux command echo. Now I’d like to introduce my implementation of id (which was another task from my IT teacher). This unix-shell command is rather simple and its task is to print real and effective user and group IDs.

Firstly, let’s see how to obtain current user’s ID and group ID. Take a look at the folowing code:

#include <stdio.h>
#include <unistd.h>

int uid, gid;

int main(){
    uid = getuid();
    gid = getgid();
    printf("UID: %d; GID: %d\n", uid, gid);
    return 0;
}

But functionality of ID command in Linux is way more complex! It took me almost 3 hours to implement all it’s features. Read more of this post

[Unix C] ECHO Implementation

When I was at my 2nd year, we studied architecture of operating systems. Our IT seminars were devoted to writing C applications for Linux. The first programme that we had to write was a simple terminal command “echo”. I’ve spend 2 hours to do it! Read more of this post