« first day (684 days earlier)      last day (3630 days later) » 

03:19
return Task.FromResult<object>(null);
This looks about as pointless as it gets
No wait, it does not. It's used to early return from an async method
but surely there must be a sexier way..
@JeroenVannevel bit more context?
Step 3
very, very good tutorial on Identity 2.1, OWIN and OAuth so far
tomorrow when I wake up I'll implement all this fancy stuff
Will this get me punched?
        p = true;
        q = true;
        System.out.print(
				p + "\t" +
				 q + "\t" +
				 (p&q) + "\t" +
				 (p|q) + "\t" +
				 (p^q) + "\t" +
				 (!p)
		);
wtf formatting
@JeroenVannevel afaict there is no reason for that method to be of type Task
p^q gets you punched ....
Actually, it all gets you punched.
03:25
@mjolka You would voluntarily return void from an async method?
except !p
making it void would 76.89% sure break it
@rolfl Exercises, eh; I almost punched myself
@JeroenVannevel no, that's not a proper async method. there's no await. it will run synchronously
Looks alot better in Eclipse though
@mjolka ah I see, good point
still though: it's override
The logical operators &, | and ^ are very, very seldom used in Java.
@JeroenVannevel good catch with the override
Almost always, the operators used are &&, and ||
03:28
The method is defined as part of Owin I believe, so you're stuck with it
how.. ugly
Not sure why the book's author is going out of his way to practice all those operators............
I do notice that he writes his type parameters in full instead of allowing type inference to handle it
so it could be Task.FromResult(null)
Which is a little better
@JeroenVannevel or create just one Task.FromResult<object>(null) and return that everywhere
@Phrancis Note that, in each case, the & and | operators can be replaced with the fail-fast version && and ||
Gotcha
03:30
@Phrancis The ^ operator can be replaced with !=
Ah yes, that too. Although I don't like using an intermediate variable for multiple return statements
Main thing I was worried about getting punched about was the formatting...
        System.out.print(
				p + "\t" +
				q + "\t" +
				(p&q) + "\t" +
				(p|q) + "\t" +
				(p^q) + "\t" +
				(!p)
		);
@JeroenVannevel i was thinking a private static readonly field
And DG this chat mangles the formatting so bad
not sure if you'll like that either though :)
03:31
@mjolka Outside of the method?!
heavy breathing
@JeroenVannevel you know you love it
@Phrancis - try:
System.out.printf("%b\t%b\t%b\t%b\t%b\t%b\n", p, q, p&q, p|q, p^q, !p);
Widening scope is sort of like being in a hostage situation: I'll only comply if there's a gun to my head
@rolfl Result is the same! But the code is harder to read
Depends on your background.... ^^^^
03:34
I do like tucking the \t right in there within the string
@JeroenVannevel "If you regularly use Task.FromResult with the same value, consider caching the actual task. For example, if you create a Task<int> with a zero result once, then you avoid creating extra instances that will have to be garbage-collected." -- stephen "Tasks await ME" cleary
Not sure what %b is either :\
@mjolka Only one instance will be created though, even though there are multiple return statements
And it's only used in the scope of this one method
@JeroenVannevel multiple calls to the method
ahh like that
hmmpf
I will consider it if I'm in a selfdestructive mood
03:38
@Phrancis %b -> Format a boolean value as either "true", or "false"
var props = new AuthenticationProperties(new Dictionary<string, string>
Weakly typed crap.. Whyyyyyyyy
@Phrancis - Also, if you ask @skiwi to do it, you will get:
boolean p = true;
boolean q = true;
System.out.println(Stream.of(p, q, p&q, p|q, p^q, !p).map(String::valueOf).collect(Collectors.joining("\t")));
Don't let that confound you, though ;p
@JeroenVannevel what's the project you're working on?
Yes, there are even images!
Although the images are rather useless since I haven't even figured out yet how it will work exactly
looks cool :)
03:44
I'll do that once the user registration process is finished
I just fixed the data scraper today. I'll let it gather all movie and show information some night soon
@mjolka No, that won't work.
@Hosch250 ah well
-1
Q: Need help in my lab test thank you

user68466Write a C++ program that asks the user to Input and store the sales records from January to December. There are five sales persons working for the company. Find and display which:- 1. sales person has charted the highest total sales. 2. month has the highest total sales.

What I may do is create a set of Menus that are basically Lists of MenuItems.
Then, I can have a List of Menus.
@rolfl Collectors :o
03:50
I can populate my value with the first item in each Menu, and load the contents of the menu, but that still has the problem of being easily breakable.
Not as easily breakable as what I have now, though, because I have every single page (probably about 100+) in a single collection.
@CaptainObvious I don't remember teachers ever allowing students to ask the Internet for help during a test...
@JeroenVannevel So this is like Pandora but for movies :)
@Jamal A few of my classes this semester are open-everything.
03:52
@Phrancis I miss Mass Effect. :-/
@Mehrad yeah, although I'm probably going to use a Tinder-like interface
@Jamal must be an open book and open flow exam :)
However, the time is fairly narrow, so there isn't much time to ask.
@Hosch250 Looks like I'm switching schools. :P
However, it is on a per-class basis.
Some say no book/no internet.
I've used the internet during my accounting midterm, but I think that is it - maybe one other exam.
I don't usually need it, fortunately.
03:54
@Jamal IKR. Playing ME3 again, stuck at Kai Leng near the end. Bastard.
@Phrancis I think I remember using lots of EMP grenades.
I'm going to get ready for bed before I get locked out til past midnight.
See you.
@Jamal Ah, yeah I don't have those :| ... I think I can get it with good old-fashnied GTFO technique though.
Just need to GTFO really fast...
He didn't seem that bad after a while. Have you played through the entire game by any chance?
Yeah, 2nd time through, whole different character
03:58
Ah. So you probably know how much the ending sucks.
Gave up after about 12 times lol
Yeah, ending is the low point, the ride is fun though
-1
Q: Which HTML code would be create the two boxes in the middle of the page in the image?

Rowena <!doctype html> <html> <link href="main.css" rel="stylesheet" type="text/css"> <head> <h1>Project 1- Sample Solution</h1> <meta charset="UTF-8"> <title>Game</title> </head> <body> <div class= "choice"> <input name="player" type="radio" id="rock" value = "0" /> ROCK <br /> <input name="pl...

@CaptainObvious Bye
It looks like I've found a bug with the design change.
04:15
Huh?
@JeroenVannevel the "community additions" on this page lol msdn.microsoft.com/en-us/library/…
Very interesting.
My USB driver went bad :(
0
Q: Text Generation in Order

StratusAs the title and tags imply, I want to do text generation in order. In my program I have the user supply the minimum number of characters, the maximum number of characters, and a character set. Ex: Min 1: Max 3: Cset "ABC" A - B - C - AA - AB - AC - BA - BB - BC - CA - CB - CC - AAA - AAB etc. ...

@CaptainObvious First time I've seen a heart ("<3") appended to a question.
04:24
This is more of a codereview.stackexchange question. — Millie Smith 1 min ago
This question might be a good candidate for Code Review instead of Stack Overflow. If you have working code and are looking for specific ways to make it better, Code Review is often a better fit. Just be sure to check out their Help Center to make sure your question is on-topic there. — Alexis King 22 secs ago
@Duga That's one long array.
Longest array I've ever seen.
@MillieSmith please can you share the link if there is similar code review is there. — Priyantha Weerasinghe 24 secs ago
04:47
I saw a "Yes Jamal" trending on Twitter and almost thought it was about me.
0
Q: Javascript Tic Tac Toe Restart Button & Keep Score

LukeI'm new to Javascript and also code review. I tried looking for my answers but I couldn't seem to find simple ones that I understood. I've used jsfiddle to work on a tic tac toe game but I'm wanting to add a restart game button without refreshing the browser. I'm also hoping to keep score somehow...

Night.
Night!
Oddly, I find myself wishing for duck typing
class LogicalOperationsTable {
    private static boolean first;
    private static boolean second;

    public LogicalOperationsTable (boolean first, boolean second) {
    	this.first = first;
    	this.second = second;

    	if (first == true) {
    		first =1;
    	} else if (first == false) {
    		first = 0;
    	} else {
    		first = null;
    	}
@Phrancis noooooooo!
the type system is your friend :)
05:01
Guess I just need more variables
@Phrancis Your code?
(please say no .... ;-) )
@rolfl shakes head... Yes
Does it compile?
No, but it does with my new fixes (moar variables)
05:05
(related: do you know what static does?)
Static... shocks?
(also related: you know primitives cannot be null....?)
private static boolean first;
private static boolean second;
^^^ static
Guess adding static to avoid compile errors is probably not the right approach
nope.
static means that every instance of your class shares the same variable.
which means, each time you create a new LogicalOperationsTable you overwrite all the previous versions of it's first and second variables.
> On your own, try modifying the program so that it uses and displays 1s and 0s rather than true or false. This may involve a bit more effort than you might at first think
Probably trying too hard, converting the values instead of the logic
05:11
How about this:
If (first) {
    System.out.print("1");
} else {
    System.out.print("0");
}
That just changes the output, though, admittedly
I have big enough hands to where basically all my forehead will fit in a facepalm
So...
<--- this
Simplified down, it would be:
System.out.println(first ? "1" : "0");
Not a big fan of the ternary(?) operations...
That will change, it's OK.
I was hoping for some different response, but I guess it will be OK.
I was instinctively thinking if output has to be 1 or 0, I need to convert the bool to int.
Guess humans can't really tell much difference between 1 and "1" after it's been put into the console
05:24
Nope. And, it's bed time for me.
(for real).
@Phrancis here's a hint, let's implement not
static int not(int a)
{
    // ??
}
Good night, count sheep bananas :)
@mjolka Go on, trying to follow but not there yet
@Phrancis ok, so we're assuming a is either 1 or 0
if a is 1, we want not to return 0, and vice versa
Sure
so how would you do that?
05:29
if not.a == 0 {return 1;} else {return 0;}
?
Pseudocode is probably all sorts of wrong
@Phrancis that's fine, i think you mean if (a == 0) { return 1; } else { return 0; } ?
Probably
ok, anything you're not sure about?
Myself, mostly :)
:) ok just ask any questions you have, let me know if i'm not being clear
05:32
By any means, please don't feel pressured that you have to teach me, either
@Phrancis no pressure at all
so let's just check that we're happy with this implementation of not
static int not(int a)
{
    if (a == 0) { return 1; } else { return 0; }
}
So we have a problem, if a is not either 0 or 1
@Phrancis true! but we're just going to assume for now that all inputs will be either 1 or 0
so -- code looks good?
05:35
Looks OK to this.beginner, for sure
great, looks good to me too :)
so now let's try to do it without using if
the code should look like
static int not(int a)
{
    return (some arithmetic expression involving a);
}
Alright let me think for a sec
Hm. Brain fart. Sounds like this should be simple, like FizzBuzz using a modulus...
OK how about this
Awkward silence... still thinking
np, take your time
i'm gonna pop out for a smoke
I might do that do, maths make my brain hurt
if (a / a == 0) {return 1;} else {return 0;} // this any better?
05:52
ok, so we're trying not to use if at all
Oh. No clue then. I did think just now above could throw arithmetic exception... but I'm all ears!
let's try to visualise it
if a == 0, we want 1. if a == 1, we want 0
so something like
OK
Still not getting it though, I really suck at math
I could think of a case statement to handle this, but I have a feeling that's not what you have in mind
yeah, we're trying not to use case either
Give me a hint maybe?
06:04
sure -- so the answer will look like return *expression* where expression consists of a, one constant, and exactly one of the following: +, -, *, /
return { a * 1 } // works?
Wait, no that's only half the operation...
well if a == 1, that will return 1, but we want it to return 0 in that case
return{Math.abs(a - 1)}
that works!
one last step -- can we remove Math.abs?
Probably, ... ... somehow
06:20
you're so close :)
Good dogs this is difficult
:)
yeah but imagine the satisfaction when you crack it
I'm picturing it
so here's what Math.abs(a - 1) looks like
That's exactly the same graph you posted earlier, aside from the right part...
Guess there is a clue to be gathered
06:28
here's one last hint: your constant, 1, was correct. your operator, -, was also correct :)
@mjolka And we're not relying on a technicality like unsigned integers?
@Phrancis nope, just some arrangement of a, -, and 1
Also consider this alternative view component. — trashgod just now
0
Q: I have a json array and I want to represent it tree structure. Here's my code and i want to do it more simplest way. This code is working fine

Priyantha WeerasingheThis code is working fine for me and i want simplest code rater than this. Function parent is defining parents of the tree and child function is for represent children. DisplayGraph() function show the tree in html element. window.onload = function() { arr(); parents(); ...

@mjolka I... can't think of any combination that doesn't have a -1 result when 0 is given, without any conversion
06:37
well... what about 1 - 0 ?
I thought of 1 - a but ... ... ...
Shit
yay!
ok i gotta get home, but i'll leave you with the next part, if you're still interested -- implement and
static int and(int a, int b)
{
    // ??
}
same rules -- all inputs are either 0 or 1. no ifs, cases, function calls, anything like that. answer will be a simple arithmetic expression, just like it was for not
@CodingChief There is a difference between not correct and not optimized. The code works for every case, but indeed rolfl his code is more optimized, and that is also the reason that his answer is accepted as correct one. — chillworld 16 secs ago
monking @all
I wanted to put @rolfl also in the comment but can notify only 1 person ^^
I hope that he understand what a lovely community we are and loose his SO attitude when commenting some more here
07:22
@chillworld Monking! And TTGTB
Wrote a pretty crappy-looking Java class, @mjolka :
class NotTest {

	public static int not(int a) {
		int b = 1 - a;
		if (b != 1 && b != 0) {
			 System.out.println("Value of 'b' cannot be reconciled to 0 or 1.");
			 return b;
		} else {
			return b;
		}
	}

	public static void main(String[] args) {
		int a = 0;
		System.out.print(not(a));
	}
}
@Phrancis sleep well
indeed crappy, even your class is package private ^^
Thanks for the reminder :D
well, I write sql like that ^^
each his speciality ;)
but isn't a switch easier?
switch (a) {
case 0 : return 1;
case 1 : return 0;
default : System.out.println("Value of 'b' cannot be reconciled to 0 or 1.");
Throw new AssertionError("Value of 'b' cannot be reconciled to 0 or 1.");
}
2 hours ago, by mjolka
the code should look like
2 hours ago, by mjolka
static int not(int a)
{
    return (some arithmetic expression involving a);
}
Anywho, I'm out :)
sleep tight
 
1 hour later…
08:47
0
Q: MVC controller/method loading PHP

Jack hardcastleMy question is, can this code be refined to be more efficient? It works fine, however I've noticed a small increment in time between requesting controllers/methods and I'm not sure where this slow behaviour is coming from. note: the intention of this code is to check the URI string (I don't use ...

09:21
0
Q: Find index of an object with a specific value stored in an array

GibboKI am using the following code in order to retrieve the index for an object stored in a JavaScript array. Scripts works fine, but I would like your opinion regarding performance. Also would like to know also if using [].map() could be more appropriate of [].some(). http://jsbin.com/nasiyiyavi/...

0
Q: Implementing insertAt for both [a] and [(i,a)] lists

wowofbobI've implemented generic insertAt function which inserts value to a list independently from is list indexed or not. Here are some examples: insertAt 1 5 [1, 2] == [1, 5, 2] insertAt 1 5 [(0,1), (1,2)] == [(0,1), (1, 5), (2, 2)] Here is code: {-# LANGUAGE TypeFamilies, FlexibleInstance...

0
Q: React Flux Structure

bencrinklewe have just started up a new app and we are using React with the Flux architecture, we have done our best to piece together what we think is the best structure for the app and would appreciate any feedback, suggestions etc. The component is essentially a settings page in a much larger system, it...

0
Q: Intel x86 Assembly Arithmetic Operations Assignment

MichaelThis is an assignment for an intro to assembly language course. The assignment was to make a program with a menu that performed the following four arithmetic operations: 1. addition 2. subtraction 3. multiplication 4. division The program works correctly. Here are the reasons I'm posting my as...

09:39
I'm voting to close this question as off-topic because it is working code and the question should ask at codereview.stackexchange.comJens 41 secs ago
@rolfl That looks horrible! lol
Still there's some truth in it
10:03
0
Q: <?php namespace declaration

Jack hardcastleWhat's more preferable, I know it makes no difference to the process but <?php namespace MVC\something; or <?php namespace MVC\something; In terms of preference and any standards - which is better?

0
Q: Learning: Creating code smaller, for loops

YoooouriI'm creating a small project to understand some more php codes and learning them i created a working code but it's to big i want to shorter the code can someone help me to understand some more for loops and if statements in it? Here what is al about; Calling information from the database $sql...

There are some issues with this code that could be improved on in terms of style, logic etc. Regardless if you get help here, I highly recommend you submit this code to codereview.stackexchange.com where you will get lots of tips to improve your coding. — Tom Dalton 24 secs ago
@TomDalton It is true that there are some such issues that can be improved. However, it is important to make it clear that Code Review requires the code to be working as intended before being posted there. — Simon André Forsberg 10 secs ago
1
Q: Maya Python. scale object based on distance between 2 vertices

Asaph KimI made this script so that i can scale objects for 3d printing from Maya. i had fun making it. I'm sure it could be cleaned up or improved. if it can be cleaned up please let me know, im always for learning better programming. ## ((Ax - Bx)**2 + (Ay - By)**2 + (Az - Bz)**2)**0.5 import maya.cm...

10:26
Just got silver badge at Stack Overflow.
10:36
@Phrancis Are we implementing logical operators?
public static int not(int a) {
    return (~a) & 1;
}

public static int and(int a, int b) {
    return (a & b) & 1;
}
public static int or(int a, int b) {
    return (a | b) & 1;
}
public static int xor(int a, int b) {
    return (a ^ b) & 1;
}
And actually, that first one isn't quite right. It'll return 0 for any odd number and 1 for any even number probably.
return (~(a%2)) & 1; // maybe?
Or:
return (~(a & 1)) & 1;
11:17
Hmm, those don't work either.
Are we implementing bitwise integer operators or boolean logical operators?
Boolean logical operators, I think.
return ~a; should be enough, shouldn't it?
No.
Then why are we using int instead of boolean ?
11:18
Exercise
I don't know what they were doing.
Why wouldn't ~a be correct? What behavior are we looking for?
~a does a bitwise negation of all bits.
Return must be 1 or 0
~1 is not 0
return a == 0 ? 0 : 1;
return a != 0 ? 0 : 1;
Negation, right?
11:20
Yeah, that.
But I think the original exercise said "no ifs", and I count ternary as an if
kids.EndBedTime ...dang, I fell asleep in the rocking chair!
2
LoooooooooooooL
return (~(a/(a|1))) & 1; // maybe?
No.
My or, and, and xor functions return right though.... I think...
No, maybe not. They all only care about least significant bit.
today, I was testing the new firmware for the camera
That was 1 hour ago.
Now, I don't have a camera anymore.
Also, the room smells funny.
It uh
started smoking
and making a weird high-pitch noise
Sounds like you're a good tester.
11:35
@Mat'sMug Good morning!
@nhgrif What are the exact specifications for the methods you are trying to implement?
@nhgrif whiskey.. tango..... ahhhhhh forget it.
Greetings, Programs.
@SimonAndréForsberg I don't know. Phrancis and Mehrad were discussing something last night.
Or maybe not Mehrad.
12:08
So just Phrancis?
Talking to himself?
That's okay, I do it all the time.
O! Hai @Phrancis! I wasn't talking about you..... ahem.... umm....
Hi.
12:21
@nhgrif A little hard to implement something if you don't know what you are doing, is it not?
Our orders module was in desperate need of a rewrite... So I began the process of rewriting that a few weeks ago. Now that's on hold because I need to rewrite the quality assurance module...
Knowing what you're doing is for people who know what they're doing.
@rolfl FYI:
19 Mar 13:30:50 ntpdate[5207]: step time server 193.11.166.8 offset -75.142651 sec
monking
and, ntpd is now running?
12:32
@rolfl added a crontab for it.
@nhgrif - out of interest, you get a notification for:
Thanks for your code NHGrif! question: Where do you place the part of code after this sentence? "As one final note, rather than putting all of this code in our view controller, I'd probably abstract this into a stop watch struct. Something like this:" — Tjalling Dijkstra 44 mins ago
?
You should put post this code in the codereview section. Otherwise, could you tell us exactly where your code needs to be fixed? — logic 53 secs ago
@SimonAndréForsberg ntp is a daemon that should run independently of ntpdate.
@nhgrif ah, right...
15 hours ago, by nhgrif
22 hours ago, by nhgrif
3 hours ago, by nhgrif
I HAVE NO IDEA WHAT I'M DOING
3
> You should put post this code in the codereview section. Otherwise, could you tell us exactly where your code needs to be fixed?
12:33
@rolfl hmm... I'll check that out...
"This belongs on code review. It's broken"
>.>
@simon -> `ps auxwww | grep ntp'
there should be a line like:
ntp       3402  0.0  0.0  39836  1528 ?        Ss   Feb26   1:31 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 119:127
@rolfl www? On my keyboard or on yours?
We only accept working code. If a code needs fixing it does not belong on CodeReview. Go straight to Jail, do not pass Go, do not collect $200 — Dan Pantry 2 mins ago
2
on your linux machine
12:36
@logic No, this does not belong on Code Review. Please read Be careful when recommending Code Review to askersSimon André Forsberg 1 min ago
@rolfl yes, I kneww that, but wwith one or three w's?
three
the w option adds more width to the output
you get more width with 3 w's than 1, or 0
although, it is a short command, and none is enough....
nope, not running
isn't crontab enough? Or is it 'better practice' to use ntpd?
12:37
OK, then :
apt-get install ntp
crontab with ntpdate will correct the time on regular occasions.
ntpd will measure the drift and jitter of your clock, relative to other accurate time sources, and will keep the time "groomed" on your system and it will never then go out of time by more than a millisecond.
with ntpd running, you can be almost as accurate, all the time, as an atomic clock.
Also, with a drift like yours, and odd timing, you could end up doing various odd things, like creating files in the future, which is a PITA.
* Starting NTP server ntpd [ OK ]
okay, thanks @rolfl
I'm voting to close this question as off-topic because it is asking for a code review. try codereview.stackexchange.com — Daniel A. White 25 secs ago
12:53
0
Q: Array to Tuple in Swift

MazyodI am burdened with the requirement of interacting with a C based library, which has a bunch of constant sized arrays (e.g. char[17]). When trying to assign or read those properties from swift, they are represented as a Tuple type of that size.. As far as I know, you can't access tuples with su...


« first day (684 days earlier)      last day (3630 days later) »