So, it turns out that that spammer from earlier today has actually plagiarized the other answer to the same question. I was too focused on that and didn't notice until someone flagged it. Now I have sent that account to the fiery pits below.
Look for patterns and breaking down into methods
From the looks of it, you are trying to 'prettify' relative time representation given minutes, hours and days, such that negative values indicate the future and positive the past.
private static String getString(int minutes, int hours, int days)...
I use bootstrap 3.2 with the latest version of jquery on my webpage and there are several issues that trouble me. Now, the code worked for a few days before it broke or something I think it's more of a browser compatibility issue.
For starters
the navbar toggle doesn't work on chrome, firefox ...
I've given the Rod-Cutting Problem a go with a non-recursive approach that use a cache instead, with a bottom up approach. For anyone who hasn't heard about the Rod-Cutting problem, it's defined as follows:
Serling Enterprises buys long steel rods and cuts them into shorter
rods, which it t...
// iCS_S_MembersCall first, so that member calls are not resolved as separate iCS_S_VariableOrProcedureCalls
implicitCallStmt_InStmt :
iCS_S_MembersCall
| iCS_S_VariableOrProcedureCall
| iCS_S_ProcedureOrArrayCall
| iCS_S_DictionaryCall
;
it works perfectly well for in-block calls... and somehow in-statement calls go bleh
I have some breadcrumbs that i use with Jquery, the problem is that i check if there is that element on page and after that i create element, but the problem it is getting to big and DOM is check so many times, that will slow my application. Now it work, but is there some simpler and better solut...
right-side picks up this.Foo as expected.. I think I'm losing it.
sorry to be rubberducking here
oh gosh. the blockStmt rule is prioritizing statements in ...alphabetical order. so implicitCallStmt_InBlock matches before letStmt. I bet I can move the implicit call statement rule near the end of the list, regenerate the lexer/parser, and my code will "just work".
After optimising my code it still seems pretty brute force and I am looking for ideas to fundamentally improve it.
I have tried improving performance by:
Avoiding creating substrings as much as possible - using while loop to compare string instead.
Intelligently anticipating ends ie. start +...
I have some code that's part of my music-js library, and most of it is very organized, using object-oriented design for my AudioAnalyser and Visualizer classes (this code has been updated since publishing but I haven't pushed the changes for several months). There's one static function though, fo...
Below is the list abstraction in functional paradigm, that encapsulates any type of data in its representation.
empty_rlist = None
#Representation - start
#Constructor
def rlist(first, rest):
return(first, rest)
#Selector
def first(s):
return s[0]
def rest(s):
return s[1]
#Represe...
What is wrong with this pattern which emulates AsyncTask functionality?:
// on the UI thread
final CountDownLatch latch = new CountDownLatch(1);
onPreexecuteWrapper();
new Thread(new Runnable() {
doInBackgroundWrapper();
latch.countDown();
}
}).start();
new Thread(new Runnab...
This is the problem statement:
In most of the range query-update questions, we are asked to update some range of the array with some constant_value which can be done using segment-tree approach. For more optimizations we can use segment-tree with lazy propagation approach.
But in this ques...
I have have attempted to use generics and constraints to create functions that retrieve and save data from a number of similar objects. Each of these objects describe their own properties. When I use these methods for a particular Type I don't understand why I have to specify new() in the constra...
This is the new version of the dictionary program which I uploaded for reviewing here.
I would be grateful if the program could be reviewed for all the points mentioned in the above link.
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>...
This looks more towards code review.. and if so, I would try to use setRoute in your constructor, so you arent repeating the code. — Karthik T21 secs ago
@KarthikT As it is currently stated, we can't be sure that the code works ("can someone check if this is correct please.") and so it will probably closed as off-topic on Code Review until has checked that their code indeed works as expected. — Morwenn58 secs ago
@logc Asking to debug the code hints that the code is broken to start with. Therefore, it will also be closed as off-topic if posted on Code Review. — Morwenn54 secs ago
@logc Well, I'm only telling you what will happen if the question lands on Code Review. Nothing more. — Morwenn12 secs ago
As the code works and the question is a design issue, I think it would be better suited to Code Review. — Quentin5 secs ago
I am converting my code to matlab, i would be very grateful if anyone code review that. the program does the following:
specify a destination folder where to creaet and look for files
look if a file named taskxxxxxxx.txt exists
if it exists then it rename it into taskxxxxxxx_inProcess_computerna...
I'm new to Clojure and decided to read the book, "Mazes for Programmers". My first task, without reading any of the book, was to think of how I would create a maze. This is my first result and I'd like good, honest and even scathing critiques:
(defrecord Cell [visited? valid-dirs open-dirs])
(de...
I have question on how to print a character from a character array pointer:
#define C_ARR_SZ 100
typedef char c_arr[C_ARR_SZ];
typedef struct1
{
c_arr a;
c_arr b;
};
void tes(void)
{
char addr[1000];
volatile struct struct1* s1 = (struct struct1*) addr;
memset((char*)s1->a...
I have written the below code for inserting an element at the position specified by the user. Though i have seen the code in multiple books for insertion of node in the list and everywhere they have used two pointer in the function which is inserting the node at specified position . But in my cod...
@logc Code should be tested before it is posted to Code Review. Code Review is not for "Does this code work? Are there any bugs?" it is more for: "I have tested this code and not found any bugs so far. How can I do it better? Have I missed any edge-cases?". I hope you see the difference between those two statements. — Simon André Forsberg59 secs ago
I would like to understand how to get rid of all the loops I am using in this code.
I have a dataframe of 20 rows. I am simply counting the number of occurences that the variables rs and occ appear together.
Here is the data :
d = structure(list(householdid.x = c("101366", "101366", "10248...
hey guys here is my problem. I am new to programming, and I am probably making a rookie mistake. In the line that reads "public var speed:Float = 200;" I keep getting "unexpected public" Error. What does this mean and what am I doing wrong?
package;
import flixel.FlxSprite;
import ...
@Morwenn My wife's grandfather built the place, I go a few times a year..... normally closer to the end of the summer when the lake is warmer than.... 14 degrees
I asked this question earlier on stackoverflow they advised me to move it here.
Problem
I have a stream composed of 2 columns and 1000 lines.
Column 1: contains the patterns that I want to find
Column 2: contains the values corresponding the the patterns in Column1
I want to search for the...
Sometimes performance questions relate to the way the program is executed and sometimes they relate to the method that the program takes in achieving its answer. OP seems like the latter and I was obviously mistaken, in that it isn't off-topic. Close vote retracted and comments duly noted.
I have created a css module and the structure is below
<div class="ad-tabs">
<div class="ad-tabs__inner-content">
<div class="ad-tabs__inner-content__header">Header</div>
</div>
</div>
I extended this module using .ad-tabs--default by two ways
created &--default class and inside ...
Thank you, I haven't realize that such a service for code reviews exists. I will definitely use it in the nearest future with some more scala examples — HeeL44 secs ago
@M.Allam Some quick code review: to save stack space, you shouldn't pass search_key, Graph and visited_nodes to the recursive function: you can store them as class member variables because recursive functions all get the same set of those parameters. Neighbors do not need a queue: it is sufficient to have them in an array and iterate over them, because FIFO functionality is not needed here. Also the hassle with subtracting 1 from current_node seems unnecessary: you can just use 0-based indexing in the recursive function. — Serge Rogatch56 secs ago
This does not work and returns error:
SELECT EAN FROM eTovar WHERE EAN GROUP BY EAN HAVING parameter_id IS NULL
Error in query (1054): Unknown column 'parameter_id' in 'having
clause'
But this query works:
SELECT EAN FROM eTovar WHERE EAN GROUP BY EAN HAVING MIN(parameter_id) != MAX(pa...
I should put online the first stones of the SGL (Standard Generic Library) this weekend, a project to bring to C11 some parts of C++'s STL (and some more fun goodies).
This does not work and returns error:
SELECT EAN FROM eTovar WHERE EAN GROUP BY EAN HAVING parameter_id IS NULL
Error in query (1054): Unknown column 'parameter_id' in 'having
clause'
But this query works:
SELECT EAN FROM eTovar WHERE EAN GROUP BY EAN HAVING MIN(parameter_id) != MAX(pa...
"teach yourself to programming in Ten Years" norvig.com/21-days.html You will always be learning, never perfect as the technology will be changing while you are learning it. — Peter Lawrey13 mins ago
This does not work and returns error:
SELECT EAN FROM eTovar WHERE EAN GROUP BY EAN HAVING parameter_id IS NULL
Error in query (1054): Unknown column 'parameter_id' in 'having
clause'
But this query works:
SELECT EAN FROM eTovar WHERE EAN GROUP BY EAN HAVING MIN(parameter_id) != MAX(pa...
Are the words isomorphs? (Code-Golf)
This is my non-golfed, readable and linear (quasi-linear?) in complexity take of the above problem. For completeness I include the description:
Two words are isomorphs if they have the same pattern of letter
repetitions. For example, both ESTATE and DUE...
The Solutions was to be assessed not just on completing the task but also on code quality and design,
presence of testing, robustness, maintainability etc.
Problem Statement-
Scenario-
Basic sales tax is applicable at a rate of 10% on all goods – except books, food and medical products, which
...
So, I've been weighting pros and cons lately, arguing with myself about whether I can or can't devote enough of my time to this, and then I talked to my wife... she's expecting me to nominate myself for these moderator elections. And I wouldn't want to disappoint her, so... I'm going to jump into the arena, Monday.
@Mat'sMug Interesting... I had a similar conversation with my wife when I was contacted and asked to "Volunteer" pro-tem. I was hesitant, my wife said "do it".
I have a view that looks like this:
@transaction.commit_on_success
def view(request):
do_stuff(...)
if condition(...):
result = do_other_stuff(...)
transaction.commit()
send_email(result)
return HttpResponse(...)
Assume everything with (...) can touch the ...
As for the site direction, I feel that the progress on that front is far enough along for me to feel comfortable with it's direction, it can't really go wrong, now.
As a pro-tem mod, my responsibilities are concluded enough to feel satisfied with my role.
I will miss the extended community a lot, but feel that others would be better in that regard too.
And, it will be only temporary... that's the way I feel about it.
@rolfl I think saying "Nothing can go wrong now." is the third, classic blunder - right after starting a land war in Asia and going in against a Sicilian when death is on the line.
@skiwi I have been around in those rooms long enough to be on friendly terms with folk, but, no, twitter is about where it's at.
Also, I take it for granted, but I guess I should say it out loud... I have 100% confidence in @Jamal and @200_success (I assume both will run, though I have not heard them say so explicitly). There is a very strong follow-on core in the mod team, and they will be able to help the new mod(s), and I trust them to do the right thing.
Really, although I sometimes feel it is all about me, it is not. The site is in good hands regardless.
As long as you don't vanish completely, we'll be fine. Perhaps you haven't noticed, but you're very important in this community. People trust you. You have instant respect the moment you walk into a question/chat and that has nothing to do with your diamond.
Given [1,2,3], I wrote the following to get [[1],[2],[3]]:
ghci> map return [1,2,3] :: [[Int]]
[[1],[2],[3]]
Is this usage of return idiomatic in Haskell? I'm asking since I could've also used pure instead.
@rolfl Have you considered answering on Programmers or DBA? I think you're quite enough of a generalist where you could create some good answers there. Or there's always PPCG... ;-)
To me (coming from a relational database background), "Big Data" is not primarily about the data size (which is the bulk of what the other answers are so far).
"Big Data" and "Bad Data" are closely related. Relational Databases require 'pristine data'. If the data is in the database, it is accur...
First of all, we have this question from four years ago:
Check if a subview is in a view
Despite carrying an Objective-C tag, ultimately this question is purely just asking about an object/method out of UIKit, which is one of the frameworks for writing iOS application. And even though the "pse...
@rolfl That is an awesome answer, I never quite understood what the heck "Big Data" meant, I always thought it was just one of those marketing mumbo-jumbo terms
Actually, I have mixed feelings about participating in it much beyond chat. I could ask/add some interesting comments/questions for the mod questionaire.
but I don't want to 'endorse' anyone (or sink them either)
With somewhat of a small site (and this chatroom), basically everyone who will run for mod knows one another somewhat well, it will certainly require some thought.
I have a big (50k*150k) matrix with co-occurrences of nouns (rows) and adjectives (columns). As most nouns don't co-occurr with most adjectives, this matrix is very sparse, >99.9%, so I'm using the CSR format. For every pair of nouns I need to calculate the Jason-Shannon Divergence to asses how s...
I'm writing a function to reverse a number in Ruby. IE, 314159.reverse should return 951413.
Here's what I have, which works:
class Numeric
def reverse
str = self.to_s.reverse
if self.is_a?(Float)
return str.to_f
elsif self.is_a?(Integer)
return str.to_i
end
end...
I have a legacy system with a class with a lot of data. I am creating a web service that inserts a new claimant into that system for a contractor. I can not refactor the claimant object.
I need help on how to refactor my tests. I would never leave this as is but I wanted you to have the raw code...