|
Stinky_Pete posted:you mean template classes? Generic programming.
|
# ? Sep 23, 2016 20:08 |
|
|
# ? May 31, 2024 10:33 |
|
In a SQL Database, what's a good way to ensure idempotency for altering a table, creating a table, and inserting values only if they do not already exist in a table. Especially in the later case, I want to make sure I'm following best practices. If there's a SQL/DB thread I'll happily go there but I couldn't find it.
|
# ? Sep 23, 2016 20:21 |
|
Space Whale posted:In a SQL Database, what's a good way to ensure idempotency for altering a table, creating a table, and inserting values only if they do not already exist in a table. SELECT * FROM Questions WHERE Type = 'Stupid'
|
# ? Sep 23, 2016 20:26 |
|
JFC I'm living up to the name I ctrl f'd for sql/db/data
|
# ? Sep 23, 2016 20:33 |
|
Jsor posted:What's the term for being able to make arbitrary "type-level" data structures? E.G. a compile-time function that works on an arbitrary sized list or tuple of types (but more general than just something like a variadic parameterization)? Is that what Higher-Kinded Types are for? I can't really answer your question, but I can tell you that this is not what higher-kinded types are for -- at least not in terms of Haskell terminology. Higher-kinded types are parameterized types whose type parameters are also parameterized types. They're the type-level equivalent of higher-order functions. I'll give a brief explanation of kinds in case it helps you find what you're looking for. In Haskell kind notation the symbol * is used to mean "type", and the symbol -> is used to separate parameters from each other and from the output type. Concrete types that take no parameters (e.g. Int, Bool) have the kind *, types that take a single type parameter (e.g. the list type) have the kind * -> *, types that take two type parameters (e.g. the map type, which has a key type and a value type) have the kind * -> * -> *, etc. Many languages support types with an arbitrary number of type parameters. An example of a higher-kinded type would be something like the Monad typeclass, which has the kind (* -> *) -> *. Unlike the map type it only takes a single type parameter, but unlike the list type it stipulates that that type parameter must itself take a type parameter. A list may be parameterized with a type that has the kind * -> *, but Monad must be parameterized with such a type. It's like a function that takes a function as input, but on the type level. As far as I know only a few widely used languages, such as Haskell and Scala, have general support for higher-kinded types.
|
# ? Sep 24, 2016 10:46 |
|
fosborb posted:On a hosted app, we have a user who logged in and saw someone else's data. Logs show they both had the same JSESSIONID. I'd guess it's some state being shared between threads that shouldn't be shared.
|
# ? Sep 24, 2016 13:13 |
|
baka kaba posted:Yeah and these are fantastic and important skills to learn, but when you're just starting with a language (especially if you're new to programming) you just want some small problems to tackle. I feel like PE quickly runs into stuff that's impossible to succeed at unless you do it the 'correct' way, like calculating large primes or adding ridiculously large numbers together. Good puzzles to think about, and deepen your understanding of a language and the tools available to it, but it just doesn't feel like a good fit for beginners. To me anyway Your point is well taken. I admit I did find Project Euler to be pretty damned difficult as a beginner (as I'm sure I would now if I went slightly deeper into it), but the struggle of reasoning through problems taught me a lot, I think. It may just come down to your learning style.
|
# ? Sep 24, 2016 19:09 |
|
fosborb posted:On a hosted app, we have a user who logged in and saw someone else's data. Logs show they both had the same JSESSIONID. If I had to guess, I'd expect that this is some sort of mistake around ThreadLocal. Either they used private static Something instead of private static ThreadLocal<Something>, or they have code that touches a ThreadLocal running inside some sort of Executor, breaking the "one thread per HTTP request" expectation that a lot of services have.
|
# ? Sep 24, 2016 21:40 |
|
updated problem below
Argyle Gargoyle fucked around with this message at 00:43 on Sep 26, 2016 |
# ? Sep 25, 2016 06:42 |
|
It's not entirely clear from your post, but are you #including your hangman.h header file in your hangman.cpp file? e: also you can just post your code here in-thread - just use the [ code] and [/ code] tags (absent the spaces) JawKnee fucked around with this message at 07:20 on Sep 25, 2016 |
# ? Sep 25, 2016 07:16 |
|
Are you not allowed to change the header? Sounds like it just needs include guards
|
# ? Sep 25, 2016 17:42 |
|
Argyle Gargoyle posted:JawKnee, the assignment tells us to write the two definitions, so I'm not sure if putting #include "hangman.h" at the top of hangman.cpp is okay, but shouldn't it have the same effect as having that at the top of the main test.cpp which is compiled first? I'm throwing 4 errors with that include only in test.cpp but when I also put it at the top of hangman.cpp it turns into 19 errors. Your errors likely have to do with other problems in your playHangman function (there are quite a few, so you'll need to dig in) rather than a dependency issue (although if you want to use cout your hangman.cpp file is going to need access to <iostream>. It seems like you're not entirely sure what's going on when you include something in a particular file, and I'm probably not the best person to explain it, but here goes (doubtless someone else will correct me if I'm wrong or using incorrect language or whatever): When you include a header file you've written (or a standard library include like <iostream>) you are (generally) providing access to that header's classes and functions to the file that has the #include statement in it, and also to any file that is #including the file with that initial #include statement. Think of that availability as moving downstream through files via those statements. As an example, just in case I've confused you: code:
code:
code:
Still with me? Then let's define another 2 files here: code:
code:
code:
So the reason I asked whether you've included your hangman.h file in your hangman.cpp file is that you've included <string> there, and your hangman.cpp file cannot access <string> merely by being itself included in test.cpp - dependencies don't flow in that direction. Hopefully someone with more knowledge than me will clean up my description here, as I don't think I've properly gotten across why the particular problem you first stated is happening. However, as I noted above, you do have a number of other errors in your code that are not caused by this particular problem. JawKnee fucked around with this message at 18:37 on Sep 25, 2016 |
# ? Sep 25, 2016 18:35 |
Is there a mobile development/android thread? Anyone have suggestions on getting Android Studio emulator to work with AMD processors? I tried using the ARM system image and it took about an hour to boot up before giving a bunch of errors and crashing.
|
|
# ? Sep 25, 2016 19:05 |
|
#include literally instructs the compiler to copy and paste the contents of the file to where the include statement is
|
# ? Sep 25, 2016 19:08 |
|
Okay, so I have to have #include "hangman.h" in hangman.cpp for the functions in hangman.cpp to have access to <string> (via hangman.h), despite hangman.h being #included at the top of the main. Right? What I am confused about now is how do I give hangman.cpp access to <iostream> if I can't #include <iostream> at the top of it because, as you say, that would give the main access to it twice which will not work? Is it correct, then, that C++ allows you to give the main access to an individual file multiple times (here, hangman.h via main and hangman.cpp), while also disallowing you from doing this with libraries? I am assuming my hangman.cpp does not have access to <iostream> because when I attempt to compile the below code (test.cpp and hangman.cpp) I get this error: code:
Argyle Gargoyle fucked around with this message at 05:15 on Sep 26, 2016 |
# ? Sep 26, 2016 00:46 |
|
Argyle Gargoyle posted:Okay, so I have to have #include "hangman.h" in hangman.cpp for the functions in hangman.cpp to have access to <string> (via hangman.h), despite hangman.h being #included at the top of the main. Right? This is the key: Stinky_Pete posted:#include literally instructs the compiler to copy and paste the contents of the file to where the include statement is So if hangman.cpp is including hangman.h, where should <iostream> come from?
|
# ? Sep 26, 2016 02:01 |
|
Fergus Mac Roich posted:So if hangman.cpp is including hangman.h, where should <iostream> come from? I really don't know. I guess you're hinting that <iostream> should come from hangman.h but this must be flying over my head. Doesn't that still give the main access to <iostream> twice when test.cpp and hangman.cpp are compiled together (as per 'g++ test.cpp hangman.cpp -o hangman')? #include "hangman.h" at the top of hangman.cpp will just copy-paste the contents of hangman.h there. hangman.h was provided to us for this assignment and we were only told to write the functions playHangman and guessLetter in the file hangman.cpp, so I believe that adding to the header file might not be the intended way to solve this, if the problem I stated above were otherwise resolved.
|
# ? Sep 26, 2016 02:14 |
|
Argyle Gargoyle posted:I really don't know. I guess you're hinting that <iostream> should come from hangman.h but this must be flying over my head. OK, so there's a few things I think will help you here: First, test.cpp and hangman.cpp are not compiled together. They are unrelated, and do not affect each other. They are separate things. It just so happens that after being compiled, the results are getting put together to result in a complete program. But nothing you change in one will affect how the other is compiled. Second, you can include <iostream> as many times as you want and it will act exactly the same as only including it once. System headers have guards that prevent them from misbehaving if included multiple times. Third, there is no difference between including something in a .cpp file, and including something in a .h file which is included by that .cpp file. You should include headers in whatever files use things from those headers. You should put includes in header files if any use of that header would require also using the included header, because it makes it a little easier to avoid stupid mistakes. Finally, this is something that's a lot easier to understand if you see what the preprocessor is actually doing. I'd strongly recommend making an appointment with your TA or professor and asking them to show you some examples of what the preprocessor does with a few simple files, independently of any of the C++ aspects of your assignment. You can play with the preprocessor on your own with "g++ -E", but I suspect you'll get a lot more out of a short guided example.
|
# ? Sep 26, 2016 02:56 |
|
Thanks a lot everybody, you greatly improved my understanding. It took my weekend but I've now got the program working beautifully and learned a great deal about C++. I think I've uncovered a love of programming.
|
# ? Sep 26, 2016 05:19 |
|
I've been staring at this Javascript issue for ages and I suspect I've lost all perspective on it. I'm making something along the lines of a dressup game (you pick clothes / skin colour / accessories and they show on an image [no it is not anime] ) and you're able to select items, but all the content in the object resets every time you select an item. Here's the relevant JS:code:
|
# ? Sep 26, 2016 16:25 |
code:
I think you meant to write: code:
|
|
# ? Sep 26, 2016 16:35 |
|
hey! thanks. Except now, i get 'key is not defined'.
|
# ? Sep 26, 2016 16:53 |
|
well why not posted:hey! thanks. Except now, i get 'key is not defined'.
|
# ? Sep 26, 2016 16:59 |
Yeah lots of things look very suspicious about your code, and I'd suggest you start out with describing the purpose of each and every variable and function.
|
|
# ? Sep 26, 2016 17:01 |
|
nielsm posted:Yeah lots of things look very suspicious about your code, and I'd suggest you start out with describing the purpose of each and every variable and function. Yeah, like I said, this is getting overcooked in my brain! Appreciate the eyes on it. I've added some extra comments explaining what I'd expect to be happening at each stage of the main function. code:
|
# ? Sep 26, 2016 17:10 |
|
So, it looks like what you're trying to do is something like this.code:
e: to clarify what you were doing: You initialized build to an array with one element, that element being a dictionary defining your attributes. Then, you iterated over that one element, checked to see if your type parameter was the dictionary, then added a copy of the dictionary as a key to the dictionary, with the value being whatever you passed into value. e2: Looking back at your original post. It sounds like you're having trouble with making this persist. Where are you storing the state of your current build? Because right now, that function defines a local variable and doesn't return anything, so that build doesn't exist outside the life of that function. Dr. Stab fucked around with this message at 17:46 on Sep 26, 2016 |
# ? Sep 26, 2016 17:22 |
|
well why not posted:I've been staring at this Javascript issue for ages and I suspect I've lost all perspective on it I've had this one problem that I've been trying to solve for literally probably 8 years. For the past few years I've spent a 10-20 hours/week for a few weeks out of each year hoping I'll make some headway on it after spending some time away and learning new stuff. I think this week I finally figured it out! I'm too embarrassed to describe the actual problem because I've always known it was because of my weak formal CS background. Anyway, my point is not so much for you exactly, but just to highlight for anyone who cares that if you bang your head against something long enough you might come up with a solution! (also I'm just excited to have made progress on this thing finally)
|
# ? Sep 26, 2016 17:27 |
|
well why not posted:Yeah, like I said, this is getting overcooked in my brain! Appreciate the eyes on it. I've added some extra comments explaining what I'd expect to be happening at each stage of the main function. Is there a particular reason you're making a totally new object instead of just making one and updating it? That seems like it would be much more straightforward than this. Something like code:
code:
code:
|
# ? Sep 26, 2016 17:45 |
|
Oh coding experts please help me! I am doing my first app in Swift and have an issue with an image picker. I have (finally) managed to get the bloody thing to compile and got to the stage where I select the image. The problem is that I want to set the UIimageView I have in the storyboard to the image. Currently it just closes the picker and leaves me with no change at all. I know the code is ugly but you gotta learn somewhere right? code:
|
# ? Sep 26, 2016 19:31 |
|
thanks for all the help guys, I'l dip in and see how I go. Appreciate the eyes on this.
|
# ? Sep 26, 2016 19:40 |
|
thegasman2000 posted:Oh coding experts please help me! Have you connected your UIImageView to your IBOutlet? It should appear under referencing outlets when you right-click the image view on the storyboard. e: I'm also seeing that imagePickerController:didFinishPickingImage:editingInfo is deprecated, maybe try replacing it with imagePickerController(_:didFinishPickingMediaWithInfo:)? https://developer.apple.com/reference/uikit/uiimagepickercontrollerdelegate/1619126-imagepickercontroller carry on then fucked around with this message at 21:18 on Sep 26, 2016 |
# ? Sep 26, 2016 21:14 |
|
Yep its linked as @IBOutlet weak internal var imagePicked: UIImageView! I just don't get how to assign the image picked to that view.
|
# ? Sep 26, 2016 21:19 |
|
thegasman2000 posted:Yep its linked as And that link shows up as a filled circle in the margin next to that line of code? Not accusing you of anything, just doing the same double checking I would do with my own because I have made that mistake before. I'm not in front of Xcode at the moment, but I think you're doing the right thing in terms of assigning it to the UIImageView's image property. I'm not sure you're getting what you're expecting. passed into the method though...
|
# ? Sep 26, 2016 21:23 |
|
No I appreciate it! This is a screenshot of the viewcontroller and the storyboard. Seems all linked up. http://imgur.com/a/vpg0C As I say I am new to this... Its all very hacky and having no tutorials in Swift 3.0 makes it more confusing as xcode is changing everything I paste in.
|
# ? Sep 26, 2016 21:29 |
|
thegasman2000 posted:No I appreciate it! This is a screenshot of the viewcontroller and the storyboard. Seems all linked up. Hmm okay. Nothing looks outright wrong there. Do you know for sure that the image is coming in, and that the code is getting inside the if let to set the imagePicked.image?
|
# ? Sep 26, 2016 21:46 |
|
carry on then posted:Hmm okay. Nothing looks outright wrong there. Do you know for sure that the image is coming in, and that the code is getting inside the if let to set the imagePicked.image? I don't to be honest. I get into the photo library and select the image, then it reloads the view and nothing is different. Perhaps adding a few prints will show me where it falling over?
|
# ? Sep 26, 2016 21:51 |
|
thegasman2000 posted:I don't to be honest. I get into the photo library and select the image, then it reloads the view and nothing is different. Perhaps adding a few prints will show me where it falling over? That would work, or you can use the debugger. Set a breakpoint by clicking in the left margin (I see you have one or two there already) and if execution gets to that line, it'll pause. So if you put one on the imagePicked.image = image line, it'd stop if it was getting in there and you could inspect your variables at that time.
|
# ? Sep 26, 2016 21:53 |
|
Ok so its not finishing the code:
|
# ? Sep 26, 2016 21:56 |
|
Okay, good. Now we know that what you're getting out of info for UIImagePickerControllerOriginalImage is nil, because it doesn't pass the if let. So for some reason there is no original image coming back. When you are doing this, are you using the camera or picking from your library?
|
# ? Sep 26, 2016 22:02 |
|
|
# ? May 31, 2024 10:33 |
|
carry on then posted:Okay, good. Now we know that what you're getting out of info for UIImagePickerControllerOriginalImage is nil, because it doesn't pass the if let. So for some reason there is no original image coming back. When you are doing this, are you using the camera or picking from your library? Picking from the library. I was under the impression the simulator doesn't like activating the camera so just testing the library for now.
|
# ? Sep 26, 2016 22:03 |