It seems like I'm repeating myself here. Is there a standard way to deal with code like this?
def getNameParts(name):
"""Return a dictionary of a name's parts.
name: e.g. 'JOHNSON, John Roberts, Jr. (Jack)'
Ignores nicknames.
"""
csSplit = name.split(', ')
try:
la...
Background
I have an RDLC that among other things displays text coming in that is captured in SharePoint, using a custom control (TinyMCE) that exposes limited formatting options to users.
The SSRS local report renderer supports a subset of HTML (see details here) and has limited configurabilit...
Usually you shouldn't do that (and when using try-with-resources you can't). Of course, it always depends.. You could also post a question on codereview.stackexchange.com if you want some more comments on custom code. — Mick Mnemonic56 secs ago
This was my second project as a beginner in Java programming. Please provide feedbacks/ tips on my program. Thank you!
import java.util.Scanner;
public class Area {
public static void main(String[] args) {
Scanner Area = new Scanner (System.in);
double length, width,totalArea, he...
Instead of having to use something like char buf[100500] and hope that no possible user input could be longer than 100500 bytes, I decided to make the following function:
char* input (FILE* in, size_t size)
{
char * input_str = NULL;
int c;
size_t len = 0;
/*initial allocation*/...
Welcome to Stack Overflow! Thanks for your interest, but working code that needs improvement is better suited for Code Review, being off-topic in StackOverflow. — Mephy55 secs ago
Also CodeReview is for complete working code. The snippet above is not selfcontained. However CodeReview would hapilly review your code, when you have updated it into a complete working code. — N3buchadnezzar14 secs ago
Imagine you had to join together attributed strings with a separator in between them. Which of the following methods would you use?
An extension on SequenceType with a function that takes in a separator. Can't use any optionals in the array.
extension SequenceType where Generator.Element: NS...
So, I'm making a file downloader using Java. I separate the file into parts and download them using HTTP Range request, with each part being handled by a thread. All of the threads share an object, which is used to keep track of the progress and print the progress bar. The code is something like ...
This question is too generic and sketchy to answer in objectively. Instead of asking this generic question, I suggest that you post real working code for open-ended critique on Code Review, and mention this as a minor concern (among other issues that you might want to raise). — 200_success41 secs ago
I want to let a maximum of 10 people in, and also have arrival time of those that I let in.
// definition:
var dict = new System.Collections.Generic.Dictionary<string, System.DateTime>();
//usage:
if (!dict.ContainsKey(key) && dict.Count >= 10)
return false; // Reject
dict[key] = S...
I am new to Python (and coding in general) and after about a week of reading "Thinking Like a Computer Scientist: Learning with Python" I decided to try and build a version the classic "guessing game". I added some extra features such as counting the number of guesses the user takes, and playing ...
My solution keeps returning infinity as the sum of all the even numbers.
I have seen that javascript has no Long and other answers suggested using libraries that handle large numbers.
How do I fix this without using any library?
Also, any suggestions on how to improve this code is welcomed.
/*
...
I am designing a program that handles many types of grooves TKY, VSingle under GrooveType.
Each of this groove is paired with its specific parameter SimulationParam (e.g. TKY will pair with SimulationParamTKY, which inherits from SimulationParam) under the Dictionary simParams. As such, if i wa...
I have several UI elements that can be opened using hotkeys for example the settings menu's key is Escape. The problem is that I have the Keycode stored in Dictionary along with an Action or a Button.ButtonClickedEvent here's how the 2 dictionaries are declared :
public static readonly Dict...
I am trying to search account table by providing a search string. I am building a query based in different conditions and then adding the returned records in a list.
The functionality is working correctly but I want to know how an below method be further optimized.
public PageReference sear...
1) Don't cast the result of malloc & friends. 2) Don't use magic numbers. 3) This is no code review service. What is your specific problem? — Olaf46 secs ago
@skiwi, if you have intel cpu the SSD will probably slow down on IDE mode
sometimes it will prevent booting, system will argue that there is no SSD
@skiwi, btw start button uses user profiles to open, so sometimes it doesn't work. Google search says that they messed up something with user restrictions or similiar
I asked the following question on stackoverflow and as a result came up with the following code to avoid circular event logic when using winforms.
There are two occasions where my model can be updated, either programmatically via some application logic, or by the user via a view.
There is no l...
I worried about this code in a ViewModel. ViewModel shoud not contain any code exept binding's. But without async update ui should stuck. How to improve it? The main problem that this is need to be done under .net 3.5.
public ShippingDocumentsRegisterViewModel()
{
this.Columns = model.Initia...
I have an associative array with data (let's say language codes and descriptions) and a second array with allowed keys (lang codes). I want to filter the data array by these allowed keys.
The problem is I'm bound to PHP 5.5 and I can't use ARRAY_FILTER_USE_KEY flag.
I came up with the followin...
So I've been tasked with helping my little cousin with a python project to build a noughts and crosses game. The game doesn't actually need any functionality, it just needs to show his ability to code the grids and place the 0's and X's in the grids.
So his teacher has sent the code for specifi...
Also, looks like a good market to stick to for a while and there's some pretty big players in Germany in the automotive business as well. So it definitely won't hurt to learn some.
context: this is somewhat related to project euler problem 5, which is:
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
I apply prime number decomposition to the range of numbers from 1 to 20, and the product of all that should be the smallest n...
Beginner here. I'm working through 'Programming in C' by Kochan.
I've just completed an exercise in which I had to create a program that searches for a string within another bigger string.
If the substring exists then it is outputted to confirm and the starting index is given where the first c...
I learned last weekend that Letzeburgesch (what they speak in Luxembourg) uses 'Moien' as general greeting, regardless of the time of the day. They don't use more specific greetings.
This probably belongs on the code review site. That being said, if this is the function in question, I honestly think it's just easier to write myList.size() == 1; everywhere instead of a wrapper call. — CyberneticTwerkGuruOrc1 min ago
As Joel points out in Stack Overflow podcast #34, in C Programming Language (aka: K & R), there is mention of this property of arrays in C: a[5] == 5[a]
Joel says that it's because of pointer arithmetic but I still don't understand. Why does a[5] == 5[a]?
I am a newbie and self taught in programming.
This is my first attempt to make app.
Appreciate any input or comment to make my code writting skill better.
https://github.com/snufflesrea/Decision-maker
A simple randomize app to give random result from the user's option input. A simple randomize ...
I'm writing Python code and working with some database tools (bash). Unfortunately there are no Python libraries available for the Database so I'm trying to find a clean solution to this problem.
First, lets take a look at some code:
import os
BIN = "/mydir/bin"
TOOL = os.path.join(BIN, "tool")...
I would like to show an XML tree as a tree using GraphViz Dot tool. Then I must convert it to a DOT file.
It is what I have tried
string dot = "digraph G {" + Environment.NewLine;
XML2DOT(XmlRoot, "r");
dot += Environment.NewLine + "}";
....
private void XML2DOT(XmlNode n, ...
> Problems became evident when I tried to extend the type notation, especially to add structured (record) types. Structures, it seemed, should map in an intuitive way onto memory in the machine, but in a structure containing an array, there was no good place to stash the pointer containing the base of the array, nor any convenient way to arrange that it be initialized.
> For example, the directory entries of early Unix systems might be described in C as
struct {
int inumber;
char name[14];
};
> I wanted the structure not merely to characterize an abstract object but also to describe a collection of bits that might be read from a directory. Where could the compiler hide the pointer to name that the semantics demanded?
> Even if structures were thought of more abstractly, and the space for pointers could be hidden somehow, how could I handle the technical problem of properly initializing these pointers when allocating a complicated object, perhaps one that specified structures containing arrays containing structures to arbitrary depth?
> The solution constituted the crucial jump in the evolutionary chain between typeless BCPL and typed C. It eliminated the materialization of the pointer in storage, and instead caused the creation of the pointer when the array name is mentioned in an expression. The rule, which survives in today's C, is that values of array type are converted, when they appear in expressions, into pointers to the first of the objects making up the array.
And that's why you lose the length of an array when the array moves scopes.
@Pimgd, thanks for the citations. I've reread them twice but still can't get why compiler can't hold the type till it finishes compilation and then convert to whatever it wants. Anyway, I will try to find it out myself. Thanks again