12:00 AM

1 hour later…
1:06 AM
@throck95 well done! Upvoted.. but I agree with Jamal there, the title would be better if it said what the code is about

1:46 AM
@Mat'sMug thanks. name changed. i still, though, think that the post may be too long but it's the first review on it due to the fact that I wasn't doing this from the start
moving forward, code reviews should theoretically be easier if i can keep on top of them, but this first one is gonna be rough

2:01 AM
@throck95 make sure you wait a few days before posting another - give the first post enough time to collect at least one or two "low-hanging fruit" reviews/answers; some if not all of this quickfix advice is quite possibly applicable to the whole project. And it's possible someone takes the time to actually sit and really dig into your code and shred some pieces, extract a class here, one there, and results in such dramatic architectural changes, that you got plenty of work already!
Besides, only one question per day counts toward the curious/inquisitive/socratic badges ;-)
I hope you get good reviews and enjoy your experience on this site as much as we do!

Just tried solving PE5 with just pen and paper, didn't get very far yet :D

And don't worry about the length of the post - if anything the narrative could be tightened a bit, but more information/context is always better than not enough (e.g. SO-style boiled-down straightforward, I-can-answer-it-from-the-home-page questions) for a Code Review post.
@Phrancis what's a pen? paper???
3

That's how I always thought, but everywhere I go always says that too much distracts.

32

How to NOT write a zombie. A zombie is a question that remains unanswered. As a question asker, your goal is to avoid writing one. Beyond meeting the on-topic requirements, I think "good CR questions" can be broken down into several question types. This answer is longer than I would have liked...

The zombie rating is quite high I must admit. But we have a thing with zombies...

I noticed in the smaller example set of \$[1,2,3 ... 10]\$ I noticed that \$(10 \times 9 \times 8 \times 7) \div 2 = 2520\$

2:15 AM
@AleXoundOS Cleaning up your code is an excellent question for Code Review. — Rowan Blush 15 secs ago

0

send_sms_message method takes text as an argument. The length of the text is unknown, it can be 0 or max let say ~1e70 (after that we will have no space for actually text, because multi-part message text will be so long. Yeah, I know :- ). The trick is that if the text is larger then 160 charact...

@throck95 while you're waiting for a review, feel free to wander interesting tags and hunt down a zombie or two :)

@Mat'sMug antiquated instruments that people once used when they needed to make a note of something before there were smartphones and tablets and email and SMS and ...

lol

wish I had time to review a large project, but working full time and volunteering as a leader in a gaming clan takes all my time :P

2:27 AM
oh, but we have little baby zombies, too :)

a baby is a monster with my free time XD
i can only talk because im working cleaning up a forum while im here lol
i'll keep it in mind for tomorrow though. if I don't get a response I'll probably have some free time that I can review something

I posted a baby Python answer earlier, I usually don't Python much but this was just really bad naming, I had to say something
(there were already 3 other answers covering the meat of the code)

i don't have a lot of programming experience. php, some java, and jquery
so beyond that, my knowledge would come from data structures and cleanliness

A lot of code in common languages starts to look pretty similar after a while

object oriented is object oriented
4
all thats different 90% of the time is syntax

2:32 AM
@throck95 that's deep
;-)
and true

Very meta
It was that weird half-English / half-French code to generate random animals/properties of animals from like 5 different text files. Very strange that someone would want to do a thing like that, doesn't really make much sense or serve any purpose

@throck95 anyway, with php, java and jquery knowledge, a readability-oriented style and 20 minutes to burn you could very well post a great CR answer on some rotten zombie, and score big

or take a nap and let @Phrancis score big?

PHP questions are a dime a dozen, especially with database/MySQL stuff combined

also

2:38 AM
If you get to them before h.j.k. or Tim get to them, you could score big :)

LOL

sql injection sheesh

"It looks like you're trying to do database code with PHP, you should totally drop that and use jQuery PDO instead"

nah, just use laravel

2:40 AM
#ClippyStrikesBack

Is Laravel a database framework/library for PHP, essentially?

i dont know how they define it, but i find that the cycle time for executing queries is insanely small

0

I have created this macro and having a small issue. I am very new to this VBA and did this with experts’ guides by googling it. I am creating an excel form for a work purpose at work. The Excel form has 7 sheets and each have named tables with different data. 1st sheet is the editable form, whi...

I usually make the database worry about itself with stored procedures & functions, and just let the application code call those, instead of writing SQL queries inside the code

depends on what your using it for
and how many different calls you need

2:42 AM
Yeah, for sure

for my application thats up for review, im probably going to code in queries
bc im likely to evolve it to allow custom reporting which means custom queries

It just seems to make sense to me to extract programmed routines into the database, in most cases

as in code that runs arbitrary user-provided code against your sql backend?

as in, a user defines what it wants to see and the backend generates the sql to execute
i want to see a, b, and d
but not c
query is generated to return abd

Ah, sounds a bit like Hibernate for Java

2:44 AM
but in laravel its as simple as one line to open a database connection
connection created and it has very little overhead

I used Redis in my latest project instead of SQL and it's much easier/safer ;-)

@throck95 I thought mysqli was deprecated (or should at least be avoided in favor of PDO, whenever possible)

from my best understanding it wasn't deprecated, it was just suggested that you move to PDO

As a disclaimer though, I never write PHP, so it's very likely that I could be wrong

i mean the php docs show that they improved the extension
php.net/manual/en/book.mysqli.php

2:47 AM
I might be thinking of mysql extension rather than mysqli

mysql is deprecated, yeah

yea i thought mysqli was pretty new

I thought PDO was more general purpose though, as in, not limited strictly to MySQL

it is
im just using mysql sooooooo
why take more overhead to allow compatability when i can use something designed for it

May as well keep things simple, since PHP and MySQL are like peanut butter and jelly

2:50 AM
or cheez whizz and celeri?

@Phrancis no. both are terrible, but they go less terrible together

can't deny cheez whizz is terrible

119

It's not so much that PHP itself has security problems (assuming needed security updates), as it is there exists a lot of popular PHP-based software with rampant security problems. You could fault PHP for being a language that gives you enough rope to choke yourself, but the real problem is just ...

php primarily gets a bad reputation because its the beginner language

0

I am writing a program that rolls a pair of dice 10,000 times. If they total 7 or 11 it is considered a win. Every other total is a loss. Need the out put to state the number of wins, losses and the probability. My code seems to be producing wins only. What am I doing wrong? Thanks for any help H...

2:52 AM
if you know what your doing, its probably one of the best languages out there

Code review is not what Stack Overflow was designed for. You are in luck, however, because there is another SE site for just that. — zondo 9 secs ago

Yeah I think PHP is often disliked just because there's so much of it around, and much of it is horribly written

in other words PHP is the web's VBA (whatever VBScript thinks of that)

pretty much

If I'm not mistaken I think Facebook runs in large part with PHP and MySQL

2:55 AM
they used to

kinda sorta

facebook used to be completely php
then zucker realized that he was losing money and rewrote the entire framework
to be custom

They have their own PHP derived dialect, Hack, which has strict typing and better templating (like React style templating)

now it uses java if i remember right but it uses a php syntax

Most of Facebook runs from React modules these days, apparently they have over 10000 React modules on Facebook

2:56 AM

@Quill at which point did Lippert step in?

The core engine is handled with PHP and nginx still though (as for DB, I don't know. Maybe BigTable or something)
@Mat'sMug He stepped in during the original dev of Hack

Oh, didn't know Lippert was involved in developing Facebook

PHP: "It works. Somehow. Don't question it."

For me, I always saw PHP and JS with a certain attraction.

2:58 AM
lol so true @arda

In one sense, anyone can apt-get node or PHP and get writing fast
In the other sense, you could buy a windows computer, (previously) pay for VS, try to use C# and build it properly

Quick and a little dirty :)

@Quill I never paid for VS
used to run Express editions

So using an easy, get writing fast language is good if you've got platform limitations (or patience issues)

then Community came along

3:00 AM
there's a trade off sometimes for having "to build" your solution to run it, versus simply executing the code

@Quill there's still some JS involved, and plenty of room to mess it all up though, no worries

PHP is an easy, executable language built for web servers, so of course it's gonna have issues that other languages that have strict typing and builtin safety functionality won't have

Can't really avoid JS if you're building anything website-like nowadays, other than a purely static website

i find that pure js doesn't really fit the bill anymore

I get annoyed that people see JS, PHP, VBA and other "executed" languages as childish, basic or insecure, but that's just a trade off of the type of language it is

3:02 AM
usually you want to use some combination of jQuery a nd angular

Vanilla JS is lackluster for things other than really simple stuff

You can use pure JS if you're not the type of person who needs abstractions

@Quill "interpreted"?

@Mat'sMug "whatever, man"

"ok"

3:04 AM
That said, it disappoints me that I can't download VS Professional for my Mac and start writing C#, because it's such a pretty language

I'm really starting to see why a lot of people like C#

everything has tradeoffs, you just gotta live with them and stop criticising a platform for its users' mistakes

Takes about half the amount of code than Java does to do the same thing

@Phrancis tell that to @skiwi lol

Well, @skiwi tends to overengineer things a bit, too ;)

3:05 AM
All that in mind, my current JS build process is longer and more annoying to adjust than the C# solution, lol

can't find the quote, but he said something along the lines of C# takes twice the amount of Java code lol

lol, that doesn't sound quite right

Oh hey, the university accepted my application to swap bachelors from IT to CS

I'm pretty sure Java is hands down the most verbose programming language ever

he's learning WPF and discovering MVVM and the command pattern all on the same night

3:07 AM
codereview.stackexchange.com/questions/114021/… -- let bounce something off you guys

Java can certainly do a lot of different things though (but so can C# and others)

@Phrancis seems pretty verbose too

this guy is looking for a way to optimize his database query

@Mat'sMug Ok, let me clarify, "serious programming language"

theoretically couldn't he use an aggregate query to limit his return results then do a computational date analysis on the remaining results?

3:08 AM
@Phrancis non-esolang

this removes his computational backlog of checking the date on everything and only checks it on everything less than a threshold or that is equal to the lowest amount etc

@throck95 Are you referring to this line? $results =$relation->where('startdate','<=',$enddate)->where('enddate', '>=',$startdate)->where('price','>','0')->get();

i haven't started picking apart his code yet. I just took what he's asking to get done and broke it down at a very high level

@throck95 wait, he's pulling a set from the database, and then doing aggregations in code?
I think you have a nice answer brewing there :)
yeah it's not a stellar question either

he's trying to take a complex dataset that involves creation date and pricing

3:10 AM
Hm, if that's what they are doing, they are definitively not taking advantage of the database's computing power

then it returns the lowest price of that dataset where the newest entry takes precendence when duplicate prices
im thinking he should be doing this in 2 queries, not one
query all the results <= some value or <= something defined through a quick search query

if it were SQL Server you could pull it all in one query

Strange

then do a second query on the remaining dataset checking the dates to remove the computational overload with the date comparison

Finding duplicate entries is a pretty simple matter with any SQL, then just getting the newest one from there is a breeze

3:12 AM
okay, so who's slaying that one?

it could be duplicated it could not, and its only one field
just the price

I'm not touching PHP questions with a 10-foot pole ;)

lol

Strictly from a database standpoint though, it does sound like what they are doing is sub-optimal

which is why he asked the question, he wants to improve it

3:14 AM
I suppose Laravel transforms the above query language into actually executable SQL code?

oh
there's an orm involved
> you know nothing, mug

I'm not a huge fan of ORMs, though I haven't really used them. They just look like they would be DB performance killers

0

I'm trying to do a nice script to be able to wrap my movies. Can you help me to improve it? I want to structure my code better but I don't know the language enough to do it. @ECHO OFF SETLOCAL SET "ROOT=%~dp0" SET "FORCE=0" IF /I "%~1"=="/f" ( SET "FORCE=1" SHIFT ) IF "%~1"=="" GOTO :E...

he's using magic methods @Phrancis

@throck95 Oooo magic huh?

3:17 AM
it's using the default database defined in the database.php file in config or .env file cant remember which and then connects it and the ->method creates a query behind the scenes

Sounds hackish

here's the docs, little messy php.net/manual/en/language.oop5.magic.php

I suppose most ORMs look hackish to me though

its effectively just shorthanding the sql query
why write 10 letters when you can write 1

It's just that it doesn't sound like the DB has a very good way of optimizing the queries if they're just arbitrary SQL "string" rather than a prepared statement or stored routine/procedure

3:19 AM

I guess for a lot of use cases that are not as performance-critical it's no big deal though

This question could be closed as primarily opinion-based because any review is merely an opinion. It could also be closed as too broad because there are many possible answers. The ask page is not as specific as other pages such as How to Ask, help center, help center, and the tour page. You are much more likely to get good reviews on Code Review. That's what it's there for. — zondo 54 secs ago

@Duga no. it could be closed as too broad because any review covers way much more than what SO is going to answer

We'll see what he says to my answer. Hopefully this knocks out a zombie

yeah!!

3:30 AM
@zondo good recommendation, but as it is currently worded, i.e., "How can I do X", would likely be closed on Code Review if it is asking how to make the code do a different thing than what it does (in other words, it doesn't really work "as intended") — Phrancis 45 secs ago

Wow, dat return statement
        return '   |   |'  + '\n ' + res[6] + ' | ' + res[7] + ' | ' + res[8] + '\n   |   |' + '\n-----------' + '\n   |   |' + '\n ' + res[3] + ' | ' + res[4] + ' | ' + res[5] + '\n   |   |' + '\n-----------' + '\n   |   |' + '\n ' + res[0] + ' | ' + res[1] + ' | ' + res[2] + '\n   |   |'

who say what now lol

^right?
The visual representation of a tic-tac-toe board should be a simple detail that only matters to the human players, as far as the computer is concerned you may as well just return a list of values

whoever wrote that is building it to look a specific way based on his machine, his window size, and his resolution. he should just be returning raw html then using some form of css to style the result how he wants dynamically to fit all screens and reses
ah its ttt

Right

3:33 AM
makes a bit more sense, but why not use image overlays instead of raw text?

It basically spits this out in the return:
   |   |
x | x | x
|   |
-----------
|   |
x | x | x
|   |
-----------
|   |
x | x | x
|   |

depending on the goal of the application and how it should be used, he should be using some tictactoe board image, .jpg should work fine

Which to a computer is likely a very useless bit of information

then it would be as simple as returing an array showing what's blank where xos are

Right

3:34 AM
then the game class would parse that array to return another image of an x or an o

I'd be tempted to just leave out the grid part and just return an array, and make a method/function to print just the values like...

assoc arrays are your friends <3

O_X
_OX
_XO

@Phrancis looks like OP is looking for a better way to do what he's already doing; the question could be closed as too broad here though, because it's not asking about a specific programming issue with a Minimal, Complete, and Verifiable example, but is rather looking for open-ended feedback on any & all aspects of the code, more particularly the way the string output is generated. And Code Review will typically cover wider than that, with various ways of making the OP's code objectively better. — Mat's Mug 50 secs ago

In any case, it could certainly be made better :D
OOP Python loooks kind of strange, compared to more traditional OOP code

3:37 AM
public function parseArray($array) { for($i=0;$i<sizeof($array);$i++) { if($array.get($i) == 'X') { return new Bitmap; } else if($array.get(\$i) == 'O') {
return new Bitmap;
}
}
}

Post here instead: codereview.stackexchange.com - Short answer is no though, don't use @ fix the potential issue instead of omitting the error — Zanderwar 45 secs ago

pretty basic but thats php

try that [fixed font] button next time ;-)

@throck95 Oh just a hint for formatting code in chat, you can inline-format code like this by enclosing it in back ticks like this
Or what @Mat'sMug said for code blocks :)

4-space indent also works for a one-liner
but {
sometimes not for multiline messages;
}

3:40 AM
BTW, my chat doesn't have a "fixed font" button, I usually CTRL+A to select all, then CTRL+K to indent 4 spaces

it only appears
on multiline posts

oh
I see it now
:D
After the reviews I got the PE4 solution in C# is super-freaking-fast

sounds good
i think

@Phrancis it always takes me a few seconds to realize that PE stands for

@Mat'sMug I guess PE problems haven't haunted you enough yet ;)

3:44 AM
nope
28

It's been a while since I last wrote some lolcode, so I felt like tackling Project Euler #1. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. This is...

that's as far as I went lol

Oh gods,
PE1 is not that interesting though since it's essentially FizzBuzz

and that's my top-voted post
74

This post is the result of reading through and following the LOLCODE Specification 1.2 ("smoking the manual", right?), and writing and executing my code on compileonline.com. My "hello world" was going to be a fizzbuzz. I like it because it nicely illustrates the basics of a language - variables...

like, ever
I'm not sure what this means

Those may as well be the same post, since the differences between FB and PE1 are very very small

yep
> Is the fizzbuzz-like logic appropriate, or I fell in the "easy" trap?

FB-style brute force is more than appropriate for a small problem like PE1, though @N3buchadnezzar wrote some interesting optimizations here
Brute force won't get you very far (or it will, but very slowly) in other PE problems, as I am learning :D

4:14 AM
How to get free stars: post a message about how PHP is bad

JAVA works too

yeah

0

I make some Formula in Excel that will monitor all my report coming and how many days left. im having trouble with the previous day because it still appear the hour that i need to meet per day. maybe there is something missing with my code/formula can you please help me. i attached some screensho...

Thanks! I guess I should have asked for suggestions on how to shorten my code instead of just saying having trouble. Would it be wrong of me to ask the question again on code review? I posted here because I was trying to get the most answers possible. — Jeremy Odell 20 secs ago

at last!!! the damn thing works!
hey @Hosch250!

4:27 AM
disables sound
Hi. It worked before.
What did you just fix?
Of course, it needs a set of updated dlls after all the recent bug fixes...

in VBA Rubberducking, 8 secs ago, by Duga
[rubberduck-vba/RubberduckWeb] retailcoder pushed commit e428a835 to master: moved \libs into RubberduckWeb folder, updated nuget packages and Rubberduck references

Oh, you broke it and and had to fix it?

sort of
took a while to realize I needed ninject.extensions.interception as a reference
it kept crashing trying to load inspections from the rubberduck assembly

Oh, you updated the dll? Nice.
Yeah, you have to reference everything.
NVM, that was kind of rude.

lol, I am slow
haven't touched that project since last deploy in... uh, ..February I think?

4:32 AM
Yeah, something. How do you like it?

could use some CSS lovin', but works great

I know, and some JS too.
I still can't get the image-click to consistently set the image in the center of the screen.

I could take a look at it later if you like

does the menu trigger on click? hover-only kinda fails on mobile/tablet

Is it a web IDE sorta thing?

4:33 AM
lol

@Mat'sMug Oh yeah, I wondered what click-enabled did...

@Quill it's Rubberduck's website

@Mat'sMug Just give it the URI of "#".
@Quill No, the only think IDE-y about it is that it inputs code and runs inspections.

WHYYYYYY

I did up a few web REPLs for some of the PPCG users' languages

4:35 AM
sudo copy * d: make me a sandwich

'sudo' is not recognized as an internal or external command,
operable program or batch file.

> windoze

permission issue?

What are you trying to do?

@Hosch250 copy movies to flash drive

4:36 AM
And why don't you just use the File Explorer to copy/pasta your files?

@Hosch250 same error

Huh.
Then... maybe the files don't exist?

oh nope
apparently the usb stick has issues

@arda I've heard of that kind of thing.

or just the driver

4:38 AM
It looks like it is empty and hasn't been properly formatted yet.

replugged and it worked

Except... NTFS file system proves me wrong.

there we go

BTW, y'all know how the Bible says "the Trump shall resound"? I never realized what it meant :P

@Hosch250 OH WAIT I JUST REALIZED

4:42 AM

Having trouble with PE5, I kind of know what set of numbers I want, but not how to express it as math or as code :\
@Mat'sMug What the... is that a web REPL for VBA...???

Poor guy, but I coulda told him: msn.com/en-us/news/us/…
@Phrancis No, you input code, we run the inspections.
That's it for the foreseeable present.

@Hosch250 So it doesn't compile/run the code, but does inspect it?

yay spaghetti code!

Nope, Rubberduck doesn't know how to compile or run code.

4:49 AM
May I suggest making the font in the code box a monospaced font?

absolutely!