Questions tagged [reinventing-the-wheel]

For when you know you are reinventing the wheel, but are doing it anyways. Questions with this tag involve code that is already fully implemented (such as from a library).

Filter by
Sorted by
Tagged with
5
votes
1answer
899 views

Lock-free producer/consumer implementation

I know of BlockingCollection in .net, but this is rather for my understanding of the pattern. Is this implementation correct ? Consumer ...
7
votes
2answers
17k views

Find whether a given number is a perfect square or not

I am trying to find whether a given number is a perfect square or not by using just addition and subtraction. Please review my code. ...
7
votes
1answer
13k views

memcpy() implementation

I have tried to write a function like memcpy. It copies sizeof(long) bytes at a time. What surprised me is how inefficient it ...
11
votes
3answers
12k views

Bubble sort algorithm in Python

I'm starting to implement basic sorting algorithms. Criticisms on the implementation is welcome. ...
5
votes
2answers
5k views

AES CTR mode using pycrypto

I've implemented CTR mode by myself (only decryption for now), using only AES built-in functions from pycrypto. It means that I'm not supposed to use mode=AES.MODE_CTR. However, I know that using AES....
2
votes
1answer
73 views

A class for dynamic inputs

This class creates dynamic input labels. You give it a pair of elements and it sets up the event listeners and CSS toggles to accomplish this. Looking for feedback on code structure and correctness. ...
3
votes
2answers
2k views

Find power of a number

Looking for optimization, smart tips and verification of complexity: O (log (base 2) power). NOTE: System.out.println("Expected 16, Actual: " + Power.pow(2, 7)); ...
6
votes
5answers
17k views

Finding index of first substring

I wrote this function to find the index of the first substring. I was wondering if you can help me find some flaws or possibly help increase performance? Example: str = "happy" substr = "app" ...
3
votes
1answer
266 views

Removing a link from a linked list

I have written a method for removing a link from a linked list for a phonebook project I'm currently working on and it works perfectly. However, I want to know whether or not my code is acceptable ...
13
votes
3answers
10k views

Python implementation of SHA1

Here is a implementation of the cryptographic hash function SHA1 written in Python. It does not use any external libraries, only built-in functions. I know that it would be faster to use an external ...
21
votes
2answers
38k views

Generic DAO written in Java

I initially thought that this was just an architecture issue so I placed it on programmers as Thoughts on refactoring a generic DAO. Then I asked on codereview meta here and decided to put up the code ...
9
votes
3answers
24k views

Binary search for inserting in array

I have written a method that uses binary search to insert a value into an array. It is working, but i would like to get a second opinion to see if i didn't write too much code for it. aka doing same ...
11
votes
1answer
542 views

C++ linq-like library

I want to implement something like C# Linq in C++ Currently only select and where is implemented, but others should be fairly ...
5
votes
1answer
770 views

Regex parser - request for review and optimization

The whole question is Simplified regular expression engine. I have solved the question, and in turn felt the need to get it reviewed. Any suggestions for clean up and optimization would help. Also ...
3
votes
1answer
4k views

Function equivalent to strcmp()

I'm starting out and need feedback in order to discover the things I'm doing wrong. This is supposed to behave like strcmp(): ...
7
votes
3answers
28k views

Day counter between two dates

I wrote this little program, but I'm not sure if it's properly written. Actually, it can't handle leap years (every year is 365 days long) and you have to write the earlier date before. It seems to ...
4
votes
1answer
466 views

Yet another shared pointer

What might be wrong with this shared pointer? One good point of it might be, that it should handle array types correctly by default (e.g. ...
6
votes
2answers
20k views

Template vector class

I am trying to implement a vector-like container of my own (just to gain a better understanding of how std::vector works under the hood). I've been using this as a ...
7
votes
3answers
338 views

Mimicking the basic interface of std::stack

I am trying to mimic std::stack in my implementation (just the basic interface - no iterators / allocators). Since I was having trouble handling all the memory ...
5
votes
2answers
3k views

Reading and parsing CSV files

This is my first real attempt at a Scala program. I come from a predominantly Java background, so I'd like to know if the program sticks to Scala conventions well. Is it well readable or should it ...
5
votes
2answers
6k views

HMAC-SHA1 implementation

I am trying out a small piece of code that would generate HMAC-SHA1. I have been asked to code the HMAC implementation myself using the OpenSSL libs for SHA1 calculation. After 'wiki'ing for the ...
8
votes
1answer
687 views

Python reversed in C++11

I was playing with some of the wonderful new C++11 features and tried to reimplement a function reversed that would behave just like the one in Python to allow ...
11
votes
2answers
2k views

Custom nullptr_t class

I tried to write a nullptr_t class based on the official proposal to be used in C++03 only. The only differences with the proposal are that we can compare two ...
5
votes
4answers
7k views

C getline function

I was looking for a C function that reads lines of arbitrary length from a file. I didn't find anything absolutely portable and safe from buffer overflows, so I tried writing my own. Does it look ...
5
votes
4answers
8k views

Optimizing a thread safe Java NIO / Serialization / FIFO Queue

I've written a thread safe, persistent FIFO for Serializable items. The reason for reinventing the wheel is that we simply can't afford any third party dependencies ...
4
votes
1answer
1k views

Iterator and Generator versions of Python's range()

I have created iterator and generator versions of Python's range(): Generator version ...
1
vote
1answer
3k views

My own implementation of Linq SelectMany extension method

What do you think of my own implementation of the extension method SelectMany? Motivating criticism is always welcome. ...
8
votes
2answers
35k views

Generating all combinations and permutations of a set of symbols

I am new to Python and want to have a "pythonic" coding style from the very beginning. Following is a piece of codes I wrote to generate all combinations and permutations of a set of symbols, e.g. <...
4
votes
2answers
2k views

Rounding a date to a dynamic unit of time, using only JDK 6

Question originally posted on Stack Overflow here. I'm trying to do an elegant round method that only use the JDK methods and leverage the TimeUnit class of that ...
7
votes
3answers
22k views

Splitting a string into tokens in C

I am trying to improve my skill in C, and this time by getting away from strtok. The following code splits the input string into ...
5
votes
4answers
331 views

Is this a good implementation of a simple "Size" value type

I have created the value type below to represent the desired size for an image. The Size.Default is used in situations where the image is required in the size it ...
2
votes
1answer
4k views

Determine total number of seconds since the epoch

I am looking for ways to enhance this function in C++. The function gets a date and returns the total number of seconds since the epoch (01/01/1970). Do you have any suggestion regarding the ...
9
votes
3answers
42k views

Converting int value to String without using toString and parseInt method

I am studying about the converting int to string and string to int without using toString and parseInt method. I already made ...
4
votes
1answer
3k views

Monkeypatching builtin open and File Mock-Up for unit testing

For a specific test-scenario I wanted: avoid accessing the file system through pythons builtin open-function don't want to use 3rd party libraries like Michael ...
11
votes
4answers
7k views

My own SHA-256 code implementation

I'm worried about my code performance. The code I've written is an implementation of SHA-256 using pseudocode from Wikipedia. It works fine, but I want to speed it up. With a buffer of 4096 bytes, I ...
5
votes
1answer
4k views

Implementation of the atof() function

I am looking for feedback on coding style. I know this function already exists, and I would never use my version over a well tested one. I am just practicing. ...
1
vote
1answer
2k views

Shared Pointer implementation

Before you say anything: Due to project constraints, we cannot use Boost and we cannot use C++11 (yet; perhaps this will change some day). The fact that I was unable to use smart pointers was nagging ...
4
votes
2answers
271 views

Optimizing error-sorting method

I just made this sort method. It runs fine and the code looks okay in my eyes. Is is possible to optimize it so it runs faster? If it's \$O(n^3)\$ now, it would be interesting changing it to \$O(n^2)...
7
votes
2answers
8k views

Implementation of itoa()

How can this solution be improved? ...
15
votes
5answers
20k views

Sine function in C / C++

Due to software constraints, I cannot use the standard libraries, cmath, algorithm, templates, inline, or boost. I am also using ...
3
votes
2answers
586 views

Matlab any function in C / C++

Due to software constraints, I cannot use the standard libraries, math.h, algorithm, templates, inline, or boost. I am also ...
13
votes
3answers
24k views

Min / Max function of 1D array in C / C++

Due to software constraints, I cannot use the standard libraries, <math.h>, <algorithm>, templates, ...
6
votes
2answers
11k views

Parsing JSON with JavaScript

I need to write some JavaScript code that will take a JSON string, parse it, and return the names of the most-deeply nested properties. For example, for this input: ...
12
votes
3answers
2k views

My own C++ Format function

I've never been satisfied with any of the possible sprintf()-like functions in C++: sprintf() is a C function and it's very ...
5
votes
3answers
942 views

Quicksort application

What do you think about this code? ...

1
14 15 16 17
18