16,004,653 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by glen205 (Top 23 by date)
glen205
15-Jun-16 10:32am
View
I understand that the links are different per user.
I put "xxxxx" and "yyyyy" in my example to illustrate where you would put *your* active content to render the url / visible text (the PHP code <?= $user_info['portfolio_website'] ?>)
In effect, my solution is just "what's the right HTML for a link" - I was just saying that the <p> tag isn't a clickable link, the <a> tag is. I assumed you already were okay with what PHP to use to put the actual text you wanted to appear.
glen205
6-Jun-16 5:54am
View
It's only my opinion, but I would keep the class. This goes to separation of your domain model, which may directly reflect the structure of your database, and the "model" part of MVC which is a presentation model. If you accept that an application can have multiple models - maybe one for the DB (domain/entity model), one for MVC (presentation) and any number of other models (business logic etc) it becomes acceptable to take a couple of fields from two entity objects and combine them to form a presentation object, which is the "model" for the page you want to render....
The OO concept of a model can therefore cover your presentation layer with a different set of classes to your persistence layer -
TL:DR - it's okay if you have a custom model to present to a view....
Just my 2 cents!
glen205
27-May-16 4:09am
View
Despite the post of 2 solutions, I worry for the problem you're trying to solve.
Making keys that should be unique in the data domain, out of real-world data that may well not be unique, can cause conflicts. In your example, if someone else already has the same last-2 characters in name (Joan == Alan), email domain (AbsolutelyAnything.com == AbsolutelyAnythingElse.com) and ending digits of phone number, then they can't use your system. A person can't actually change any of these things at will to accommodate your restrictions. Unlikely scenarios happen more often than we'd like to think.
Consider adding an additional numeric sequence to the end to keep it unique for Joan and Alan (although even this has limits, do you use 2 additional chars and limit yourself to 99 Joans/Alans?)
Also, make sure you're not using "meom67" as the primary key on your users database table. Google "Surrogate Key vs Natural Key" for reasons why. Store "meom67" but also have a seeded incremental integer ID column on the table or things will get sticky.
Good luck,
Glen
glen205
13-May-16 8:23am
View
I'm also struggling to understand this question. Here's what I've got:
"I have three seperate values - U,T,C Each value has a different number assigned to it, usually in the thousands."
So - for example these are variables of an integer type e.g. U = 1000, T = 5000, C = 10000 ?
"I need to make up each value of U,T,C by using items, I have about 20 items"
Does "item" mean "object/class" e.g. you have a class with U, T and C properties (let's call this class "container"), and you have 20 instances of container, each with different values e.g. (using C# as an example, I'm not an Objective-C guy!)
Container c1 = new Container() {U = 1000, T = 5000, C = 10000};
Container c2 = new Container() {U = 6000, T = 2000, C = 4000};
etc....
I'm getting lost after that - can you explain: "calculates the best combination of items that will equate to U,T,C with the least amount of overflow possible"
Maybe I've totally understood the problem. What is meant by "best combination out of 20" - is it a fitness function like a genetic algorithm would want? Are your "20 items" like a population where fitness is to be evaluated?
glen205
12-May-16 3:02am
View
Timespan is a type containing a period of time between two fixed times. e.g. Timespan from 10:05am to 12:15pm is 2 hrs, 10 minutes.
That Timespan has the properties:
Hours: 2
Minutes: 10
Seconds: 0
but also:
Total Minutes = 130 (2hrs * 60 plus another 10)
Total Seconds = 7800 (130 * 60)
These properties are designed to solve your problem exactly i.e. "How many minutes long it this timespan?"
George's link to the MSDN documentation explains this.
glen205
11-May-16 7:31am
View
Timespan TotalMinutes property should address this, rather than using Minutes?
glen205
5-May-16 3:28am
View
"What I have tried" ... is just your question repeated again.
What have you tried?
Google for information on the SQL aggregate functions: SUM and GROUP BY - this will get you started
What is the business case for "show 100 and 200 separate in two lines as balance"? If "balance" is the sum of all the transactions, why would you choose not to show two of them (the +500 and -500) - just because they net each other out? If I put 500 in my bank and then take it out again, I don't want that hidden on my statement because it's a net zero movement - what's your actual requirement here as the "100 and 200 separate" is not clear.
glen205
12-Apr-16 5:14am
View
The backslash character is an escape character in C# strings. If you want your string literal to ... literally ... have a backslash in it you can:
1) escape the backslash with a backslash: (note there is now a double-backslash)
string foo = "^[+-]?[0-9]{1,9}(?:\\.[0-9]{1,2})?$";
2) declare the string as a string literal with the @ symbol
string foo = @"^[+-]?[0-9]{1,9}(?:\.[0-9]{1,2})?$";
glen205
11-Apr-16 6:43am
View
In the spirit of the community - you could post your answer as a solution so others may learn...
glen205
11-Apr-16 4:57am
View
The student grading system is a very common homework assignment that we see on CP a lot - without wanting to assume too much: has the course you're on taught you about arrays yet? This would be the solution to the "save more than one things to a variable" part of your question.
Seek information on arrays either in your previous course material or good-old-Google for help...
glen205
29-Mar-16 5:14am
View
The question is - why do you need to decrypt your passwords?
1) you want to see if the user entered the correct password:
- in this case - DON'T try to decrypt the stored password - hash the user-entered password and compare the hashes!
2) you want to retrieve the password for some use (maybe a reminder email or on-screen for a support operator)
- this is very bad security practice. The user should be guided to reset their password, never sent a copy of it. Remember email is plain-text, unencrypted, and easy to intercept, copy and modify.
- Nobody in a data/support centre should ever be able to see a user's password. In short (and as OriginalGriff and his linked article says).
not being able to decrypt == doing it right.
glen205
14-Mar-16 9:03am
View
I'm not sure you have a true "inheritance diamond" problem here, because your ConcreteClass isn't "inheriting" from two abstract bases, it's inheriting from one abstract and implementing one interface.
The "inheritance diamond" problem comes when two competing implementations are inherited and it's impossible to tell which one the derived class should inherit - you don't have that here because only one "side" of the diamond has an implementation....
... I think!
glen205
23-Feb-16 6:51am
View
Your code contains no less than twelve conditional -> output i.e.
if (condition to test)
cout << "output string";
After writing that 12 times, can you see a pattern and infer that it's possible to write the test/conditional statements (and output strings) for grade > 100 and grade < 0?
glen205
23-Feb-16 5:08am
View
Please provide a specific example of the text entered into the two TextBox controls: txtTodate and txtdesigndate.
Please also supply the exact text of the "conversion error" - i.e. can you give the stacktrace or exception message?
glen205
28-Jan-16 9:52am
View
CPallini's solution is still valid - if you split the strings and the resulting array only contains 2 items then you have the case where customerId is missed. If the array has 4 items then the third item is your customerId.
It's probably not great to rely on hard-coding it like this but you've only provided 2 possible use-cases (two strings present and four strings present) so this would be a simple solution....
glen205
26-Jan-16 6:44am
View
If I understand your code, it does this:
- copies image1 into image3
- overlays a 50% alpha copy of image 2 onto image 3
- the desired outcome is image 3 = a blend/overlay of the two?
Some questions then, about the meaning of your issue : "it doesn't keep the size of both the images".
- in what way is the size "lost" ?
- are your source images a different size to each other, or to the fixed 483x338 pixel output?
- have you tried changing the fixed size of image 3: instead of hard-coded pixel sizes, perhaps the size of image 3 could be X = Math.Max(image1.Width, image2.Witdh), Y = Math.Max(image1.Height, image2.Height). Then the output image is always as large as required to contain both images.
glen205
16-Dec-15 7:00am
View
Hi,
Sorry I don't have a solution in mongoDB, but it might help you get answers if you change the following:
Your request seems to be "Get all LocalFile which are *NOT* in ServerFiles".
This is not an intersection, this is a "relative complement".
https://en.wikipedia.org/wiki/Venn_diagram
glen205
18-Nov-15 9:11am
View
What error is the code throwing?
It looks like you're trying to multiply two strings together, this won't end well....
Cast (parse or TryParse) the items to a numeric datatype e.g. int otherwise you won't be able to perform multiplication...
glen205
28-Sep-15 4:58am
View
You probably won't get a code-complete solution here, CodeProject members like/want to help out, but not to provide complete solutions.
Decompose the problem into functional pieces:
- a class to represent a time period (start, finish etc)
- a collection to hold an ordered list of time periods
- a method which detects "overlap" of any two time periods
- a method which shortens a time period (move end time forward)
- a method which shortens a time period (move start time back)
- a mechanism for inserting a time period into a list
- an overall method which solves your problem, which in turn relies on all the other working parts of the application.
Give each piece a try in isolation (use a unit test framework to help) and ask specific questions (with code where possible) if you get stuck.
Sounds like a perfect Test-Driven piece of development!
Best of luck!
glen205
20-Jan-15 11:57am
View
Is it possible that node.js is a server-side javascript framework/language - and therefore examples of its usage are in the context of server-side, not client-side execution?
I may have misunderstood as my experience with node.js is only second-hand. My colleague develops using node.js, jade, npm and I get the feeling that whilst your client-side view can have javascript in it (like any html page), the actual "node.js" portion of this concept is server-side execution?
glen205
10-Jul-14 10:35am
View
Nuts - I mentioned ambiguous formats, SQL Injection and Parameterised queries .... and posted a comment instead of a solution. D'oh!
glen205
10-Jul-14 9:40am
View
When I write insert statements to SQL server, I always use the ISO date format: yyyy-MM-dd hh:mm:ss.
Reformatting your dates to ISO instead of the format you've listed might help. The format you're using is also ambiguous as 08/07 could mean "8th July" or "7th August" depending on where in the world you are.
Best recommendation:
move to a parameterised query - your current code is very susceptible to a SQL injection attack.
glen205
17-Jun-14 4:20am
View
Thanks for this - apologies it's gone so long before I've rated your answer... and I can't find any "accept answer" button on-page. I only see "reject solution", which I don't want to click! :)
Show More