Linux is a Free (libre), Open Source, Unix-like operating system.
4
votes
1answer
32 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
f=open('file.txt', 'r')
...
15
votes
3answers
544 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)
Here is the header file (wav.h):
...
5
votes
0answers
68 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 ...
6
votes
2answers
88 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 ...
2
votes
1answer
56 views
Is this an efficient way of mounting a file-system via SSH (SSHFS)?
#!/usr/bin/python3
# Description: Python script that will mount FTP-Server via SSHFS protocol
import sys
import os
import subprocess
def mount():
#Function for mounting the networked drive
if ...
0
votes
2answers
57 views
Optimize this path location script?
Example Script is located in /home/insp/public_html/deploy/
I want to return the /home/insp/ section
$path = realpath(__DIR__);
$parts = explode('/', $path);
$newPath = array(
...
-2
votes
1answer
33 views
Listing daemons from Linux [closed]
I have this code that lists daemons from Linux. I use /proc filesystem to get the data that I want to read:
This is the file structure:
/proc/24/status
/proc/344/status
/proc/456/status
.......
...
3
votes
4answers
36 views
apt alternative for proxy environment with bash shell
As I am new to bash scripting, and want to use apt-get in my university. I know that many people have issues when trying to do so. My focus is simplicity and ease of use, but still need to be ...
2
votes
1answer
46 views
Bash to find all placeholder variables in a file and replace will real variables
I am looking to make a generic config file using variables such as:
$PLACEHOLDER_USER
Then after moving the file into the correct position I want to replace every instance of *$PLACEHOLDER_VARIABLE* ...
1
vote
1answer
70 views
Bash script to set up an ad hoc wireless network
This script creates an adhoc network using hostapd.
I have tested it and seems to work reliably.
I am new to linux networking and not sure if this is a recommended way to create an adhoc network this ...
2
votes
1answer
130 views
Moving and organizing files in download folder
This is a Python script that I use on my Android tablet. It moves the files in the download folder to a folder on the external SD card. The files are sorted based on their extensions and are moved ...
3
votes
2answers
83 views
Simple linux char driver, am I following recommended and modern idioms?
Since the resources I found to learn are generally out of date, I'm having to read a lot of documentation, which makes the learning process somewhat haphazard.
The module makes a simple character ...
4
votes
1answer
144 views
Is this CPUID parser ideal for any usage?
NOTE: I'm not perfectly sure of some of the parsed data, so any corrections are more than welcome.
Parser (cpuid.c):
#include <stdint.h>
#include <string.h>
#include "cpuid.h"
enum {
...
3
votes
1answer
204 views
Object-oriented Linux networking library
I needed to perform network communications in my Linux C++ project. I thought that it was a good idea to operate on a higher level of abstraction than raw system calls. Also I love OO design. So I'm ...
5
votes
3answers
159 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):
.data
s:
...
0
votes
0answers
86 views
Push backup script
I just wrote a little bash script for rsync push backups of my laptop to my Synology-Diskstation at home. See the code below. Since I am a bash beginner and don't have any experience with ssh, rsync ...
0
votes
0answers
70 views
How to design a robust class for Packet Capturing tool
I need to design a class for packet capture tool. Class should provide service to start and stop a dumpcap packet capture. Class should be capable of accepting all sorts of inputs which includes ...
1
vote
1answer
36 views
Input Columns with Awk
I wrote a small script to manipulate fields of a file based on the input of a user. Is there something I could've done better, or perhaps a better refactor? I do know however that I need a way to ...
2
votes
2answers
118 views
Error handling, general architecture and commenting style review
I'm writing a C++ wrapper library for sockets which will hopefully be cross-platform.
It's basically two headers: mizaru.hpp, which contains the wrapper classes themselves, and trans_layer.hpp, which ...
4
votes
3answers
204 views
Is my overall Python script design the right way to go?
So I'm relatively new to programming in general, and I've finally strapped in and started learning Python. This is my first significant project using it and I'm trying to build good habits with layout ...
2
votes
2answers
215 views
Reference counted dynamic byte array
What?
I have a reference counted dynamic byte array written in C. I'm currently using this implementation in a FIFO fashion. Particularly reading data from files into the arrays, then parsing the ...
1
vote
3answers
78 views
How to improve the computation speed of my shell script/program?
I have written a shell script to process my huge data files (each one having around 7,000,000 lines ~ a weeks data in a single file). Below is the sample of my data file (i.e., input file) structure:
...
5
votes
2answers
307 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 ...
1
vote
1answer
376 views
Functionality to read large files (> 3 GB) in chunks
Here is a function I wrote that can read chunks of large files (> 3 GB). It's designed to be used contentiously so that one can use it in a while loop until it returns EOF.
It's an early prototype ...
2
votes
2answers
324 views
Python class to abstract the iptables Linux firewall
I've written the following Python class that fetches iptables rules using basic string processing in Linux. Am I doing this in the correct manner? I've tested the code and it's running fine.
I'm ...
3
votes
1answer
185 views
How to replace duplicate files with hard links using python?
I'm a photographer and doing many backups. Over the years I found myself with a lot of hard drives. Now I bought a NAS and copied all my pictures on one 3TB raid 1 using rsync. According to my script ...
0
votes
0answers
74 views
Directory's disk usage list
For my classes i had to finish this task.
Problem 5.5 Directory's disk usage list
For indicated directory print a list of files and subdirectories in descending order according to their total disk ...
2
votes
3answers
144 views
What can I improve in my coding style?
I wrote an example program about UNIX semaphores, where a process and its child lock/unlock the same semaphore. I would appreciate your feedback about what I could improve in my C style. Generally I ...
2
votes
1answer
190 views
Simple IPSec/tunnel setup script
I've developed a script to set up an encrypted tunnel between two Linux hosts, using iproute2, ssh and setkey.
The goal is to allow setting up ad-hoc secure tunnels with minimum of setup and ...
1
vote
1answer
61 views
Bash script to manage multiple Java Development Kits installations
I'm writing a bash script to manage multiple JDKs, the script is very simple, you have to choose a directory when you store all the jdk's, and the script maintain a symlink to the current jdk'. ...
2
votes
0answers
82 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 of this function, whether there any ...
1
vote
2answers
299 views
Bash script that can uncompress: tar, gzip, rar
This code generally works exactly as it is supposed to. I'm learning bash I'm looking for some constructive help that could help me improve my work.
#!/bin/bash
usage()
{
echo "Program for ...
3
votes
1answer
183 views
lightweight packet sniffer review
This is a simple packet sniffer that turns on LEDs when there's network activity. It works by picking up filters in a configuration file and listen for activity in those filters. When there's a ...
2
votes
0answers
37 views
Accelerate OpenGL 2d on python3
I used OpenGL to draw about 20 circles. Each circle has 2 lines, ~10 segments, and all of them have different colors and lenght. FPS ~=4. How can I do this faster?
I am using Python 3 on Ubuntu
Sorry ...
-1
votes
1answer
39 views
bash file manipulation [closed]
I have files in a directory named so:
1welcome.avi
2introdution.avi
I have a rhcsa.txt file that has what these files should be named as:
rhcsa_1_welcome.avi
rhcsa_2_introduction.avi
both the ...
1
vote
3answers
188 views
Possible improvements for this small C program?
I'm learning C and today I wrote a program that displays info about my hardware on ubuntu.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch, file_name[25] = ...
1
vote
2answers
145 views
First Database Schema - How did I do?
I would really like some advice from any DB gurus who have a few minutes free. After doing some reading and playing with sqlfiddle over the weekend I have constructed this postgresql schema and it is ...
2
votes
2answers
143 views
Need some advice and feedback on my C code calling Bash functions
My intent is to use Bash functions defined in functions.sh in a C program. I am doing this so that I don't have to rewrite the Bash functionality again in C. I want to use one common library for ...
1
vote
1answer
63 views
Are these set-uid scripts/binaries secure?
I have a system that needs to be able to reboot a different piece of hardware partway through a script that programs it. It used to wait for me to come and reboot the hardware halfway through, but ...
-1
votes
1answer
257 views
Readers and writers (writers-preference). I'm not sure whether my code is wrong or not [closed]
I've found on the wikipedia pseudo-code, so I've decided to try it.
That's the Wiki's code:
int readcount, writecount; (initial value = 0)
semaphore mutex_1, mutex_2, mutex_3, w, r ; (initial value ...
5
votes
3answers
119 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 ...
4
votes
0answers
239 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 ...
2
votes
0answers
536 views
C++ TCP Socket Server for Unix
I'm very new to C++, (7 days ago I wrote "Hello World") 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 ...
1
vote
1answer
3k views
Producer-consumer in C using pthread_barrier
We're preparing for an exam at the moment, and our lecturer has given us a sample problem to work on. I have it completed, but would like to know a) If it is actually doing what it's supposed to, and ...
2
votes
1answer
112 views
Ls improved, constructive criticism
I have written a script that improves the Linux terminal experience.
This script is introduced here: http://hermannn.com/programs/aa/.
It basically displays the content of the terminals current ...
1
vote
1answer
549 views
Python pyinotify script to run in the background Linux
I want to be able to run this script in the background on a linux machine. Not really doing a program.py & but if you notice to kill the notify process I have a try & except statement that ...
4
votes
4answers
179 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 ...
1
vote
1answer
74 views
Trimming whitespace from the beginning and ending of a file
In the code below, I want to remove the "white space character" from 2 places only, from the end of 1st line and from the end of last line. How can I optimize it ?
Platform : Linux , gcc compiler
...
2
votes
0answers
177 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 ...
1
vote
3answers
1k views
Bash script to swap out, edit host files
So this is my first useful bash script. It's meant to make it easy to switch between a "work" hosts file (that blocks sites like reddit.com, youtube.com, etc.) and my normal hosts file, and also to ...