« first day (923 days earlier)      last day (3392 days later) » 

11:01
I think you should re-evaluate.
@JeroenVannevel No.
pero señor por favor
es por mi mamacita
My actual usecase is evaluating expressions
I don't speak Americano
Zak
Zak
well, I've found my culprit.
@JeroenVannevel don't.. use a predefined library on npm
Zak
Zak
11:04
One function that's taking up 83% of the entire runtime
I'm looking at mathjs now though, maybe that supports everything I need to do
there's definitely going to be one that is for the use of parsing abstraction expressions..
You don't want to use eval for parsing expressions, you want to use a custom syntax parser
or run the javascript in vm
mathjs seems to hold all the operators I'm interested in
and I won't even have to do any transforming myself!
I was looking forward to using eval() though
I've always wanted to feel like a badboy
Using eval() is never something to look forward to :-)
I'm voting to close this question as off-topic because it is asking for a code reviewQuentin 49 secs ago
11:07
There is much to learn about the dark side of eval(). Things the Jedi don't want to tell you about
It can bring your loved ones back to life
Yeah, and that guy ended up with 3rd degree burns and having his arm chopped off
That's what happens when you use eval().
eval() responsibly; don't eval() and drive.
epic breathing mask though
pros and cons
oh, sure, when he has the mask it's "epic"
but when I do, its "asthma"
and a "medical condition"
pff
I wrote a monster of an answer. Could anyone have a look at it in case I did something stupid along the way?
0
A: Python differential analysis of heat loss across a pipe

MastGlobals in Python are not necessarily a bad thing, especially for what you're using them for. However, they can be prevented. There are a couple of major flaws I found so I'm glad you came over to get a review. The point you're most worried about will be handled at the end. Style Clean Python c...

@DanPantry It can usually be avoided.
11:18
I'm voting to close this question as off-topic because it belongs to codereview.stackexchange.comJordi Castilla 55 secs ago
@Mast Reading that now, was about to say you should warn them off using global almost all the time till I realised they didn't use the global keyword. +1 OP
Using eval FTW: text =~ s/\b(\w)/uc(\1)/ge;
@SuperBiasedMan Yup, at least he didn't fall for that trick.
input: hello, this is some text Output: Hello, This Is Some Text
@Mast You linked to peponline when mentioning naming conventions, that might imply it can detect improper naming. It might be better to put that at the start with the general style point
11:29
@SuperBiasedMan Ooh, nice catch
Looks solid otherwise though.
Fixed.
hey @Mast
@chillworld Hey
Huh. Apparently Progammers has a meta post explaining how they're reducing the amount of close votes needed, because they don't close enough borderline questions.
Zak
Zak
11:43
@SuperBiasedMan They can do that?
Ah no, a SE community manager is doing it for them
But I'd have thought the opposite conclusion would be drawn there.
I was just contemplating posting a question and hoping it wont be closed immediately.
@SuperBiasedMan Isn't that solving the wrong problem?
Their community needs to vote more actively.
Well it's based on the fact that basically almost all close votes are put on questions with 5 close votes, which seems to indicate that no-one wants to spend a vote on a borderline question if they think no-one else will follow suit.
22
Q: The number of votes required to close and reopen questions is temporarily reduced . . . for science!

Jon EricsonFor the next 30 days, closing a question will require just 3 votes. Also 3 votes will be sufficient to reopen a closed question. In essence, each close and reopen vote has 5/3rds the normal value. After 30 days I will revert the site setting back to 5 and evaluate the results. I have tested thi...

That's the vote count distribution.
Compared to this one from Super User which is considered healthy:
If nobody is willing to risk their votes there is going something seriously wrong.
That's not how votes should work.
Zak
Zak
"The documentation of the site reads:" "KEEP THIS AN ODD NUMBER"
I feel like there's a story there
11:52
Yeah, if that is what's happening. Hence they wanna encourage votes by making them seem more valuable. It's just funny cause I always heard that Programmers were close happy.
Caps in documentation always has a story.
@Zak I was just reading that. In all fairness, that's a quite good comment. It states exactly what it needs stating without troubling with the 'why'.
> But this site closes well over 50% of new questions, which is the highest rate on the network.
And they are still not closing enough? What will be enough, 90%?
Zak
Zak
To be fair, programmers (probably) also gets the highest percentage of Off-Topic questions
Yeah. They have a weird topic, and it's probably narrower than most assume.
I wonder what kind of stuff they have to do to try enforce and clarify it.
> Our scope is more cleanly defined than we are given credit for.
Well, that's not that difficult.
3
We don't give them any scope credit whatsoever.
2
@Mast TS, except then it'd mess up the order on the starwall
11:57
lol
Jan 16 at 16:56, by Marc-Andre
Nobody understand Programmers scope correctly :P
Zak
Zak
Well, we just need somebody to star both then :)
@Zak That's the spirit, I like it when people think out-of-the-box.
Zak
Zak
Apparently, I'm back to crashing Excel again today
0
Q: Ordered dictionary in swift 2

overactorLoosely basing myself on this blog post, I implemented an ordered dictionary. In essence, it's a wrapper struct for a list of tuples with some initialisers and some functions (map, filter, toArray, ...) added to it. struct OrderedDictionary<KeyType: Hashable, ValueType>: SequenceType { typea...

@Zak Do what you do best ^^
2
12:05
@SuperBiasedMan yes, thats bad practice IMO
I assume you mean my Programmers question and not the starring behaviour
@SuperBiasedMan Haha no I mean the programmers question
The value might be constant from that point on, but the value itself is not constant
I feel it would be inappropriate to mark it as a constant as such
f.e, in javascript, we also have the same convention. CONSTANT is in shoutcase
but we also have the keyword const.
const CONSTANT is used in my code to denote a constant that is well defined and constant at compile time i.e magic numbers
const value = foo(); is used to define a value that is constant and immutable, but the value is not known until runtime.
Yeah, that's what I was wondering about. Python has no concept of actually defining something a constant, so lines get muddy and it's entirely up to you whether you want to signal it as such because it has no bearing on how it runs.
Does const then actually affect the execution?
@DanPantry And const VALUE = foo(); is?
@Mast illegal
12:09
Oh weird, the compiler enforces the naming convention?
There's no rules against it, of course, but const VALUE is usually assigned a primitive value or string. Think enums.
No, the compiler does not enforce naming convention. That's why I mentioned afterwards that this convention is in my code
@SuperBiasedMan the spec does not do anything with const value = whatever, but it will have a go at you if you try to reassign a const value.
So in that manner it enforces constancy
I've never seen a const value = foo() construct either IIRC. Perhaps I'm not reading enough code.
Ah sorry I misunderstood when you said 'illegal'. I thought you meant it would complain.
const value = foo() is perfectly fine, but const VALUE = foo() isn't
That makes sense
12:11
one is camelCase and denotes that its a standard variable who won't be changed after it is defined.
One is SHOUTCASE and denotes that the value wont' change at all and is known at compile time.
Again, this is just IMO.
In your case @SuperBiasedMan I would denote that code as normal snake_case.
SUB_FOLDER might be constant after its definition, but its not a constant value at compile time
and you may confuse others who expect ti to be known at compile time
because there's no way to determine the difference between constant at compile time and constant at runtime
(if this makes any sense at all)
standard i-am-not-a-pythoner-disclaimer.
It's funny though that when I extend the logic it feels weird to have dictionaries as constants even when they're entirely formed from string literals. I think my brain is just warped and views the mapping as a mini calculation.
@SuperBiasedMan Ah, yes, I'd definitely use lowercase there.
@SuperBiasedMan string literal are constant values at compile time, though
12:14
Yeah most Python doesn't have compilation which makes it a bit looser, but I think practices still apply. Especially if I might bring this inclination into Javaland.
Think about pure functions.
a pure function can only invoke other pure functions
if it invokes other pure functions, then it itself will be pure
but if it invokes an impure function, then it will be impure
Zak
Zak
Well, I've figured out what my problem is. My code is getting exponentially slower
its the same thing here.. if you compose a type entirely out of compile time constants then you could argue that that type is known at compile time as long as no magic is going on at the compilation.
Relevant:
5
A: Racetrack plotter

janos This is my first Python script using argparse instead of sys for argument handling. I'm especially interested in whether the way I implemented it is up to par. You nailed it :-) Under the argument parsing I have a couple of BOLD_SNAKE_CASE variables which are pseudo constants. There's pr...

Zak
Zak
Which means ineffective memory management
Great.
12:15
The main distinction to make is that the shout case constant must be known at compile time and must be write-constant.
@Zak Sounds like algorithm troubles
Zak
Zak
More like iterating over a data table
Yeah, that makes sense. Feel free to post an answer, you've made a solid clear distinction that makes total sense to me. Thanks guys!
Zak
Zak
It's the part of my program that takes the raw data and converts it into objects
Any of you handsome fellas got a regex handy that replaces 'log(a)' with 'log(a, 10)'?
where a is unknown, of course
@SuperBiasedMan i'm too lazy to post an answer :( this is why I don't review often
12:22
Haha, ok.
@JeroenVannevel depends on what a is, but usually you'd just do something like:
I post to procrastinate on slow work days...
@SuperBiasedMan That's what 2nd monitor is for
I can manage both.
Procrastinating on slow work days
(My work ethic is awful :s I get stuff done on time but I always procrastinate it)
12:23
s/log\(([\d]+)\);/log(\1, 10);/
assuming a is some digits and using sed syntax...
Zak
Zak
@DanPantry You and me both
FeelsBadMan
Zak
Zak
But hey, as long as it gets done on time, nobody really cares how
hm... if you got it finished sooner, you can slack off with a clean conscience though?
@Vogel612 Yes, but that's not as fun as procrastinating.
12:26
@Vogel612 I'll try it out after lunch!
I just seem to innately do it :s I don't know why
I hate it when I am doing it but i'm like BUT THIS STUFF IM READING ABOUT IS SO COOL
Zak
Zak
One of the many reasons I love my job: As long as I'm not doing anything completely inappropriate with my time, I can pretty much do what I like so long as stuff gets done in good time.
Same.
I also like to delay a bit so that I return to code after a break and notice places where I made a mess, rather than doing that after I finished.
Monking!
Greetings, Programs.
Zak
Zak
12:38
@Phrancis MONKING!
Howdy, @Donald.McLean.
I have few minor changes to change function. Some better practices JSFiddle. Also just a case: try typing "31/02/2015". This will pass regex but is not a valid date. I had same issue and had posted it on CodeReview for better option. Do check this as well. — Rajesh 55 secs ago
@Harry No, there were no changes in extract. In other words the snipped can be simplified to this (Not counting of course that since the OP uses predefined set of colors (as what we usually do with preprocessors) the whole Q snippet made around gray function becomes useless, since the only thing he needs actually is a mixin with detached ruleset arg to set .disabled:* selectors. But the story is more for code review or so). — seven-phases-max 50 secs ago
13:03
0
Q: JavaScript implementation of Pascal's Triangle

OhFiddyYouSoWiddyI'm working my way through teaching myself JavaScript. If someone could critique my implementation of Pascal's Triangle I would be very grateful. My code is hosted on JSFiddle.

@Zak They have deleted 55% of questions ever posted there.
13:30
@EBrown On SU?
@Phrancis On Programmers.
Ohh.
/me not surprised.
13:57
0
Q: Time Complexity Analysis,Linear Sliding Window Algorithm Fails in SPOJ Aliens in a Train?

Siddharth SinghI need to find the largest interval with Value Less than a Limit Lt. The Data is as Follows For Every Test Case T Number of elements N , limit Lt N number of elements data I wrote the Following Algorithm Create a CF Table while taking input while size of interval plus current_Pos < Nu...

0
Q: how to get the content of a folder and pass it to a Java Server Page

Alex Redsin a Java web application, how I can get a list of all files stored in a specific folder and pass them to the JSP? I tried to do the following: I stored all files in a folder images under WebContent In the Controller, I created a list of strings to which I added the URL of each file the Contro...

0
Q: Tic Tac Toe in Haskell

SpikeAfter reviewing many Tic-Tac-Toe implementations, I decided to write my own. Here it is: Logic.hs module Logic ( Symbol(..) , Space , Board , Position , GameResult(..) , GameState , placeSymbolAt , isFree , gameResult , initialState , makeTurn ) where import Data.Maybe (isNothing, isJust) impo...

Anyone care to proofread a post I'm preparing for my blog?
About what @EBrown
The switch statement.
Switch/Case statements <3
14:04
But don't expect to get any hints about grammar or spelling ;-)
Alright, I'll get it around on GitHub here in just a moment.
That's fine, I need someone to review the technical aspects of it as well.
I can do the grammar review ;-)
@DanPantry @Heslacher It's on Gist.
> The switch and if statements both solve the same problem: how does one redirect the flow of a program conditionally? This is an important problem, without being able to redirect the flow of a program on some condition, there would be no reason to write programs.
> there would be no reason to write programs.
This is not grammatically incorrect but a false statement
There are plenty of programs that don't use switch or if
For example, i have a program that will remove all whitespace from a file
this just replaces a regex with another character (emtpy)
Right, I guess I didn't mean to imply the only way to redirect flow are those two statements.
14:11
It also seems like fluff and unnecessary IMO
I give you a point for saying they are control flow
thats a good thing to have in there
> The switch statement can be substantially faster than an if statement
Don't make that statement without benchmarks and heavy disclaimers
I have benchmarks.
This depends entirely upon the underlying system and even the processor instruction set
...oh
hurr durr
this is a post comparing the performance of the two.
my mistake, I misread.
I thought you were writing an article on the general usage of the two statements
And I have the disclaimer on the switch statement in the notes section.
Nah, it's an article to explain that the switch statement can be a better choice in certain scenarios, and how the switch statement actually works internally (in most systems).
Add a dagger or ^[1] in superscript to denote that
No worries, everybody needs to start somewhere learning Java :) I also recommend codereview.stackexchange.com to get better feedback on how you write even better code — RobAu 8 secs ago
14:14
Oh, this chat doesn't support superscript
btu yeah, make it look like a citation. make sure its obvious there is a citation in the report, rather than just stating it and waiting for the reader to read to the end of the report
I also like how you included info about branch prediction, but if you're doing a further reading side of thing here is a great SO article on branch predictions
or rather, branch prediction fails
-1
Q: Minesweeper Multiplayer code java

AmyCan any one help me in coding my minesweeper i finished it but i dont know how to make a multiplayer using server side and client side

Zak
Zak
btw guys, IT'S FRIDAY!
6
@Zak *sigh* *begrudgingly upvotes* TO THE STAR WALL WITH YOU
er
?
You need to make the string a regex literal (or use new Regex(...)) otherwise javascript will think it is a string
14:21
@EBrown Its a good read but I miss some code in it. I have the feeling that the advantage in the meaning of performance of if vs switch is only marginal seeing that you just save only about 9 ms for 4.000.000 iterations.
@JeroenVannevel pinging so you see the jsfiddle
@Heslacher I'm including a link to the code on GitHub when I finish the article.
Of course. There's ANOTHER way to write literals
as if ', " and ``` wasn't enough
@JeroenVannevel There's only one way to write a regex literal
Ah
but then you've also got string literals and interpolation literals
it gets a little much
14:23
Is that the JS way to avoiding having to deal with escape characters?
I like to have the code in the post rather than clicking a link
@Heslacher There's far too much code to embed.
Each file is 186 lines long. :P
or regex literal
Its just my preference ;-)
@SuperBiasedMan are you taling about the interpolation literal?
14:24
@DanPantry your regex isn't correct though -- I need it to display log(5, 10)
No I mean the regex literal. Because you need to use \ a lot in regex but that's also used for escape characters.
@JeroenVannevel oh, right, no, you'll need to make further alterations because that involves a capture group..
0
Q: ajax: Information overprinting and running slow

Karen Chanthis is my scenario for the website: 1/ When user enters the website, they are asked to type their name in #term. 2/ If their name is on the Google API that I created (eg. Alexis), it would print their name and associated information. If their name is not on the Google API, it would print the na...

and your "replace" explicitly puts 1, 10, not 5, 10.
@SuperBiasedMan you still have to escape stuff in regex literals
@DanPantry Bah, I hate how messy that makes everything look.
14:26
its just regex is used often and its nicer for you to do /[abc]?/gi instead of new RegExp('[abc]', 'gi')
I'm not sure if the flags section I just put in that constructor is correct but w/e
Makes sense.
javascripts literals IMO are quite nice..
you shouldn't expect a 'string' to behave like a /regex/, in the same way that you wouldn't expect a "string" to behave like a 'c'har in c#/java
I think I'll just use a few good old str.replace with literals instead
I shouldn't but did expect that in Java haha.
and the interpolation literal is fking AWESOME
14:27
Yeah I don't know anything about it so I'll take your word for it. Only used Python's regex.
`${foo}${bar}/${baz}` is so much more readable than foo + bar + '/' + baz
Also, @Heslacher, I did make one (subtle) optimization that I'm sure made a significant impact. I only calculated i % 10 once and stored it into a variable.
Then I used that variable in each if and switch statement comparison.
and also avoids lots of nasty string concatenation (even if most javascript transpilers currently concat under the hood......)
@JeroenVannevel that sounds best, this isn't sed :-)
Oh do must languages use String concatenation to make a regex? I usually just have predefined literals.
@JeroenVannevel str.replace(/(5)/, '$1') will work as you would expect
@SuperBiasedMan no, I was talking about itnerpolation in terms of concatting strings. regex and interpolation strings aren't related other than both having literal forms
@JeroenVannevel jsfiddle.net/jwvjnwz2/4
14:31
Oh right, I know nothing about interpolation so we were just having two different conversations there, oops.
(I botched the regex a bit)
@MostafaBouzari my answer wouldn't really be consistent with the question, because this becomes a 'different' implementation at that point. I would advise you to ask another question on the matter.. perhaps in codereview.stackexchange.com .. — Brett Caswell 46 secs ago
@DanPantry well, that beats my
const indexOfLog = expression.indexOf('log(');
if (indexOfLog > -1)
{
	const indexOfClosingBrace = expression.indexOf(')', indexOfLog + 1);
	expression = expression.substring(0, indexOfClosingBrace - 1) + ', 10' + expression.substring(indexOfClosingBrace);
}
@JeroenVannevel my god
I'D SAY THEY'RE ABOUT EQUALLY GOOD
I'll use yours though, for reasons
14:36
@JeroenVannevel just like post-disney and pre-disney star wars are "equally good"? ;-)
That's a generation battle I'm not going to get involved in
@JeroenVannevel hahaha!
aws.amazon.com/iot/how-it-works Has anyone else seen this? It seems really cool
That's literally what I'm working with
lol
What device are you using?
I would imagine the only devices I could use would be a (small) army of raspberry pi
We've got a thermometer and some other -meter on the desk next to me
but yes, connected to the raspberry pi
did you see my message from last night?
14:40
@JeroenVannevel I don't think so
I went to bed pretty early
18 hours ago, by Jeroen Vannevel
guess what daddy brought home from work today
Oh.
This is awkward.
That's what I read to read about IOT this morning.
LOL
to read or not to read
So, how does that work then? You get an electronic thermometer that has some kind of external port that connects to the pi?
but yes, the whole IoT thing connected to an Amazon cloud of all kinds of fancy things is this entire company's work
Yeah, there's a port connected to it which constantly sends its data to AWS
now it's still using HTTP but we're going to move to MQTT
@JeroenVannevel okay, so how do I "listen" for those messages on the server side? say from EC2
1
Q: Simple login system using Python Flask and MySQL

SakirThis is my first post on Code Review. I've made a login page using Python Flask which works with MySQL. I started learning Flask 2 days ago and it was fun. So I came up with this: from flask import Flask, session, redirect, url_for, escape, request, render_template from hashlib import md5 impor...

Messages through MQTT, you mean?
You should post this at codereview.stackexchange — dguay 33 secs ago
@JeroenVannevel Yup. so say I press a button which sends a message to the cloud, how would I react to that button press?
hoping you can ELI5 it so I don't have to dive into MQTT docs.
14:49
HTTP: same as any other request, you just send it to the server
MQTT: you publish the message to a channel (with automatic offline buffering if there is no connection) and that channel is.. somewhere. Then you can read from that channel in your backend
But all I know from MQTT is a small introdution yesterday at out workshop
and some reading up on it a few weeks back
HTTP seems like a bad choice, then - you would be tying the button to your server
It's supposed to be very lightweight and the offline buffering is pretty awesome
yeah, MQTT seems to be the way to go there
I intend to play around with that button thing I have -- maybe somewhere this weekend
so if you have any suggestions, let me know
If I had suggestions I would be rollling in money from my own projects haha
14:53
"You should post this at codereview.stackexchange" ...but with a lot more explanation as to what the code is supposed to do. — Andy Turner 43 secs ago
But you don't have a clicker. The clicker is life
@JeroenVannevel Haha :P Shame amazon arent selling those
Zak
Zak
@SimonForsberg Always upvote Dilbert :)
0
Q: Compare 2 arrays and preserve the row number

ClaudiuBackground: You have an ecommerce order of 10 products but you want to refund only 5 of them. The stock managing system needs to preserve the order of row number (orderline) when you do the returns, but don't send the items that are not refunded. So the order looks like this: "Poduct1" Orderlin...

ugh
2 - pi mod ((tanh(ln(3)) + 8)) is interpreted by mathjs as 2- pi but by wolfram alpha as (2 - pi)
what's the order of operation for mod?
I'd wager it's the same as multiplication / division
which means MathJS has a bug? no?
15:03
@EBrown Perhaps make more bare-bones example(s) you can include in the post itself? (maybe use something short like Python or such that fits more easily in a small code block)
@Phrancis Well I run four scenarios, and there's no good way to shorten them up.
5
A: Modulo in order of operation

Mehper C. PalavuzlarThe relative precedence levels of operators found in many C-style languages are as follows: Wikipedia - Order of Operations

this has answers for c-style answers (javascirpt)
yeah I saw that too
tldr modulo has same precedence as division
I don't know if it's something different in a math context though
every resource talks about programming-oriented implementations
15:04
in js modulo/divsion share the precedence
the real answer here is use brackets..
so.. mathjs has a bug then?
or.. well..
Wolframalpha has?
it SHOULD be interpreted as (2 - pi) mod (....)
then mathjs has the bug
this is why I don't do math
just use brackets
because your expression is confusing without those brackets anyway
BTW mod is %
Oh I don't care about that. It's just to test that the expression evaluator works with my modifications to it
15:07
> Since %, / and * are (usually) left-associative, they are evaluated left to right.
so yeah, it should be interpreted as (2 - pi) % (tanh(ln(3)) + 8)
youre right tho, screw math
2
@EBrown Ah ok, fair enough
Now I can't reproduce that C++ bug I found yesterday.
0
Q: Handling exceptions in java

ReivajErriugaI have this code in java, but I want to improve it. What would you do ? class Setup { public static void main( String args[] ) { Supervisor s = null; OrgChartIterator orgIter= null; String RESP = "no recibida"; System.out.println ( "Iterate over bank ('b') or alterna...

15:33
@DanPantry .replace(/log\((\d).*\)/, 'log($1, 10)') removes all text before and after the log()
This question is not suitable for SO. Code Review might be a better place. — That1Guy 16 secs ago
15:52
TTQW + TTGH + ATOTTT (All The Other "Time To" Things)
@SimonForsberg TTTS

« first day (923 days earlier)      last day (3392 days later) »