Linux is a Free (libre), Open Source, Unix-like operating system.
1
vote
1answer
35 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
54 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
73 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
0answers
113 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 {
...
1
vote
0answers
119 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 ...
4
votes
1answer
92 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
61 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
52 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
30 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
111 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
178 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 ...
1
vote
3answers
142 views
Reference counted dynamic byte array in C
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
74 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:
...
1
vote
1answer
237 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
221 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
123 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
57 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
139 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
137 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
56 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
63 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
224 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 ...
2
votes
1answer
161 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
35 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
37 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
177 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
130 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
129 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 ...
17
votes
5answers
3k views
Naive C++ Matrix Multiplication 100 times slower than BLAS?
I am taking a look at large matrix multiplication and ran the following experiment to form a baseline test:
Randomly generate two 4096x4096 matrixes X, Y from std normal (0 mean, 1 stddev).
Z = X*Y
...
1
vote
1answer
56 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
167 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
109 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 ...
2
votes
0answers
215 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
514 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
2k 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
477 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 ...
3
votes
4answers
148 views
Improving file reading
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
73 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
165 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 ...
2
votes
2answers
83 views
How to improve the way I handle greping in this script
What my script does is:
Append data to a file on a continuous basis.
If an error pattern is observed, then do something.
I need feedback on the way I am grepping for patterns in the continuously ...
4
votes
2answers
228 views
Suggestions needed to improve my code ( bash script)
I wrote a bash script to print contents of files in a given directory in a loop. I kindly need suggestions mainly on the following aspect:
How can I improve command line parameters handling to the ...
4
votes
3answers
2k views
Linux C++ Timer Class: How can I improve the accuracy?
I wrote this class today, but I am trying to figure out how to make it more accurate. I pass in seconds and multiply by 1000 to make it milliseconds and the time does not line up. I need the ability ...
1
vote
2answers
375 views
Correct User Input - x86 Linux Assembly [closed]
So I am working on an x86 Assembly program for Linux using NASM. This program basically asks the user for their name and their favorite color. After doing this and storing the two strings in variables ...
2
votes
0answers
578 views
mutex and condition variable implementation using futex
I have implemented mutex and contition variables using futex syscall. I believe that my implementation is correct, but would like it to be verified by some one else. If some of you could verify its ...