« first day (503 days earlier)      last day (3516 days later) » 

7:02 PM
hello
 
0
Q: Best way to build json object with php json encode

AndyI am trying to return a json object to an ajax call $arr = array('states' => ''); $sql = "SELECT * FROM `states` WHERE `country_id` = 1"; $result = @mysql_query($sql, $db); while( $list = mysql_fetch_assoc($result) ) { $arr['states'][] = array('id' => $list['state_id'], 'name' => $list['n...

 
hello
 
At the moment, VB.Net has the cool advantage of the conditional catch, that isn't supported in C#.
 
@TopinFrassi conditional catch?
VB.Net having advantages?! (over any modern programming language)
 
Sometimes it catches the problem, sometimes it does not .... ;-)
Huh......
 
7:09 PM
How do I put code in chat? To show what I mean
 
Try
    ' Code goes here.
    ' Check for type mismatch error.
Catch ex As Exception When Err.Number = 5
    ' Code reacting to exception.
End Try
Like that ^^^ ?
 
Yeah
Like that
 
indent the code with 4 spaces.
Paste it in, and there should be a new button on the right of the input box "fixed font"
 
Well, I don't need to do it anymore, you just showed what I meant!
 
it will indent for you
Like this
 
7:11 PM
@skiwi I said over C# :p I don't know if another programming language as the "conditional catch", I don't know what the real name is
oh yeah, fixed font
 
The button only shows up if you have multiple lines of text.
Use shift-enter to do that.
(or paste).
 
I had an empty line before
I'm used to shift-enter because of facebook
 
If you have just one line, manually indent with 4 spaces
 
@RubberDuck well does everything can do (just with uglier code) - the Microsoft.VisualBasic namespace is the smelly -compatibility crap that ought to burn in the eternal flames of Hell... but yeah when I see VB do things like assign Nothing to a value type, and someone say "it's perfectly legal", I die a little inside.
 
Nothing is something - VB.Net
 
7:19 PM
@rolfl I feel like I'm missing something... do I need this function? like, isn't there something built-in that would do this for me?
ALTER FUNCTION [dbo].[ConvertIsoDate6]
(
	@value char(6) null
)
RETURNS date
AS
BEGIN
	DECLARE @result date

	set @result = case
		when @value is null or isdate(@value) = 0
		then null
		else convert(date, @value, 12)
		end

	RETURN @result

END
 
@TopinFrassi you can also select all your text (Ctrl-A, duh) in the chat box and then press Ctrl-K to indend 4 spaces
 
@Phrancis so basically, it has the same engine as the answer box
 
For the most part
 
except for the strikethrough and html stuff
 
Alright, thanks @Phrancis and @rolfl
 
7:21 PM
<strike>...</strike> doesn't work in chat, and ---strike--- doesn't work in answer
(would conflict with the horizontal line formatting)
 
@Mat'sMug char(6) input? Really?
 
yes. don't ask! :'(
 
Sorry, just did
 
it's pre-Y2K
 
Dates stored as 190914 ?
 
7:23 PM
yymmdd
 
convert-code will show....
 
Blech.
 
I want to insert a null when I come across things like 980431.. or 000000, or 999999
(yes, April 31st!)
 
AngularJS + Ubuntu + SublimeText is how I am spending my Friday night..
Hope everyone else's is going well :-)
 
I'll spend my friday night kicking people and beating D3 ubers, yay
 
7:28 PM
Oh yeah, could anyone advice me a C IDE on Linux/Ubuntu?
 
@skiwi SublimeText
>: )
If you feel really hardcore, vi / vim
 
@DanPantry Rather not :P
is SublimeText only a text editor, or more?
 
there is a very extensive plugin for c/c++
 
@skiwi But seriously, give Sublime a try, it's amazing
it is a text editor on it's own but you can install packages for git and stuff
 
@Mat'sMug - Is it necessary.... probably. The isDate part is a big factor.
 
7:29 PM
It's indeed pretty cool. I didn't use it much but it's like a super notepad++
 
@rolfl thanks.. just wanted to be sure.. without it the whole procedure just blows up. FML.
 
it is ugly, but your data is worse.
 
I'll make sure to try it, tomorrow I'll lock myself up in the Ubuntu case for a Operating Systems practical assignment
 
@skiwi: git diff example
 
7:30 PM
Need to use the POSIX library, hence Ubuntu was best choice according to the teacher
 
You can even compile stuff inside of it if you get the appropriate addon. Notepad++ on steroids is a pretty good description for it.
Except the upside of Sublime is that EVERYTHING is configurable.. and you can have keybinds for everything :P Ctrl+B will compile SASS into CSS for me for example, or Java if I am in a Java file
 
@skiwi there is no C specific IDE for linux that I know of, just many C++/Java cross language IDEs.
 
^^^^ There's vim?
;-)
 
^^^^ I have already suggested this. :-(
 
7:31 PM
Monkenoonafterking!
 
o/ @SimonAndréForsberg
 
o/ @DanPantry
 
o/ Simoz
 
o/ null
5
 
7:33 PM
@skiwi seriously, give it a go :-) It's worth the try. it's probably the best you're going to get unless you want emacs or vi/vim. or gedit.
 
I'll do, I just don't want it now as I want to enjoy my Friday evening without it being destroyed by the frustration of learning a new programming language ;-)
@Mat'sMug You've got a bug
 
hehehe... just got an e-mail... Returning a bug I filed in 2010.
> Note_Entry: This is an very old issue. Returned it for now. If it still exists, please reopen with updated info. Resolution: Fix in Future Release (from [no entry])
That was from before IBM bought the company I worked for.... and before I moved inside IBM to a new area.
 
@rolfl They might've been working on clearing a backlog
 
This bug is no longer a bug because it has been around so long it is now a feature!
7
... and we can't be bothered to look in to it to see if it still exists, or, perhaps we fixed it, by mistake.
 
@skiwi dang! I knew it!
 
7:39 PM
Speaking of emails, @Mat'sMug @TopinFrassi @Marc-Andre should get a kick out of the subject line of this email I just got:
 
@Phrancis every once in a while I get one with nothing in the body and a subject that goes "can u come see me when u have a minute?"
 
lol
3
This email would be equivalent, if it were a letter, to writing the entire message on the envelope, and on the letter it just says "Best regards, Francis"
2
 
That's my kind of email, no need to open it to understand what's happening
Until there's something important in the body, and I miss an important point I had to prepare for a meeting..
 
Ahahaha, if you press Cancel, it will be saved on Mars
3
 
7:49 PM
YOu can only save one.
 
Time to go home, have a nice weekend!
 
Toi aussi!
 
@TopinFrassi TS
 
RSA
 
SNAP has a weird bug where if you pull up a contract where the country is Canada, it instead tries to update the city to the last US contract you opened before that one. Oh, snap.
 
7:53 PM
@Phrancis, Montreal or Dallas?! Wtf dude?
 
Sounds like someone failed to initialize a variable, huh?
 
It actually sounds like testing code that never got replaced with real live production code.
Is it always Dallas?
 
No it's whichever City the previous US contract you pulled up in the app had.
Like if it were still in memory. But only if the current one is Canada. Odd.
 
sounds like a feature, not a bug...
 
Bugs don't exist, only features. War is Peace.
Is that that old VB6 app @Phrancis?
 
8:01 PM
it's good ol' !
 
So it'll never get fixed because no one knows where the source code ever got off to. And even if they do, no one has a compiler...
 
1
Q: Quicksort in Python

mebobThis is my first actual attempt at writing a Python program. I have a background in C++, so it was a big change (where's my iterators?), and I'm looking for criticism on my use of Python and its idioms. Here it is: def quicksort_pivot_select(l, b, e): return b + (e - b) // 2 def quicksort_p...

 
We actually had that problem once.
 
@RubberDuck LOL
 
can we still buy a legit VB6 IDE somewhere?
 
8:06 PM
in TCG Creation, 2 mins ago, by skiwi
@Duga That's a bug feature request...
^ WTF was I even thinking?
 
a bug feature request??
 
I think so @Mat.
Hmmm now I'm curious.
 
(I sense intense googling going on)
 
A new copy will run about $1k. amazon.com/gp/aw/d/…
 
wut
 
8:12 PM
@CaptainObvious O god, l as a variable.
 
@RubberDuck a used one goes for $199
odd. ReSharper $$ == VB6 $$
 
@RubberDuck that one? Yes
 
@Phrancis that's just... beautiful ... in its own way
2
 
Beauty is in the eye of the beholder developer...
 
Dude, that logo was futuristic in '99
 
8:16 PM
If you look closely, the triangle logo is heavily pixilated; but someone knew how to make a nice shiny little doodle in Photoshop.
I'm actually surprised there is no clip art anywhere in the program
 
if I look closely, my eyes explode
2
 
From the sheer awesomeness I assume.
 
I pity the poor souls that have this app on their screen all day
 
(accepts your pity)
There's this other one...
 
I <3 it.
 
8:26 PM
@Phrancis
 
I miss the 90's. The 90's had the best music.
 
Legit business tool.
 
well that's a happy icon!
 
oh come on
 
8:31 PM
We like acronyms here. This is our Jira logo.
 
I have one named NEMO.
 
"SN" is for "Shameless Nineties" right?
 
New Electronic Merchandising.... Something.
 
@RubberDuck the beauty is that it also works for the Newer Electronic Merchandising..
 
I just liked Finding NEMO to be honest.
It does!!!!
Organizer. It's organizer.
 
8:34 PM
Finding NEMO ... Is that like Writing JAVA?
 
bbl
 
Lol. Yeah. I guess so @Phrancis.
 
8:52 PM
^^ banner on internal knowledge base website.
 
@Malachi Holy crap I've answered 136 questions.... Thanks for posting that query. You've confirmed that I should spend less time here and write more code.
 
LOL
I am trying to implement that cool E-mailer class that Dreza wrote. and see what I can do with it. then I am going to study NLog and figure that all out on Monday I think...
but I still have an hour left here at work.....ugh! I wanna get on my bike and ride!
 
If anyone know , here's a zombie that needs slaying.
2
Q: Basic XML template

blackboxI am currently exploring the play framework. I'm about to replace the proposed templating system, using the powerful XML processing of the Scala library. Here is what I have come with: import scala.xml._ import play.templates._ import play.mvc.results.ScalaAction object Gui { def asset (file...

 
@RubberDuck @Donald.McLean is your man
and @amon
 
Leaving early isn't an option @Malachi? Get out and enjoy it.
 
8:58 PM
trying to save up my Vacation time. I am under a week's worth right now
 
Yeah. I know nothing @Sim. Did my part by bumping it. Bbl guys.
 
Found it, I just had to lure in those unicorns so I could kill them
 
@SimonAndréForsberg I'm not all that familiar with what they're doing.
 
@Donald.McLean me neither but I figured you're probably more familiar with it then I am - who only tried to use Scala once
Best quote I have heard today:
> "Best" solutions always lose out to "actually working" solutions in the real world. If you stop and worry and get paralyze over every "which is better" question you have during development, you will never ever actually have a working product. If you choose wrong, you can always go back and change the code later.
4
6
A: Is it efficient to use lua to store game data?

Sean MiddleditchLua was actually designed to be an efficient data file format. It's original use was to load huge geographical data sets. Actual scripting/logic features came later. Even with all the new scripting features, it is still used by its original authors to store and load large data sets. That is n...

 
Damn, from 2011 @ducky
> You have fully used your vote allowance for today
 
9:08 PM
Weird use of the list operator. But then, I tend to revert to Java-isms, having 12 years Java experience and only 3 years Scala experience.
 
PHP question... I read this:
> String values may be enclosed in either double quotes
(“”) or single quotes(”). (Quotation marks within the string itself can
be “escaped” with a backslash (\) character.) String values enclosed in
double quotes are automatically parsed for special characters and variable
names; if these are found, they are replaced with the appropriate value.
From reading this I would become tempted to always use "double quotes" for strings... is this correct?
 
depends
single quotes are for string literals like if you have a bunch of these / in the string
and depending on if you are using double quotes or single quotes in the string
 
@Phrancis always use single quotes, unless you explicitly want the features provided by double quotes (variable interpolation, escape codes). Especially double quotes for strings containing SQL statements are a red flag …
 
▲▲▲ What he said
 
Ah I see
So if I have this:
<?php
// variables
$myName = 'Phrancis';
$myId = 1;
echo "Hello, World! <br> My name is <i>$myName</i> and my ID is <b>$myId</b>";
?>
How would I write this with 'single quotes'?
Or, would it be better not to?
 
9:17 PM
@Phrancis That example is OK, because you do want variable interpolation (= replacing the variable names with their contents in the string)
 
OK
I think I get it now :)
 
With single quotes, you'd need to explicitly use the concatenation operator ("." not "+"), and that is ugly.
 
@Phrancis You could use string concatenation. echo 'Hello, World! <br> My name is <i>' . $myName . '</i> and my ID is....';
as you can see, @amon is quite right ^^
 
That is pretty ugly.
 
it's important though to remember to not print user-input data directly, as that can lead to XSS attacks
> One common approach is to use JSON: data entities are basically maps, or property bags or any of a dozen other terms because there's nothing programmers like more than inventing names for stuff that already exists.
 
9:20 PM
LOL
 
… except that JavaScript and JSON call them“objects”, not maps or tables or dictionaries or hashes or …
 
I will have to check out NLog. on Monday... — Malachi Sep 12 at 22:02
I meant a week from Monday @Mat'sMug
 
lol
 
I do have it downloaded though
 
I'm stuck at the office for a while
just had 2 double-shots of tequila
 
9:22 PM
Facebook time?
lol
how do you do that at the office?
 
it's the CEO's birthday
 
NICE
 
NICE
 
+ = funky nested joins
 
You could upvote all my Javascript answers, I am 19 votes from getting a badge....
I have about 37 minutes left.
I am working a new emailer into my code, then I have to figure out how to test it for exceptions and stuff....oh wait I just got an idea
 
9:25 PM
SELECT * from my Table WHERE myInt = "1"  -- need more teqiula
 
gosh SQL Server is faster than MySQL.
 
Surprised?
 
lol
you guys could all upvote this answer, codereview.stackexchange.com/a/31511/18427
lol
 
Referencing to w3schools on StackOverflow is like begging for downvotes. There are better sources, for example the Official Mozilla DocumentationSimon André Forsberg Nov 20 '13 at 17:25
 
I know....I put the other reference in there too, and they both say the same thing.
@SimonAndréForsberg, I know, but I also provided code and explanation to show that the information was correct, and that it worked the way I said it did. I will add a link from that page as well — Malachi Nov 20 '13 at 17:33
 
9:35 PM
@Phrancis nope. grateful :)
 
and Rep Cap!
Thank you Santas!
 
@Malachi DVLR ;-)
 
DVLR?
 
Nice!
 
9:39 PM
You should pimp your "big" answers more often. I found some that I thought were great
3
A: A simple HTML / JavaScript calculator

MalachiFormatting You really need to format your code properly, it looks horrible. this is what it should look like <!DOCTYPE html> <html> <head> <title>Simple Calculator</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> inpu...

 
@Phrancis I lost about 80 rep....lol
I haven't been Pimping a lot lately.....
maybe I will just pimp a tag every day or something...lol
 
I just had the epiphany today reading about PHP about what server side means.
I can see why someone would want to use that, as opposed to, say, Javascript
 
Javascript can be manipulated
@Phrancis PHP or ASP
 
If you're going to pimp an answer, it should be an exceptionally good answer.
 
9:55 PM
<?php
$quantity = 10;
$price = 30;
// which is more standard?
echo $quantity * $price; echo '<br>';
echo $quantity * "$price <br>";
?>
 
@200_success agreed
like .....
23
A: Can this stored procedure be cleaned up or made even more efficient?

MalachiYou have a lot of if statements in your SQL. This screams at me that you are doing something in your SQL that should be done in the application, and that this SQL should be separated into two distinct stored procedures. The benefits of doing this: Faster stored procedures Use a coding langua...

 
@200_success I'm a bit guilty of not doing that, aren't it. I'll keep that in mind
 
or this one, which might be a victim of Eric Lippert -itis
12
A: Using C# properties for simple operations, where should I draw the line?

MalachiMethods Set and Get Properties through their Get and Set methods, so it isn't a really good idea to perform operations on properties inside their get and set methods. you should use the object methods to do this. public string DisplayErrors { get { var errorString = ""; ...

and TTGH!
@Phrancis I have lots of C# ones that I think are good...
but I am outta here for the weekend...
 
Bye!!
Just noticed echo $quantity * "$price <br>"; was incorrect, after I put more stuff after it
<?php
$quantity = 10;
$price = 30;
// which is better
echo $quantity * $price; echo '<br>';
// or
echo $quantity * $price . '<br>';
?>
 
7
Q: Congrats, Chemistry SE is graduating!

AnaChemistry Stack Exchange has a steady flow of high quality questions and answers, and a growing number of users contributing to site health and maintenance. You're on a consistent upward trend, and the Community Team (of which I am a member) has taken notice. Chemistry SE will be graduating soo...

 
10:10 PM
@Phrancis welcome to the “fun” that is PHP. You weren't expecting some kind of type error, were you?
 
I think we are the red headed stepchild of SE sites :)
 
They have a growing site-activity chart: data.stackexchange.com/chemistry/query/161411/…
but, the scale is quarter of our site's: data.stackexchange.com/codereview/query/161411/…
 
10:39 PM
Boing
@amon should I have?
 
@Phrancis I would prefer echo $quantity * $price; echo '<br>'; the other variant is confusing, as you're concatenating a multiplication with a string
@amon Compilers FTW!
@Mat'sMug I once referred to w3schools in an answer on SO. I learned the effects of that the hard way
 
w3schools
That's actually I first learned SQL. Then I got a book and learned w3s was terrible.
 
11:03 PM
(Found the modulus operator...)
 
bet you it was hiding in the remainder .... ( the last place you looked? )
 
TS
 
OK, time for me to prepare to eat crow ;-) Answered a python question.
just to get another 'sorting' answer.
then I realized the question was not tagged with 'sorting', but 'quick-sort'.
mutter mutter mutter.....
 
$total = $quantity * $price;
echo $total . '<br />';
 
edit tags! Solved.
 
11:06 PM
@JeroenVannevel that's elegant enough!
 
So, is codereview.SE still beta because it doesn't have the right... chemistry?
5
 
I'm not used to thinking in variables, guess a non-RDBMS language will help.
 
@DanLyons We are still in beta because ..... we don't like to make other sites feel bad?
Actually, officially, it is your fault, @DanLyons
People like you never ask questions......
We are a bunch of people, some never ask, but most never answer.
and we need to get people crossing the divide ;-)
 
My google-fu is strong :(
 
heheh.... don't feel bad. You're doing a good job here.
Just scored through 2K rep, congrats.
You are officially part of another beta-progress too!
You now have access to moderator tools, ..... with great power, @Dan....
 
11:11 PM
2K nice @DanLyons!
 
See, good beta sites are supposed to have 10 users at 2000 rep .... and.... with you we are closer to 100!
in fact, on all those stats, we are 10X better than intended.
 
Does this seem elegant enough in style?
<?php
$quantity = 10;
$price = 30;
$total = $quantity * $price;
echo $total; echo '<br>';
echo 'End';
?>
 
no.
1-line for echo $total; echo '<br>'; ... really?
 
@Phrancis don't put two echo's on the same line
 
Oh OK
<?php
$quantity = 10;
$price = 30;
$total = $quantity * $price;
echo $total;
echo '<br>';
echo 'End';
?>
Better?
 
11:15 PM
much
Now, if you can get rid of the ... ?
 
Or should I just concat like Jeroen? Never been a fan of concatenating stuff
 
Concat like Jeroen
Jeroen knows best
4
 
lmao
I know these scripts are super-simple, apologies for bugging the room with them, but I want to get the best practices down right up front
 
You realize that you are directionally challenged, there, @Phrancis ?
Going in 4 different directions all at once?
 
I have no idea what that means
 
11:18 PM
And left and back are lonely.
> but I want to get the best practices down right up front
 
LOL
2
 
which special move does that do?
 
Facepalm?
 
It makes a monkey jump out of its seat
What does <td> stand for?
(html)
 
table data.
it's a "cell" in the table.
 
11:27 PM
Thank you sir
 
let me fix that for you..... ^^^
 
...?
 
Nevermind, it's OK like that ;-)
 
Fair enough
83 unanswered PHP questions... I better learn fast ;-)
 
I have an idea for a new tag or two, should I create them first and ask on meta later, or ask on meta first and create them later?
 
11:41 PM
If it warrants discussion, the discussion should probably be done first
 
And when does it warrant discussion or not?
 
I figured you already deemed that to be the case since you brought up meta
 
lol, good point
 
I don't like meta-tags like performance and stuff so for me personally I would only duplicate tags from SO. But I'm fairly alone in that conviction so I can't really say when something should be discussed or not
 
The only bad thing about asking on meta is that others might create the tags, which means that I won't get taxonomist :)
 
11:48 PM
@SimonAndréForsberg ask forgiveness.
You're trusted user for a reason ;-)
Just to disagree with Jeroen.
 
@rolfl Let's not start signling out PHP-Concatenation-Experts
 
user image
3
 
@JeroenVannevel you mean 'PHP-' . 'Concatenation-' . 'Experts' ?
<?php
$status = 'Out';
echo $status;
?>
 
0
Q: format a number to include commas

user53414This is my attempt to format a number and put commas where appropriate. I was wondering if this could be done in a simpler way. It's used by doing the following: format_string_number("123456789") and prints 123,456,789. Thanks in advance def format_string_number(st): inputVal = list(st) ...

 

« first day (503 days earlier)      last day (3516 days later) »