This is not an answer, but a talking point about whether this is on, or off topic
What is the best practice regarding synchronization?
I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best pract...
@syb0rg @rolfl I've responded. It's plausible that the author believes in good faith that it is working code. It compiles and runs, and the author might be unaware that it is buggy. I could vote to close the question, but why do that when I could score an easy 25 points? Leaving it open would be a win-win.
Bugs are an opportunity for a review. If the code can compile and reach perform it's objective, I would say that is working. It doesn't have to perform it well, or without hiccups though.
@syb0rg what is your answer actually recommending? that the best-practice wiki is updated, and that the best-practice requirement is dropped from the 'asking questions' help?
Help Center > Asking
It is hard for me to visualize the proposed changes. Here is the current Asking help page:
Code Review Stack Exchange is for sharing code from projects you are
working on for peer review. If you are looking for feedback on a
specific working piece of code from your p...
I think that identifying edge-cases is OK, but being asked to look for them is not... I don't want a bunch of questions coming through as 'will my code work when ...?'
or 'are there any bugs in my code?' ?
There is probably a reason why I could not find a tag to put there....
Yeah, but it should not be the primary request of the question, it should be implied that there are no bugs.... and anything found is incidental to a good review
Your point is worthy of discussion, but I have to go now. Feel free to continue discussing, or suspend the discussion. Some egregious examples might be good.
> Furthermore, the chance that the same API key would be generated twice is about 2-250. It's more likely that your server would be struck by an asteroid tomorrow than that it would generate the same key twice using this technique, so don't worry about accidental collisions.
It feels like you are combining lots of hashing and string transformation in hopes that complexity will make your scheme more secure. That's not engineering or computer science, though — it's Cargo Cult Programming.
There are two ways that an API key scheme could work:
To generate the API key...
Don't like the idea of using size rather than begin and end. It goes against the normal way C++ code is written. If the code had been tagged C then I would have agreed. — Loki Astari22 mins ago
The indentation in TelekomRechnungEinlesen makes it hard to tell where it starts and where it ends. Sub and End Sub define a scope - anything in between should have a Tab:
Sub TelekomRechnungEinlesen()
Dim lastSetTelekomRow As Long
Dim lastSetNovatecRow As Long
Dim iterator As Long...
@Corbin I'd just like to interject for moment. What you're refering to as Eyes, is in fact, GNU/Eyes, or as I've recently taken to calling it, GNU plus Eyes. Eyes is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
@Corbin Many users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Eyes, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.
@Corbin There really is a Eyes, and these people are using it, but it is just a part of the system they use. Eyes is the kernel: the program in the system that allocates the machine's resources to the other programs that you run.
Anonymous
@Corbin The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Eyes is normally used in combination with the GNU operating system: the whole system is basically GNU with Eyes added, or GNU/Eyes. All the so-called Eyes distributions are really distributions of GNU/Eyes!
I can easily beat the computer at TTT, but I don't think I can even figure out a good way to do the AI. Plus I still need to refactor my regular TTT program.
Thanks for this answer, to be truthful I've been very busy with other work related things but eventually I'll come round to this since I asked this some time ago. I do appreciate this so give me some time :) — Patrick Magee4 hours ago
Consider this class:
using Ninject;
using Ninject.Syntax;
using Ninject.Parameters;
namespace MyApp.Dependencies.Factories
{
public abstract class FactoryBase<T> where T : class
{
private IResolutionRoot _resolutionRoot;
protected FactoryBase(IResolutionRoot resolutionRo...
I've posted this on stackoverflow as well, but I've realised its more a codereview problem.
I've got a nested foreach that iterates firstly through a map and then through each key within the map to create an object.
for(Map<String, Object> csvRow : csvRows){
Contact contact = new Contact()...
My first crack at clojure... if you have time to provide input, I'd appreciate it. I'm as much interested in style as proper usage. I'm just getting started.
The task to start with an vector of N zeros, and then "scramble" it by: Select 2 items in the vector. If one is less than 4, and the other...
I've created this thin wrapper class for a socket project that I'm working on. Can someone review my class and give me some points on if I'm on right track?
#include <iostream>
#include <WinSock2.h>
const int MAX_RECV_LEN = 8096;
const int MAX_MSG_LEN= 1024;
const int PORT_NUM = 1200;
class...
I have a mode object class like this
namespace ConnectBLL.DTO.Response
{
public class CategorySettings
{
public bool NeedsLoginToViewLongText { get; set; }
}
}
And I am trying to set value for this object like this from another class
using ConnectBLL.DTO.Response;
n...
@Jamal There are more effective ways to get my attention than to post an "answer" with a username "philwantsfish" and wait for a moderator to delete it and flag me.
@rolfl, for your JS question, it seems from first sight that you are wrong
@rolfl "Mijn allereerste test".replace(/\S+/g, "x"); gives a 6 character string, so your code would return Words: 6, which is wrong. Furthermore I assume you meant to use xwords instead of spaces in line 2
This seems a bit redundant to me, but I'm not sure of how else I might be able to write this. Normally I'd use a switch statement, but I don't think that'll work here. I realize I could also do this in a for loop, but the main heart of the question is what's inside the loop itself. "arr" is an...
If you are given the string variables
{fn}
{ln}
{fi}
{li}
{mi}
{mn}
How would you create the following?
{fn}
{ln}
{fn}{ln}
{fn}.{ln}
{fi}{ln}
{fi}.{ln}
{fn}{li}
{fn}.{li}
{fi}{li}
{fi}.{li}
{ln}{fn}
{ln}.{fn}
{ln}{fi}
{ln}.{fi}
{li}{fn}
{li}.{fn}
{li}{fi}
{li}.{fi}
{fi}{mi}{ln}
{fi}{mi}.{ln}
...
Are there good applications that perform dictionary based compression algorithm (like LZ77 and LZW). And it is good if the program show: Compression ratio, Compression and decompression Time.
I want to apply the compression in the text file and see the changes of file’s content after compressing.
I would very much appreciate a general review of my php code which grabs information from mySQL database and also inserts some information.
Overview on how this works.
Users go to /main.php and answer math questions. The 20 math questions are pulled from the database. The answers are pulled at...
I noticed, that accelerometer and gyrometer sensor data tend to have problems. The gyrometer is not very precise and the accelerometer is getting problems with vibrations. I built a quadrocopter (to be honest more then one). My first one had a poor frame and the motors (very big ones) were vibrat...
I ma making a php script which fetches the data of the emails whose sending date and time has been reached and then send emails to those records, am following these steps. I am integrating it in a API, that is.
https://github.com/infusionsoft/PHP-iSDK
Step 1: get the communication records whos...
@konijn Yes, spaces should be xwords.... hmm, and I expected that "Mijn allereerste test".replace(/\S+/g, "x"); would be 5 characters, not 6, and then I take those 5 characters, and strip the x to become 2 characters.... and in my answer, the number of words is 5 - 2
Delphi is a nice language in that it is not case sensetive. However, I would still encourage you to stick to one casing. Decide on if you want to use if or If and stick to that. (My personal opinion: Use all lowercase). This also goes for var and for in your code.
Your code has a bit of incons...
I want to know what is the best practice to write code in view. Here is the snippet of my code:
/Views/Emp/EditEmp.aspx
<% if(HttpContext.Current.User.IsInRole("Manager")) { %>
<div class="small right" style="margin:5px 0 10px 0;">
<a class="btn" href="/Emp/Edit"><i class="icon-doub...
Is it possible to simplify the code below:
dynamic model = GetExpandoObject(); //model type of ExpandoObject
var result = model.FirstOrDefault(x => x.Key == "node").Value;
dynamic model = GetExpandoObject(); //model type of ExpandoObject
var result = model.FirstOrDefault(x => x.Key == "node")...
So first of all I am a beginner in PHP5, and I have some question if it's possible,
This is the questions :
Create a PHP 5.4 script to check availability of many Sites (via Echo Protocol):
Get the list of sites (domains) from MySQL database.
The Table fields: Domain(varchar), status(enum(UP|D...
I have a script that sends multiple commands after logging in a remote machine via ssh.
Problem is, it's barely readable. I've tried quoting everything with "", but it's terrible (everything appears in pink), and here documents are just as bad (everything appears in gray). I'm using Gedit as an ...
@rolfl looks better, all you need now is lowerCamelCase and 1 single var, feel free to point to this : jsbin.com/puzox/1/edit?js,output as a live example
I sent a PR to a repo the other day and want to make sure I have the right idea for URI validation.
function validateURI(files) {
//...
// files can be either a string or an array of paths
// validates the relative path exists or is an http(s) URI
// returns a filtered list of va...
you have a lot of if statements in your SQL, this screams at me that you are doing something in your SQL that should be done in the application, and that this SQL should be separated into two distinct stored procedures.
the benefits
faster stored procedures
use an actual coding language to d...
I've seen questions edited to remove the language name from the title. Won't search engines - and folks using search engines - have an easier time finding them if these "tags" are kept as part of the title?
Return to FAQ index
I just want to know if : Validate that a relative path exists or is an external URI; is a good replacement for : Grunt relative path exists or is external URI
According to my lecture notes , there are benefits to refactoring the code from original code to refactor code
Original code
double basePrice = _quantity * _itemPrice;
if (basePrice > 1000)
return basePrice * 0.95;
else
return basePrice * 0.98;
Refactored code
if (basePrice() > 1000)
return...
Yes it could be on-topic, but as of now I don't find it on topic! But for the moment is not a bad question so I'll wait for someone to act on it if needed
I have multiple models which all have the same functions in it in my framework. So I decided to create one "parent" model and all of my other models would extend and inherit its functions like:
http://pastebin.com/55NjGqmS
And my other models would be like:
class Games_model extends MY_Model {...
Can someone help me further optimize the following cython code snippets? Specifically, a and b are np.ndarray with int value (range(256)) in them, they are one dimension arrays with dynamic length, resultHamming is a two-dimension array with float value in it (dynamic length), bits is an int list...
The first thing that pops out is the repetitive calls that look like this:
result = ((ExpandoObject)result).FirstOrDefault(x => x.Key == "node").Value;
Which are all similar. Half of your calls end in .Value and the other half don't. Which brings up a question on my part, since I don't un...
FirstOrDefault is a LINQ extension method (see ExpandoObject Extension Methods), so you are using LINQ!
@Ryan's answer looks like it's addressing the structural issue with your code, got my +1.
I'd like to add that you should avoid reusing the same variable for a different meaning.
It's very h...
According to my lecture notes , there are benefits to refactoring the code from original code to refactor code
Reasons for refactoring
Replace Temp with Query
You are using many temporary variables to
hold the result of an expression
This can result in long methods, since the
(...
While your code does look good, you can make sure you've maximized your performance using a profiling tool (there are many). Also, JRockit and OpenJDK HotSpot(which is free and Open Source) can be used to optimize your code.