You've posted a lot of code, so I'm going to give a general overview of some common mistakes I see people making (and are also happening here).
You are using lots of magic numbers and magic strings. Let's instead create constants somewhere for all of these.
You're using NSLog statements withou...
Problem:
Some numbers have funny properties. For example:
89 --> 8¹ + 9² = 89 * 1
695 --> 6² + 9³ + 5⁴= 1390 = 695 * 2
46288 --> 4³ + 6⁴+ 2⁵ + 8⁶ + 8⁷ = 2360688 = 46288 * 51
Given a positive integer n written as abcd... (a, b, c, d... being digits) and a positive integer p we want to find a...
One thing you could do is create functions to call instead of writing each sub function out every time you want to animate something.
var hideText = function(element) {
$('#menu ' + element).stop().animate({
width: '0px',
opacity: 0
}, $('#menu ' + element).hide);
}
var sho...
this is my implementation of a tictactoe game with Tkinter GUI. So far I've set up the game to play with another player. For an interview coming up, I am suppose to build additional feature such as play with AI.
I would love some general feedback on this. (Does my code smell? Can I organiz...
You could do: str.split('<') and then iterate through the array that is returned, taking the first character of each element and pushing it to a separate array.
Next release of Rubberduck (should be 1.4) introduces a reorder parameters refactoring, which lets user reorder the parameters of a module (or class) member, and automatically adjust all usages.
Before:
After:
This is the IDialogView interface implementation:
interface IReorderParameter...
This is my implementation of a tictactoe game with Tkinter GUI. So far I've set up the game to play with another player. For an interview coming up, I am suppose to build additional feature such as play with AI.
I would like some general feedback on my code. (Does my code smell? Can I or...
In a further exercise of my original Battleship test framework, I have enhanced and refactored the SmartRandom class from an earlier question and have updated GitHub project to incorporate most of the suggestions I received for the previous questions. the full context), I have finally written a ...
Boba Fett is a fictional character in Star Wars. A recurring antagonist in Star Wars Episode V: The Empire Strikes Back and Star Wars Episode VI: Return of the Jedi, he is a bounty hunter hired by Darth Vader. He also made a cameo appearance in the digitally remastered Special Edition of Star Wars Episode IV: A New Hope working for Jabba the Hutt. Star Wars Episode II: Attack of the Clones establishes his origin as an unaltered clone of the bounty hunter Jango Fett raised as his son. His aura of danger and mystery have created a cult following for the character.
== Appearances ==
=== Original... ===
Here is an updated version of my Loot Table. I dropped the "all probabilities must add up to 100" and instead left it open for the programmers own implementation.
using System;
using System.Collections.Generic;
using System.Linq;
namespace NovaEngineFramework.Framework.Probability
{
public ...
I have tried the below program to find (Kth element from tail) of Singly linked list. I will Appreciate your time for review. I have tried to utilize the length field which I am incrementing whenever an item is added into the list or vice versa.
public Node<T> findKthFromTail(int kth) {
// l...
I would like someone review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand.
I used code climate and I got 4/4 and my test coverage is 96%, yet I would like a professional opinion about it.
'use strict';
var cheerio = require('cheer...
I would like someone review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand.
I used code climate and I got 4/4 and my test coverage is 96%, yet I would like a professional opinion about it.
'use strict';
var PromisePolyfill = requir...
I'm stuck with a contest problem.
Description:
What is the minimum number of removes in an int array where the remove actions is as follow:
- If the top (first and last) elements of a vector are equals. Remove then.
- Else remove one of the top elements.
Input
The first line is the number of te...
Having a bit of trouble with my assignment (bear in mind that this is an assignment so I'm really after psuedo code if anything).
It's using these datatypes:
`typedef struct edge{
int toVertex;
unsigned int distance
} Edge;
typedef struct edgeNode{
Edge edge;
struct edgeNode *next
} *EdgeList;...
I'm in the process of attempting to write a parser compiler. In this, sets play a major role. I'm in the 'lexical ambiguity' isolation phase, and to that, I need to yield a set of every possible permutation of a given set of items which represent an ambiguity.
An ambiguity is reached when ther...
I have a XAML UserControl embedded in a WinForms/WPF Interop ElementHost control. The control is pretty simple - it's just a dropdown with a button - here's the entire markup:
<UserControl x:Class="Rubberduck.UI.FindSymbol.FindSymbolControl"
xmlns="http://schemas.microsoft.com/winfx...
Here is a copy of my entire code. Everything in it works except, in the IsAlphaStr function, the if and else statements at the end to output whether the string[] has only alphabetic characters or other characters as well. The output automatically jumps to the else statement declaring that it has...
Cross post from stackoverflow, as suggested.
I have an ordereddict, and I need to store it in CSV file.
Input:
dic = collections.OrderedDict([('k1', 'v1'),
('k2', 'v2'),
('k3', [ [('k3a',21), ('k3b',22)],
...
i've managed to create a working shopping cart and my next concern is security. Mostly about the arcitechture and session security.
Should i make sessions somehow secure, if there's no authenticated login and sessions are deleted when browser closes? or is session_start() enough in this case?
W...
The goal of this query is to get a list of payments where all the corresponding payment lines and transactions have the status CLOSED. These are one to many relationships. The database is Informix.
I wonder if there is a more efficient way to write this? In its current state it has a lot of repe...
I was pondering the close reason today and I can't think of an instance where a question that is on-topic for Code Review is too broad.
When is a question too broad? How could a too-broad question be edited to be acceptable?
This assignment is taken from here
Introduction
In this project, you will develop a geographic visualization of twitter data across the USA. You will need to use dictionaries, lists, and data abstraction techniques to create a modular program.
The map displayed above depicts how ...
Here my DAO:
Dataprovider for excutenonquery with store procedure.
public SqlDataReader GetData(string query)
{
SqlCommand comm = new SqlCommand();
comm.Connection = openConection();
comm.CommandType = CommandType.StoredProcedure;
comm.Comm...
I am very new to programming and I like it when I can look at a program someone else makes a program and then I can mess around with it afterwards.
Can someone please show me how to make a prime number generator that I can choose the length of how many I want (like all prime 1 to 100 or 1000000)...
@JeroenVannevel you've been playing with the analyzer code. I've got a question for you when you have a second. Let's say I have a class that I use internally, but am in turn exposing a slightly altered interface of it to COM Interop. So, for the sake of code reuse, this class needs a particular constructor that should only be used by code in my Rubberduck.SourceControl.Interop namespace.
If I created a custom attribute, like Obsolete only different. Something like InteropOnly say... I should be able to write an analyzer to reflect over the code, look for the attribute and if the namespace isn't Interop, raise a warning about it, right?
I know that sounds very theoretical (because it is), but it seems to be an interesting possible use of a project specific analyzer. Thoughts about it?
You just register a code inspection on ObjectCreationExpressionSyntax and look at semanticModel.GetSymbolInfo(expression.Type). Now you can retrieve all the attributes using symbol.GetAttributes(). For each attribute, look if its attribute.AttributeClass.MetaDataName is equal to InteropOnlyAttribute. Now all that's left is verifying if you're in the namespace you should be in using expression.AncestorsAndSelf().OfType<NamespaceDeclarationSyntax>().First().Name
I've voted to close this question as unclear. At this point, based on the asker's comments the question seems more like a rant or a troll. This question could be improved if the asker either added an example of what "evidence" might look like or if an explanation of what they'd like to see in response to a potentially inaccurate on-hold reason being used. — nhgrif13 hours ago
@nhgrif - it's not a duplicate of that question. That question is Float -> Int. This is NSTimeInterval -> Int. I didn't know NSTimeInterval is a Double. — TIMEX3 hours ago
In chronological order:
session.php:
If you're into ternaries, you could always change it to:
(session_status() != PHP_SESSION_NONE ?: session_start() );
My Ajax is terrible, so I'll have to skip that, sorry.
add_to_cart.php:
You call two main variables: $error & $success. For $error, inst...
I've voted to close this question as unclear. At this point, based on the asker's comments the question seems more like a rant or a troll. This question could be improved if the asker either added an example of what "evidence" might look like or if an explanation of what they'd like to see in response to a potentially inaccurate on-hold reason being used. — nhgrif13 hours ago
I have a method which creates an excel workbook using COM Interop:
using System.Runtime.InteropServices;
using Excel = Microsoft.Office.Interop.Excel;
...
private void CreateWorkbook(string WorkingDirectory, string FileName)
{
Excel.Application excel = new Excel.Application() { DisplayAler...
As an example a piece of my code:
function togglePerspective(event) {
switch(event.which) {
case 32: // space
perspectiveView();
break;
case 97: // a, left
leftView();
break;
case 100: // d, right
rightView()...
Code Review currently has three standard off-topic reasons:
Questions containing broken code or asking for advice about code not yet written are off-topic, as the code is not ready for review. After the question has been edited to contain working code, we will consider reopening it.
Questions m...
Well, this question is for CodeReview, not for stackoverflow. But I'll give one advice at least, don't evaluate all numbers from 1 to 1000000, searching for palindromes. There are not too much of them, it's better to generate them. — mkrakhin14 secs ago
Posting from my phone... So this'll have to done for now. One reason should cover the general case of the asker isn't even seeking a review. That can include code not yet written or asking for an explanation of code or the results of run code. This separates code not yet written from broken code and let's the broken code reason elaborate on "not working as intended" as well. — nhgrif18 secs ago
@200_success I will post an actual answer this afternoon if what I'm trying to get across still isn't clear
I'm having some confusing with async/await keywords. I've gone through a couple of tutorials and they seem to follow the same pattern, which goes something like:
Create this class and call it's Async method, isn't it awesome?!
Which is great, but it doesn't really explain how these methods impl...
I believe we should use 5 close reasons. This will significantly reduce the confusion people may express when they have to figure out which of multiple close reasons was actually used to close a question:
Questions must include the code to be reviewed. Links to code hosted on third-party sites ...
@SimonAndréForsberg - I feel it is impossible to 'police' the not-your-own-code - when it is obviously "not their code" it is easy to close for all sorts of reasons. When it is not obvious... what then? The explaining the motivation is key. — rolfl ♦15 secs ago
I'm voting to close this question as off-topic because it is not about a specific programming question, but a general code review. As an aside this would be a really good question on Code Review, and I have flagged it for migration. — rolfl33 secs ago
Did the original code not include an unlock somewhere in there?!? In answer to the question, usually delegate-protocol pattern or completion blocks are better, where the time consuming process pro-actively notifies the caller when it's done, rather than spinning/waiting for completion. But it's impossible to say without far more details about what this separate thread is doing. Also, this might be a better question for codereview.stackexchange.com. — Rob28 secs ago
There, moved the auto-generated unit test files to a NuGet package. Now I can use it more easily as a dependency and I can fix that ugly unit testing code they had in there
I'm pretty new to client side scripting and I'm still learning.
I've written this JS plugin which animates blocks of HTML (fade-in from left/top/right/bottom) as you scroll down the page.
Everything seems to be works correctly, but was just wondering if there is anyone who could suggest how I c...
Let's say you have a Employees table mapped to a Employee class. Now you want to code a Edit page for general information. You need a ViewModel with all the properties you need to build the page, so you create EditEmployeeViewModel. Then you make your action EditEmployee and your view EditEmploye...
is it possible to add AJAX stuff to the Tool Box of Visual Studio? or is it easier to just write the code? I mostly use the toolbox so I know what there is to use
Ik, I just never know what to search on google, ironically. The last time I tried to search for them, I typed this into google: "Javascript online google hosted libs". facepalm.
I am writing a script that will check the set values against a .properties file and I am just wondering if there is any nicer way to right what I have here ?
#!/bin/bash
# @summary Check Values
# --------------------------------------------------------------------------------------------------...
interpretation is everything in the Programming world. you are always trying to interpret something that someone said or trying to interpret results of something
@Mast you must not have been doing it right. they are super nice and simple.
@Mast that's over my head, I haven't done anything supercool with JavaScript. but I know that soon I will be needing to learn more advanced things with it.
Well, I am doing a game, this game use nape physics in ActionScript, but my question isn´t about language and it is about use of pattern.
I had fruits in my game. I did one interface Fruit and fruits like Banana using this interface, I made too a class Fruits to get random fruits in runtime.
p...
I've migrated your post to Code Review; it'll start afresh there. Just sign in on Code Review with the same credentials you use on Stack Overflow and the question will be assigned to your account. — Martijn Pieters ♦12 secs ago
Our school grading scale is from 1..10 with one decimal. If you do nothing you still get a grade of 1.0. A passing grade equals 5.5. A a 'cesuur' percentage defines at what percentage of correct answers the 5.5 will be given to a student.
Examples:
List item
Grade(0,100,x) should always result...
So I've been experimenting with MVP pattern on Android, using dagger2, Otto eventbus, butterknife, android priority jobqueue, and using retained Headless Fragment as a presenter.
The basic setup is this:
LoginActivity
public class LoginActivity
extends BaseActivity
implements L...
Well, I am doing a game, this game use nape physics in ActionScript, but my question isn´t about language and it is about use of pattern.
I had fruits in my game. I did one interface Fruit and fruits like Banana using this interface, I made too a class Fruits to get random fruits in runtime.
p...
I'm voting to close this question as off-topic because it is not about a specific programming question, but a general code review. As an aside this would be a really good question on Code Review, and I have flagged it for migration. — rolfl ♦1 hour ago
Aim: Find a value via a stored procedure then run a second process in the same stored procedure than than calling a second stored procedure.
Query: When a call is 'simple' i.e. not Where x y then... I keep the stored procedure, even when I need to get a variable, in the same procedure.
Why her...
The need came up the other day to be able to easily switch back and forth between making IBM DB2 queries and MS SQL queries. I didn't want to mess with NHibernate as I was on a time crunch, and I also didn't want to have a million connection strings. Lastly I learned a while ago that for classes ...
A Friend gave this puzzle:
Find 3 numbers (say, A B C) such that `
ABC+ABC+ABC = CCC
`ABC means ((A*100) + (B*10) + C). and also,these 3 digits must be distinct,
I wrote a quick code to find out the answer:
int main(void) {
// your code goes here
int hun,dec,unit;
int final_nu...
This question is a followup to the last one.
I followed RobH's advice and his edge case bug found in my code with this solution:
private Line CreateParallelLine(Line target, int offset)
{
var parallelLine = new Line();
var xDifference = target.point1.x - target.point2.x;
var yDiff...