• What are you working on? v65 - July 2016
    3,881 replies, posted
[QUOTE=FlakTheMighty;51122071]Had 15 minutes of free time, got bored. [t]http://i.imgur.com/Kc7nlY8.png[/t] There's a million of them and it's nothing special. [editline]28th September 2016[/editline] Maybe if I have time and actually care to do it, I'll fix some of the glaring issues. [t]http://i.imgur.com/8ABizmW.png[/t][/QUOTE] [t]http://i.imgur.com/8rzE7Hp.png[/t] Fixed one of the issues at least.
[QUOTE=Map in a box;51122279]The risk doesn't come from them, it comes from the potential for a MITM. If they tried to pull something malicious to potential pirates they'd be in for a legal attack.[/QUOTE] It doesn't have to be a man in the middle, a simple DNS spoof (using the windows host file, of course assuming the victim is running windows) could cause the program to redirect to your own server. The sad things is that a SSL Certificate could solve all of the company's vulnerabilities in this aspect.
[QUOTE=MexicanR;51122973]It doesn't have to be a man in the middle, a simple DNS spoof (using the windows host file, of course assuming the victim is running windows) could cause the program to redirect to your own server. The sad things is that a SSL Certificate could solve all of the company's vulnerabilities in this aspect.[/QUOTE] If a malicious party has write access to your hosts file on Windows, you're pretty fucked anyway.
[QUOTE=ThePuska;51123315]If a malicious party has write access to your hosts file on Windows, you're pretty fucked anyway.[/QUOTE] -snip-
[QUOTE=ThePuska;51123315]If a malicious party has write access to your hosts file on Windows, you're pretty fucked anyway.[/QUOTE] This. You need administrator privileges or higher to write it now. That said, it's extremely easy to do active MITM on HTTP once you're anywhere on the same (dumb-switched) network, since you can then do DNS poisoning very easily. That's part of the reason I consider it a very avoidable and pretty large security risk.
Currently working on screen-space light shafts / light scattering [t]http://i.imgur.com/yP2RAHz.png[/t]
Professor has us writing a function which reverses the bits of a short int and returns the new short int. Guy in my class turned this in: [code] unsigned short reverseBits(const unsigned short &x) { unsigned short result = 0u; for (unsigned char i = 0u; i < 16u; i++) if(((unsigned short)(x << (15u - i)) >> 15u) > 0u) result = result | 1 << (15u - i); return result; } [/code] Does this seem needlessly verbose? This is so "look at me I know C" that I'm surprised he didn't put ++i in the for loop [editline]28th September 2016[/editline] There were no requirements about signed vs unsigned, and I'm p sure const short isn't needed
The unsigned/const modifiers seem to be unnecessary but I don't really get the point of criticizing your classmate for posting a pretty clever working solution to your assignment..
Why did he use a const reference for x? There's literally no reason for primitives. Apart form that it seems fine.
[QUOTE=proboardslol;51125207] There were no requirements about [b]signed vs unsigned[/b], and I'm p sure const short isn't needed[/QUOTE] As far as I know, a left shift of a negative integer is undefined behavior. [editline]29th September 2016[/editline] If you wanted to properly access the bit pattern of a negative signed integer, I think you would have to use a union.
I don't think you can reclaim those lost bits if you shift with signed types? I don't really remember though.
[QUOTE=WTF Nuke;51125366]Why did he use a const reference for x? There's literally no reason for primitives. Apart form that it seems fine.[/QUOTE] There is actually plenty of reasoning for const primitives. You allow yourself to show the reader that you have no intention of mutating the state of them, even if it is just the local state of a value type. I believe Effective C++ has this as part of the const correctness rules as well as Deitel & Deitel books.
[QUOTE=Proclivitas;51126121]There is actually plenty of reasoning for const primitives. You allow yourself to show the reader that you have no intention of mutating the state of them, even if it is just the local state of a value type. I believe Effective C++ has this as part of the const correctness rules as well as Deitel & Deitel books.[/QUOTE] Passing primitives [i]by reference[/i] without wanting to modify its contents is bad. As far as I know (with x86), passing by reference in will insert a pointer onto the stack (or into a register) to the data. So you're writing a 4-byte memory address, then de-referencing it to read less than 4-bytes of data. If you pass by value, you're still going to probably push 4 bytes (due to memory alignment), but you're not de-referencing it when it comes to reading. It's nitpicky but if you have a function that will be called frequently, this is an optimisation any native developer should consider. [editline]29th September 2016[/editline] [QUOTE=proboardslol;51125207] This is so "look at me I know C" that I'm surprised he didn't put ++i in the for loop [/QUOTE] As much as "++i" looks like dick waving, if someone changes the implementation of the data type in the loop, you're creating an unused copy of the data (see postfix). I think learning early to use "++i" will help when the subject of C++ iterators is approached. There's no harm in doing it, but it doesn't score points in most for-loop cases.
Using "unsigned short" instead of "uint16_t" : hr literally has "16u" in there and doesnt check the size once, so shouldnt he use the latter?
Come break my site I suppose -snip- that's enough.
[QUOTE=reevezy67;51126317]Come break my site I suppose [url]http://202.67.113.228:3000[/url][/QUOTE] How did anybody think an anonymous chat would be good for WAYWO :ohno:
Was pretty fun while it lasted.
I guess that did come off as dickish, but I really wanted to know: is it unnecessarily verbose to use [code]unsigned short int x = 0u;[/code] It honestly just looks like showing off to me
how would it be showing off thats just one way of many to declare a short
It's a string of text, you shouldn't care if it has an opinion or not.
worth noting that lookup tables are much better for reversing bits
[QUOTE=proboardslol;51126687]I guess that did come off as dickish, but I really wanted to know: is it unnecessarily verbose to use [code]unsigned short int x = 0u;[/code] It honestly just looks like showing off to me[/QUOTE] I mean, "int", and I suppose maybe the "u" is redundant, but apart from that it's a completely legitimate statement.
[QUOTE=proboardslol;51126687]I guess that did come off as dickish, but I really wanted to know: is it unnecessarily verbose to use [code]unsigned short int x = 0u;[/code] It honestly just looks like showing off to me[/QUOTE] maybe you should state what you think is showing off. I wouldn't call it 'showing off', if anything it's a waste of time. Can someone explain what would be wrong with just 'unsigned short x = 0;' though?
[QUOTE=Dr Magnusson;51126739]I mean, "int", and I suppose maybe the "u" is redundant, but apart from that it's a completely legitimate statement.[/QUOTE] And I can't tell why he'd use &x. That seems pointless to me as well. [editline]29th September 2016[/editline] [QUOTE=war_man333;51126760]maybe you should state what you think is showing off. I wouldn't call it 'showing off', if anything it's a waste of time. Can someone explain what would be wrong with just 'unsigned short x = 0;' though?[/QUOTE] I think there's a tendency in college courses for students to try to make more verbose code or use syntax which shows more knowledge of the language to try to impress the professor. Such as: If the assignment was to take a short (which, I think need be said, has already been truncated and converted to a positive number from an original float which was then modulo'd by 16, so it's a given, in this assignment, that the number be positive, and no greater than 16) and reverse the bits, his method is clearly correct (I, independently, did something similar), but adding all these restrictions weren't required by the assignment and as far as I can tell don't really do much given the context of the assignment
[QUOTE=proboardslol;51126764]And I can't tell why he'd use &x. That seems pointless to me as well. [editline]29th September 2016[/editline] I think there's a tendency in college courses for students to try to make more verbose code or use syntax which shows more knowledge of the language to try to impress the professor. Such as: If the assignment was to take a short (which, I think need be said, has already been truncated and converted to a positive number from an original float which was then modulo'd by 16, so it's a given, in this assignment, that the number be positive, and no greater than 16) and reverse the bits, his method is clearly correct (I, independently, did something similar), but adding all these restrictions weren't required by the assignment and as far as I can tell don't really do much given the context of the assignment[/QUOTE] I don't understand why you care so much about it. It's just a 6-liner and a small assignment, nothing more?
Does it matter if he's trying to impress the professor? It's not like you're competing for a job or anything. [editline]29th September 2016[/editline] i think the more pertinent question is how did he modulo a float (don't u dare say fmod i will shank u)
[QUOTE=Map in a box;51126805]Does it matter if he's trying to impress the professor? It's not like you're competing for a job or anything. [editline]29th September 2016[/editline] i think the more pertinent question is how did he modulo a float (don't u dare say fmod i will shank u)[/QUOTE] The assignment earlier was: 1. get some input floats from the keyboard (I changed scanf to fscanf so I can just pipe them in through a bash script i made) 2. Truncate these numbers and then get their absolute value. Then, modulo them by 16 (we had to come up with bitwise ways to do these, other than truncation (we casted to int)) 3. print the float array and int array 4. quicksort the arrays 5. write a function which finds the most common integers in the integer array 6. write a function which finds the number of even numbers in the float and integer arrays 7. cast the integers to shorts and pass them through a function which reverses their bits. Then, print the numbers as binary (we had to write a function which composes a string representing the number in binary) So, I guess I'm kinda coming off as an asshole, but part of me cynically is thinking that this guy is just trying to show off but I think more of me genuinely is thinking "wait why [I]did[/I] he do that?" So I'm asking, really: is there a reason to do any of this stuff? It seems to me like no
You just sound weirdly irritated that your classmate is demonstrating a solid understanding of C, it's probably smart to just drop it dude.
[QUOTE=srobins;51126892]You just sound weirdly irritated that your classmate is demonstrating a solid understanding of C, it's probably smart to just drop it dude.[/QUOTE] I'm not [I]irritated [/I]by it... I think that you guys are more irritated that I even brought it up. Honestly, I forgot I even posted it this morning.
[QUOTE=proboardslol;51126914]I'm not [I]irritated [/I]by it... I think that you guys are more irritated that I even brought it up. Honestly, I forgot I even posted it this morning.[/QUOTE] Haha guys it's just a prank I'm not even irritated that my attempt to mock someone fell flat, it's YOU who's irritated haha pranked ya Why care so much about other students, unless you're like the TA and grading things?
Sorry, you need to Log In to post a reply to this thread.