I probably broke some rule but calling the functions the way I did though. it doesn't look right to me at all but I didn't want so many variables either because placing the variables was a chore in itself.
@amon, you have 3 return statements in a small function, and one can be done away with? that is bad code, why would you disagree with eliminating a return?
it's still readable, granted the functions are called several times, that is easy to change with assigning variables. the point is, that the OP doesn't need 3 returns in the function, it looks wrong to me with 3 returns. maybe it is personal preference.
We are given a string which is compressed and we have to decompress it.
eg. "(a(bc2)d2)$"
'$' indicates end of string
"(abcbcd2)$"
"abcbcdabcbcd"
This is the final string.
My code:
import java.util.*;
class decompress
{
public static void main(String[] ar)
{
int end = 0, s...
you don't even use linkedContact in that function, I assume that the getLinkedResource needs a linked contact, if that is the case then you really only need to check for the linked Resource, maybe something like this
var linkedResource = getLinkedResources(getLinkedContacts(this));
and then ...
@Malachi *sigh* You have half a point there, but I prefer avoiding one level of intendation with an else when the if branch terminates the control flow anyway (break, return, throw,…)
@amon alright, now I will delete it.... I have been defeated but not like the armless legless knight from the search for the Holy Grail (Monty Python edition)
First things is first.
When you create a database, you only do it once, and you script it out and execute in the SQL database itself. I wouldn't use ruby to create the SQL Create Script for you. It seems illogical to me that you would create the tables on the database in a language other than ...
Not sure if this is the right place to post this. Tried Stackoverflow but told that it wasn't appropiate there so I came here.
Anyway, my company recently started doing formalized code reviews. The process goes like this: you submit into a github, request a pull request, code gets reviewed by ap...
A long time ago, in a galaxy far, far away...
There was this Bounty Hunter that travelled the Stack Exchange world like a Chuck Yeager, always the fastest gun in the west, always on time, always right, never afraid to steal a checkmark.
Most of his posts managed to get 500 views in 2 days, but ...
I have a team that works on multiple technologies. I want to know how can I automate the process of code review for .Net, .Net MVC, Python, PHP, Drupal and HTML5/CSS with JavaScript.
I have read about and have used some tools like StyleCop/FxCop for .Net and PHP Code Sniffer and likes for PHP an...
Indentation. If you are using Eclipse, please select all your code and press Ctrl + I. Your entire for-loop should be indented one step further.
Use methods. One method for inputting a String, one method for making one iteration of the "decompression".
Did you forget about how to properly use in...
I'm trying to embed a player to play a video from a CDN.
This code was generated by the setup tool, and will work just fine:
<object width="470" height="320">
<param name="movie" value="http://osmf.org/dev/2.0gm/StrobeMediaPlayback.swf"</param>
<param name="flashvars" value="src=+rtmp%3A%2F%2...
By the way, if you ever see anyone create code-review or something like that, please tell the OP that it's a bad tag to have, most likely send them to Programmers, and then edit out the tag. If this happens again, I may need to request a blacklist.
The task is to compress a string.
eg. "abcbcdabcbcd"
Here as you can see some characters are repeated, so it can be compressed.
"abcbcdabcbcd" -> "(a(bc2)d2)$"
'$' denotes end of string.
My code:
import java.util.*;
class compress
{
public static void main(String[] ar)
{
...
Your naming is awful. Even void main(String[] args) has been butchered to void main(String[] ar)... and the only identifier that's more than 2 letters in this code, is called found - which implies a search, but the method is called compress.
What exceptions are you swallowing, and why? I'm no ja...
^^ thanks whoever upvoted my answer here, that was my 5th post with 2+ score since WB2013 has started, I got my 20th and 21st hat!
We don't do code golf here. The purpose of CR is to write good code. If you're looking for golfed code, I'm afraid you've knocked the wrong door; please see help center — retailcoder7 mins ago
I'm trying to improve the following code for testability.
public function can_apply_extension()
{
$search_dates = [
Carbon::createFromTimestamp(strtotime($this->billing_verified_to))->subMonth(1),
$this->billing_verified_to
];
$record = ORM::factory('a model')
...
I'm a 14 year old programmer who recently started PHP and has prior knowledge of CSS and HTML. I recently created a website (http://heyitsprodigy.com) that has the capability to upload files to your own directory(essentially a dropbox/mediafire). I just want to know what the more experience progr...
I anticipate using the following fiddle as the UI For navigation in my site for a portfolio (one day). I was wondering what could be done to further optimize this code. As you can tell, I'm new to javascript; but please be as brutal as possible!
Edit: the reason I did this was because it was imp...
I wrote a Java lock free queue implementation.
It has a concurrency bug.
I cannot find it. This code is not important. I just worry about I cannot explain observed behavior related with volatile variables.
The bug is visible by the exception ("null head").
This is impossible state because there ...
On the attached fiddle is what I hope will the be future UI for navigation on my own personal portfolio site. I was hoping you guys could critique the javascript I wrote to accomplish the most compatibility with the most browsers. I've tested as far back as IE 7 with this code and it works. Where...
I am working on my game, and have made a level class, but my parselevel() method will not let me parse the level, because of "Block" not being a global variable (Block is my block class).
Traceback (most recent call last):
File "C:\Users\Benjamin\Documents\GitHub\ShipGame\entity.py", line 5, ...
Let's say I have a model that has 'purchase' method. The purchase method should take care of purchasing a product.
Signature of purchase
public function purchase($token, Model_Member $member, Model_Product $product, Model_Recipient $recipient);
To call this method, I need to make $member, $pr...
Related: On migrating from SO: how to do this efficiently and appropriately.
I've just come accross a question which I believe is ideal for code review. However it's already got an accepted answer.
I can't flag that it should go on code review, and I'm not sure flagging is the best approach.
S...
You Data Needs to be more
ATOMIC AND HOMOGENEOUS
on this table
create table StudentGradeReport
(
StudentGradeReportId int primary key identity(1,1),
StudentInstanceId int foreign key references StudentInstance(StudentInstanceId),
SubjectId int foreign key references Subject(Subject...
On the attached fiddle is what I hope will the be future UI for navigation on my own personal portfolio site. I was hoping you guys could critique the JavaScript I wrote to accomplish the most compatibility with the most browsers. I've tested as far back as IE 7 with this code and it works. Where...
The phrasing was probably changed because I talked about other attempts and their lack of portability. Just wanted to make sure I could still ask for optimization advice in future.
That's fine. Next time, just keep the specific request in the body and the code purpose in the title. You should also use optimization for such request.
@SimonAndréForsberg: I see that change as a more programming-specific one anyway. I can only change most titles if I can find the purpose from the request. Otherwise, I let someone else handle it.
Hah; well I've got to finish up a presentation on the basics of HTML and CSS for my company anyways. So I should probably go wrap that up, as it's due tommorow. Have a good day y'all! Thanks again!
I think that I was searching for something similar, and then I answered on it, so it got bumped, maybe people are checking out our profiles @retailcoder
I am being a Grinch right now, but I think that this question is off-topic in that it is asking for code to be written, the OP asked where to add indexes. it's really walking the fine line.
I'm creating an open source stack exchange clone and the following is my schema. What should I add indexes on for it to be optimal?
Here is the schema in Rails format (SQL format below as well):
create_table "comments", force: true do |t|
t.integer "id"
t.integer "post_id", ...
There isn't much to review here. However I did find this:
public class CustomerRepository : ICustomerRepository
{
public IValidation<Exception,Customer> GetById(int id)
{
if (id < 0)
return new None<Customer>().ToValidationT<Exception>(new Exception("Customer Id less...
My needs outpace my abilities, this code (mostly) works, but it is really ugly, doesn't always add correctly, and is in desperate need of some help refactoring. I can't wrap my head around what needs done with it.
I have a sqlite table "WorkLog" which contains rows of (int, long, long, long, lo...
For a moment just now I thought: What kind of parent are you, putting a baby to sleep at a quarter to one in the middle of the night?? Then I realized, oh, timezones...
@amon yes but only like the ones you see next to the kitchen sink, with the little button and the retractable hose....
@rolfl you don't have an account on dba.stackexchange.com????
@retailcoder, my awesome amazing code that I self answered on that one question with, works in Stage but not in Production. the 3rd party application must be different somehow, or something
I am writing a c program to read a list of words , sorts them in ascending (alphabetical) order , count the occurrence of a user entered word and searches for a user entered word all in the same program but i did each request separately first
however i do not know how to write it in 2D array of ...