I'm not familiar with 8051 assembly in particular, but there are some readability things I want to point out.
Commenting
This should really be stressed: well-commented is not the same as excessive-commented. You have comments after pretty much every line, which just makes your code hard to rea...
ECMAScript is the scripting language standardized by Ecma International in the ECMA-262 specification and ISO/IEC 16262. The language is widely used for client-side scripting on the web, in the form of several well-known implementations such as JavaScript, JScript and ActionScript.
History
JavaScript was originally developed by Brendan Eich of Netscape under the name Mocha, later LiveScript, and finally renamed to JavaScript. In December 1995, Sun Microsystems and Netscape announced JavaScript in a press release. In March 1996, Netscape Navigator 2.0 was released, featuring support fo...
I guess they will have to use the Implementation name for the tags
I still think it is wrong to synonimize ecmascript -> JavaScript
please give me some feedback to my malloc implementation. i implemented this design to understand the basic concept...
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#define HEAP_MEM_SIZE 150
#define MEMORY_AVAILABLE 1
#define MEMORY_USED 0
struct chunk_header {
struct chunk_h...
Things you did well:
Some use of comments.
Use of typedef.
Things you could improve:
Syntax/Styling:
Never use goto. Yes, there are some rare situations where you may find it necessary to use it. This is not one of them.
err:
printf("could not allocate mem\n");
return 0...
I put together this implementation after playing around with various partitioning- and pivot-strategies, and it runs fine. I wrote this off a version which seemed a bit different from the majority of implementations, so I'm curious on what you guys think. It works and handles duplicates.
def qui...
I apologize in advance if this is the wrong venue. So I have been trying to create a class that would list prime numbers forever. I know it has already been done but I think I learned some valuable principles during my trials.
This project helped me understand(to a better extent) return values, a...
Is there a better (functional or more idiomatic) way to get the first positive number that is not included in a set.
val set = Set(4, 1, 2, 0, 5)
var x = 0;
while(set.contains(x)) x +=1
println(x); // Should print 3
i have a server application using TcpListener in Backgroundworker, where my application is doing some work, and in the background listening to a IP:PORT.
The DoWork Of The BackgroundWorker :
private void m_oWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (true) //in...
Sorry for my English
I tired to write code that inits or restores state in onCreate() (by checking whether or not the savedInstanceState argument is null), and saves state in onSaveInstanceState().
So I wrote these classes:
StateManager
public abstract class StateManager {
public final v...
ugh, at this very moment Bob Martin is doing a corporate training seminar for the 10 members of my team,in the room directly below me, a seminar with empty paid seats but my boss said I can't go because I am too busy.
I would like to know how can I tell to compiler that a #define is an unsigned char.
#define SET_BITS_LOW 0x80
Here SET_BITS_LOW is, by default, an int but I want an unsigned char
This case is really on the edge I'd say, but normally you are out of luck and to be blamed yourself if you post an answer as a comment, and someone steals it
I would say it's one of the main problems on SO: the trivial question/answer couples are the ones that get the most points. Typically the answers you can find in any documentation or tutorial.
Given a mongodb collection that stores trees as nodes with parent references this methods returns a deep nested tree where every child nodes are stored in
def getTree(rootId: BSONObjectID): Future[CategoryTreeNode] = {
def collect(parent: CategoryTreeNode): Future[CategoryTreeNode] = {
...
So in my latest project I am using fullscreen background images for each page. I decided to write some code to fetch the different thumbnail sizes and then use it as a background for the appropriate viewport size using media queries. I also made sure that in the case of big screens the smallest i...
Ok so I have this adventure game, where when you click a button, it replaces the div you're currently on with the new div option that you chose. Example:
Sample of my HTML:
<div id="menu">
<button class="menubutton" onMouseover="mouseoversound.playclip()" onclick="start()">Start</button><br>...
The code below will split environment variables from a command line (always appear at the end of the command line). Environment variables are represented by '-E key=value'. I've achieved this like so, but I'm wondering if there's a more elegant way
public class TestSplit {
public static void ...
@Morwenn Despite being trivial, if the question isn't answered on SO yet, it needs to be. The goal of SO is to be a one-stop shop for all programming questions. With that said... if the question IS already answered, it should be marked as a duplicate and closed.
What actually bothers me is when I take the time to post a (in my opinion) pretty-well written answer that is composed of a few paragraphs making several different points... but the answer starts with the straight-forward answer to the question. Then, 5 minutes later, someone else posts an answer, and it's basically a copy and paste of my first sentence.
Not only is the answer copied, but it's 5+ minutes after an already-posted answer (the one in which you copied from)
For what it's worth, if you are considering a career in software development, there is not much that is better than an algorithms class.
I never did an algorithms class, and I regret it..... I work with people and I say, I have problem X, and I need to do Y, and they say do Z .... if you knwo wha tyou have, and what you want, then knowing the algorithm to get there is, well, just plain useful.
It's the sort of thing that google sucks at
I implement formal algorithms in complicated problems at least once or twice a year... and then in the day-to-day grind you are doing it on a small scale all the time.
If you are worried about taking a class, then that should still be possible I think via online universities... for free if you do not want a grade/support, paid if you do want
I am running in to Java Array-size limitations ... workaround?
int[][] data = new int[1 + (size >>> 8)][1 << 8];
for (long i = 0; i < maxindex; i++) {
data[(int)(i >>> 8)][(int)(i & 0xff)] = .....;
};`
Obviously the 8 and the 0xff are constants..... ;-)
It is also nice to be able to do:
java -Xmx192g .......
That's essentially what the above does.... It splits it in to many arrays of size 256.
I am playing with the right size of the shift.
It seems that somethng much larger will be better for memory management....
I am using 16MB memory pages, and I think I should try to align it closer to that...
but I want each array to fit in a single page, so I can't use as much as 16MB per array because there is some overhead, and I don't have too many 16MB pages ;-)
Doing some math
about 2MB per array sounds about right, so it's about a 19-shift... for int.
But a 16 shift (256KB) sounds useful.... I like byte-aligned shifts just like I like round values for rep
I am trying to make a thread test in which 4 threads are all trying to set a bool. Only one should be allowed to set it. After the first thread has set the bool(m_isRunning) to true, no other threads should set it to true because of the check isRunning(). This implementation works, but I wonder ...
I have recently written the program for the above mentioned hackerrank challenge. That's working fine but the problem is that it takes too much time if a big number is given as a input so I would like you guys to help me out in optimising my code so that it could run under 16 seconds, yes, that's...
I have been trying to create a class that would list prime numbers forever. I know it has already been done but I think I learned some valuable principles during my trials.
This project helped me understand (to a better extent) return values, arguments for methods, simple math arithmetic and wha...
HTML form field names must be equal to SQL table field names.
Changing only table name and allowed fields can be used in many other update pages.
How can I improve this?
$allowed = array("name","surname","email","rank");
$items = '';
foreach($_POST as $key => $value) {
if (in_array($key ,...
I'd like some additional assistance on refactoring. This is my latest update for this iteration.
The previous post can be found here.
#region WMI Classes
/// <summary>
/// The Win32_OperatingSystem WMI class represents a Windows-based OS installed on a computer. Any OS that can be
/// install...
Your algorithm is way off.... ;-)
Let's consider the solution to a decent number.
For any decent number, the more 5's we put at the front, the better.
So, let's break it down to some maths....:
d => number of digits in the decent number
f => number of fives in the decent number
t => number o...
@rolfl If you want it (more) dependably fast, build it as a number instead of a string which you then convert to a number: for (int i=0; i<fives; i++) total = total * 10 + 5; for (int i=0; i<threes; i++) total = total * 10 + 3;.
I have an Olympics database from each Olympic year and I want to find the person that has made the most medals - The main problem is that I'm basically querying the same sub-query twice in SUBSET1 and SUBSET2. How would I go about changing this so that it would be more efficient
Select athlete ...
@JerryCoffin but-seriously: The intended output is as a string to the console... it never needs to be a number, and it does need to be a String, so using a pre-allocated-size StringBuilder is actually the fastest Java way....
I have long been looking for an elegant, one-line solution to map enum to strings automatically, for use with the << and >> stream operators.
I know that a lot of macro have been proposed to achieve that, but I never found a really simple scheme, with only one macro call.
This is my attempt, an...
@konijn: I've just realized something. It seems that people could confuse code-challenge with programming-challenge, and they should not be used similarly. I'm not even sure if we need the latter tag.
It is very exciting to get badges on Stack Exchange, but, how many badges are you one vote away from?
Badges can be somewhat complicated to understand, but, sometimes you are just one vote away from that Enlightened.... but, were you the first answer? Are there badges you missed?
Is there a vot...
I need to clear my plate at home and have another look at my code. someone has given me a review that has almost twice as many lines as my actual code, and they aren't done.▼▼▼▼
I went with what I know and can use well, not what I know and can't figure the syntax out to make it look good.
so please enjoy the code and prepare to school me (probably in the basics) in C#
public static void Main (string[] args)
{
/* Here are your rules:
"Scissors cuts paper,
...
Task:
I know we can all add two numbers the short way, using +. Your task is to create the longest code you can to add two input numbers.
Rules:
All of the code must be on topic (don't fill it with non-addition code to add length)
The count is in characters, but do not count tabs, spaces, or ...
@JerryCoffin some of it is probably going to go over my head though. I need to get back to that code and make some changes to it, from the answer with the most votes and such. then re post I think
@user35265 by the sounds of it, you need to be adjusting your expectations, 38 milliseconds is not 'slow', or inefficient... is there a real problem? — rolfl19 secs ago
@skiwi I am going to work in the Upvoted answer first, and see how it works for me, and if it gives me ideas to expand, then I will post a new question. Hopefully!
In Farbox, I am trying to insert videos in Markdown. I can insert 2 videos. But when I am trying to insert 3 videos. It didnot work out. Does anyone know why?
works. But:
doesn't.It works here. But the second one doesn't work in Farbox.
It looks quite good, some, mostly minor notes:
class Controller implements ActionListener {
Having an actionPerformed method in the controller smells a little bit for me. I'm not sure about that but I'd rename the controller's method to changeModelState() (without any parameter) and use an ...
The original question where the general concept of this implementation was discussed: Using ID's with a "scope" -like hierarchy
I have designed a resource manager as part of a game programming project that I have been working on as a hobby. Implementing as much functionality as possible in the l...
I keep seeing /subsite/../global/css/file.css when I look at my code, and today I decided that I want to get rid of the unnecessary traversal in the path itself, so it becomes /global/css/file.css. I made myself a function which I now use for all paths on my site. Here is the base of my function ...
I’ve built a web site that uses AJAX to update a div. Most of the data displayed in the div is drawn from a MySQL database. All the pages are PHP.
I’ve tried to follow best practices. I put all the query strings into stored procedures in the database. The PHP files call the stored procedures wi...
For some reason, I'm having difficulty remembering. I've got a photo of the ingredients, but some advice on exactly how to combine them would be appreciated.
I received a ton of help from 200_success once again here.
Since then, I decided to go with OOP Style and prepared statements, and so far I like it a lot more than the procedural style. Much more understandable in my opinion.
For this CodeReview, I've just included my PHP code that interacts wi...
"Forcing a system crash from the keyboard does not work if the computer stops responding at a high interrupt request level (IRQL). This limitation exists because the Kbdhid.sys driver, which allows the memory dump process to run, operates at a lower IRQL than the i8042prt.sys driver."
I read on the net that it is Punkbuster accessing invalid/unauthorized GPU memory locations, while some other program is doing something with the GPU aswell (MSI afterburner, etc.)
I've no idea about Punkbuster. I was (uselessly) answering your question theoretically: as in "yes, in theory you can get a crash dump. after you have a crash dump, good luck with analyzing it!"
I like the demo, from a once over:
the functionNames make my eyes glaze over, data tables variables should be sorted and tabbed in my mind:
var functionNames = [
{ name: "matrix", type: functionParamTypes.length},
{ name: "matrix3d", type: ...
A few random notes:
If I'm right it's not thread safe.
progress = auCDtect.getProgress();
output = auCDtect.getOutput();
summary = auCDtect.getSummary();
I guess the calls above runs on an event dispatcher thread while the fields of auCDtect are set by StreamGobbler which is run on another...
I guess I'm a little late with my entry, but I decided the world must need yet another RPSLS implementation to critique.
#include <vector>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <time.h>
/* Here are your rules:
"Scissors cuts paper,
paper covers ...
I just finished creating a simple Python module that converts a number to words (done to death, I know). It's basically something that I thought of earlier today while teaching my 2-year old daughter how to read numbers and letters. Since the normal progression would be to tackle spelling, I thou...
I've got the following Elixir code:
defmodule Envvar do
def exists?(env) do :os.getenv(env) != false end
def get(env) do
if exists?(env) do
{env, :os.getenv(env)}
else
{env, nil}
end
end
end
Two things:
Am I using the ? correctl...
Here's an attempt I've made of implementing the Barnes-Hut nbody algorithm, or it's initial stage - The quadtree. That there're lots of lengthy doc strings might excuse the lack of detailed explanation here. My primary concerns as a beginner are to-
Avoid complexity
Avoid library imports
Make f...
Task:
Draw a grid with a given number of rows and columns. Each cell can be any color. The same grid should also be updated at a predetermined time interval. The grid should cover the entire visible portion of the page in the browser. Add a context menu with which you can change the parameters o...
I'd like some advice about any better or cleaner way to implement this class, if there's any.
I made it using this answer, posted on stackoverflow, as reference. A lot of problems arose when I switched C function pointers to std::function due to the lack of the equality operator on it, so I end...
From Coderbyte:
Have the function StringReduction(str) take the str parameter being
passed and return the smallest number you can get through the
following reduction method. The method is: Only the letters a, b, and
c will be given in str and you must take two different adjacent
chara...
@ChrisW Because the compiler does not have to analyze what type the function is to test if it is void, find where that function ends, and then manually insert the return itself. Sure, it won't reduce the compilation time by much, but it still reduces it.
@syb0rg benchmark needed. I don't believe that, and would be surprised if this would be measurable (or even just technically true). Wouldn't the absence of a return make the code faster to parse, because there's less stuff to parse? (No, because other steps are much more expensive than parsing)
BTW I'm disappointed that my answer to that question has no upvotes: IMO my answer found several huge bugs in his implementation, and started to explain what a heap-manager must do (which was the point of the OP's exercise).
I'd find it neater without chunk_header_begin and heap_size as global variables: instead, assume that chunk_header_begin is at &buffer[0] and assume that the heap size is defined by the several chunk_header->size values.
I'm worried about what happens when you free-and-then-reallocate memory: th...
I have a function that returns the index of the first alphabet letter found in a string, or -1 if no letter is found. It seems like there should be a way to do this with extension methods instead of looping, but I can't think of one:
int findFirstLetter(string str)
{
for(int ctr=0;ctr<str.Leng...