Portable code can be run with little to no modification in multiple environments. Portable applications can be run from, for example, a USB drive without modifying a computer's environment.
12
votes
3answers
804 views
Endianness conversion in C
I have written a simple C header for converting the endianness of short integers and long integers. It uses the GCC macro ...
8
votes
1answer
843 views
Guessing the JDK home directory
My project is using a specific version of JDK which is jdk-6 and the default JDK_HOME path will vary from distribution to distribution, so I wrote a script to guess it. Is there any way to do this ...
3
votes
1answer
83 views
C++ small 2D matrix class
I make a 2D matrix class (where matrix elements are of type float) which so far can:
Create a matrix of zeros of any size by typing ...
5
votes
2answers
111 views
Cross-platform file hash sum generator in Python
I'm back for more community punishment review of my own scripts and code! This time, I'm looking for general code review of my approach to a Python way of getting one or more hash sums for a provided ...
1
vote
0answers
45 views
Library for manipulation of binary protocol headers
I'm starting with implementing a TCP/IP stack for embedded systems which will be done in C++ and I've found I need a good way to work with protocol headers involved (e.g. ARP, IP, TCP). Major ...
5
votes
1answer
63 views
4
votes
1answer
52 views
Secure file system utility functions
For Khronos, I've had to develop these utility functions to help me deal with storing the .wav files. However, they could also be used in a variety of applications....
17
votes
2answers
397 views
The birth of my intelligent assistant: Khronos
I've done a lot of reworking to this main file recently, in regards to using a new speech recognition engine and integrating the last reviews suggestions. My question before is going to be phrased ...
8
votes
1answer
132 views
2
votes
2answers
457 views
Portable periodic/one-shot timer thread - follow-up
This is a much improved version (I hope) of code in this previous code review of mine.
I have:
renamed several things. Are the names good?
made it lazily start the worker thread only after the first ...
3
votes
1answer
73 views
Reverse Polish notation calculator similar to dc on Unix/Linux systems using dynamic libraries
This problem is using dynamic libraries so that additional calculator functions can be added by dropping a library into a specific directory.
What I'd like to get out of this code review is:
What do ...
7
votes
2answers
80 views
Portable byte order conversion
I'm trying to improve the portability of a file format converter, specifically to POSIX platforms other than Linux. I'd appreciate a review of the following functions used for converting between ...
3
votes
2answers
50 views
Constraining stdin in Python, v2.0
Rags, again.
This is the rewrite of Read stdin like a dictator.
From that post:
All too often I find myself wanting to allow only a certain list of characters to be written to stdin, and only ...
3
votes
2answers
332 views
Timestamp function with millisecond precision
I want to be able to print timestamps with milliseconds precision and time_t doesn't provide this. I also want the code to be portable, so operating specific ...
0
votes
2answers
60 views
3
votes
1answer
68 views
Non-curses pager in C (revision 2)
In this revision (follow-up of this post) I've fixed reading from stdin, and also tried to minimise the damage caused by typing additional characters. You might want to see my original post on this.
<...
1
vote
0answers
45 views
Check if page was scrolled all the way to the end
I am not sure if this is the best way of doing this or if it works in all situations.
...
5
votes
1answer
37 views
Pseudoportable C script pattern - follow-up
See the initial/previous iteration.
I have rewritten the script following the answer of @200_success.
Now it looks like this:
...
5
votes
1answer
64 views
Pseudoportable C script pattern
(See the next iteration.)
From time to time, while working with a command line in *nix family of operating systems, we have to write those scripts doing a rather specific task. Usually we use ...
0
votes
1answer
58 views
Print a “shebang” line, or prepend it to a file
This is a sort-of-useless "utility" I wrote to learn my way around shell programming better.
My concerns are:
Is the code readable? Could it be more efficient, or just simpler? The logic ends up ...
2
votes
2answers
292 views
Colored <hr> in emails
Sometimes, I need to change the color of <hr> elements in an email.
The only achieveable way is by using CSS. But not every email client supports CSS. Most ...
7
votes
2answers
60 views
Printing the days of the week for every day this year
@chux pointed out that my attempted solution contained several problems. Since I screwed that up so badly, I figure that I should put my revised solution up for review.
...
15
votes
1answer
154 views
Khronos: Primary CMake file
So recently I made a large project of mine open source: Khronos. I will be dissecting parts of it so that I can have it reviewed more easily here and so that the project as a whole will be improved. ...
6
votes
1answer
333 views
ANSI colors cross platform
I am trying to write for both NT and POSIX (my two usual platforms) and have come up with the code below. The clrs code I refer to is apparently from blender build ...
3
votes
1answer
93 views
Userscript hiding boxes on LinkedIn
When looking at people you may know on LinkedIn (requires you to be logged in) there are sometimes some annoying boxes that are for people who are email contacts but not on LinkedIn. I don't want to ...
11
votes
2answers
528 views
jQuery plugin that makes a slider out of an <ul> list
This is one of my very first jQuery plugins. In short: it makes a slider out of an <ul> list filled with <li> items ...
6
votes
3answers
201 views
Cross-platform performance and statistical information script
My usual disclaimer, I'm new to Python and scripting and I'm still studying the PEP8 guide, so please forgive any huge failures with respect to syntax, formatting and style. I'm open to any ...
8
votes
1answer
162 views
Looping until browser document is ready
I made a do...while loop in order to wait for the web browser to load completely in order to enter username and password. I don't know whether this impacts the ...
2
votes
3answers
162 views
Simple and safe file reader for C
As an exercise to improve my coding ability in C, I have attempted to write a simple and safe file reader. I believe this should be portable as well to major platforms (correct me if I'm wrong). For ...
3
votes
3answers
3k views
Unix shell function for adding directories to PATH
Adding a directory to the PATH in Unix/Linux is a very common task. However, what if the directory is already in the path? My goal is to write a shell function (...
3
votes
3answers
612 views
More portable toLower() implementation
I am challenging myself to try to attempt to write a function that is as efficient, portable and failsafe as possible. The function is very simple and just converts a ...
0
votes
3answers
71 views
Data-entry keypads for entering addresses
This was a little app I wrote looking for a way to create consistency in the way employees taking phone orders enter the address.
The purpose of the app is to require a user to enter a valid address....
8
votes
2answers
1k views
Speed optimization for block XOR
In code I'm currently maintaining, there is a need to do very many repeated XOR operations of blocks of memory. The block size in my case is always 16 bytes. Because the code is executed very ...
1
vote
1answer
188 views
Load stylesheet for “rem” value fallback to “px”
I'm applying fallbacks to rem values only if required (you know, the whole progressive enhancement train), without conditional comments (because it's not just an IE ...
8
votes
2answers
125 views
Making multiple copies of a pattern
Here's a function for making multiple copies of a block of memory in another block of memory. It handles the case when the size of the target is smaller than or not a perfect multiple of the source ...
6
votes
2answers
94 views
Inferring Memory Alignment
The following code is intended to infer the alignment of double.
My questions include:
Is there a better to do this? Either by refining the code or using an ...
2
votes
2answers
1k views
Preventing XSS attacks with proper escaping
The following page simulates XSS attacks and successfully (?) prevents them. I want to know if I've missed any other major attack vectors (or small ones) and/or if anyone has suggestions as to ...
7
votes
1answer
2k views
Restricting user to one open tab in browser
I had a requirement to restrict my web site's users to just one open tab in the browser. I am aware that this is not the best thing to do in terms of general user experience guidelines but its an ...
5
votes
1answer
284 views
Vertical-align in Nested Column
Requirements:
There are two columns. The left column is fixed width.
The height of two Column should be the same.
Left column contain a title (can be multi-line) and an Image (limit max width to ...
3
votes
1answer
106 views
Parsing OS names
I am making a function to return a two-item tuple of ('os basename', 'os distro'). For instance, the return for Vista should be ...
6
votes
1answer
279 views
Program that replicates itself
While misreading the beginning of Stage I of this classic paper by Ken Thompson, I decided to create program that replicates itself.
Let's say this program is called Replicator.exe. Upon running it ...
-1
votes
2answers
228 views
A platform-independent implementation of “which” in Ruby
I like to know if there's anything that I may have missed in this implementation. The method tries to provide the absolute path of the binary or script which is likely to execute based on the provided ...
4
votes
1answer
92 views
Pathname matching and listing program
This Python 3 program outputs a list of all pathnames in the filesystem
that match a list of rules taken from a file. You can add and remove
sets of pathnames.
The original purpose was to generate ...
4
votes
2answers
200 views
JavaScript parallax cross-platform efficiency
I wanted to get some feedback on this JS I am working on. It works wonderfully on my desktop, but on my and my friends' laptops (especially Safari) it is very slow. I need some pointers on improving ...
9
votes
1answer
430 views
Recording audio in C 2.0
I posted my audio recording program to Code Review before, and received a stern review along with the other reviews that caused me to rewrite the entire code base. Here is what I would like reviewed:
...
16
votes
2answers
20k views
Windows keylogger in C
I have had this keylogger code for a while now (a few years*), and I figured I would put it up for review. Here is what I would like reviewed (in order):
Portability - right now, this program can ...
5
votes
2answers
219 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 ...
4
votes
3answers
4k views
Checking endianness at compile-time
I've tried to make a portable way of ensuring endian-specific code gets generated at compile time using C++11, however I only have a computer with Windows on it to test at the moment. Because of this, ...
8
votes
1answer
369 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.
...
15
votes
1answer
1k views
Brainfuck-to-C compiler written in C++
This compiler, implemented in C++, takes brainfuck code and produces a valid (but still obfuscated) C program, which in turn can be compiled to a native binary.
Expected usage is as follows:
Build ...