I would like to revise the fundamentals of Java Threads on Pre-Java5 world , so that i can further appreciate + understand improvements brought forward in Java 6 and beyond.
I started of with a Custom collection
I would need help on :
Things i am doing wrong / grossly overlooking
How to make...
@Jamal Your version looks way better. Roll it back and leave a comment, and if he undoes it I think that could be grounds for a super-ping so we can correct him.
@Jamal I didn't see anything important removed. I'll double check.
@Jamal Improvements on the comment?
Please don't revoke edits on your posts unless they vandalize it in some way. The past edit you undid was more easier to read and understand, which can possibly reduce review time. For the sake of quality, I'm rolling back to that edit. — syb0rg1 min ago
basically, i googled around for secure random number generation and random string generation, combined them with some user data. is this good or am i totally offbase. I don't know much about cryptography but i do not see much alternative, other than some bad code that gets copied around alot with...
The code displays a video that will play a video and then display some text on the screen at specific locations on the video screen.
The code works but I would like to see if I could change somethings to make it better and how I would do that. You should be able to just copy the code into a web ...
I wrote the following Python program, which reads text files as mazes and displays the solution with a trail of Xs. The files must have an S for the start and an E for the end, and the walls must be +s, with everything else an empty space (or line break).
The basic algorithm is this:
The maz...
Before I answer, I wonder how many programmers really understand the importance of code reviews in the lifecycle of software construction. It was not until I read this blog post that I realized the impressive evidence showing that code reviews significantly reduce bugs.
Doing code reviews saves ...
@syb0rg: I have updated my answer here. I've implemented my own program based on it, and since I don't have a C compiler with me, I had to test it on a C++ compiler with some changes first. Could anything be said about it?
It looks a little weird to have newlines between the function statement and body since they're associated with each other.
If case_letters() is just supposed to print something at the end, it should return void, not int. main() isn't doing anything else after calling the function.
Unformatted o...
I've just finished my fist iteration on a type inference and basic reflection library for C++, which is part of a small game engine I'm writing on my spare time. It features type instantiation by name/id and runtime type inference for classes that register with the system.
I'd appreciate to have ...
Scrape results from thefreedictionary.com
#!/usr/bin/python
from bs4 import BeautifulSoup as bs
import re
from requests import get
def remove_non_ascii(text):
return re.sub(r'[^\x00-\x7F]+', '', text)
def get_soup(url):
raw = remove_non_ascii(get(url).content)
soup = bs(raw)
...
I just started getting into the Less CSS framework and I am wondering if I'm doing it right and how the code can be improved if possible.
global.less
@themeRed: #cc1111;
@themeColor: @themeRed;
@marginBottom: 10px;
@contentRadius: 5px;
body {
font: 12px Arial;
color: #333;
backgrou...
I decided to try simple brute force, and it worked surprisingly quickly. Here's my code:
"""Considering quadratics of the form:
n^2 + an + b, where |a| < 1000 and |b| < 1000
Find the product of the coefficients, a and b,
for the quadratic expression that produces
the maximum number of primes f...
I realized that the spiral was essentially an arithmetic sequence, so I based my code off of that. Any suggestions would be greatly appreciated!
from timeit import default_timer as timer
start = timer()
def spiral_diag_sum(n):
if n < 1: return None
elif n == 1: return 1
elif n % 2 =...
I'm trying to find the best - read: readable, maintainable, robust, threadsafe, usable - solution for a State Machine in python.
For this I've been looking at the State Design Pattern. However I want a pythonic and lean solution (saying not implementing functions in subclasses that are not needed...
Background
I have a base (only 2 classes inherit from it, and only from it) abstract (meaning I don't want it to be used directly) class that implements some common functionality.
Some of it depends on certain methods being defined, methods whose implementation differs per the exact sub-class; ...
@YatharthROCK: Regarding your question: What happens if you don't have the functions defined and want to use them? There should be an error? Does your code deliver a better error?
Althought in hind-sight, I realize that not implementing them would cause an error anyways as the mthods would hopelessly try to look for the missing ones.
@Nobody: Actually, I had some static methods in the top class which were named similarly to the methods in question; which is probably why I, in a frenzy, added those lines.
I agree that I should just let the missing methods error uot naturally.
Rubber duck debugging, rubber ducking, and the rubber duckie test are informal terms used in software engineering to refer to a method of debugging code. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug his code by forcing himself to explain it, line-by-line, to the duck.
Many programmers have had the experience of explaining a programming problem to someone else, possibly even to someone who knows nothing about programming, and then hitting upon the solution in the process of explaining the problem. I...
I'm not going to explain the purpose of the code provided below. If you do not understand it, i know that i have to improve it (naming, structure etc.).
I would like to know how to improve this code in terms of readability and complexity.
Data structure:
<?xml version="1.0" encoding="utf-8"?>
<...
This question is a revision of Parallel sieve of Eratosthenes. The goal is to implement a sieve of Eratosthenes with parallel strikes out from the boolean array. I tried to fix the data races and all the threading-related errors as well as to add some of the ideas from the previous thread. Now, t...
Im a beginner to Model-View-Presenter pattern and Im finding a way to use it in a sample application
In my C# winforms application has a Employee Class and it has properties like EmployeeID,Name, Address, Designation etc. Also it has behaviors like viewEmployee(), AddNewEmployee(), PromoteEmploy...
This is my first question!
It started out with my answer to Radix Sort on an Array of Strings?. Since I intend to write a generic radix sort for my own purposes anyway, I continued a little bit, and here is a version tested on:
a fixed std::array of unsigned numbers, each treated as a fixed se...
I've brute forced solve Project Euler 14. This is my first attempt at trying to solve it, by caching already solved answers, and skipping them as I run it, I ham finding the program take's almost twice as long as the simple brute force method of checking each number.
I could also use some insigh...
I'm very much on the beginner end of the PHP scale but I have read plenty of the entry level books and completed the online training at teamtreehouse.com so I know the basics.
I'm at a point where I've built a tax calculator in PHP (UK income tax) and it works and is accurate but I have no clue ...
I'm not sure what you're intending to do with this class so I can only offer some general tips.
Make private variables private:
def __init__(self, url):
self._url = url
Use properties instead of get_ methods. For example:
@property
def request(self):
return self._requests.get(self._u...
This is my first solo project as part of my college course and I'm not sure about the quality of my code. Could someone take a quick review of this class to suggest improvements or practices I should be incorporating into my coding?
I tried to tidy up the code by dividing it up into regions and ...
In a CCG, is it neccessary that the best most powerful monsters need to be weak at some point to maintain balance? Or would it be completely fine to have a few very powerful monsters around
First, please pardon my ignorance. This is my very first Python program.
Also, please forgive the cross-posting. I was advised to post again here.
I retrieved Bloomberg data using the Excel API. In the typical fashion, the first row contains tickers in every fourth column, and the second ro...
Does anyone happen to know the Java concensus on value-based classes vs subclasses? For the CCG I'm going to design a class called `Card`, and it there exist two sub-identities, namely a monster card and a fusion card. Should it be an enum value or a subclass?
I guess it's applicable to all OOP languages actually
What about deciding what to do with a certain type of card? Should they still have some public enum available so you can resort to switch-statements over ugly instance-of if-else-blocks.. I think the latter might be worth it