@200_success I think it's supposed to be distance from the center of the planet, which would be ~6 x 10^6 m, and he drew it a little too far to the right :)
They can be useful for concurrent data structures.
(There is now a non-concurrent real-world usage sample below - that would not be there if @Neil hadn't mentioned FORTRAN. ;-)
For example, ConcurrentDictionary<TKey, TValue> in .NET 4.0 RC use linked lists to chain items that hash to the same ...
I have implemented the "Find the N longest lines in a file" problem from CodeEval quoted below.
I got a full 100 score and 182ms execution time of their data set on the site so I consider the code to be working and effective. What I'm wondering is, is there something I can do to make this faste...
I have two functions right now:
TUNNEL_COMMAND = "ssh -L 27017:localhost:27017 username@ip -f -N"
def kill_tunnel():
p = subprocess.Popen(["ps", "aux"], stdout=subprocess.PIPE)
out, err = p.communicate()
for line in out.splitlines():
if TUNNEL_COMMAND in line:
pi...
@skiwi Big-O is concerned more with scaling rather than performance for a specific case. Occasionally the better scaling functions have more overhead, so they don't become better in performance until you scale things way up.
> or—in Intel's terminology—hyper-threading (HT), which allows an alternate thread to use the CPU core while the first thread waits for required CPU resources to become available.
A CPU cache is a cache used by the central processing unit (CPU) of a computer to reduce the average time to access data from the main memory. The cache is a smaller, faster memory which stores copies of the data from frequently used main memory locations. Most CPUs have different independent caches, including instruction and data caches, where the data cache is usually organized as a hierarchy of more cache levels (L1, L2, etc.).
== Overview ==
When the processor needs to read from or write to a location in main memory, it first checks whether a copy of that data is in the cache. If so, ...
@DanLyons That's right, and LinkedList vs Array is one example where cache misses occur often... But your algorithm should also not be accessing locations that are far away repeatedly if I'm not mistaken
int a = 0;
int b = 1000;
while (b > a) {
a++;
b--;
}
I know, it's a stupid example ^^
But that would have horrible performance then?
It's probably more complicated than this single picture though...
sorry about that! the code doesn't show any error on runtime though. I have put the code for review not for error checking though. — lisbeth3 hours ago
I am having problems with my code because I am using a system called styleci. Can you please check it.
<?php
/*
* Tecflare Corporation
* Copyright Tecflare Corporation
* Provided by the Tecflare Corporation System
* * Code has been scanned by styleci.io
*/
$host = $_POST['hostname'];
...
I have a device I connect to on TCP socket. I send it a message with what I want and it sends back all sorts of useful information:
+---------------+----------+----------+
| StartTime | 4 bytes | Variable |
| Duration | 4 bytes | Variable |
| Temp | 2 bytes | Variable |
|...
So, this is going to be a performance focused review. I'm going to be sacrificing other things to get some more performance. Keep in mind that you should benchmark each run because JIT compilers, memory paging and all the other stuff that tries to make code run fast these days can and will someti...
If the code works as intended, this could be a good fit on Code Review as @khelwood mentioned. If you do post it there, you may want to write a title which says something about what your code does. — Phrancis14 secs ago
If you have no hidden layers, then (in just one specific test case) it achieved a 90% correctness rate, while with a hidden layer (of n=[30]) it got up to 95%
Maybe his original code would be more readable if it wasn't that weirdly formatted
This was a learning experience. I have looked around and found some better ways to write some things but wanted a second opinion to look at what i've written and kind of analyze it as well.
So I just finished my first "Text based game" Sort of deal. I believe that it's poorly written and is pre...
> But most importantly, Trump doesn't like to talk about his failures. So a lot of the time your code will fail, and it will do so silently. Just think of debugging as a fun little game.
In software engineering, don’t repeat yourself (DRY) is a principle of software development, aimed at reducing repetition of information of all kinds, especially useful in multi-tier architectures. The DRY principle is stated as “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.” The principle has been formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer. They apply it quite broadly to include “database schemas, test plans, the build system, even documentation.” When the DRY principle is applied successfully, a ...
Exception in thread "main" The first set is 1-2. Pick 1, or 2.
java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:105)
> While it was technically possible to have all the main memory as fast as the CPU, a more economically viable path has been taken: use plenty of low-speed memory, but also introduce a small high-speed cache memory to alleviate the performance gap.
Yeah... let's not have 16GB worth of registers on your CPU
I'm voting to close this question as off-topic because this code apparently works and would be best on codereview.stackexchange.com. — Daniel A. White54 secs ago
I've been working on numerals conversion lately. Now the JavaScript course I'm following asked me to do something similar for Roman numerals.
To keep things fresh and given the amount of test-cases provided I decided to write this one Test-Driven Development style. That is, for as much as I unde...
I have a function here and wondered how well this can be refactored.
I currently have this:
status=`git status 2>&1 | tee`
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo ...
I am looking to build a list of words (three letters or more) that make up a large list of six-letter words. I was wondering if there was a cleaner or more efficient way to loop through the characters to build these subsets.
The top of this program (not posted) takes two .txt files - one contain...
I have a Multivalued map (javax.ws.rs.core.MultivaluedMap<String, String>) which I want to convert to regular HashMap so I got below code:
private Map<String, String> convertMultiToRegularMap(MultivaluedMap<String, String> m) {
Map<String, String> map = new HashMap<String, String>();
if ...
In Python 3.4, a Counter object called cnt like this:
Counter({'0200': 3, '3000': 2, '3011': 2, '0210': 1, '4000': 1})
is to be written to a comma-separated file.
I first tried with csv and DictWriter that I had not used before, but I kept getting misty errors and was pressed for time, ...
I just wanted to add that the --disable-async-dns flag was removed; see here for the details. If it wasn't removed, at the very least it doesn't seem to do anything anymore on Windows. sigh back to developing using Firefox... — FireSBurnsmuP58 secs ago
> The optional parameter PreferredType is either Number or String. It only expresses a preference, the result can always be any primitive value. If PreferredType is Number, the following steps are performed to convert a value input (§9.1):
> If input is primitive, return it as is. Otherwise, input is an object. Call obj.valueOf(). If the result is primitive, return it. Otherwise, call obj.toString(). If the result is a primitive, return it. Otherwise, throw a TypeError.
> If input is primitive, return it as is. Otherwise, input is an object. Call obj.valueOf(). If the result is primitive, return it. Otherwise, call obj.toString(). If the result is a primitive, return it. Otherwise, throw a TypeError.
I think you can do something similar in JavaScript with .prototype, but I'm not sure about that.
> Fortunately, the draft specification has been implemented in recent versions of the major browsers, with the exception of Internet Explorer of course.
You are discussing working code without obvious problems, which makes this question more appropriate at codereview. For Stack Overflow, this goes down as primarily opinion-based. — Gert Arnold34 secs ago
I wrote a abstract Configuration class, then a abstract ConnectionConfiguration class and a then a abstract DatabaseConnection class.
ConnectionConfiguration extends Configuration
DatabaseConnection extends ConnectionConfiguration
My reason for doing this was learning more about object-orient...
It sounds like you need git rebase. Personally use git up to pull down all branches every morning, then rebase my development branches onto master. Before merging into master and after code review I'd squash all commits on my branch before pushing. Also see kentnguyen.com/development/visualized-git-practices-for-team — Meredith33 secs ago
I've started building extension methods for my EF classes like below because it makes building queries so easy, and the intellisense provided helps keep people from writing a new Where() clause in code every time they do to do something.
Example Extensions to an EF User Class
public static cl...
Today I saw a JavaScript syntax (when invoking a function) that is unfamiliar to me. It was like:
def('Person') ({
init: function(name) {this.name=name;}
,speak: function(text) {alert(text || 'Hi, my name is ' + this.name);}
});
, and
def('Ninja') << Person ({
kick: function() {this.spe...
> If input is primitive, return it as is. Otherwise, input is an object. Call obj.valueOf(). If the result is primitive, return it. Otherwise, call obj.toString(). If the result is a primitive, return it. Otherwise, throw a TypeError.
The WhereInRole method's purpose is to get all users in a role. My example query was getting "all admins named Bob" -- so for that it's ok I think? Also, as per the comment in the main area I moved this over to CodeReview which is where I guess it belongs. — FirstDivisionjust now
function StringBuilder() {
this.data = "";
}
// Called by <<
StringBuilder.prototype.valueOf = function () {
StringBuilder.current = this;
};
// Used to access the aggregated string
StringBuilder.prototype.toString = function () {
return this.data;
};
function add(value) {
return {
valueOf: function () {
StringBuilder.current.data += value;
}
}
}
var sb = new StringBuilder();
sb << add("abc") << add("def");
console.log(sb.toString()); // abcdef
Have one user reply to the comments on Stack Overflow, not five users.
This answer is not intended to address whether or not you should keep the chatroom or not. What is important is that we shouldn't "gang up" on SO users. Even though we don't intend to do that, here is what I often see happen:...