« first day (929 days earlier)      last day (3091 days later) » 

Zak
10:00 AM
Whereas we're the opposite. EU, EEA but no Schengen
 
@Zak And no Euro ^^
 
Zak
@Mast That too
To be fair, only really possible because we're an island
 
@Zak Yeah, because Islands Are Different (quote CGPGrey)
 
Most countries I've actually travelled to in this continent haven't used the Euro, what a waste :(
 
Zak
If you're on the mainland, whether you like Schengen or not, it's pretty difficult to enforce border controls
 
10:02 AM
Yea, but you guys could at least be a sport about it and still accept the darn things.
 
Well Sweden still doesn't use the Euro and they ain't no island.
 
Zak
I meant schengen
 
Ah, never mind me then.
 
I want to move to the mainland tbh
hopefully before UK decides to hold the EU exit referendum..
 
When I went to China, I lost 10 pounds in three days.
 
10:04 AM
@Mast I lose £10 every day to train fares.
Oh. That type of pounds.
 
Still had those in my pocket and the Brit next to me had better use for hem than I did.
@DanPantry No, your type. But the confusion it brings to a mainlander when spoken is there, every time.
Out of all things, you couldn't find a better name for your currency.
 
@Mast we named it pounds because it's pounds better than the euro
:^)
 
Having weight and currency use the same name, why would that ever be a good idea?
 
@Mast we don't use lbs as a unit of measurement, that's why.
We use stones and kilos
(I'm trying to teach myself european measurements though like lbs, meters, etc)
 
lbs is not a European measurement AFAIK
 
10:07 AM
Yeah I was just thinking that, mostly American at this point isn't it?
 
Zak
@Mast Pretty sure we've been calling them Pounds for, like, over a Millenia
 
Yup.
@Zak About time to change then, right?
I mean, we don't pay with salt anymore either.
 
> silver coins known as "sterlings" were issued in the Saxon kingdoms, 240 of them being minted from a pound of silver... Hence, large payments came to be reckoned in "pounds of sterlings," a phrase later shortened
 
So the weight is actually where the name came from?
 
it has been in use since at least 400 AD
okay, we lose.
Pounds was known as libra from Roman times.
That's why the symbol is libra
So the romans (and lbs) came first
 
10:12 AM
Before the euro, we had the guilders. Also called florins.
 
We just had irish pounds :( Not imaginative.
 
1
Q: Find a serial port device through WMI (windows management instrumentation)

Oscar GuillamonThe idea here is to be able to find a USB serial port device connected during runtime, thus not knowing its port number, and use it in the application to retrieve information from the device. string comportInfo = string.Empty; using (var entitySearcher = new ManagementObjectSearcher("root\\CIMV...

 
Not that we had them for long.
 
Those were a couple hundred years old, but not as old as the sterlings IIRC.
 
Zak
@DanPantry I think that's about when my school was founded
 
10:14 AM
I still need to grab myself a decent LINQ book.
Looks like it's everything I've been missing in C++ all those times.
 
@Mast Why do you want a book for LINQ?
Its pretty simple stuff
 
I got the basics down. But I think it can do way more than I'm currently aware of.
 
LINQ is not that impressive. It's just higher order functions that are deferred until you enumerate the collection
If you want to read about something that needs a book (and is similar to LINQ): introtorx.com
Rx takes the higher-order functional style of LINQ one step further
 
Hmmm, looks good and complicated.
 
10:30 AM
class redditor{
    Boolean isCool;
    redditor(Boolean isCool){
        this.isCool = isCool;
        theGate();
    }
    private void theGate(){
        if(this.isCool){
            System.exit();
        }
    }
}
I know this was joke code on reddit, but my god, there is so much wrong with this that I don't know where to start.
 
0
Q: Balancing extra backslashes while using preg_quote along with preg_replace

Sandeepan NathThis is my first question on Code review, so please be lenient. I have a user defined expression like this - {geo} == "23.45" Which is evaluated at run-time, after the value of the macro, e.g. {geo} here is replaced. Following is the code I have, currently - $finalQuery = '{geo} == "23.45...

 
I've got a book on LINQ
It's huge
Also 80% pointless
There are a few functions I could learn more about like .Zip() but aside from that.. They all work pretty much the same and once you understand deferred execution, you know most of its internals
There's interesting performance considerations to be made that require deeper LINQ knowledge though
One day I'll read the book and see if it handles those
 
too much / more a case for Code Review. Also not safe: someThing.addAll(SynchronizedSet) iterates over the set. And that needs external synchronization i.e. sychnronized(nextPageQueue). And you will have super high CPU load because you're constantly trying to empty that list. That's what blocking queues are for. — zapl 50 secs ago
 
@JeroenVannevel Yeah, LINQ makes it very very easy to write O(n^P) without realising it lol
(Where P is a polynomial obviously) I don't know maths.
Polynomial = n^power + n. power is exponent, not polynomial. HURR DURR
I need to learn comp sci:\
In computer science, the time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the string representing the input. The time complexity of an algorithm is commonly expressed using big O notation, which excludes coefficients and lower order terms. When expressed this way, the time complexity is said to be described asymptotically, i.e., as the input size goes to infinity. For example, if the time required by an algorithm on all inputs of size n is at most 5n3 + 3n for any n (bigger than some n0), the asymptotic time complexity is...
This is in English, just not the English I know. Why can't these concepts be exlpained in basic terms..
 
Zak
@DanPantry Did you mean simple.wikipedia.org
 
@JeroenVannevel Yea, he LINQ I wrote yesterday is awfully slow.
@DanPantry @Zak Feel free to write it :-)
 
@Mast I can't write it, I dont understand time complexity in the first place
At least not to the degree I need to understand algorithms well enough
 
@DanPantry Yea, I was linking your message hoping Zak would go for it. Or @JeroenVannevel for that matter.
 
I just know O(n) is okay, O(1) is great, and O(n^p) is the Very Bad Thing
 
Somebody.
 
Zak
10:41 AM
@DanPantry What's to understand? It's just a measure of how (time to execute) changes with respect to (size of input)
 
I think moderators can but I would copy paste and adjust for their guidelines in the process: meta.codereview.stackexchange.com/questions/2436/…zapl 56 secs ago
 
@DanPantry That's about as much as I got, yea.
 
@Zak Moreover the different types of time complexity.
 
Zak
So, n is the size of your input
 
F.e, polynomial time complexitly.
 
10:42 AM
That's not the slow aspect of LINQ. LINQ has a lot of optimizations for that with lazy evaluation and eager-exiting
 
NP problems
etc
 
It's mostly about heap allocations with all the overhead objects it creates
 
And there's logarithmics in there.
 
Zak
O(1) means that it always takes a constant amount of time no matter how big the input
 
@JeroenVannevel Yes, but you can still write O(n^4) easier with LINQ without realisign it - compared to for example writing 4 for loops deep.
@Zak no, I get that, I know what the basic ones are like o 1 o n and on2
 
10:43 AM
@DanPantry fair enough
 
but O(log n) for example
 
Zak
Okay, do you know how log works?
 
I think (log n) is better than (n)
 
I've only just learned what an asymptote is, so would I be right in assuming that O(log n) isnt' as linear as O(n) but rather takes less time (ish) per element
because log is an asymptotic function (right?)
 
but then there's also (log n * n)
 
10:43 AM
so it never quite reaches n, but gets closer and closer to it
 
@DanPantry You never learned tan functions?
 
tangens? I learned those.. 8 years ago
once
 
@Mast We don't learn that (at least in my school) until A Level Maths, which I dropped out of.
 
Zak
@DanPantry Essentially, log(n) is to n, what n is to n^n
 
Because I had to start working.
all I know is tan is the tangent line to a circle
where it touches the circle at exactly one point
 
Zak
10:46 AM
basically, log(n) increases exponentially slower as n increases
 
tan is the missing key once you've learned what sin and cos are. tan is what finishes the deal
 
@Mast might be worth me learning sin and cosine too then :p
 
Zak
great example is binary search
 
@Zak so, in a sense, it approaches the limit N slower than linear increases
 
@Zak That's a hard way of saying log(x) is the b in a^b = x
 
10:46 AM
basically O(log n) < O(n) in terms of complexity
 
Zak
@JeroenVannevel maybe, but I think easier to grasp
Binary search: with 2 nodes, 1 computation
4 nodes, 2 computations
1,024 nodes, 10 computations
1 million nodes, 20 computations
1 billion, 30 computations
 
that went from 2 to 1024 pretty fast.
 
Zak
nodes =2^n
computations = n
that's what log is (in essence)
 
didnt realise binary trees were that efficient.
 
 
10:48 AM
So.. yes, log is an asymptotic function :P
It approaches n in smaller and smaller increments but never quite reaches it
I always imagine asymptotes as reaching the speed of light (because that's where I learned them from)
you can approach the speed of light but never quite hit it because that would require infinite energy
same deal with log?
where n is the speed of light
 
Zak
not exactly
 
and obviously log can be used to get the approximate exponent of a value
 
Zak
 
@Zak nailed it
 
Zak
log(n) is always increasing
and will, eventualy, reach infinity
but it will increase exponentially slower than n
so yeah
O(n) increases linearly, which is fine
O(n^y) is bad
 
10:51 AM
didn't realise logarithms could reach their Nth term
 
Zak
log(n) < n for n >= 1
 
so logarithms aren't asymptotic, then
 
Zak
but if n is infinitely large
log(n) can be infinitely large too, just considerably smaller than n
 
What branch of mathematics is this called? I think I should probably learn about it
calculus?
 
Zak
I guess.
Honestly, just go straight to "Learn logarithms"
And you should be able to grasp it pretty easily
Basically, any kind of n^y is bad, because computation gets less efficient at scale
 
10:54 AM
Yeah, I know that much
 
Zak
O(n) is okay, because efficiency is constant
 
quadratic time = The Very Bad Thing
that's why you don't (or try to avoid) doing two nested for - like iterating a two-dimensional array
 
Zak
log(n) is great because efficiency gets exponentially better at scale
@DanPantry yep
 
0
Q: CRUD strongly typed data access

MathematicsI have a data access class which looks something like below, using CompanyX.DataAccess.CompanyXTableAdapters; namespace CompanyX.DataAccess { public class CompanyXDataAccess { #region Invoice public CompanyX.InvoiceDataTable GetInvoiceByID(int ID) { ...

1
Q: Multithreaded Webcrawler in Java

Simon ZhuI am working on a multi-threaded webcrawling program in Java. Each WebCrawler starts at a root page and repeatedly extracts new links and writes them to a database. I have included most of the code below: public class WebCrawler implements Runnable { private ConnectionPool connectionPool; priva...

 
hooray computer science
I would join the Compsci SE but I don't think I know enough for them to even want to answer my questions]
 
Zak
10:55 AM
log(n^n) is, essentially, O(n)
 
They could just tell me to piss off :P
 
Zak
It's not really, but for practical purposes, they're similar
 
yeah, thats what I thought. Isnt' there a difference though? Otherwise you wouldn't create the log(n^n) notation.
I would imagine the variance is very slight
 
Zak
log[base n] n^n = n
log [base A] B^C = variable
depending on A, B and C
 
This doesn't actually solve any questions :(
 
Zak
10:57 AM
just means, in terms of scale
log(n) is one step down
 
unless you mean to say that when you said log(n^n) you actually meant log(n^y)
 
Zak
N^n is one step up
 
I should probably do some work.. I'll check back in later
 
Zak
so if something takes O(n) time
something that takes log(n^y) time will be within an order of magnitude of O(n)
log(log(n^[y^z])) same thing
it might be double, or a tenth, or 23 times more/less efficient
but it won't be exponentially different
And the key to making a computation log(n) complex
is to be able to ignore as much of the imput, as quickly as possible
hence binary trees are great because each computation cuts out half of the tree as irrelevant
hi @Polarbear0106
@Polarbear0106 IS there a good reason for posting that here, or is it spam?
Because if it is, delete it before I flag it.
 
it isnt spam
what do you think about the website`?
 
Zak
11:03 AM
In what sense?
 
the design
 
I notice you posted it in multiple random chatrooms. If you're just trying to advertise then yes it is spam.
 
Zak
@Polarbear0106 If you want a design review / general feedback. Formulate a question and post it somewhere appropriate.
@Polarbear0106 Just throwing up a link in random chatrooms is going to get you all sorts of negative attention
 
He's been sent for a time out according to someone in the GameDev.se chat.
 
Monking
 
Zak
11:09 AM
@skiwi Monking
@SuperBiasedMan I figured it was something like that, but didn't seem like malicious intent so I figured I'd try and communicate first.
 
Wow, someone spoke so unclear over the phone that I thought he was from another country
 
Zak
hi @FuzzyLogic
 
monking @FuzzyLogic
 
hi. just browsing. what's up in here?
 
@Zak Yeah, same. But then I saw they'd done the same on 4 other chats without explanation.
Welcome
 
Zak
11:15 AM
@FuzzyLogic Not much at the moment
 
You missed an improvised lecture on time complexity.
 
sounds interesting ^_^
 
It was :)
Though I probably won't retain al ot of it I appreciate the info nonetheless
 
Just remember O(log(n)) < O(n) < O(n ^ 2), that's my main take away
 
Yup, same
Or condensed further: Binary trees are great
 
11:22 AM
But I appreciated hearing an explanation Zak, I think I got it :)
 
Zak
glad to help :)
The thing to take away is that something being 10,100,1000 times better/worse is insignificant
compared to how that changes when the scale changes
 
Indeed. And nested for loops are the devil's work.
 
Zak
pretty much. Best thing to think about:
"If everything was 10 times bigger/longer/etc.", how much more time would this code take to run?
you want the answer to be 10 or lower
preferably log(10)
10^(# of nested loops) is not a good answer
 
@SuperBiasedMan O(n log n) is also a very improtant one
 
Do you actually calculate Big-O? I never have. I'm familiar enough with it though that intuitively, I just tend to know how a function will fit.
 
11:27 AM
In most of what I'm doing (at least right now) the primary bottleneck is always bad stuff like reading multi GB JSON files.
 
I'd say that actively investing time in optimization before you run the code is premature optimization
 
Stuff that can't be reduced.
 
though, I guess if I were an engineer it would matter more, when you have to prove your designs :)
 
But if you know that you are dealing with very bad performance in Big-O terms and you can fix it with no more effort than the naive implementation, then why not?
 
@FuzzyLogic When working with big data, you have to
I work in the largest commercial credit firm in the world. Complexity is important when searching through records.
 
11:29 AM
@DanPantry Doesn't the database (with indexes) handle most of it already?
 
One of our constraints for one of our features is to search potentially billions of records with a query and it must return in under 4 seconds.
 
Zak
@skiwi Actively optimizing code is usually premature, but just having a general awareness of the complexity you're implementing is IMO, very important
 
@skiwi The tradeoff with indexes is space.
Calculating indexes is expensive - and so are updating them.
With the amount of data we have its getting to the point where it is simply not feasible to index the fields we want.
In that case we use full text searching
 
Zak
@DanPantry what language(s) do you program in for work? just curious
 
I discussed this issue with Vogel and Mug before, essentially we are going to run into scaling issues down the road - I'm 99% sure of it.
 
11:30 AM
Yeah there's premature optimisation but then there's just being mindful of time complexity when you know it will matter.
 
so I'm trying to suggest we pipe records to a separate database like ElasticSearch which is there specifically for full text searching.
 
But can you still reason about Big-O if you are writing things purely in SQL? That's more my worry
 
That does increase redundancy, however if the records are read-only then it doesn't matter as long as they are kept up-to-date.
@Zak Our stack is JavaScript, SQL, C#.NET 4.5
I personally write JavaScript and some C#.
@skiwi our SQL devs don't tend to, but I do think in terms of that when I see their SQL code and any algorithms we do on the server side (for whatever reason, for example, transforming data from 3rd party sources).
It's not premature optimisation when speed is a feature and part of the specification :-)
 
Zak
Yeah, it's a case of: You should optimise before you start (design / structure) and after you finish (review) but not when actually writing the thing
 
You can't optimise before you start.
But you should plan ahead for reasonable concerns down the road.
 
Zak
11:34 AM
I mean, designing a structure / system / algorithm / whatever so that it'll run at a required level of time-complexity
 
For example, if you're going to be doing full text searching on literally hundreds of gigabytes of data, it makes sense to use a service like ElasticSearch with redundant read-only copies instead of putting the load of that search on a SQL box with everything else.
That lends you so much better to horizontal scaling than vertical scaling (Which is the root of all evil)
BTW, if I sound like I know what I am talking about, I don't. I'm just good at bluffing.
YMMV.
 
Zak
@DanPantry You and everybody else in the world :)
Nobody doing anything interesting knows what they're doing
 
@DanPantry But you'd also need to take into account the O-complexities of whatever the database uses to insert, select and delete
 
@skiwi We can reasonably assume those to either be 1) constant or 2) out of our control.
As a result, it doesn't make sense to factor those into any calculations of algorithm efficiency.
 
I only started here in January and back then I didnt know a tenth of what I know now
 
11:37 AM
Them being out of control still affects the total O-complexity
 
@skiwi No.
The speed of the database does not affect the time complexity of the algorithm.
 
I'm still confused where you are running the algorithm
 
In the same way that the amount of cache you have in your CPU doesn't affect the complexity of your algorithm.
The time complexity of your algorithm will be the same no matter where you run it
It may take more time to run that algorithm
Based on hardware specs
 
Time complexity is directly linked to the data structures you're using
 
But time complexity doesn't aim to tell you exact time of execution, it aims to tell you the relative time of execution of an algorithm compared to other time complexities.
 
11:39 AM
Big-O is used to measure other things besides time isn't it?
 
Zak
I think skiwi is trying to say that if your algorithm includes functions that are native to the database
then those functions will still affect the time-complexity, even if you have no control over them
 
Of course they will
 
Say in C# you could be storing data in a Set, List or Dictionary or some more sophisticated data structure, but on the database side the data is stored in data structures that offer better time complexities, hence why we use databases over persisting it manually in an application
 
But there's no point us factoring those in, because we can't control the implementation of those.
 
Zak
Maybe, but you should know what effect they will have
After all, if those functions execute in O(n) time
 
11:41 AM
That's not my job :p my DBAs do all the SQL writing
 
Zak
then there's no point optimising anything else below that
 
I see your point. I think I might have misunderstood what @Skiwi was saying
@FuzzyLogic Big-O doesnt' give you absolute time measurements per sé, it just tells you how long you can expect -relative to the other complexities - algorithm A will take.
As the set of data scales
So O(n) insertions might be okay for data sets of 10.
 
yeah, I know. but it also applies to r/w and cpu load doesn't it?
 
But if you do an O(n) insertion on a data set with 10000 members in... you're in trouble.
 
Zak
I think the point that's being made is that if you have a definitive number (4 seconds) you have to meet. You should know the general time-complexity of everything your algorithm does/requires. And then once you're within an order-of-magnitude of your required number, things like actual numbers and hardware specs can be enough to push it below the value you need
 
11:45 AM
Yeah, I suppose
either way, I am 99.9999% sure that we are going to go over the 4 second limit
Because the SQL devs eschewed full text searching (despite it being perfect for the job) and are using a normal WHERE with LIKE.
 
Them not taking into consideration your advice seems to be a bad idea...
 
We did initially use full text searching
I'm not sure why they got rid of it.
Maybe it could have been indexing concerns, but you'd have to put an index on each of the searchable columns to achieve reasonable performance anyway
 
0
Q: `r` permutations of `n`

Kenil FadiaI have written this snippet to find k-permutations of n, i.e. if i have an array of n=3 {0,1,2}, then k=2 permutations will be {{0, 1}, {0, 2}, {1, 0}, {1, 2}, {2, 0}, {2, 1}}. Can somebody review it and help me optimize / reduce its complexity (I don't want to use recursive function): "_getAllP...

 
^^ speaking of Big-O
 
for (; index < input.length; index++) {
oh god
This could be done using a simple .map call :(
would make it a lot neater
I am confused.
OP:
 
11:53 AM
for loops that ommitt one of the three statements always look weird to me.
 
> (I don't want to use recursive function):
He then proceeds to use a recursive function?
 
I think they're asking to have it refactored to not be recursive.
 
Hm.
Also, his r is never initialised.
 
It's an argument of the function
 
@SuperBiasedMan I know, but I would have expected that to have been an optional parameter
 
11:56 AM
^ that's a parameter
 
@DanPantry Ah ok. I thought you might have just missed it cause I did at first.
 
same for usedIndicies and allPermutations.
 
(also yes, parameter. I'm in Python mode)
 
Both of those sound like variables that are created during the lifetime of the function.
 
12:20 PM
Monking
 
12:32 PM
hi @Phrancis. nice avatar ^_^
 
Hahah, thanks :)
 
1
Q: Re-sorting an array of integers based on distinct digits from even to odd

RyuMy task was to receive an array of integers and then reassemble the array as required: The array size is to be of element index 0 The next element(index 1) has the number of even distinct digits(digits that appear in only one integer input but not the rest). And the next pairs(if any) of elemen...

 
12:55 PM
I felt special
turns out I'm just one of many
4
 
1:26 PM
Monking
 
Zak
In the review queues, under "close as duplicate". It shows the "question" and the "duplicate". Which is the one being VTC'd?
specifically, here
 
the one with Question marked as active tab is the one VTC'd
at least that's what I'd expect
 
0
Q: Whats the correct approach to deal callbacks in NodeJs?

TomasI'm working on this simple project I can't get my head around callbacks in Nodejs. What I'm trying to do is get some data and display it in a nice format in slack. But before I can do that there are quite a few steps I have to take, which makes it more complicate for me to follow through callback...

 
Zak
@Vogel612 It's also what I'd expect. But in this case the "question" is 2 years old and asked by @rolfl and the "duplicate" is 2 days old by the guy who's been a bit over-enthusiastic with his tag privileges
 
meta duplicates are not strictly chronoligical
in general the better question is the dup target
 
Zak
1:38 PM
I get that, but I'd like to know which one I'm VTCing before I do it
 
that being said, I'm not sure whether these are even dups, so I skipped..
 
@Zak If I see this correctly the "Duplicate" is asked 2 days ago and rolfl 6 days ago.
monking @Vogel612 btw
 
@Heslacher there's two review tasks
 
Zak
@Heslacher Oh yeah, I keep forgetting how SE displays current-year dates
Now I definitely want to know which one is the one I'm voting on. Not just for this, but for future reference too.
 
@Vogel612 I see
 
Zak
1:41 PM
nvm, I did the simple thing I should've thought of. Went to visit the actual questions to see which had open close votes
It's the "question"
 
You're really not supposed to ask two questions in one question (since it makes it hard to select the "right" answer if one answer focuses on one and another on the second), but that's somewhat immaterial since neither is appropriate for SO; you should read the TOS for boots.com for 1) and asking for a more elegant solution is more appropriate for code review for 2) — Foon 21 secs ago
 
his arms are heavy
knees weak coffee mug ready
there's bugs in the backlog already
code spaghetti
(its one of those days)
 
that's not a full metric haiku, is it?
also Haiku aren't our meme...
 
I am no linguist so probably not
Its a play on Eminem's Lose Yourself
 
0
Q: i got feedback from one company that this code is not good. Could you say what is wrong here?

JavaNode.comhere is example of code public class IndexerV2 implements Indexer{ private static final Logger log = Logger.getLogger(IndexerV2.class.toString()); private List<String[]> list = new ArrayList<>(); /** * only one key/value pair will be stored * if file has more than one key/value pair ...

 
Zak
1:46 PM
His arms are heavy
Knees weak coffee mug ready
Its code spaghetti

That would be a haiku
3
 
> The title is awful
It's hard to tell what the code does
Here a vote to close
3
 
If you were unsure, or only had a hunch, and don't have any real idea whether your suggestion would even work, then you really should not have made this suggestion in a code review, whether you turn out to be correct or not. It's fine to raise the question and discuss whether it might be of benefit to change the order, but surely there are more important things to focus on. The point of code reviews is to educate and motivate, and I think that your suggestion probably did neither. — Gary McGill 14 secs ago
 
Zak
@Phrancis I would star, but that middle line has one too many syllables. maybe s/It's hard to tell/ I can't tell?
 
@Zak Hm, too late to edit :(
 
Zak
Also, s/The title is awful/[Title is awful] or [The title's awful]
If Haiku's are going to be a meme, I think it's important to get the rules straight form the outset :)
 
1:58 PM
I'm about as good at writing haikus as I am at writing Java; that is to say, not very good.
3
 
Zak
Specifically, 5-7-5 syllable structure.
But hey, I like it, have star :)
^^ "English" Haiku
 

« first day (929 days earlier)      last day (3091 days later) »