« first day (1065 days earlier)      last day (2958 days later) » 
00:00 - 20:0020:00 - 00:00

12:07 AM
0
Q: How specific should error testing be with cucumber/capybara?

user2367593I'm working on writing tests for a rails application using cucumber and capybara. I have a scenario for a user editing a post, and making it invalid. The scenario looks like this: Scenario: I edit a post and make the data invalid. Given I have 1 post And I view my 1st post Then I click "Ed...

 
@DanPantry what purpose & city?
 
in The Whiteboard, 2 mins ago, by Phrancis
This will be closed on Code Review due to asking about code yet-to-be-written... I just wanted to run by you guys if it would be on-topic on Programmers?
 
12:26 AM
Woot, new SSD works.
 
-1
Q: Using Dictionaries to count first letter in a string

NicoleI've been working on a dictionaries exercise in Python, and I'm fairly new to the language and programming in itself. I've been trying to take a string or list of strings and have my code compare the first letter of the strings and make a dictionary out of how many strings begin with a certain le...

 
Is this pseudocode, or can cucumber/capybara actually run this? — Hosch250 7 mins ago
@Hosch250 do you really think that... thing is actual code...???
If so,... that's realllllly weird
 
It might be.
There was a similar question I've seen before that was.
 
totally reads like that
 
Yeah, Cucumber generates that reaction a lot, but this code actually runs. — dankohn Feb 26 at 22:03
 
12:30 AM
WTF. OK
 
no wait
I'm silly
I read a similar descriptive language once but Prolog is too far off
 
@JeroenVannevel Is there a way to log things in a portable library?
 
yes but no
 
OK. I'm kind of struggling with Roslyn just now.
I can't find any problems with my analyzer/fix, but it isn't working.
 
I think portable libraries can log but they use the log settings as described in the calling project (like a web api or console app)
 
12:33 AM
Scenario: feeding a small suckler cow
  Given the cow weighs 450 kg
  When we calculate the feeding requirements
  Then the energy should be 26500 MJ
  And the protein should be 215 kg

Scenario: feeding a medium suckler cow
  Given the cow weighs 500 kg
  When we calculate the feeding requirements
  Then the energy should be 29500 MJ
  And the protein should be 245 kg
^^ from the cucumber manual .___.
 
Told you so.
 
That's just ludicrous. But, I'll pull my VTC and comment again...
 
A library shouldn't log outside the control of the calling code. I like libraries that ask me to implement a logging interface and just pass me the stuff they'd like to log and let me decide where to put it.
But logging should mostly be used for debugging purposes, and in the release build of my app, I typically want to turn off all logs from 3rd party libraries...
 
Yeah, Roslyn is so hard to work with because I can't just debug it (or I haven't figured out how yet).
I have to run it from the command line with a special command. I can't just hit debug.
I can't just add the System.File reference.
 
Then you need your library to print to stdout if you want to see the logsz
 
12:38 AM
Right. Except that Console.WriteLine doesn't work because they didn't reference Console in this project.
 
Console.writeline doesn't print to stdout
 
Oh. Hmmm.
 
Does it have a network reference?
 
Console.WriteLine("stdout");
Console.Error.WriteLine("stderr");
The web says it does.
@EBrown Not sure, probably not.
 
@Hosch250 If it does just send pings in morse code.
 
12:40 AM
LOL.
 
5
A: How to write to a program's StdOut Stream directly in C#?

MikePYou can get a hold of the application's stdout by calling Console.OpenStandardOutput. From there, you can do whatever you want with the stream, although you won't be able to reassign it. If you want to do that you'll have to P/Invoke SetStdHandle and handle the details yourself. EDIT: Added exam...

 
Then monitor the network traffic.
 
@nhgrif That looks... evil.
 
...---...
That's my morse code error messages.
 
If console.writeline prints to stdout, you will see it when running your app through console
 
12:43 AM
The problem is the Console class isn't references by the project he's debugging.
 
using System;
 
Well, can you call C libraries?
 
@Mat'sMug It still isn't referenced, I tried.
 
Just use printf
printf is standard C...
 
I may have just found the problem--a missing attribute.
@nhgrif I'll try that if this doesn't work.
 
12:48 AM
Sounds like C# isn't cool enough to printf
 
printf("hello 1970");
 
Heh, now you sound like I client a deal with who has referred to Swift as the "flavor of the week"
 
#TooCoolToPrintf
printf doesn't work.
 
@nhgrif maybe he thinks Swift is a JavaScript framework?
 
1:15 AM
lol
BTW, printf works fantastic in Java.
System.out.printf("Welcome to %d, %s!%n", 2016, "@Mat'sMug");
 
@Phrancis Except that's not the same as the C printf.
 
Oh. OK then... lol
 
@Phrancis great. now try making a GUI that doesn't suck in Java ;-)
 
@Mat'sMug Impossible.
 
@Mat'sMug You mean like your Android phone's GUI? ;p
 
1:20 AM
cornered
 
Marketing dweebs; how about you let the devs work on the backlog of customer requests today and not some awful April Fools landing page?
 
@Phrancis Which are the definition of suck.
Gah, I need to get started on this bot stuff.
 
I'll readily admit though, many GUI things in Java are ugly, but I think it's more because Java developers are in general not good designers ;)
 
“How can I add the Start button back in?” - Windows user using the Windows 10 Linux command line.
that guy's hilarious
 
LOL
Yeah @iamdevloper is one of my fav feeds
I'm really jamming to this, y'all should try it
Great music for implementing Java interfaces
 
1:30 AM
I constantly worry about the modules in my applications being decoupled, but then I remember you have to quit iTunes to update Xcode.
 
@EBrown That sounds incredibly idiotic.
 
What’s a dinosaur’s favourite file format? .rar
 
@Hosch250 It's all in good fun. Apple is not very much unlike what he said
OS X / Apple is kind of an obnoxious ecosystem, which does you good most of the time, but some things are PITA
 
it's like VBA was Apple's doing
 
I'm here, by the way...
2
 
1:37 AM
hides
 
lol
 
I like my Mac, I've had literally one issue with it so far and I'm pretty sure it was my fault for being a dummy.
 
^^
 
iForbid m'iWife to install iTunes on m'iComputer
4
 
Eh, iTunes is mostly good
 
1:39 AM
except if you're running Windows
 
iTunes is only useful on Windows/Linux if you have an iOS device.
 
What's the alternative? Windows Media Player?
 
Spotify...
 
Sadly, I've had more success with iTunes and Winamp than Windows Media Player.
 
iTunes is exactly why I never got an iPod
 
1:40 AM
The Microsoft one just cannot handle my library of 40K+ songs.
 
From my perspective, I've loved how iTunes helps me organize my music projects, and has some really good encoding algorithms built in
 
Doctors say that you should do something that raises your heart rate every day. Thankfully I’m doing Angular at the moment
 
I'm sure it's excellent on an Apple machine. but it wrecks Windows.
 
@EBrown LMAO
 
1:41 AM
@Mat'sMug I've never had problems with it. :P
 
WinAmp is still a thing?
 
maybe it improved since 2006
 
when I used to use Windows, iTunes was the bane of my existence, now that I'm on a Mac, it's much better. At least before iCloud Library integration
 
@Phrancis I still use it.
 
@Mat'sMug I'm just not sure which aspect(s) of iTunes didn't work out for you. I've used it on Windows machines too
I do know which aspects of iTunes bug me, and how to work around them
 
It's a completely different app on Windows. It's not that great on windows.
 
@Quill lol, they link to a dead link http://stackoverflow.com/seriously/unikong
 
I got it to work again.
 
I just found out this is a thing
 
2:03 AM
> It's free for Open Source!
nice
 
public interface IDefaultMethods {

    void implementMe();

    default void implementMeMaybe() {
        System.out.println("Implement me... maybe...");
    }

}
 
looks like my unit tests
 
Maybe I'm having too much fun with this...
 
@Phrancis wait that's legal?? an interface with a default implementation?
 
@Mat'sMug Yeah?
 
2:10 AM
Java doesn't have abstract classes, right?
 
Sure it does
 
wtf is the difference then?
 
@Mat'sMug Well, one is an interface, one isn't...
 
@Phrancis I've never seen this done before!
 
@Phrancis gee thanks
 
2:12 AM
AFAIK default methods in interfaces is relatively brand new (Java 8)
 
    public abstract class Something
    {
        public abstract void ImplementMe();

        public virtual void ImplementMeMaybe()
        {
             Console.WriteLine("foobar");
        }
    }
 
@Mat'sMug Looks pretty similar
 
^^ works since C#'s first version
default implementations feel a lot like C#'s virtual methods
but an interface can't have virtual methods.. it... doesn't make sense
 
May be a case of Java abstract classes not forcing you to implement a method, while interfaces do. But either can provide a default implementation
 
you're never forced to override a virtual method. you have to for abstract ones though, but an abstract method can't be defined with a body
 
2:15 AM
C# virtuals are like Java's abstracts AFAIK, concur?
 
Not IIRC.
 
a virtual method is pretty much like your default implementation
 
Actually I think Java's abstracts are like C++ virtuals
 
@Mat'sMug That's a very simple way of putting it...:P
I need to finish this damn blog post.
 
@EBrown Still!?
(joking)
 
2:19 AM
@Phrancis Yeah...
I think it's time to buckle down, finish this, and have @Mat'sMug and/or @JeroenVannevel evaluate it for me.
 
Talking about blog posts, can someone review this for typos? hosch250.wordpress.com/2016/03/31/…
 
 String blogPost() {
        String finishedPost = "";
        if(author.hesitate) {
          author.prod();
          author.finishBlogPost(lateIdeas);
        }
        return finishedPost;
      }
 
@Hosch250 Cucumber is a language used for writing BDD tests
 
@Phrancis Serious formatting issues.
 
you can write it for .NET using SpecFlow
 
2:24 AM
2/10 fails review
 
@EBrown Sue me ;0
 
@Phrancis Roger that, making some calls.
 
 String blogPost() {
    String post = new StringBuilder(semiCoherentIdeas);
    if(author.hesitate) {
        author.encourage(String ... ideas);
        while(!post & ideas.length != 0) {
            post.append(ideas);
        }
    }
    return post;
}
 
Still not great.
3/10
 
LOL
Just finish the damn thing.
 
2:30 AM
Well hesitate is a field on the author object, which is wrong.
It should be isHesitating(), as a get method.
 
code.improves
 
Then you should have a space between the if and the opening parenthesis, same with the while.
 
And, why are you ANDing !post and ideas.length?
 
@SirPython Because if post is true then additional ideas will just fall aside
 
Wouldn't you use && then?
 
2:34 AM
Yeah, you should be using &&.
& is a bitwise operator.
 
No, it short-circuits
 
Not the single &.
The double does.
The single doesn't.
 
It does in java :)
 
Wut
37
Q: Java logical operator short-circuiting

AaronWhich set is short-circuting, and what exactly does it mean that the complex conditional expression is short-circuting? public static void main(String[] args) { int x, y, z; x = 10; y = 20; z = 30; // T T // T F // F T // F F //SET A boolean a = (x < z) && (x == x); bool...

False, @Phrancis.
The double short-circuits.
 
Whoa, I didn't realize you are Phrancis again!
3
 
2:35 AM
@SirPython LOL
 
Gosh @Phrancis, L2P.
 
@EBrown OK, I admit I got them mixed up; BUT & and | are still not necessarily bitwise, depends on context
 
@Phrancis While it does depend on context, it's easier to think of them that way and remember that & will always evaluate both sides.
Which is why we prefer &&.
 
Good trick
 
public boolean longerThan(String input, int length) {
    return input != null && input.length() > length;
}

public boolean longerThan(String input, int length) {
    return input != null & input.length() > length;
}
For that reason there.
The second one can throw an exception if input is null.
The first will never throw an exception if input is null.
 
2:39 AM
Ah very good, I get those mixed up a lot ._.
 
It doesn't depend on the context.
& and | are always bitwise. The result is treated as a Boolean though in some contexts
Where 0 is false and everything else is true
Try...
if (4 & 2) {
 
0
Q: Fixed time step game loop c++

Bla Bla BlaI'm writing a direct2d game in c++ / winapi, I need to render things 60 times every a second using fixed time step. Here's my game loop: __int64 time_before = 0; __int64 time_now; __int64 frequency; __int64 time_elapsed; double frameTime; if (QueryPerformanceFrequency((LARGE_INTEGER*)&frequency...

 
I finally got my laptop's VS 2015 updated with the new stuff from Microsoft and XNA I worked on my game a little bit today...
got it committed into my private BitBucket repo
and am ready to attack it head on! I am even going to look into making it into a really awesome Windows phone game!
@Hosch250 I just added your blog to my feedly as well
anyway TTGTB
 
Later @Malachi
 
later
 
3:03 AM
0
Q: Tic Tac Toe "Cats Game"/End Game

Seth GreeneI have almost finished making my first game in python, however I'm stuck on the final step. My program can determine when there is a winner, however I am unsure what to do if the board is full and there is NO winner (a cats game). I'll post the code below. Any help would be awesome! import cT...

 
 
2 hours later…
5:07 AM
0
Q: How to make this java code more modular and readable

srkI am solving a coding challenge whose objective is to print the right diagonal of a matrix. And below is my code to do that. package basics; import java.util.*; /** Problem statement : Print right diagonal of a matrix. Example: For input : a b, c d ; the right diagonal is b c **/ public class Pr...

 
5:58 AM
0
Q: How can I finish building out a PJAX "driver"?

a coderI'm not much of a javascript developer, and am building out a PJAX "driver" that requires 0 interaction, and easy manipulation of a website, so how would I improve this function, and make it work completely? var pjax_e = 0; function swapContent(href, url_data, target, loads) { $.ajax({ ...

 
6:27 AM
0
Q: TetrisPiece Class in C#

AdmiralAdamaI am writing a Tetris program in C# for programming practice, and I've got it working. This will be the first post in a multi-part series. Future posts will cover the TetrisBoard (the game logic), the WinForm, and maybe a graphical board and sounds that I will code later. Design Some design dec...

 
6:43 AM
0
Q: Operator Oveloading: "+" and "==" for two classes

UnbreakableI have one class Number (base class) and two child class Fraction and Integer. I am suppose to provide the functionality to add and compare two Integer obj, two Fraction obj, One Integer One Fraction obj by operator overloading. Below is what I have come up with. Can someone kindly review it. I a...

 
7:19 AM
0
Q: One dimensional array representation of a binary search tree

Lariza MaeI've been searching codes that displays the array representation of a binary search tree but still I can't find the code.. Here is my program that only display the traversal: can you please help me out.? import java.util.Scanner; /* Class BSTNode */ class BSTNode { BSTNode left, r...

0
Q: Java thread-safe performant algorithm

samHere is problem to be solved problem: TradingAlgorithm employs a trading algorithm which, based on the prices it receives, will return a trade to execute. The trading algorithm must implement the following interface: public interface TradingAlgorithm { Trade buildTrades(Price price);...

 
7:35 AM
Also, 100% true story. When I was stressed out working on SO, I would look at Jon Skeet's profile pic to calm down. This really happened.
 
 
1 hour later…
8:47 AM
0
Q: Python Tkinter Game - Treasure Hunt

RobinI posted this on Stack Overflow and someone suggested this was a better place for it. I hope it's OK here. I used to write a bit of BASIC years ago, and recently found an old book called "Fun Mathematics on your Microcomputer" with some mathematical games in. I'm learning Python and have tried t...

 
9:07 AM
0
Q: Given a string S and Q query strings(q1,q2,...), check for each query string whether or not it is sub-sequence of S

SantoshHere is my approach. import java.io.InputStreamReader; import java.util.Scanner; public class Query { public static void main(String[] args) { Scanner scanner = new Scanner(new InputStreamReader(System.in)); String str=scanner.next(); int n=scanner.nextInt(); while(n-->0){ ...

 
feels good man
 
0
Q: Solving a M*N board of different colors into a single color optimally

user6149854I am trying to finding an optimal solution of the flood filling puzzle game. My strategy is starting from the top left block, I will search for the neighbor blocks with maximum elements(nodes) and flood the top left block with this color and proceed in this way until the whole board becomes a sin...

 
9:23 AM
@Quill Addicted? ^^
 
I guess that makes SO my dealer ;)
 
10:04 AM
0
Q: AVL Tree Array Representation

JanelleIn a school assignment I'm supposed to create a program simulate insertion, deletion, count nodes, and delete tree algorithm and displays the traversal, level order, and array representation of it. The nodes are in their correct traversals. The problem is that this doesn't display all the indice...

 
I was actually really surprised my answer on an SO zombie was accepted so fast
or at all
 
10:52 AM
Seems like our friend @Duga has been dead for the past four days or so. She should now be up and running again.
 
RIP
 
What happened to her?
 
She was just playing an April Fool's joke I guess
 
Perhaps.
@Quill Not sure. Her webhook stuff still worked, but her tasks went broke. (comment scanning, answer invalidation scanning, reputation differences checks)
I'm not sure I want to know how many answer invalidations there are out there now.
4
 
11:16 AM
I'm voting to close this question as off-topic because this has no single right answer. Ask for code review on codereview.stackexchange.com. — bignose 1 min ago
 
11:33 AM
Changed my tinder bio last night to an explanation of my puppy picture. Already receiving matches that say they're impressed by it
Those puppies pay off tenfold
and I'm not talking about my biceps
 
11:45 AM
0
Q: how to connect liaison API lapi.ocx with php page

user101902i have sample code in vb but i don't know how to connect it to php page. send command and receive the result from sita servers. analyze the answers and show the result. here the sample code in vb Option Explicit Private Connected As Boolean Private Data As String Private Const TIMEOUT = 15 Pri...

0
Q: Haskell: Find biggest palindrome which is the product of two 3-digit numbers

PignaisPalindrome :: Integer -> Bool isPalindrome n = reverse x == x where x = show n is3x3 :: Integer -> Bool is3x3 n = any (\x -> cond1 x && cond2 x) [101..999] where cond1 x = n `mod` x == 0 cond2 x = length (show $ n `div` x) == 3 main = print $ head [p | p <- [999^2,999...

 
12:15 PM
@user No, this would get closed as example code on Code Review unless you provide us with context. The people recommending Code Review should learn to read the scope about that site BEFORE recommending. I'm sorry new users like you get caught in the crossfire. — Mast 30 secs ago
 
@CaptainObvious , off-topic.
 
0
Q: First time using entity framework with simple repository

Robert SnyderI'm working on updating a GitHub project that I use at work, but I think the person abandoned the project as there is a pull request for it since 2014. At work we use a Repository pattern with NHibernate and mappings and so forth but this project they use Entity 4.? I had to update the project to...

 
@Dex'ter: this question is fine here. This is too narrow a scope for Code Review. — Martijn Pieters ♦ 28 secs ago
 
1:12 PM
If you have working code that needs to be improved then you should ask this question on Code Review And include code in the question itself. — Dalija Prasnikar 28 secs ago
 
1:33 PM
isSub("hello", "eo") gives true -- is that a bug or a feature? — janos ♦ 2 hours ago
 
-1
Q: JAVA: Bubble Sort Implementation

EllieI'm a beginner and yes I've checked other similar questions, but I didn't quiet get the answer. I want to know where I'm getting wrong. While I ran the code I got this exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at bubblesort.BubbleSort.main(Bubbl...

 
1:46 PM
this kind of question should probably be posted on codereviewRC. 35 secs ago
 
2:04 PM
RC I will post my question in codereview, thanks :) — user3006595 38 secs ago
 
0
Q: Enhance the performance of the source code in Java

user3006595I need help to enhance the performance of java source code. The code take txt file that has name, amount and date in form (name) (amount) (date yyyy-mm-dd) separated by spaces. After reading the file the data will be (name) (amount) (date dd/MM/yyyy). public static void main(String[] args) t...

 
@Phrancis that turned out to be a feature
This solution does not give sub-sequence of String S. For example, S="hello" and q1="elo" . Return output is "No" whereas it should be "Yes" because "elo" is sub-sequence of String S. — Santosh 3 hours ago
 
2:33 PM
0
Q: Refactor for loop in ruby

Jay_PandyaI am doing program which is listed in codewars.com and the definition for the program is The product of a and b should be equal to the sum of all numbers in the sequence,excluding a and b with in given range. def get_correct_array(n) beginning_time = Time.now puts " Begin with #{Time.now}" mul =...

 
2:45 PM
1694
Q: Why does Windows think that my wireless keyboard is a toaster?

ydaetskcoRI've inherited an old PC from my girlfriend's dad and when setting up the printer I got a bit of a surprise: Two questions spring to mind here: Why does Windows think my wireless keyboard is a toaster? Why does Windows even have an icon for a toaster in the devices menu?

 
@EBrown so, my earliest thoughts on how to get a proper looking calculator model probably start with something looking like this:
enum Operation {
    case Add(Double)
    case Subtract(Double)
    case Multiply(Double)
    case Divide(Double)
    case Exponent(Double)
}
struct Formula {
    let startingValue: Double
    let operation: Operation

    var evaluated: Double {
        switch operation {
        case .Add(let addend): return startingValue + addend
        case .Subtract(let subtractor): return startingValue - subtractor
        case .Multiply(let multiplier): return startingValue * multiplier
        case .Divide(let divisor): return startingValue / divisor
        case .Exponent(let power): return pow(startingValue, power)
        }
    }

    init(startingValue: Double, operation: Operation) {
and then you need a FormulaQueue.
 
monking
@Quill One of the only questions with a lot of upvotes and more than the accepted answer.
 
Of course, @EBrown you can also add these two cases:
case CustomUnary((Double) -> Double, Double)
case CustomBinary((Double, Double) -> Double, Double)
 
3:17 PM
@MartinR so... Xcode 7.2 is giving me more fits than I expected with your code. :( I'm downloading 7.3 now to see about having them installed side-by-side.
 
0
Q: accuracy of percentage KNN classification by MATLAB

amrI have problem to classify the data in some of ratio like (70%=training) & (30%=testing) by KNN in MATLAB. Actually I have 20 randomly sample Left and Right dominance.13 sample left and 7 sample right.Every sample have 4th data(Delta,Theta,Alpha &Beta).So how to i classify and get the accuracy pe...

0
Q: Return a list of data made from an Ajax/HTTP in the order they were called

Clifford FajardoIs there a way to get your data back in the order in which you called your AJAX requests, without using promises, also no synchronous code or jQuery, but simply pure javascript? I'm quite familiar already with asynchronous programming in javascript, however I was asked the following question & i...

 
I'm voting to close this question as off-topic because it belongs on The code review Stack Exchange. — Basil Bourque 6 secs ago
 
4:00 PM
@nhgrif I don't have Xcode 7.2 available at present, but if I remember correctly, replacing return AnyGenerator { by return anyGenerator { should make it compile with 7.2
 
k, I'll try that
indeed it did
 
The global anyGenerator function was deprecated in favor of a AnyGenerator init method.
 
Gotcha.
The difference between while and until, hmm.
I want it to simply be
func iterate<T>(from from: T, until condition: T -> Bool, next: T -> T) -> AnySequence<T> {
    let whileCondition = { (arg: T) -> Bool in
        return !condition(arg)
    }

    return iterate(from: from, while: whileCondition, next: next)
}
but that produces a different result
 
The "until" version was motivated by the 3n+1 sequence example. With while: { $0 != 1 }, the final 1 is not included.
It is like the repeat { ... } while loop where the loop body runs at least once.
 
Yeah.
So, at some point soon, my company will be putting together a library with some Swift functions we like to commonly use, make it a pod. So instead of reimplementing them in every code base, we just pull the pod in. We had one of these for Objective-C. When we get this up, can I ping you so you can make a PR for these? (I'm still looking at posting an answer which covers, if nothing else, the colon spacing)
 
4:16 PM
Sure.
 
k. I'll let you know. I'm trying to decide on a path... because there are three options...
It is *pure* Swift and designed to be used for any platform.
It is designed to be used with several of the Apple frameworks, but not necessarily iOS/OSX specific.
It is iOS specific.
 
Btw. when Swift 3 is released, all Swift answers have to be rewritten heavily: github.com/apple/swift-evolution/blob/master/proposals/…, e.g. SequenceType -> Sequence, GeneratorType -> IteratorProtocol, ...
 
Code Review answers or Stack Overflow answers?
I don't think all have to be rewritten necessarily. But yeah... there'll be some changes.
 
It was just a thought ... applies more to SO answers.
 
yeah.
 
4:24 PM
0
Q: Basic animation in Typescript

CarcigenicateI decided to play around with doing my own super-basic animation. For a previous Javascript project, I needed the ability to flash an element. The code below is the result of me attempting to generalize the main animation loop function, and learn Typescript at the same time. What I'm looking for...

0
Q: Program calculating the equivalent value

DarKn1ghtI'm new to programming...I started learing C# and this is my first "project". It's main purpose is to calculate the equivalent value of two resistors or capacitors connected in either series or parallel. I just finishted it and was wondering can you review it for me? Tell me whats bad, whats good...

 
I imagine the whoever down-voted this did so because "what do you think?" is not a real or specific question. And you pasted in big chunk of code without indicating what you want to know. SO is not a code review or debugging site. — horchler 46 secs ago
 
Welp, I post an answer at least... I'm not sure it's that great.. just nitpicky.
0
A: A general iterator to replace "non-standard" C-style for loops

nhgrifFirst thing I notice is the inconsistency in the colon placement between the actual code you want reviewed and the example cases you've provided. I wouldn't necessarily bother bringing it up, except that in your code to be reviewed, you've used a style that doesn't seem to be preferred quite as ...

 
0
Q: Factory Pattern for image or shape marker

kangtakuI'm making photo marker app and need to make a factory pattern for marker. i think it is not flexibility and good. would you check my code?> import Foundation enum MarkerType: String { case Shape, Image } enum MarkerError: ErrorType { case ImageNoExist case ShapeNoExist } stru...

 
5:22 PM
By the average javascript developer. With no authority. Heh. Can you try a little experiment? For your next code review, try putting global handlers in your markup. I believe you'll get what authority means quite quickly ;) — Frédéric Hamidi 21 secs ago
 
5:34 PM
-3
Q: What is the best coding language for making simple software and maybe games for absolute beginners

Zehan ZorakI want to learn coding,but after digging in to it I found out there are tons of Programming language and all of them are useful and special in their own ways.So I want ot knwo which one is the est for a total beginner,I have never written I code knwo how to!. I don't even know where to begin.So p...

 
@CaptainObvious Nope.
 
6:04 PM
What made him think CR was the site to go?
 
@Mast "Code"
 
Pffft.
 
Alright, gotta go.
 
You might read this: I want to be a game developer... now what? When it comes down to it, programming for games is not really much different than any other "type" of programming. It's all just programming. — Phrancis 19 mins ago
That post I linked is actually not bad, grammar notwithstanding.
 
I might disagree.
 
6:13 PM
Maybe move the question to Code Review? — jdarthenay 21 secs ago
This may be suitable for Code Review if the code works as intended already and the author is looking for improvements to it. See the on-topic page there first. — Phrancis 57 secs ago
 
I can't recommend C# or Java as starting languages.
They both force you to deal with OOP from square one.
You can't write procedural code in them. You're inside a class, inside a method.
 
Honestly I don't know that there is any such thing as a "recommended" pick for starting languages... maybe I'm wrong.
 
0
Q: How efficient is my eraser tool?

Jason HeddleI am making a GIF Editor in c#, and currently I am working on the eraser tool. I am not sure what I can do to make it more efficient, because when I make the thickness (diameter)0 more than 30 (pixels) it starts to get a bit slow. Here is the code: if (click && eraserSelected) { ...

 
I guess Python is probably about as close to that as it gets
 
You can make recommendations for beginners, but there's not a good blanket "This is the language" pick.
 
6:20 PM
^ right
 
There are languages like C# and Java which I'd recommend against because it forces you to immediately deal with OOP before learning procedural basics and focusing on that.
 
I thought that procedural (with SQL being the exception) was a pretty outdated programming paradigm...
 
I mean, people still write embedded C programs.
 
Good point
 
But even if it were honestly the case that procedural programming is purely outdated, the fact of the matter is that procedural fundamentals are still applied in object-oriented programming
And to that end, for a pure beginner, choosing C or C++ as a language to start on for learning the absolute basics is a decent option.
Choosing C++ will make it a little easier to do a little more because input/output through the console is slightly more straight forward (at least to write the syntax), but choosing C will force you to write your outputs in a way more similar to a lot of other languages (printf).
 
6:25 PM
I think what the author of that article is trying to address, in fairness, is probably the mentality that "<insert popular game> is written in C++ so I should start learning C++"
 
But in either case, unless you really need to master C or C++, I'd certainly recommend moving on from those languages before you get into the mess of pointers and manual memory management.
And C is also a good starting choice because so many languages today are based in C, descendants of C.
So much of what you'd learn in, say, a college semester course of C programming, is going to apply basically exactly on to C#, VB, Objective-C, C++, Java, Swift, and probably plenty of others...
 
No doubt
 
0
Q: Eval is evil: Dynamic method calls from named regex groups in Python 3

Mikey T.K.I'm working on a simple dice roller for a Python IRC bot. The particular game this roller is for uses six different kinds of dice, which I've defined using a simple base class, and created six instances of it, passing a string array with the possible values of each dice. class DiceBag(object): ...

0
Q: Project Euler #7 10001st prime

denistoday I decided to start working on the Euler project exercise's I'm doing fine for now but the seventh problem is running quite slow and I cant think of anything to make it work faster. It takes around 1300-1500 ms to finish which doesn't satisfy me while I know it can be done in maybe 20-30 mil...

0
Q: Follow up - StringRef - read only std::string like class similar to boost::string_ref

NickThis is follow up of: StringRef - read only std::string like class similar to boost::string_ref Idea behind the class is same as boost::string_ref or llvm::SrtingRef. StringRef is immutable and not-owning. I did not implemented substring() yet, because I will not need it. Example...

 
what does C# method syntax look like?
for isPrime for example
bool isPrime(int value)
Like that?
 
Looks about right...
<Access Specifier> <Return Type> <Method Name>(Parameter List)
{
   Method Body
}
 
6:36 PM
@nhgrif Yeah, but you can also specify attributes on it as well.
 
no need
 
Attributes are awesome.
Especially if you want aggressive inlining.
 
Wow, while (primes.Count<10001) seems like an expensive way to keep track of how big an array is
 
@Phrancis it's a List
 
How so? :P
 
6:39 PM
Well, wouldn't you have to count the elements each time to know how many there are?
 
@Phrancis usually the count is stored separately to exactly not do that :D
 
Not for a List<T>.
 
Monking btw
 
Oh. My bad
 
in general you'd be correct, but counting separately is the "easy" fix
the problem is, in the moment you start keeping count separately you start to be open to multithreading problems
then the count can become out of sync with the actual count and that's a problem
and that's why there's specially threadsafe classes like ConcurrentList
 
6:42 PM
Make sense
 
IIRC in C# List<T> is thread-safe.
 
> Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
nope
 
0
Q: is this a good approach to implement Peterson's Algorithm (Mutual Exclusion) using C?

EliA simple algorithm that can be run by two processes to ensure mutual exclusion for one resource.Shared variables are created and initialized before either process starts. The shared variables flag[0] and flag[1] are initialized to FALSE because neither process is yet interested in the critical se...

 
it's too much of a performance hit to make those always thread-safe
especially since you don't need it in most cases
 
Would it be a common thing to do to extend it to make instances thread-safe (if the need called for it)? (just curious)
 
6:49 PM
Well there's a version for that.
 
@Phrancis the problem is, that there's different ways to ensure threadsafety. Sometimes a subclass cannot do the necessary steps for a certain mechanism so depending on how you do the securing, you may need to reimplement from scratch
 
TTGTW
 
0
A: Project Euler #7 10001st prime

nhgrif bool isPrime = true; for (int j = 2; j < i / 2; j++) { if (i%j != 0) continue; isPrime = false; break; } if (!isPrime) continue; This is one of the most primitive and least efficient ways to calculate whether or not a value is prime. First and foremost, we deserve a method which ...

Regarding the thread-safety of methods & properties of collections... I don't know about C# in specific... but the general idea is that they're not thread-safe and instead you should write your code in a thread safe way and avoid mutating mutable collections on multiple threads....
 
7:11 PM
Multi-threaded project Euler? Not sure whether that's even remotely the intention.
 
There is no multithreading in the question
 
Yea, figured out after reading the question and answer your comment wasn't related to the link you posted.
 
0
Q: My suggested review would suggest not using the code altogether

MattNot sure how to phrase the title as there are two large concerns with what I am thinking of doing for the review of this question: Batch script to make folders hidden It is largely a batch script with some PowerShell in the mix. The latter of which I am more familiar with. Main issue that I h...

 
7:33 PM
0
A: My suggested review would suggest not using the code altogether

MastI personally believe security questions can be answered in such a way. That's because one of the main rules in security is "Don't roll your own". Examples: Generating XKCD passwords Password hashing and matching To answer your questions: How well received would suggestions be to use anot...

 
0
Q: Rewrite rails query as scope

MicFinclass Team def self.grouped self.all.group_by { |e| e.type }.map { |k, v| { k => v.group_by { |e| e.sub_type } } } end end How would I write as a scope? class Team # scope :grouped ?? end

 
I'm on a roll
closing SO questions left and right
 
0
A: Project Euler #7 10001st prime

nhgrifWhile my other answer focuses primarily on your algorithm itself, there's something else in your code I'd like to address: primes.Add(i); Let's look at the MSDN remarks on this Add method: If Count already equals Capacity, the capacity of the List is increased by automatically realloca...

I posted two C# answers... now who's on a roll?
Also, I've cast 2,479 close votes, @JeroenVannevel.
 
I've got 4996
ooooh close to a milestone
 
I can't see that tab.
Other users can't see how you vote.
 
7:52 PM
oh really?
there we go
 
0
Q: TetrisBoard Class in C#

AdmiralAdamaI am writing a Tetris program in C# for programming practice, and I've got it working. This is the second post in a multi-part series. My previous post covered the TetrisPiece. You can view the TetrisPiece code and critique here. Future posts may cover the WinForm, the AI, and maybe a graphical b...

 
00:00 - 20:0020:00 - 00:00

« first day (1065 days earlier)      last day (2958 days later) »