« first day (1381 days earlier)      last day (2931 days later) » 

00:00
RELOAD! There are 3448 unanswered questions (91.7261% answered)
00:38
0
Q: Dynamic programming solution for cross river algorithm (part 2)

Lin MaWorking on below cross river problem (start a new thread for new code, since fixed bug and applied comments from previous post Dynamic programming solution for cross river algorithm), and post my code in Python 2.7 using dynamic programming. Any advice on performance improvement in terms of algor...

 
1 hour later…
01:42
Gah. I need to go get a traffic citation.
02:04
@EBrown You need to get one?
@Trojan404 Yeah, I use them as bookmarks and I ran out...lol
lol
novel concept here - maybe use a bookmark?
Gross
02:46
lol
0
Q: Is randomly generating passwords from an assortment of dictionary words cryptographically secure?

EBrownWe should all know the XKCD comic on password strength, suggesting (appropriately) that a password based on multiple common words is more secure and memorable than a password such as Aw3s0m3s4u(3 or something. I have an application (multi-platform) that I want to generate somewhat secure passwor...

That was a mouthful just to ask 'is this totally going to eff me over?'
@EBrown Do you really think it's worth it to rehash the users password on every login?
I can see the benefit, but that seems excessive
@Trojan404 It's cheap enough, and if I re-salt and re-hash it, then an attacker can never know when a user's password changes.
So for my application, I'm using the same salt, but I could theoretically rehash and update the db on each login
It's easy, I used to do it in all my PHP applications.
02:57
Yea it's not hard
Just because for the ~30 minutes of work it's a huge benefit to prevent attackers from knowing how long a user had a password for.
Because let's assume the attacker can see the passwords at any given point in time.
So they can keep a log 'this user changes passwords every 3 months it seems'.
Now if they see a password change they have 3 months to crack it, or so they can assume.
But if I re-salt each time they login it severely limits the timeframe they can attack, assuming there's no 'keep me logged in forever' box.
But if the user never relogs...well...
Yea I'm just gonna rehash my passwords, for the sake of the current implementation
resalt can be a future addition
Rehashing won't do any good if you don't change salts.
You'll get the same hash.
Not in laravel
Wut
That's so bad
Lol
03:02
well php but
same password will be a different string every time
then you just use this to verify the password
php is nice bc every password generates its own salt, but i was wanting to expand on that for my future addition
I think this belongs on the Code Review site. — shmosel 29 secs ago
@Duga wut. I suggestion to migrate that actually makes sense...
@EBrown 30 minutes? Took me like 3...
@Trojan404 I don't use built-ins for that. :P
All it is is generating a new hashed password and updating the db. :P
@EBrown Why not use the php built? What advantage are you getting from custom over the password_hash and password_verify?
@Trojan404 I can re-salt. ;)
03:10
i mean technically you can with password_hash too
just very complex
03:41
0
Q: Multiply vector by selected columns of dataframe - elements not lining up?

human12I'm new to R and to StackExchange so sorry in advance for mistakes. I'm trying to adjust some expenditure values for inflation. They are 8 columns of a dataframe (all of which include some NAs). They look like this: nominalAUGEX Source file | Company name | 2009 | 2010 | 2011 | a ...

04:15
possible answer invalidation by anandm on question by anandm: codereview.stackexchange.com/posts/154877/revisions
04:35
if your code works, maybe it should be on codereview.stackexchange.com instead? — A. Lau 55 secs ago
Might want to move this to code review website. — Dani Springer 11 secs ago
I wasn't aware that there was a code review site. I will move it there. — TychoTheTaco 34 secs ago
The question is why is this a problem in the first place? Also, consider <codereview.stackexchange.com> — Andrew Li 10 secs ago
04:56
If this code works, try codereview.stackechange.com. if it doesn't work, provide as detailed as possible a description of what it does incorrectly. — rici 21 secs ago
0
Q: How can I make this Java code more efficient that runs every frame?

TychoTheTacoI am making a game for android using Java and libGdx. I have an ArrayList of enemies that are updated each frame. The update method for the enemy looks like this: public void update(float delta){ if (waypointIndex < waypointCount){ waypoint = path.getPoints().get(waypointIndex); ...

05:13
0
Q: Python PID simulator controller output

3kstcI'm trying to write a piece of code (in Py3) that graphs out the controller value of PID controller. This is so that by changing the various sub controllers (P/I/D) I can visualise how the graph changes. I've written the following code, but having difficulty in the PID algorithm, and obtaining a ...

05:33
Monkevening
0
Q: Android: Design Pattern - Code to interface

Android jack - Rajesh GosemathI am learning design patterns from Head First Design Patterns and the first pattern i came across is to "Code to interface".Now i want to use that pattern in my android app.My app includes lots of api calls.I am using Retrofit for for network calls.So i have used that design pattern considering s...

@CaptainObvious Interesting question but needs a better title, left a comment
06:20
0
Q: code optimization check each variable if it is empty

olovar h1 = '', h2, h3, h4, h5, _title1, _title2 ... if(h1){ //mycode here } if(h2){ //mycode here } if(_title1){ //mycode here } I think too many if is hard to maintain and also I would have more variables to be added. How to optimize the code and make it shorter? Thanks

06:35
I'm voting to close this question as off-topic because questions about coding style and application design are more appropriate for codereview.stackexchange.com. — Barmar 41 secs ago
07:12
It's Monday: (ಥ﹏ಥ)
6
0
Q: Code error php 7 with filter array in bitrix

Vasilyuk  Dmitry<? if($_SERVER['REMOTE_ADDR'] == '93.89.191.30' && $GLOBALS['USER']->IsAuthorized()) { //echo '_'; global $arrFilter; $arrFilter = Array(['PROPERTY_DRAFT'] => 'Y'); } ?> I'm have bad error FATAL - [ErrorException] E_COMPILE_ERROR Illegal offset type (0) when i'm moved to php7. W...

@Dex'ter Holy cow, nearly 100K commits on cpython
07:28
@EBrown Am now.
Monking all.
404 docs not found
3
@Phrancis Yea'. More to come
Monking.
Monking !
Today I wrote my first Magik script at the company, without any help. And it looks awfully beautiful:
_package user

_pragma(classify_level=basic, topic={script})
def_slotted_exemplar(:ne_for_sites,
{
}, {})
$

_pragma(classify_level=basic, topic={script})
_method ne_for_sites.new()
	# Author         : -

	_return _clone.init()
_endmethod
$

_pragma(classify_level=basic, topic={script})
_method ne_for_sites.init()
	# Author         : -

	_return _self
_endmethod
$

_pragma(classify_level=basic, topic={script})
_method ne_for_sites.get_ne_for_location()
	# Author         : -

	_local locations << cit_manager.collection(:cit_circuit_location)
> If you don't read instructions
> ------------------------------
>
> Congratulations on getting this far. :-)
07:43
@Dex'ter We don't have a tag for that yet, do we? I see an opportunity for you here.
@Mast nope, we don't. Been talking about this subject a while back with .. I don't quite remember who
I don't know what to do either
@Dex'ter Assuming you have tag creation privileges (hit me if you don't): Write some code, post it as a question, don't forget to properly introduce the language with some relevant links, add the language tag as a new tag in your question.
Easy as that.
Of-course, write a proper description of the language in the tag wiki and tag excerpt directly afterwards.
@Dex'ter OMG Magik looks horrible o.o
@Dex'ter I think I was present when you did
@Phrancis It looks, indeed. But it's a really powerful language. You can do anything with it (it just lacks multithreading - which will kinda be available in the next release 5.0 when they'll use JVM)
@Mast I'll have that in mind, I'll start building a question when I'll have time !
There are lots of languages with which you can do basically anything, it's not really a big selling point for me
C++, C#, Java, Python, JavaScript, etc.
What I'm wondering is what is different about it vs all those
07:53
@Phrancis I'll make sure to describe that when I'll add the tag
Excellent!
Python has multiple methods of multithreading. Actual multithreading, processes, etc.
@Dex'ter Very good :-)
One of these days one of us is going to compare some of the languages used on CR into a crazy big table.
But sincerely, it's quite a private language and I'm not sure whether it will bring us questions or not. But who knows...
I think some JS libraries allow multithreading, though I don't know if "vanilla" can do that out of the box. I think Node.js can (though there's rarely a good use case for using that vs. async)
Btw, not sure if you guys saw this
To give you a brief overview, Magik is quite popular when it comes to GIS(Geographical Information System) applications.
07:58
Jeff Atwood posted on Twitter yesterday
I mean, I've seen crazier things happen here.
@Dex'ter I thought Python was the ruler of that kingdom.
@Mast It is, when it comes to open-source languages. Magik it's popular among companies that use GIS technologies ^^
0
Q: Generating a report

Sirwan AfifiI'm using this class to export a letter as an image: public class LetterReport { private const string DOC_TYPE = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"; private const string SPACE ...

08:13
@CaptainObvious I'm surprised that this title was not already used
OK well TTGTB later @ all
@Phrancis Web workers.
If you count HTML5 additions as "vanilla" JS.
In a browser they have a valid use case, since you can move time-consuming tasks away from the main event loop. For example if you do video filtering, which might make the user's browser a little bit unresponsive.
08:35
possible answer invalidation by TheCrazyProfessor on question by TheCrazyProfessor: codereview.stackexchange.com/posts/151595/revisions
oh dear
        char character = randomNumber <= 15 ? 'B'
        : randomNumber <= 30
            ? 'I'
            : randomNumber <= 45
                ? 'N'
                : randomNumber <= 60 ? 'G' : 'O';
That sounds like the BINGO kata on Codewars.
yep, I was just looking at the solutions, some of them are pretty crazy
If you know C#, maybe you can help that guy.
Unfortunatelly I cannot open this link, my company blockes gitter :-|
08:44
But it doesn't block Codewars? :D.
nope, and it doesn't block facebook lol
they bought some blocking proxy and some #§?§"§%! cannot even configure it correctly
@Zeta it's a pity that Codewars doesn't support C# 7, this looks so nice ;-)
@t3chb0t I've just noticed that '§' shows that you're using QWERTZ. The symbol is too awkward to type in other layouts.
@t3chb0t Oh, nevermind. The questioneer of that question is the guy that needs help in the gitter channel. So you've already helped him.
@Zeta are you a spy? :-P I'm using a keyboard with german layout
@Zeta lol you must be a spy
@Phrancis It probably was, we keep editing them into something better.
@t3chb0t Well, you see '§' not often, that's all. Especially if someone censors an expletive.
@t3chb0t Nah. I only remember random s$%t. Except for the important stuff. I somehow manage to forget that alw… what were we talking about?
09:29
lol
@t3chb0t So your company isn't against employees wasting their time on social platforms, but does have something against employees sharing code.
Of-course, you can't prevent the latter anyway...
Just to be pedantic, that's not really an appropriate use for a unit test. You are talking about code inspection, the easiest way to do this is with code reviews. Another way to do it is to write a VS/Roslyn addin that parses the AST - like Resharper does. — slugster 50 secs ago
@Mast I don't know what my company is against of, they buy the filtering-proxy and don't care to cofigure it in any way, the filters come precofigured.
gitter is even qualified as a chat by that filter and not a sharing platform, seems to be something really dumb
Standard filters will be standard filters.
09:54
0
Q: How to optimize the check date method by a more performed way

SomarI have this method that checks if a date is correct or not, and it returns True or False. In the method, first I check the format, then the date by using the function checkdate then I check the time HHiiss. /** * Function that checks the format, date, and time of a given timestamp. * @auth...

Kaz
Kaz
Monking @all
10:21
@Kaz Monking !
10:45
@Dzmitry Lazerka in most code review tools u do not have this level of highlighting. So it does make sens in a big open source project. — JWqvist 11 secs ago
11:10
I would suggest you look into doing code reviews with a co-worker. Personally I think your solution is a lot less clear than the accepted answer. — Thorbjørn Ravn Andersen 57 secs ago
that's what I tried in future... see my post here: codereview.stackexchange.com/questions/154928/… - now I'm confused :D — Matthias Burger 33 secs ago
I tried using malloc and free - the person who answered on codereview told me not to use this. So I tried. now you are telling me to use malloc. — Matthias Burger 55 secs ago
11:34
0
Q: Is there a standard replacement for system("PAUSE")?

Toby SpeightQuite often, I see C or C++ code containing system("PAUSE"); or similar constructs. None of my machines have a command of that name, but I understand it's some sort of workaround for a misconfigured terminal. Is there a standard answer we can link to when we see that antipattern, that explai...

0
Q: simple forward_list

Rıfat Tolga Kiran// NODE implementation template <typename T> class forward_list_node{ public: using value_type = T; using pointer_type = T*; using reference_type = T&; forward_list_node(value_type value = 0) : data(value), next(nullptr) { } forward_list_node<value_type> * get_next() c...

0
Q: Increase Performance of INNER JOIN with sub-query: SQL SERVER

Coding manIs there any way for optimizing the below query without further addition of any INDEX, if possible? CREATE VIEW [dbo].[VFUN_Late_Evnt_By_Acct_Doc_Id] AS SELECT L.Doc_Id ,L.Evnt_Id as Latest_Event_Id ,E.Evnt_Name as Latest_Event_Name ,L.Crtd_Dt ,L.Evnt_Xml_Doc as Latest_Even...

12:23
@StackExchange Off-topic
12:40
Monking
Monking.
Monking
Monking
Monking
0
Q: can anyone teach me how to do?

sozaican anyone help me ?? write a c++ program based on this HAPPY Holiday Tour Agency will give a special rate for a holiday in Langkawi Island, Pangkor Island, and Tioman Island during the school holiday. Full cost for 3 days for an adult are as follows: Destination Flight(2 ways ) Hotel(3 days) Lan...

12:46
I still think that there is a strong possibility that you simply execute 6 even if you don't execute 5. And your check 2 HAS to (also) happen inside the transaction. But if you don't add your actual code (which might be too much for stack overflow, but you might try codereview) and also don't add all details like for update or additional checks, we cannot tell you where the wrong behaviour comes from. But we can assure you: the error is somewhere in your code, your data or your setup. If you do it correctly, there is no possibility that a transaction is just partly executed. — Solarflare 48 secs ago
I still think that the most likely suspect is that you simply execute 6 even if you don't execute 5 when the checks fail. And your check 2 HAS to (also) happen inside the transaction. But if you don't add your actual code (which might be too much for stackoverflow, but you might try codereview) and also don't add all details like for update or additional checks, we cannot tell you where the wrong behaviour comes from. But we can assure you: the error is somewhere in your code, your data or your setup. There is no possibility that a (working) transaction is just partly executed. — Solarflare 47 secs ago
@CaptainObvious Off-topic no code
Also do we have a standard comment for those questions? I don't have it in my auto comments
13:16
@Peilonrayz Not yet. How about "Welcome to CodeReview.SE Unfortunately, we don't provide code, we review code you've written. Please see our help center for more information."?
possible answer invalidation by Edwardo on question by Edwardo: codereview.stackexchange.com/posts/155190/revisions
@Zeta Looks good, I don't like the bold, but might be worth posting it here, :)
@Duga Answer was already invalid.
If you have working code and you want it to be reviewed use CodeReview.SE. If this is non working code please explain how it does not work. — NathanOliver 13 secs ago
If you have working code to improve better ask this question at SE Code Review. If you follow this advice delete your question here please, cross posting is frowned upon. — πάντα ῥεῖ 34 secs ago
13:32
0
Q: Handling false or array parameter?

LukeI have a function that accepts false as a default value but can be passed an array. protected function sendMessages ($recipients = false) { //cast to an array $recipients = is_array($recipients) ? $recipients : [$recipients]; // if no recipients are passed get email from current ob...

0
Q: Should I enforce the 'one instruction per line' rule?

celloverI am reviewing the following code: $creationDate = $order->getOrderCreationDate(); $dir = Mage::helper('moduleX/order')->getPathOfTheDay($creationDate); The $creationDate variable is only used once in the aforementioned code. I was suggesting to my coworker that it could be simplified to: $d...

@Peilonrayz Was already on it, but got interrupted. Done.
Monking!
13:48
Greetings, Programs.
Hey @Donald.McLean :)
will someone double check my Rather lengthy Comment on my C# SecureString Answer --> codereview.stackexchange.com/a/154285/18427
14:04
This looks to be a general discussion question about writing tests. Please try to ask a more specific question, or post on codereview.stackexchange.comBrad 28 secs ago
@EBrown Why aren't you using Forms for that? is this going to be a Windows game?
14:38
0
Q: Game where you shoot characters, counts and displays your kills/friendly kills/status, and sets everything in a 30 second time limit

J.Fitzthis code is a game as described in the title. import pygame import time import random import timeit pygame.init() display_width = 1600 display_height = 850 speed = [1, -1] black = (0,0,0) white = (255,255,255) red = (255, 0, 0) grey = (177,177,177) blue = (0,0,255) green = (0,255,0) ga...

0
Q: Klingon Name Converter

Aaron NelsonI'm pretty new to Python and kinda learning on my own. So I decided I'd try a name generator and to make it fun turn it into a Klingon name generator. Enter your name and get your Klingon name. here's the code: #!/usr/bin/python3 ''' convert your name in to Klingon! enter your first and last ...

ooo heh
looks at that
@CaptainObvious VTC Offtopic Broken Code
in other news, GOOD CHAOS TO YOU ALL!!!
14:59
If you turn klingon into a proper function, you can return the result and all will be well. — Mast 9 secs ago
Code Review, where we turn Klingons into functions.
@Mast Well, Klingons are tools already, so…
lmao
0
Q: JavaScript code improvent

paula.kaCan you take a look on my code? Specially the JS part. I am searching for some improvement but don't know where to start. http://codepen.io/paulaka/pen/pRqmgx

@CaptainObvious CBL
15:22
15:32
Code Review is however :) If your code works, it can be reviewed there — StoryTeller 22 secs ago
That's not a production code, I ask about principles, not the code review. — Alex Tiger 51 secs ago
@CaptainObvious The targets of that shooter almost warrant a meta question. Almost.
15:50
possible answer invalidation by Luke on question by Luke: codereview.stackexchange.com/posts/155229/revisions
0
Q: Makefile for VST Plugins

Alex ZywickiI have adapted a Makefile that I found here and it works just fine for my purposes, but I have doubts that the way that the Makefile is written follows best practices. # path to VST SDK folder: VST_SDK = ../VST3.SDK # output file name FILENAME = anacreon.vst BASELIB = libbase.a INSTALLDIR = /...

16:10
@Duga Handled by 200.
@Malachi Yeah, and non-windows.
@Mast You know any good, cheap sensor manufacturers? I need some GPIO-compatible sensors for an R-PI.
@EBrown that is why you don't want to use forms then
@EBrown What do you want to sense?
@Malachi I made my own, ignoring the default Windows Forms entirely.
There's accelerometers out there which go cheap.
16:12
@Mast Temp, barometric pressure, humidity, etc.
Basic weather stuff.
I got some info on that. Will pass it to you when I'm back home, which should be in 2 hours or so.
Sweet, thanks! :)
This question appears to be off-topic because it is a code review request. This might be better suited to the Code Review Stack Exchange site. Before posting there be sure to read their FAQ to ensure that your question meets their guidelines. — John Conde 28 secs ago
16:29
You have to be careful doing this. Sometimes, when you push the whisker down, dynamite explodes.
3
0
Q: Mutex implementation without built-ins

Alex  TigerI want to implement simplest mutex without built-in functions or the <pthread.h> module. #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <string.h> // strcpy #include <unistd.h> // usleep #define MICROS (1) #define THREADS (300) #define ACCESSES (1000000) char * names[] = ...

1
Q: Calculator that does basic functions, but also calculates area/volume in Python 3.6

Levi PorterThis is my first big project that I've made in Python. I've noticed as I was writing it that it's extremely repetitive and I just don't know how to make it less so. If anyone has any pointers, please don't hesitate to throw help my way. Here's my code: # This is a basic calculator that also h...

@ashwanisingh stackoverflow.com is not here to validate code for you. The site you're looking for is: codereview.stackexchange.com Though, I can already tell you that they're going to recommend that you go with a dynamic-programming solution, but you could still ask there and see what happens. — Jonathan Mee 8 secs ago
16:58
@RMunroe XKCD has been having HTTPS issues for my mac lately...
Monking
The code works, so I probably formatted it wrong in stackoverflow. Also I didn't know about codereview, thanks — Jammy Dodger 17 secs ago
17:17
1
Q: Bootstrap file input styler

Ismael MiguelThis simple Javascript code styles all file inputs to match with Bootstrap's style. Simply, it turns this: Into this input: Here's the code: (function(window){ window.jQuery(function($){ $('input[type="file"]').each(function(){ var $this = $(this); var ...

0
Q: Python 3 Program to download Homestuck

Jammy DodgerI've been working for a program over the last few days which should download a range of pages from the webcomic Homestuck. I've created a working version in python 3, but it is horribly inefficient. Can anyone see ways to improve and shorten this code? import urllib.request range1 = int(input("E...

0
Q: Going c php 5.3 on php 7.1.1

Коля ВысоцкийI decided to move the project to php 7.1.1. Mysql function, it does not support translated into mysqli. The result stopped working entrance. Help me please! This is the html login code: ` Ошибка! Внимание! Выполнено! ...

0
Q: Partition numbers as polynomial, each number in a thread

HMDI'm beginner at multithreading programming and i wanna write piece of my code using it. I'm trying to split different numbers into multiple parts and store them as a polynomial. I wanna do this using multithreading as each number being splitted in one thread, all simultaneously. For example 5 sep...

17:52
0
Q: unordered_map(string,vector<string>) modification

AncientGamer2kI'm having a hard time coming up with a way to do this. I have an unordered map of pairs (key, vector). I'd like to be able to modify a particular sub-element of the vector based on whether a particular key is present on the unordered_map or not. So I'd like to do something like: unordered_map_it...

@CaptainObvious Yay, my first use of the new template.
18:42
Remonking
Remonking
Remonking
@Zeta You know we have a list filled with canned comments?
It's good to see you taking an active role in keeping this site clean :-)
shuts up and upvotes
Noo, don't shut up @Mast! I've been wanting to ask, I wanted to make a PCB for a Cherry MX keyboard, and was wondering if you know any 'for dummy's guides to PCB' that are good?
18:56
Making your own PCB :o
@Peilonrayz IIRC the ErgoDox keyboard had an open source PCB.
0
Q: I need split a list of numbers into multiple lists

Juan Carlos OropezaI need split the list I get from the select into multiple list so I can use Parallel.For() to generate the next query in different threads. I create the main list Create the sub list Keep filling sub list until reach max capacity. Add sublist to main list Create new sub list When finish the ...

It's using some other kind of switches (not the Cherry ones), but maybe that gives you enough inspiration?
Thanks I'll look into it, but when it comes to new things I'm normally terrible, ):
19:05
posted on February 13, 2017 by CommitStrip

Hmpf, C++ is pretty difficult
I thought I was going to be smart by letting my constructor accept an std::fstream&, a reference to a filestream that can be used for input and output
But now I realize that I want it to be opened in binary mode, but currently people can pass in whatever they want
"binary mode"? You mean std::ios::binary? How do you want to use it?
@Zeta Yes, that's what I mean
I want to use it as a binary file
0
Q: How secure is this script ... php download counter script with htaccess

Kaleidoskopbecause StackOverflow has a lot of good coders, I'd like to show you my script and would like to hear your security hints. Maybe the code is also useful to someone else. What I want to archive: Someone clicks on a link on my webpage a htaccess file looks for some file-extensions and if the req...

I'm just a bit confused as in Java you'd pass around File objects (or Path objects in Java 8), they're not opened yet but it's an indication that you're working with files
Using std::string file gives less safety
19:10
@skiwi So you want outfile << 1 write 0x01 (in binary), not 0x31 (aka ASCII '1', in binary)? (assuming 8bit integer for simplicity).
@skiwi An ifstream doesn't need to be opened either.
Wait, binary mode just means that the data inside has no specific textual meaning, doesn't it?
@Zeta I don't think I even want an open fstream to be passed to my function
I'm voting to close this question as off-topic because this belongs on Code ReviewSani Singh Huttunen 37 secs ago
	class DBMS {
	public:
		DBMS(std::string file)
		{
			std::fstream fs(file, std::ios::binary);
		}
And I'm probably stupid, but that doesn't compile ^
@skiwi It basically means that text isn't a bunch of lines anymore. If you use out << some_regular_data_value;, it should look the same, regardless whether you've used binary or not.
@skiwi There's usually a compiler error telling you what's wrong :D.
Oh. Which C++ version?
@Zeta I'm hoping C++11
19:19
std::fstream takes a const char * as first argument, not a std::string (before C++11)
std::fstream fs <- incomplete type not allowed
@skiwi Did you include fstream?
Yep
Actually
No
:D
I just remember reading about this issue with forward declarations and includes yesterday
I'm voting to close this question as off-topic because questions about programming style and design belong on codereview.stackexchange.com. — Barmar 55 secs ago
It seems to work with std::string too?
19:23
@skiwi In C++11, yes. In C++03, no.
someone just downvoted one of my SO answers....the question did get closed, but I thought it was a reasonable answer to the question. --> stackoverflow.com/a/41249679/1214743
@skiwi Wait, so it was missing?
@Zeta Yes, I lied :(
You can use forward declarations of a type if and only if you use pointers or references of that type. As soon as you use values, the size must be known, and therefore the declaration of the type must be available.
Do I use uint32_t or hope int works?
@Zeta Ah okay, thanks, I guess that makes sense
19:28
@skiwi Depends. But the first is unsigned, the latter isn't. Also, if you want to write binary data (not formatted data), the exact size/type is important.
I'd use using db_uint = uint32_t; and call it a day. (If that's the only unsigned type you're going to use`.
Okay I am deleting this question. Shall ask on codereview.stackexchange.com — Gourav Kumar Shaw 56 secs ago
Hopefully my code will be reasonable as it's mostly SO snippets but I understand them :P
DBMS(std::string file)
{
    std::fstream fs(file, std::ios::binary);
    if (fs.is_open()) {
        uint32_t database_count;
        fs.read(reinterpret_cast<char*>(&database_count), sizeof(database_count));
    }
}
I doubt this works if using signed integers though?
Argh. I just had a wrapper for that stuff, but I accidentally deleted it. Just. Now.
Even though I see another answer on SO that just uses fs.read(&database_count, sizeof(database_count));
@skiwi Syntax error, unmatched parentheses.
19:32
Though that latter one doesn't compiel for me actually
Brain hurts. Must add missing parentheses: ).
Fixed ^ Still doesn't compile though
3
A: read 32bit integer from binary file

VolAndOpen file in binary mode and then use read() method, something like: uint32_t a; ifstream file ("file", ios::in | ios::binary); if (file.is_open()) { file.read (&a, sizeof(a)); }

It got 3 upvotes though
@skiwi And the error is? Couldn't match char* with uint32_t*?
@Zeta Exactly
Yeah. That was to expect. std::istream::read takes a char*. That's what the reinterpret_cast is for.
19:36
Then the question remains why the answered got upvotes
> , something like:
It's not completely wrong. It's just missing the cast.
Either way, you don't want to use read all the time by hand. It's error prone. There's probably something in boost, but give me a second…
Hm okay, thanks anyway, will be working a bit more on it but short on time during the week
Found this though, which made me cringe a little...
5
Q: I got a programming job but I'm not sure if I can do it, although I want to

sameerI am a Masters student in Computer Science and I have read a lot on different programming languages but never used any of them anywhere. If I have, that was just some few lines at a basic level. Now I have a student job at a very highly reputable scientific institute. They needed someone for dev...

template <class T>
std::istream & get_binary(std::istream & in, T & out) {
    return in.read(reinterpret_cast<char*>(&out), sizeof(out));
}
If you don't mind you can safe that for a CR answer :P
Though I'll open a tab for it :)
Maybe I'll actually implement it in the first version, but I'd first rather have it working
Err, sorry. It's a habit after correcting those programming exercises back in the day.
19:46
I did definitely notice the copy-paste pattern already though
Maybe I'll also be able to understand templates then :P
I'm voting to close this question as off-topic because questions to review working code should to go codereview.stackexchange.com — GhostCat 5 secs ago
@skiwi To be honest, that seems reasonable. A first job is daunting.
Especially if you don't know if you have the knowledge to pull it off.
@Zeta I just wonder what you're doing as programmer with no experience. If you cannot self-learn then I'd be disappointed
20:02
-1
Q: why My calculater can*t show answer and equal buton can't work

APURBO DATTAwhy My calculater can't work? http://pastebin.com/U5A9pQz9strong text

0
Q: OOP using Javascript

Gourav Kumar ShawWhat changes should I make to keep all other outputs same except the last two? I wanted to implement few OOP principles (data hiding and inheritance) using JavaScript. I have achieved it. But I feel that what I have written is not a good practice to do as it does not make code reuse and that is...

@Peilonrayz Uh, how much DIY are you planning to do? Just routing it yourself and sending it to a manufacturer or will you do the manufacturing yourself as well?
@Mast I'm planning on sending it to a manufacturer. Otherwise it'd be too much
Yea, also too much risk involved. Hard to do right the first time.
I'll snoop through my library and see what comes up. I'll have some advice either way, but you specifically asked for a book.
Ah, I know I can skip a PCB, and go straight copper wire and manual soldering, but I'd rather it to be a bit less getto
I don't mind if it's a book or not, :)
Depending on what kind of signals you're using, you might really need a PCB.
Don't go dead-bug style on a gigabit line.
20:14
IIRC others went that way, but they used the Teensy 2 rather than 3
The basics are easy. Don't route two possibly interfering signals too close to each other. Don't use right angles in your routes. Fill most of the areas you don't need with a groundplane.
Make them broad enough, but not overly so. Keep them short.
Watch out for PCB impedance and capacitance constructs.
Luckily keyboard PCB aren't very complex.
Great. Now I saw my starred message about Haskell, got excited and noticed that it's my message. That's it. I'm going to sleep. Have a nice day/night all!
7
Hmm, I'll have to relearn impedance and capacitance, but Keyboards are really simple, like 180 diodes and switches
But that's some great tips, the right angles I'd have done, XD
If you want something really stupidly simple, there's a Keyboard PCB guilde on GitHub of relatively good quality.
Personally, I try to keep the amount of vias to an absolute minimum (not counting the ones nailing groundplanes together), but I've been told I'm somewhat excessive in that regard.
Also: auto-routing is evil. Learn to do it yourself.
The computer has no clue why something is hard to route, while you usually figure it out yourself in the process. Once you've figured it out, you can usually optimize the lay-out of your components to improve the routing of your traces.
Anyway, hit me again once you've read the guide I linked. Should get you up to speed with the basics, I'll give you some pointers if anything remains unclear.
You're making me want a PCBReview.SE, ;P Thanks I'll try to keep to your tips, I'm not too good with Electronics and never done anything advanced, ):
20:26
If you want to do some serious work with it, you may want to invest in some software. Altium is a bit though for beginners and hobbyists, but Ultiboard is pretty good as well. They got an Academic Evaluation for those interested (if you're eligible for such things).
The guys behind Ultiboard, National Instruments, have some relatively good advice on routing as well.
I may look into those two, I'll start the basics off with KiCad, and I'm no-longer anywhere near education, so I'm not eligible to anything free, ): I'll be sure to read that after the Keyboard PCB Guide, :)
0
Q: Recode array in java code

RuslanI am beginner in programming of Android and please not strictly judge). I want write array from strings. xml to the array in java code. For example: (strings. xml) < string - array name=" names " > < item >Red < / item > < item > Green < / item > < / s...

In that case you probably want to stick to the free software at first. It gets expensive very fast.
@CaptainObvious Request for code. Hammer it.
hrngh ... learning for "software engineering basics" lecture and the current set of slides just all refer to a government owned website T.T
@Mast I just realized that "unclear" and "nuclear" are anagrams.
5
20:41
Reading a PDF, the wrong way:
   xmpRights:Marked="False">
   <xmpMM:DerivedFrom
    stRef:instanceID="xmp.iid:DDEBBA396E80E4118F3C94B89FAD296A"
    stRef:documentID="uuid:2C6E1893960BE111BDCCB0F2047D4E66"
    stRef:originalDocumentID="uuid:CDC443BDDC2A11DE9CB496C12FBA8AED"/>
   <xmpMM:History>
    <rdf:Seq>
     <rdf:li
      stEvt:action="saved"
      stEvt:instanceID="xmp.iid:02801174072068119109A169567E9A6B"
      stEvt:when="2010-02-24T07:45:44-05:00"
      stEvt:softwareAgent="Adobe Photoshop CS4 Macintosh"
      stEvt:changed="/"/>
No wonder my parser takes hours to make heads or tails of it.
Except most of it still looks like this:
��6��8ڻ������T8��0%ثx��i]��`��Li[U��[t�]�o�4������]�w���~�
U�1Wp�Wp�]�b���]A��A���b���_���?���T�������2֧�~*���:n�+��<���s]�n����mn��il��#;�~U�׮*�����~B����ci�~��
EӴ���F��tR���iY��AJ�0U������C����C�m<�eo����P�Q$�K>B]�h�˔��vn#��U�?������Z��������Z�I";_�“Q9
Oh well, I'll fix that later.
Does your current code work? If so, and you're asking for a performance-oriented code review, this might work better on codereview.stackexchange.com. But at least use String.StartsWith(String, StringComparison.OrdinalIgnoreCase‌​) rather than converting each string to lower. — dbc 33 secs ago
0
Q: Better way to do filtering

Raman KumarI am writing Code to filter data on base of attribute Values. It is possible that user can select multiple values function Models.Products filter(ViewModel.Filter search,IEnumerable<Models.Products> product) { if (search.filter!= null && search.filter.Count>0) { var f = ...

0
Q: Completed code wondering whether I need to make any corrections

MOMOThis is my completed code I was wondering whether it needs a correction This is my first class public class Account { private double balance; //STATE private double interestRate; //STATE private double rate;//STATE public Account() { balance = 0; interestRa...

@CaptainObvious Better way to write titles
@Mast Reading binary files is hard isn't it.
(PDFs aren't pure texts :P)
20:47
@DainIIIronfoot what about it?
I have move prompts done.
And you can disable them in the settings.
cool
where is this if I may ask :P
My Checkers application. I thought the whole world knew.
I've been drifiting in and out of the timeline randomly, so... :P
2
@ThomasWard They're pure mixtures of whatever the author put it it. Which can be a lot of different things.
20:58
@Mast Truth. Hence evil.
Yup.
0
Q: How can i simplify my code but still have it find and display the position of a word in a sentence?

Abi_FoxxHow can I simplify this code: Public Class Form1 Private Sub BtnPositions_Click(sender As Object, e As EventArgs) Handles BtnPositions.Click ' 'txtSentence.Text = "The cat sat on the mat" ' Temp for testing If TxtAddSentence.Text = "" Then MsgBox("The text you are searching is e...

0
Q: Can the following code be optimised any further?

Sreetam DasI've optimized the code using caching as much as this, but it needs to be optimized further. from collections import deque def memodict(f): """ Memoization decorator for a function taking a single argument """ class memodict(dict): def __missing__(self, key): ret = ...

21:22
If your code works and you're just looking to improve it, it may be better to put it on the Code Review site. — AntonH 17 secs ago
This isn't code review site. Goto review site and ask to review. But I will suggest think about your code and make your own solution. — Farhadur Raja Fahim 30 secs ago
I'm voting to close this question as off-topic because questions asking for a code review belong on Code Review, not Stack Overflow. — TylerH 28 secs ago
21:55
0
Q: Is this "smart" way of populating the admin page ok code-wise?

arlyonI am currently hooking a large database up to a django site and want to populate the admin page with a number of models. I am using inspect to get a list of classes from each model file (one file per database in MySQL) and then registering them by name. from django.contrib import admin import in...

If you have working code that you think could be improved, once you've finished implementing everything, see Code Review. — jonrsharpe 1 min ago
22:08
This question in my opinion should be in code review and not here. Therefore, I am not going to post an answer. Having said that: IValueConverter is to be used for converting back and forth between types. This is not what you are doing. — CodingYoshi 9 secs ago
0
Q: Checking if a date comes after another in Java

AlexTI need to test if a date is posterior to another in java, I just need to be sure that my approach is a good one public class Date { private int day; private int month; private int year; public Date(int day, int month, int year) { this.day = day; this.month = mont...

0
Q: Java / MySQL Database Class

Andy HSo I've written this MySQL database class for my Java application, I'd just like some feedback on it before moving onto making my next class. The idea here is that I have a simple properties file which stores the hostname, username, password, and database name. I then connect to the database (if...

22:24
0
Q: how to apply async or promises in nodejs

motchezzi have a server built on nodejs and mongodb and express, my routes are built callbacks and my code is hell itself, i have a lot of redundant same codes all over the code for example i create a parent and then create a user for that parent and save the id of the parent in the student object for ex...

0
Q: What's the best possible way to not overuse if statements in C

BaldrI was working on a class assignment today and I wrote this code which works perfectly fine. It looks tho kind of has too much 'if statements' in it, and I was thinking that it could be written much better than this. (I'm still a beginner in C). Do you suggest any new techniques that I could use/...

22:37
0
Q: Create a template class for same algorithm different type of member variable

r xu I want a template class that defines the same algorithms, but can work on different type of data stored in a member variable. The exact type of data ideally depends only on a single template parameter. I don't want run time polymorphism (like have an argument of a pointer to base class that can...

Your last condition will never run, since val() always returns a string, never NaN. You probably want to parseInt($('#replyNumber').val(), 10) before checking the value. If this code works as is, this question might be better asked on Code Review, but check their help center first. — Mike McCaughan 8 secs ago
23:00
0
Q: LinkedList and nodes

mivanx77Just a little backgrounds before I start asking questions. I am in data structures currently working on Linkedlists and Nodes. I had a gap with my semester where I did not take any programming classes therefore I'm really rusty with these things. package LinkedList; import java.util.NoSuchElem...

23:35
0
Q: Replicating Bash's command substitution in PowerShell

Robbie CrashI want to be able to use Bash's ^search^replace functionality in PowerShell, the closest I can come is with this function and linking it to the alias ^. So in Bash I would do: $ ping google.com $ ^google^bing And then I'd get to ping bing without re-writing the command. In PS with this cod...

0
Q: Finding factorions

user230452The objective of this program is to find all factorions. Numbers which are equal to the sum of the factorials of their digits. #include <stdio.h> #include <stdlib.h> #define base 10 //We are working in base 10 #define upper_bound 2540160 //This is 7 x 9! because a factorion can have at most seve...


« first day (1381 days earlier)      last day (2931 days later) »