Linux is a free (libre), open source, Unix-like operating system.

learn more… | top users | synonyms

21
votes
4answers
4k views

Recording audio in C

This is a program I wrote as a .wav audio recording library for Linux. It was developed on a Raspberry Pi, so that may affect the dependencies required.(1) wav.h ...
14
votes
1answer
176 views

Calculating the harmonic average

In this program I was required to calculate the Harmonic Average using an assembly program with a C driver. Harmonic mean is defined as: $$ \frac{n}{\dfrac{1}{x_1} + \dfrac{1}{x_2} + \cdots + ...
14
votes
1answer
172 views

Regular backup/snapshots

A (long) while ago I set up a file server in my basement running Linux. I am OCD when it comes to backups. I set the server up with (remember, this was a while ago): disk for OS disk for 'valuable' ...
13
votes
2answers
3k views

To calculate the total CPU usage as a percentage

I have been developing the below method to calculate the CPU usage of a Linux system at a point in time, as a percentage of the total number of cores available in the system. ...
12
votes
3answers
189 views

Making kexec reboots less painful

kexec is a way for a Linux kernel to directly boot another Linux kernel without going through the usual BIOS startup sequence, which can take several minutes on enterprise servers. The big problem ...
12
votes
1answer
339 views

x64 assembly clearmem / zeromem

I've just started learning assembly yesterday, and the first useful thing I've written is a clearmem function. I'm looking for general feedback regarding my coding ...
12
votes
1answer
1k views

Linux NASM assembly linked list implementation

Inspired by all of the lovely linked lists lately, I decided to implement one in assembly language. This code maintains two linked lists - one is a free store and the other is the active linked list. ...
11
votes
3answers
896 views

Bash script that updates Intel e1000e driver

I am now writing a small bash script that updates an Intel NIC driver to the latest version from the official website. Is there any way to improve\simplify the script? I want to avoid a lot of ...
11
votes
1answer
244 views

Set of wrapper functions for POSIX signal APIs on Linux

Please feel free to comment on the accuracy/validity of the following wrapper source for processing signals using the new POSIX sigaction API. If you feel I'm doing anything wrong or potentially ...
11
votes
1answer
58 views

Callback in Linux kernel driver in order to hide device's low-level protocol

I'm am writing a Linux kernel driver for HD44780 LCDs connected via I2C bus. In my last change I tried to decouple low-level code (which talks to the device via I2C) from device's logic (printing ...
10
votes
3answers
1k views

Parsing ARP cache in C

How can I make this better? ...
10
votes
3answers
285 views

Iptables Lockdown

I have nginx serving files with uwsgi and I wanted to lock my server down just to allow SSH and Nginx to run. ...
10
votes
2answers
353 views

Minimalistic rmdir

In my eyes most of the GNU stuff is bloated and doesn't really fit my view of how a Linux environment should look like. I have come up with my own minimalist implementation of the GNU Coreutils, but ...
10
votes
2answers
460 views

Parsing of a (Linux) netlink hotplug uevent packet

The netlink service is used, among other things, to notify userspace about hotplug events (e.g. "a device has been connected"). These events come in the form of packets, which follow the following ...
9
votes
3answers
492 views

Daemonizer in C

I am aware that the malloc is a potential memory leak, but with an execvp coming, and that never returning. The purpose is to ...
8
votes
2answers
205 views

Self-mutating C (x86_64)

As a learning exercise I wrote a short C program that changes the instructions of a function at runtime in order to execute a shell. It's obviously dependent on x86_64 architecture and Linux (for the ...
8
votes
3answers
1k views

x86 strcpy - can this be shortened?

I got about 4 days of assembly knowledge so, I need a review on this strcpy function and if it can be done better (At least I have the feeling). Full code (with the test included): ...
8
votes
3answers
3k views

Correctness of calculations with struct timespec

I've noticed some discrepancies in timings in our system, and I'm trying to narrow down what could be causing them. I'm reviewing out time abstraction, and as far as I can determine it's fine. Am I ...
8
votes
1answer
272 views

VLC media player watchdog daemon

I'm looking for bugs, ways to make it more portable or standardized, improvements of any kind. Seems to do what it is supposed to on my Ubuntu 12.04 PC. ...
7
votes
1answer
321 views

Bash script - automate an upload image + description process on a server

I was tasked at work to improve a system where through a web interface a client, which eventually became us, uploads a bunch of images with descriptions (latter coming from csv files), the images are ...
7
votes
3answers
240 views

Can I speed up this simple versioning/backup script?

I'm writing a simple automatic backup/versioning bash script. It should basically mirror a directory structure somewhere, and then copy files over there when they've been altered. The ghost files ...
7
votes
1answer
252 views

Push backup script

I just wrote a little bash script for rsync push backups of my laptop to my Synology-Diskstation at home. Since I am a bash beginner and don't have any experience with ...
7
votes
1answer
55 views

Detecting two keys pressed in quick succession

My computer has been having this issue where when I press a key, two key presses get registered. The goal of this program is to detect the time delta between the two keys so that I can set an ...
7
votes
2answers
119 views

Backup Linux system to web

First I create a .tar of the root directory with all the file permissions saved and excluding all irrelevant directories (are these the right folders to be ...
7
votes
1answer
2k views

Using /proc/stat to calculate CPU usage

Inspired by this question: To calculate the total CPU usage as a percentage I wrote the following bash script (as an answer) to calculate the CPU usage for a (configurable) period over all CPU cores ...
7
votes
1answer
344 views

Writing SIMD libraries for C++ on FASM in x86-64 Linux

I have recently started a project of SIMD libraries development for C++ on FASM for x86-64 Linux. I would be glad to hear any opinion or feedback about the project, cleanness of the code and ...
7
votes
1answer
67 views

Adding support to Busybox vi for reading file from stdin

I am writing a patch for Busybox's implementation of vi, the classical command line code editor and predecessor of vim. It can ...
6
votes
2answers
247 views

Batch rename flac files

This is my first real program in python (and my first real program) and I would like to have input by some more advanced programmers on the code, on the writing style and on the amount of comments (is ...
6
votes
5answers
249 views

Mounting multiple partitions on a disk

Is it possible to improve the code of this bash script? ... or should I just use another language? (If so, which one would fit the best the situation, according to you?) Here is the code (simplified, ...
6
votes
3answers
308 views

Locating a PID based on an IP address and port

I wrote a simple Python app that is given an IP address and port and the app then finds the PID listening on that IP:PORT. I would like to hear constructive criticism regarding the bellow code. ...
6
votes
2answers
273 views

Printing a directory's contents in a loop

I wrote a bash script to print contents of files in a given directory in a loop. How can I improve command line parameters handling to the script? I feel the parameter processing as of now uses too ...
6
votes
1answer
319 views

Fast Thread- and multiprocess-safe file operations in python under Linux

I'm trying to implement an alternative to python built-in open(), but safe for use in multi-threaded and multiprocessing environment. I'm using advisory locking, ...
6
votes
1answer
891 views

Calculate query coverage from BLAST output

I have a BLAST output file and want to calculate query coverage, appending the query lengths as an additional column to the output. Let's say I have 2 7 15 ...
6
votes
1answer
126 views

Copying files as fast as possible

I am running my shell script on machineA which copies the files from machineB and machineC ...
5
votes
2answers
405 views

Abstraction for an IO device

I have a C++ class which acts as an abstraction for an IO device which is controlled through file descriptors. As I am very new to C++, I would be glad if you can give me devastating feedback on ...
5
votes
3answers
102 views

Check disk space against a threshold

The below script is one I made to check the disk space on mounted partitions under Debian Wheezy. I tried adding a -d switch to force printing out the used data, ...
5
votes
2answers
576 views

Benchmarking our LAMP servers with this php script

I've written a small script to benchmark our LAMP hosted servers that assess the performance based on three factors: Disk I/O Database I/O (mysql) Database I/O (sqlite) The logic is as follows: ...
5
votes
2answers
6k views

Running a shell command and getting output

This is the code I'm currently using to run a shell command on the current machine, intended for use only with GNU/Linux at the moment: ...
5
votes
1answer
181 views

Extracting emails from a file and writing them to another file

The code below works fine for me. Is there any way that I can improve this code more? Note: delimiter is single whitespace only for email address. getmail.py ...
5
votes
2answers
120 views

Packaging a single-file Python copy-tool

I'm currently working on a very simple one-file project: Lumix provides the possibility for the camera TZ41 (and others) to load GPS data and tourist information from a DVD to a SD-card so that you ...
5
votes
2answers
160 views

VLC media player watchdog daemon v6

This question is a follow-up to a previous version of this program, which I wrote because I found it annoying that VLC Media Player (which I love) prevents the screensaver from starting after playback ...
5
votes
2answers
5k views

Small bash script to start and stop named services

I've been working on ubuntu since many years but not quite familiar with bash scripting. My development tools involve servers like nginx and apache, the mysql database and beanstalkd. Obviously, I ...
5
votes
1answer
118 views

Accelerate OpenGL 2D on Python3

I'm using OpenGL to draw about 20 circles. Each circle has 2 lines, ~10 segments, and all of them have different colors and lengths. Frames per Second are around 4. How can I optimize this to run ...
5
votes
2answers
951 views

TCP socket server for UNIX

I'm very new to C++, but I really want to write good code and increase my development skill, so I ask you for some review. Scheme of socket server This is the scheme of how my socket server works. ...
5
votes
1answer
270 views

First steps with amd64 assembly

I try to learn amd64 assembler. This is the first thing I tried. This piece of assembly should replicate the functionality of the following piece of C code, which turns a binary sha-256 hash into a ...
5
votes
1answer
36 views

Simple file locking wrapper command in C

A simple command that wraps another command, locking a file first. It is similar to flock, just simpler. ...
5
votes
1answer
70 views

Finding unique/obsolete binary Debian packages

I have a script I use to prune packages that have gone stale from my custom Debian repository (i.e. they no longer exists on any of the official repositories): ...
4
votes
4answers
212 views

Improving C file reading function

I am programing in C language and have created the below functions to read files. There are two functions that I can use to read files. I wanted to know how I can further improve these two in terms of ...
4
votes
2answers
397 views

Bash script to send emails when web server does not respond

I've made a simple bash script to check if a web server responds, and to send emails to a list of addresses if the website is down. Any suggestions as to how to improve it/ edge cases that I missed/ ...
4
votes
2answers
374 views

Bash CGI Upload File

I'm using the following Bash CGI to upload a file: ...