Consider the following code which uses the ability to intersect types, which was added in Java 8:
private <E, T extends List<E> & RandomAccess> void takeList(T list) {
}
private void fakingRandomAccess() {
List<Integer> linkedList = new LinkedList<>();
takeList((List<Integer> & RandomA...
I have spent a few hours on this code, but think it could be improved a bit. It requires eSpeak to be installed to run the speech synthesis, but the voice can be toggled on or off using the togglevoice command. This was created for python 2.7.3. My major concerns are the fluctuations of the use o...
is there another stackexchange outlet I should be asking this in? Im really just trying to gain the basic concept of this OOJS stuff and would love it if I could see how someone with advanced jquery/js skills would approach the module I have included — user262600920 mins ago
@konijn The idea is that 100% of users have 1 rep or more, and x% have 10k rep or more etc. This is not good for making pie charts, but is much more common when analysing wealth distributions
Graduation does five things for you, mechanically speaking.
Reputation privilege tables are changed. That answer really explains it so I don't need to go further. Given the rep distribution at current, this is actually somewhat negative since you have a pretty tiny fraction of 5% that surpasses...
I am a high school intern, and I am trying to parse my mentor's code so that he can read in an xml file and call simple methods to edit or get information from his xml file.
I was hoping someone could provide me with some (any) feedback - ways to optimize the code perhaps?
The XML file that my...
I am a high school intern, and I am trying to parse my mentor's code so that he can read in an XML file and call simple methods to edit or get information from his XML file.
I was hoping someone could provide me with some (any) feedback - ways to optimize the code perhaps?
The XML file that my...
I'm trying to implement interfaces in my design but not sure if this is correct or if there is a better way to do it.
What I need to do is
1 - open a text file
2 - keep searching blocks of text until I find a string that matches against one of the classes that defines that string pattern
3 -...
I've built this small jQuery plugin to work with HTML5 History State functions. It's my first jQuery plugin, so I'm not sure if it's up to the best practices, or what could be done better. Keeping it simple and small is my main concern.
If you have any suggestions on how to improve it, I'd love ...
I'm unable to follow this code from C Pine book, ch8 on methods. I'm sure this is as clear as day, except I can't get it. In the comments I try to follow the code and indicate the place at the very begging where I get stuck and can't understand the code.
def englishNumber number
# We only w...
I wrote this script for a code challenge on TreeHouse. I already submitted my code, but I am looking for an after the fact feedback.
The challenge was to open a file of text, remove specific words (provided in another file) and do the following:
Output to the screen in a readable fashion
1...
I have a GUI that contains a Table Object (for displaying columns of data) and a Table Model. The Table Object contains the Table Model.
Is it better to store the Table Model as a object in the User interface or de-reference it as needed? Is there any performance gain keeping it separate? If ...
Is there a better way to handle this ClassNotFoundException ?
private Class<?> getClass(String value)
{
Class<?> columnClass = null;
try
{
columnClass = Class.forName(StringUtils.trim(value));
}
catch (ClassNotFoundException ex)
{...
Every once in a blue moon, a question gets posted (often as a new user's first post) where the OP is asking a quite specific question about very minimalistic code, for example:
if (strstr($url, "?")) {
$url = strstr($url, "?", true);
}
There is something to say about this code, of course....
Obviously related to this, but I want to know the opposite. How short is too short? For example this doesn't seem long enough to be appropriate for a code review:
Highlight input if empty
The entire code sample:
/* highlight input, if it is empty */
$(function() {
var highlight_if_no_val=f...
I'm trying to build as stated in the title an app which crawls a website to find the emails that it has and then I want to print them. Also I want to allow the user to type in the console false when they want to skip the website ( maybe he already found 2 emails and he doesn't need any more).
Is...
This is my second jQuery script: a universal tooltip for my entire web page. It took me a couple of days to research and make it work... i'm so proud :)
Now, I need help from the experts to optimize my newbie code :)
This is one of the ways i can show the tooltip.
<a class="tooltip" data-toolt...
@rolfl's answer summarizes a meta-debate, and @konijn's answer summarizes the summarization by providing a to-the-point demonstration of why these questions are on-topic.
I have been trying various formats of namespaces and modules patterns, however I have not come across a solution that I would use for all my projects.
I've been developing the following, that would allow me to separate my application through applications, modules, functions and global variables....
Two trees are called isomorphic if one of them can be obtained from other by a series of flips, i.e. by swapping left and right children of a number of nodes. Any number of nodes at any level can have their children swapped.
Looking for code-review, optimizations and best practices
This...
As a general comment, your code has improved significantly in the last few months. It is to your benefit for multiple reasons.... the 'easy' things to review have gone (code style, variable names, etc.) and the core logic is much more readable. Reviewing your work is harder now because the easy t...
So I just jumped to a new project, which uses activerecord pattern. It's a subscription service website.
I have the following User object that extends a framework specific ORM object.
class User extends ORM {
public function isSubscriber()
{
$activeSubscription = $this->subs...
I have a class created for the sole purpose is to help handle files.
The class holds a path(folder) that contains a single file at a time. Some extra properties to this class are: age of a file and max file size. I'm a very procedural style coder, and I'm trying to shift my work to a more OOP and...