If you don't have a specific problem in your code, you should take your question to codereview.stackexchange.com. Personally, I don't see why you'd refactor a simple if/else when you only have two conditions. It doesn't look hideous. It looks exactly like what the construct was made for. — Mark Leiber47 secs ago
I recently created a custom static class in C# to encode, hopefully, any object it is given (or collection of objects), because I was, at the time, unaware of a native C# library that did the same thing. I am using Generics instead of System.Object because I am aware of the overhead that comes wi...
I have a query that is pulling data from a Mysql database using php. As the while loop progresses the variables $student, $course are captures and $mark is calculated outside of the database using php so I can't get the data directly from the database. At the end of the while loop I have all the ...
Meme: Jamalized
Originator: Jamal ♦ (actually, apparently me)
Cultural Height: All over CR (see this chat transcript search)
Background: Jamal being a frantic editor. And he's fast. So fast, we're all waiting for the day he will edit a bad question title before it's even posted. You never know...
And he's fast. So fast, we're all waiting for the day he will edit a bad question title before it's even posted.
I am currently using the following glsl code to retrieve separate textures from a tile atlas:
#version 330 core
in vec2 TexCoord;
out vec4 color;
uniform sampler2D image;
void main()
{
int width = 8;
int height = 8;
int x = 1;
int y = 4;
float scalarX = 1.0 / width;
...
If you want to share this, make it a proper question and selfanswer it. As it is, it's not the proper format for SO and we can only close it. Also SO is not Code Review. — Roland12 secs ago
Stack Exchange is not a network of forums; it is a network of question and answer sites. This is neither a question or an answer. If you wish to share this, please do so in the question-and-answer format (post a self-answer to an actual question). If you're looking for improving the code you've shared here, presuming it works exactly as intended, you can consider posting the working code to Code Review. — nhgrif29 secs ago
I've created two classes that contain only sudoku logic. One class Sudoku generates sudoku grid and returns SudokuGrid object with has specific number of values in it(removing values from filled grid). Second class SudokuGrid contains all logic that player needs, checking whether any rules are br...
There's only so much a code analysis tool can see.
using (SqlCommand command = CreateCommand(query, parameters))
You're using a parameterized SqlCommand, and given the example you appear to have everything under your own control, strongly typed and all.
Depends who is calling this ExecuteNo...
I have three tables:
Table A Table B Table C
------------------- ------------------- -------------------
id | cQ | cR | id | cQ | cR | id | cQ | cR |
------------------- ------------------- -------------------
1 | 1 | ...
It's nice when a question actually explains what the code is supposed to do, instead of expecting you to reverse-engineer the specification from the code.
I have writen a small function to generate an array of page numbers for displaying a pagination. The inputs to the function is an active page number p, and the max page number. The function will return an array of 5 possible page numbers available near the active page.
Example input, output:
p...
In our automated test framework, written in Java 8, there are different entities representing test data, having different states and transitions between them.
To model this behavior, I started to implement a simple finite state machine (or at least what I understand as a FSM)
The idea to use it...
Depends what you call elegant. The most elegant solution to me is the one that produces the smallest number of WTFs in a code review and makes the next guy not waste half an hour trying to understand what the code is supposed to mean. :) — simbabque1 min ago
http://www.commitstrip.com/en/2015/05/29/always-stuck-somewhere-in-my-head/ CommitStrip - Blog relating the daily life of web agencies developers Always stuck somewhere in my head CommitStrip 1432913790
After seven years it's probably time to assume that beginners are using Python 3, and leave Python 2 for experienced programmers dealing with legacy code.
Please see this fiddle I have set up.
You are first confronted by three links. Each link triggers divs to slide out.
The link 'john smith' slides out and in at the speed we want. When it slides out the first line slides out then when that is completed the second line slides down as though comin...
The reason that tutorials should be aimed at Python 3 is that code written for Python 3 (at least the kind of code that appears in tutorials) generally back-ports easily to Python 2
Whereas the converse is not true
If you write print("hello world") (Python 3) then that also runs fine in Python 2
But if you write print "hello world" (Python 2 only) then that's a syntax error in Python 3
If you learn Python 3, then going to Python 2 is easy (you lose a bunch of features and only gain a couple of simple things like the print statement). But the other way around is hard: you have to learn the difference between strings and bytes
@Mast There's plenty of point in doing so: it means you can write code that's portable to legacy platforms that don't yet have Python 3. (e.g. ultra-conservative Linux distributions like CentOS)
I had to make some code portable to Python 2.3 recently — that was a painful experience. No generator expressions, no collections.defaultdict, no sorted, no key argument to list.sort, etc.
I have just finished the sololearn C++ course and wanted to create a basic login program in the vein of a basic operating system.
#include "OS_login"
#include <iostream>
#include <string>
using namespace std;
Ubuntu_Login::Ubuntu_Login()
{
cout << "\t Welcome to Ubuntu!\n" << endl;
}
void ...
I have the following two blocks of code. I also have other similar sections with similar blocks and want to reduce the complexity of it all. As it is, it is impossible to follow anything. What kind of things can I do to simplify and have it easier so understand and modify?
This part performs ho...