I've written a DNS tool in Node and would like to know if there's a better and more efficient way of handling the conversion from an IP to a long. I'm not too good at bitwise just yet and would like to hear any suggestions. Psuedo-code has been provided below.
var _parse = function (ip) {
var ...
I have designed a database for my institute. Here I have attached my design for better understanding.
So I am expecting your reviews who are professional for the database design.
Thank you.
Any JavaScript people in here? Been ages since I've written a JS review, so I'm hoping someone can glance over this and let me know if I've gone crazy: codereview.stackexchange.com/a/54779/7308
@Corbin for the most part it's a great answer, but there are a few things I don't agree with
for one thing, -1 >>> 0 != -1
the other thing is subjective, but the node style guide is just something some guy wrote, I wouldn't take it too seriously. I don't agree with a lot of Crockford's ideas about good style, but one thing I do agree with is declaring variables at the top of a scope, for the reason he mentions
> JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages. Define all variables at the top of the function.
since it's such a subjective thing I don't know if I'd mention it at all (although I've mentioned it in reviews also)
everything else looks good
fwiw, my personal style of var declaration is to declare everything at the top of a scope except things like loop iterators, like:
for (var i = 0; i < 10; i++)
other things in the node style guide I don't agree with or see any justification for are multi-line ternaries and ===. That's why I don't take it too seriously
oh, and using named function expressions everywhere. It's confusing to someone looking at a piece of code for the first time, makes you want to look for a function invocation using that name
plus it makes absolutely no sense to suggest that given that the next suggestion is "no nested closures"
a lot of the advice is good, but a lot of it is not-so-good imo
I'll edit out the bit about >>> 0 doing nothing for all numbers, but I have to disagree with you on the variable situation. Perhaps the node style guide is a terrible justification for it, but lexical scoping or not, I find things much, much clearer when variables are declared at first use. My rule of thumb is just never reuse variable names and to always keep lexical scoping in mind. If a function is big enough that I can forget I've already used a name, it's far too big.
@Corbin yeah, the variable declaration thing is something I've gone back and forth on a lot over the years. I wouldn't be surprised if I change my mind about it again at some point. That's why I'm probably not going to mention it in any further reviews. I think either style can be justified, really. If you're committed to the declare-on-use style, I guess there's no reason not to recommend it.
Yeah, perhaps I'll refrain from mentioning it in future too. I've actually gone back and forth on it a few times too. Seems no one can make up their mind. Well, except for Crockford and Felix :p. lol
@Corbin the reason I like them at the top of the scope is, it's kind of like a forward declare, a way of saying "these are all the variables this function will use." If it makes the code unclear, I take it as an indication that I need to break the function up into smaller parts.
@DaggNabbit Hrmm, that makes sense, especially given how scoping works in JS. It's just jarring to me to see a variable's use come out of no where, and without declaring near use, it's hard to see at a glance where usage began. Kind of like a "hey, this variable is no longer a junk value!" sentinel.
Hi I'm wondering if its possible to omit empty parenthesis when chaining in coffeescript.
for example
myFunction = -> [...]
chain1 = -> [...]
chain2 = -> [...]
myFunction().chain1().chain2()
to instead
myFunction.chain1.chain2
ids contains 100 ids that are comma delimited. Is it fine or does it need improvement?
def getFriendPoints(ids: String) = {
DB.withConnection { implicit c =>
try {
var pointMap:scala.collection.immutable.Map[String,String]=null
var i=ids.split(",")
for(pos<-0 ...
Hrmm, Scala is such an interesting little language. Nearly completely compatible with Java syntax, but weirdly functional. I should get around to toying with it a bit. Perhaps after I get around to trying Rust.... lol
@Yuushi yeah, that's kinda the feeling I've gotten from it in what little I've seen from passing :/. Is it worth it, or is it just yet another fleeting language?
yeah.... and it's always a risk picking up a new language. other than a dozen or so of them, the rest run a very, very high risk of being a passing phase.
This particular example is verilog, but my question is more about the state machine structuring, which would be relevant to both VHDL and verilog.
So if I have a state machine, this one is fairly simple:
always@(posedge m_axi_clk) begin
if(m_axi_resetn == 0) begin
current_state <= ...
While your point may be correct, your way of expressing it was inacceptable. I tried to edit your answer. If you disagree with my edits, you can apply a rollback in revisions. If you want to discuss anything else, please ask a question on Code Review Meta or come to Code Review Chat — Vogel6121 min ago
I am creating a database project in java using file handling. The program is working without compiling error. Following points are not working
1. File is storing only first record. (if program is running again it is overwriting file)
2. I want to display all records but the only first record is d...
I want create extension for IQueryable for dynamic filtering
IQueryable<User> list = db.Users; //Users table
//Search "a" in fields FirstName or LastName
//etc list.Where(x => x.FirstName.ToLower().Contains("a")
list.ApplyFilterPatern<Order>("a", x => x.FirstName, x => x.LastName, ...);
public ...
@Nobody yeah, true. Sometimes I feel the same way. C++ is a very simple language to become proficient in, but incredibly, insanely complex to every truly fully know :/
I am practicing my code by writing a small application that lets the user search drives for their given input string. I am only returning the fullname of the files. What I have now is the following method to retrieve those fullnames:
private IEnumerable<string> FindOccurences(string searchQuery,...
Naming:
I am going to be blunt here... Your names are bad. Not horrible, but seriously bad.
var i = ids.split(",");
first thing jumping me here is, that you have a single thing (the id-string) named with a plural. next thing that jumps me, is that you have a collection with multiple element...
I have the following code which attempts to match all strings like "*SOMESTRING" (which can include numeric values), but not "*SOMESTRING*". For this I am using a negative lookahead as follows;*SEX and *AN01ZORA should match, \*PCCL\* should not match.
string s = " if 'L,....' MDC = '13' Then ...
Right. Who they let have it was an important part of the transaction. Its not like they just put Alaska up on Ebay and anybody could bid. — T.E.D. ♦Jun 20 '12 at 16:32
Given a Node with a reference to a child, its next, its previous, and a variable for its value (1/2 tree, 1/2 doubly linked list structure), you have to find a way to flatten the structure.
1 = 2 = 3 = 5
| |
6 = 7 8
|
9
(reference down is child and reference ac...
I've got a JSON response that is contained in an outer array like this:
[
{
"type": "a"
},
{
"type": "b",
"id": 1
},
{
"type": "c",
"name": "somename"
}
]
I've tried to convert this to object like this:
class LoginOptions
{
public IList<ILoginOption> Option...
Based on my previous post I completely re-factored my code to make it object oriented.
Anything I could improve when it comes to:
Object oriented code;
Efficiency;
Readability.
Any other suggestions are also welcome!
Validator class:
class Validator
{
private $rules = [];
private ...
Answerers are way too agessive on SO. You hardly have time to produce a good answer. The OP is more likely to accept a worse answer by the time you finished yours.
Could you check that whether this question has any deleted answer or not? https://stackoverflow.com/questions/2407540/what-are-the-downsides-to-using-dependency-injection?answertab=votes#tab-top
I assume you're referring to the 400 upvotes one that got deleted 10 days ago
Sorry, 2*
> It can be dangerous for your career because it may increase your overall knowledge of good API design. Once you learn how proper loosely coupled code can look like, it may turn out that you will have to decline lots of job offers because you would otherwise have to work with tightly coupled legacy apps. Happens to me a lot :)
So I have this peice of code I've been working on for quite some time. It's a ListView with a search filter. Inside each row, it contains a user Image, a User's name and how many friends they have in common. Also the row contains a button each, for actions.
I'm just indeed of some code refactori...
@palacsint I wouldn't be terribly surprised if that entire question were deleted at some point. SO has been moving further and further away from questions like that for quite a while...
I just spent 2 hours of debugging this damn JSON response only to find out that my parsing wasn't the problem; the request only worked for one environment while my library targetted another
How to do optimization and provide less of code here:
for _ in _get_valid_json():
if _['size'] != '':
available_params = [
{'productSku': _['upcID']},
{'productUPC': _['upc']},
{'productColor': _['color']},...
@chillworld he, removed all my notes, and took away good C# practices, like. using String.Empty vs "" (emptyquotes), then yah changed the actual mechanism a bit.
@chillworld Not at all, a good/big user base of SO/Stack Exchange are just passing by and read questions and answer. So why we should keep them from editing if it's good, it's not like it will not be reviewed by anyone !
I was bored and burnt out on more serious projects.... until I saw this Computerphile video on YouTube. Now I'm inspired again. Now I feel like spending some time implementing that recursive algorithm in a little console program. Fortunately, recursion is unbearably slow in this case. So, I ended...
My users may need to supply a 'disease category' to my site. I need to let them use all alphanumeric characters, hyphens and single quotes. Would someone review this to see if they feel its reasonable safe.....very happy for suggestions to make it tighter...
$disease_category = "some user ...
I recently bought this math-based boardgame for my little cousins, and am now trying to verify its design with some MATLAB code. The relevant parts of the game are:
A board with numbers from 1 to 100 in one tile each, and each tile colored in one of nine colors
There are three dice, the usua...
On a programming contest I came upon this question:
I was able to print my source code and study it. It works and all but upon results my solution was graded as "inefficient".
Here it is:
package com.gmail.inverseconduit.test;
/**
* Procrastination: I'll add a javadoc description later.<br>...
I am working on this problem here:http://acm.timus.ru/problem.aspx?space=1&num=1220
I have developed a solution here:http://pastebin.com/7MA4iZrs
The memory limit for this question is around 0.75MB = 750KB. My program, out of 20-30 runs on an average is taking around 800KB, with 770KB being the...
@rolfl I hate Does this code follow best-practices or Refactoring my class for x reasons Yeah sure I bet everyone wants or will do that when you are on Code Review !
I must be stupid! I can't understand how to represent <element value="anAttribute">text</element> in xsd.
Hum somethign is fishy with our xsd or generators to generate java classes. I added new classes in a other part of our project which should not have been impact... investigation time!
@Phrancis The syntax for an update is something like update <table-name> SET {<field-name> "=" <expression> } [ "where" <predicate>], where predicate is something that can evaluate to true or false for a particular record. The effect is that only records that meet that criteria get updated. (Using something like EBNF, where [] means "optional" and "{}" means "repeated an arbitrary number of times").
Considering that about 30% of the edits are approved, I think anonymous users seems to be very helpful in editing posts and therefore see no reason to ban them from suggesting edits. This is almost one out of three and is a bigger number than I expected.
Sure, one could argue that it should be a...
@Jamal There seem to be enough tic-tac-toe questions to warrant its own tag. I would also leave questions tagged as game, if not for the five-tag limit.
What can I do to optimize reading the user input?
Don't. For these kind of problems you will virtually never need to worry about time spent reading input.
What can I do to optimize resource efficiency and how I am dealing
with the data? I stored bytes instead of char which I think was ...
WINSTON!
I'm tempted to leave a comment like : Hey you seems like a regular here, come join us in chat ! (it's Friday, I'm sorry I'm tired )
I have a search-function, that searches for specific data within a huge Object.
Depending on how good a found entry matches, the finding gets "matchPoints" (or "Priority")
var findings = {};
for(var element in hugeObject){
var points = getMatchPoints( inputToSearchFor, hugeObject[element] )...
I have a large file that I want to refactor, my idea is to make helper classes with helper methods so that I can modularize methods, is that a good idea? For instance before refactoring:
public void collision(PhysicsCollisionEvent event) {
if (event.getObjectA() instanceof BombControl) {
...
MariaDB is a community-developed fork of the MySQL relational database management system, the impetus being the community maintenance of its free status under the GNU GPL. Being a fork of a leading open source software system, it is notable for being led by its original developers and triggered by concerns over direction by an acquiring commercial company Oracle. Contributors are required to share their copyright with Monty Program AB.
The intent is also to maintain high compatibility with MySQL, ensuring a "drop-in" replacement capability with library binary equivalency and exact match...
Ah. I'll look into it. So many RDBMS, so little time. My ideal RDBMS would be one where the syntax/supported features are as close as possible to SQL Server, but can run on a Mac.
For instance, MySQL does not support CTEs or global variables, and the PROCEDURE syntax is kind of a PITA
I've seen several sites claim that Postgres is installed by default for OSX 10.7 and above and I see there's a psql command in /usr/bin/, but there doesn't seem to be a pg_ctl anywhere.
So is the default install of Postgres something that I can actually develop against or is it just there for OS...
@200_success Sufficiently dependable that one instance has been running continuously since 1942 (okay, it's possible I'm exaggerating just a tiny bit).
I have a one website. I want to fetch perticular data contained in those website in a local file.
Has anybody done that with PHP? General guidelines and gotchas would suffice as an answer.
I have a large file that I want to refactor, my idea is to make helper classes with helper methods so that I can modularize methods, is that a good idea? For instance before refactoring:
public void collision(PhysicsCollisionEvent event) {
if (event.getObjectA() instanceof BombControl) {
...
For questions, it's easy: the code has to be preserved verbatim. The only exception is if the poster obviously had trouble conveying the code as intended (systematic tabbing problem).
I was actually a little surprised you fixed that spelling error in my question @200_success. It seems like the kind of thing that should be called out in a review. It just now crossed my mind.
Given a set of non-negative integers, and a value sum, determine if there is a subset
of the given set with sum equal to given sum. On similar lines, Partition problem is to determine whether a given set can be partitioned into two subsets such that the sum of
elements in both subsets is same.
...