Hot answers tagged

16 votes
Accepted

Pluggin' in Plugins

I think surely there must be a way to avoid so many ugly looking else statements. Return early, for example: ...
user avatar
  • 24.9k
15 votes

Pluggin' in Plugins

I'm aware of return early but the opportunity is unfortunately quite rare Two levels removed as @tim's suggestions, it's quite significant. With his other suggestions applied too, the whole thing ...
user avatar
  • 107k
8 votes
Accepted

Responsive text by JavaScript

Thoughts: Variable names: I hate typing unnecessary text as much as the next dev, but variable names are not a good place to skimp. It's one thing when using i as an index variable, for example, but ...
user avatar
8 votes
Accepted

Voting plugin for an IRC bot

Grumble, grumble. Browser tab crashed and SO didn't save my draft apparently. I'll try to recreate everything I remember writing: First off, your question is fantastically written. Often one of the ...
user avatar
7 votes

Showing a list of plugins to filter

Early Return You can return early to reduce the nesting of your if statements: if (plugins.isEmpty()) { plugin = null; return; } Also note that I ...
user avatar
  • 24.9k
7 votes

jQuery plugin to cycle through text and "typewrite" it out

The API design is rather weird. You expect your plugin to be called like $().typeText({ selector: '.words' }) But a design like this would be much more natural ...
user avatar
6 votes

Monitoring params via JMX

Stylistic (Always assuming this is not garbled by the pasting) there is inconsistent indentation in some places, parameter lists sometimes have spaces, sometimes they don't and the names aren't that ...
user avatar
  • 11k
6 votes
Accepted

Calculating areas of map features

You can greatly simplify this code by introducing a helper function that calculates the area_score for one of the categories. Let's take the first category as an ...
user avatar
  • 40.6k
6 votes
Accepted

Update GIS Project by matching files from directory with files already loaded and apply relevant symbology

Wow. That's a lot of code. The very first thing that needs to be done with it is modularization. You need to structure your code such that named functions and/or classes encapsulate shared ...
user avatar
  • 7,673
6 votes
Accepted

NRPE script for monitoring load average

This looks pretty good. Some suggestions: [[ is preferred over [ in Bash. This script could benefit from ...
user avatar
  • 8,737
5 votes

Responsive text by JavaScript

something that I would definitely do on the next iteration, before this code gets too big, is to make the variables meaningful. I can't take a quick look at this and tell you that I know what it is ...
user avatar
  • 28.5k
5 votes
Accepted

jQuery Datepicker Plugin

One thing that caught my attention: // Check for Leap Year if (parseInt($yearElement.val(), 10) % 4 === 0) { I reckon you know that ...
user avatar
5 votes
Accepted

jQuery carousel plugin

From a once over; Very well commented Assigning element to element is overkill here and does nothing: ...
user avatar
  • 32.7k
5 votes

jQuery plugin that makes a slider out of an <ul> list

One thing that jumps out to me is locking your plugin to one element: ...
user avatar
  • 567
5 votes

Sublime Text plugin to modify text before it's pasted

If your intention is to escape certain characters by prefixing them with backslashes, you would be better off with a function that performs that specific task, rather than a generalized function that ...
user avatar
4 votes
Accepted

Plugin for communication protocols in browser(s)

Interesting question, 2 upfront general notes first: Run your code through JsHint.com, there are a ton of little things you could fix Run your code through a beautifier, there are a ton of ...
user avatar
  • 32.7k
4 votes

Scanning a directory for plugins and loading them

Since you seem to be using Python 3, you could use the new pathlib module from Python 3.4 to have a Path object. Since paths ...
user avatar
  • 19.9k
4 votes
Accepted

Scanning a directory for plugins and loading them

I started a project with a structure similar to the one you detailed: My first order of business was to move the import plugins out of the ...
user avatar
  • 2,794
4 votes
Accepted

Metalsmith plugin for stripping UTF8 BOM from files

As @konijn said in the comments, it looks pretty OK, though I do have some comments. I don't know anything about Metalsmith specifically, so it'll just be more general JS/Node comments. Firstly, it ...
user avatar
  • 32.9k
4 votes

Animating a block of HTML on scroll

When you have multiple conditions on the same value, then you should chain the conditions using else if. For example in most in most of the conditions on ...
user avatar
  • 107k
4 votes

Animating a block of HTML on scroll

loadValues() is rather problematic. It checks for each possible data-attribute and if present overrides the value in settings. These repeated checks are just ...
user avatar
  • 2,064
4 votes

jQuery plugin that makes a slider out of an <ul> list

I saw something that could make your code more dry... ...
user avatar
  • 28.5k
4 votes

jQuery plugin to cycle through text and "typewrite" it out

...
user avatar
  • 13.2k
4 votes
Accepted

Bash plugin to setup project for books

Single responsibility principle The input validating functions do two things: Read input (when invoked without parameters) Validate input It would be better to make a function do just one thing ...
user avatar
  • 107k
4 votes
Accepted

Reduce list manipulation for QGIS layer tree

Your lists manipulations are indeed messy. It seems like you are trying to perform multiple things at once and thus you end up mixing variables that serve different purposes into the same loops. ...
user avatar
3 votes

Monitoring params via JMX

First impressions can make a huge impact when assessing someone's code. Let's look at your Main class: ...
user avatar
  • 96.8k
3 votes

Showing a list of plugins to filter

A few things that are jumping me here, though it might get a little harsh :( @NotNull @DataModel("plugins") List<Plugin> plugins; This one is smelly, ...
user avatar
  • 25k
3 votes

Scanning a directory for plugins and loading them

After several more tries, I came up with a solution with some advantages: slightly simpler, using __import__ instead of the imp ...
user avatar
  • 107k
3 votes

Small jQuery mobile plugin to handle touch events

Architecture Right away, something jumps out at me about the overall architecture. You have written this as a jQuery plugin, but it hardly relies on jQuery at all. On the user's end of things, it has ...
user avatar
  • 4,531
3 votes
Accepted

Small jQuery mobile plugin to handle touch events

Interesting plugin, some observations: Use JsHint, there are a ton of minor issues with this code that you should clean up Use JsBeautifier, there is quite a bit of inconsistent formatting ...
user avatar
  • 32.7k

Only top scored, non community-wiki answers of a minimum length are eligible