I was writing the below section of code which adds some user properties to an Active Directory user, and got wondering - surely we can improve the readability of this :
var firstname = newUser.FirstName;
var lastname = newUser.LastName;
var email = firstname + lastname + "@mydomain.com";
var do...
Yeah, I didn't know the syntax yet for functions, the thing that threw me off is setting the table in the returns clause, I'm used to procedure syntax where it's not quite like that
Probably the most risky post I ever posted on AU, nevertheless need to get it of my chest...
Don't ask me how I got the impression, nor whom it involves, but there seems to be a tendency lately that people "exchange" favours.
No one on AU has any objection to an occasional sympathizing vote, n...
Building complex applications can sometimes be a pain when extending or editing later on; I read online about the S.O.L.I.D principles of OOD, I want to understand if I am following a good approach that I can follow when developing the rest of the app.
I need answers to the following questions
...
-- TicketsAvailableFrom = -- (select -- case -- when ListingCreateDate >= (select max(OnSaleDate) from [Event] where ) then ListingCreateDate -- else (select max(OnSaleDate) from [Event]) -- end -- ),
Hello this is a swift program I wrote to calculate the sum of primes below 2 million, but it is tediously slow and I do not have the patience for it to complete.
I am curious about what makes it so slow.
func initArray (p:Array<UInt32>) -> Array<UInt32> {
var arr = Array<UInt32>()
...
Temp tables can have indexes, so if it's a performance-critical query you usually gain a good bit of speed using temp tables. It does create some IO on the server but usually not bad at all
@Mast Alright, in any case though, SQL's max() function can only take one argument, so you'd still have to make a way to assemble a result set that the query engine case use, and if it's aggregating from multiple tables, it has to perform those operations separately
It's really not that hard if you know ahead of time how the database "thinks", but if you are used to more flexible type of procedure/function input, it can be a bit annoying
Problem:
I have seen a few questions around hangman. Usually this is done in a very hackish way, which usually can not be generalized any further. My thought or question is about the creation of the gown, which is a central part in any hangman game.
I want to create the ASCII image below
___...
I want to be able to reuse this method so it's not restricted by the Event class being called in the for loop declaration.
The problem is the compiler has no idea what id actually is, so I cannot use . notation on it. I need to cast it to a whatever type of Event class i'll be passing it, inste...
I have a bunch of methods that are exclusive to each other and as such can run in parallel. Is there a good way of doing this? So far I have the below two implementations, but I am not so sure if I should go with one or the other.
Using Parallel.For:
Parallel.For(0, 2, i =>
{
switch (i)
...
> A teacher about writing code (on paper) on an exam: "The parser will be my brain, and I am more flexible than your computer. If you make syntax errors, I might nto even notice, and I will certainly not care."
Often when I am reviewing code on CodeReview.SE I focus on readability of code, SRP, testing and things of that nature. For example, as I am writing an answer, I point out bad variable, function and/or class names and suggest (better) alternatives. I clearly state why bad names are bad in general...
Apparently my professor gave me bad code, right before the exams.
struct node{
int ID;
float Datum;
struct node *left;
struct node *right;
};
int insert(struct node NN, struct node **R){
struct node *cur,*F=0;
cur=search(*R,NN.ID,&F);
if (cur) return 0;
cur=(struct node...
> I don't envision anyone over here suing you in the near future. I may sue Undo, and possibly ArtofCode, but only if I get super-bored, and most likely for reasons unrelated to their use of SO/SE.
Lol, I found something from vwo 4 on my desk, my school history is like havo/vwo 1 - vwo 2 - vwo 3 - vwo 4 - vwo 5 - vwo 6 - uni 1 - uni 2 - uni 3 - uni 4 - uni 5
I have this tiny library for measuring the execution time in milliseconds and returning the duration plus the result:
execres.h
/******************
* File: execres.h *
******************/
#ifndef EXECRES_H
#define EXECRES_H
#include <sys/time.h>
typedef struct {
unsigned long long milli...
I'm implementing an interface to the Force.com REST API, with very specific ideas about which parts of the API I need. My problem is with testability of consumers of this API abstraction.
The first thing I came up with was a Gateway, one method per action:
interface SalesforceApiGateway {
f...
Hi @marsze... yes I've read that a few times... I don't need this to be 100% reliable, this is to assist with a manual code review. There are a LOT of nested For loops many of which should be refactored out to their own function, hence the question. RegEx is the only tool that I can implement quickly and easily, imperfect as it is. — SlowLearner39 secs ago
Hi @ThomasAyoub - first time the web page didn't load properly (text only)... stared at it for ages then gave up. Looked again and sure... it seems to work. I am attempting to put the RegEx into MZ Tools 8 - Code Review function, should (as far as I understand it) be using the .Net RegEx... although your Expression seems to meet my need I can't get it working in MZ-Tools :-( (yet) — SlowLearner9 secs ago
This is my first attempt at a Model-View-Presenter pattern Winforms application. The model is a class that stores a bunch of primitives, and the view is a Form that provides a ListBox for selecting individual Data items, whose members are then displayed in text boxes.
DataModel.cs
using System;...
I have a large piece of code for minesweeper, and I can get it to mostly work but sometimes certain buttons do not count up or down left. I also can't get the check win for the difficulties to work even though I've checked it out with other working sources and had no difference.
This is the code ...
take line1/file1 and loop through all the lines of file2 to check if there's no matching line. If there's no line, print line1 from file1 and go to the next one
@Cajuu' Yeah, I'd add a flag to keep track if there are any matching lines and after iterating through all of file2 check the flag and print out the line if necessary
I started to write a library for linear algebra for personal use, but also for revitilization of my C++.
Below is the first class of this library, a templated vector class, which is templated over the type of the elements as well as the size. It supports all common operations of vectors as membe...
The problem can be found here.
The file, poker.txt, contains one-thousand random hands dealt to two
players. Each line of the file contains ten cards (separated by a
single space): the first five are Player 1's cards and the last five
are Player 2's cards. You can assume that all hands...