|
PiotrLegnica posted:Modifying memory behind literals is undefined behaviour, and more often than not will end up being a segfault (especially if compiler does string pooling). I don't think it's the string pooling that does it so much as putting the string in section .rodata or whatever (i don't have gcc at the moment but you can throw a couple of versions of hello world into objdump and see where things get put)
|
# ? Sep 21, 2012 14:03 |
|
|
# ? May 30, 2024 02:15 |
|
Otto Skorzeny posted:I don't think it's the string pooling that does it so much as putting the string in section .rodata or whatever (i don't have gcc at the moment but you can throw a couple of versions of hello world into objdump and see where things get put) It's UB at the core, but yeah, segfaulting is due to them being put in memory marked as read-only. I mentioned string pooling only because then it's pretty much guaranteed to be in an read-only memory.
|
# ? Sep 21, 2012 14:17 |
|
Someday if I get a job doing PH stuff I'll make a system where certain undefined behaviors actually make demons fly out your nose
|
# ? Sep 21, 2012 16:27 |
|
PiotrLegnica posted:Not really related to the problem, but important to remember: never assign string literals to char*, if you're using a pointer, always use const char*. Modifying memory behind literals is undefined behaviour, and more often than not will end up being a segfault (especially if compiler does string pooling). Just to be clear - the problem here isn't in the assignment to the char *, it's in actually trying to modify it, right? I ask because you can't always guarantee that the const can stick around through eighty function calls or whatever, especially if you're bouncing around between different libraries.
|
# ? Sep 21, 2012 23:59 |
|
GrumpyDoctor posted:Just to be clear - the problem here isn't in the assignment to the char *, it's in actually trying to modify it, right? I ask because you can't always guarantee that the const can stick around through eighty function calls or whatever, especially if you're bouncing around between different libraries. Yes. const is there so the bug is caught at the compile time, not runtime. You should always guarantee that const sticks — if a function takes non-const char*, you either shouldn't pass string literals to it (because it might legitimately try to modify them) or you should yell at the author for being an idiot and violating const-correctness.
|
# ? Sep 22, 2012 00:21 |
|
Cross posting from the game dev thread, I'm working with another goon on a game and was wondering how we should approach project planning and management? It's just the two of us right now, although we may hire one or two more.
|
# ? Sep 22, 2012 05:46 |
|
Otto Skorzeny posted:Someday if I get a job doing PH stuff I'll make a system where certain undefined behaviors actually make demons fly out your nose gcc used to invoke nethack under certain conditions, IIRC.
|
# ? Sep 22, 2012 07:40 |
|
I'm not sure where exactly to put this, so let me know if a different forum would be better. Is there any way to get through a locked computer in windows xp, windows server 2003, or windows server 2008 using my own credentials? I've tried some console commands like tscon and I've googled for days, but nothing seems to be working. What I really want to do is remotely log into a computer running windows server 2003 or 2008, then unlock the computer so I can run autohotkey to interact with the desktop and different internet applications. Currently I do this to windows XP machines by using RealVNC, but the voodoo doesn't work on these two different OSes and the machine stays in a locked state.
|
# ? Sep 23, 2012 21:44 |
|
So I have a client's site which has some custom code running various mapping functions. Said mapping functions have developed a bug a long while after the original launch. The original development was done by a third party developer. I'm already assuming the client will have a hard time understanding why she has to pay "to fix something she already paid for," as she's made similar claims in the past. Does anyone have something really good I can tell her to make her understand that developers don't support things they've coded indefinitely for free? I can probably come up with something on my own, but I'm sure 99% of developers have dealt with this before. Anyone have a really great analogy, or some website or something I can send her?
|
# ? Sep 24, 2012 22:00 |
|
edit: oh god, posted this in the wrong thread. sorry!
Acer Pilot fucked around with this message at 01:50 on Sep 25, 2012 |
# ? Sep 24, 2012 23:45 |
|
kedo posted:So I have a client's site which has some custom code running various mapping functions. Said mapping functions have developed a bug a long while after the original launch. The original development was done by a third party developer. :thisisacaranalogy?: There isn't a website you can point her to because she is someone who doesn't respect your time to pay you. If you want to avoid dealing with problems like this, either raise your rates and work for companies/people that just care about what you can do or add into your contract some kind of monthly maintenance cost.
|
# ? Sep 25, 2012 10:10 |
|
Strong Sauce posted::thisisacaranalogy?: Point taken, although knowing the client as well as I do (been working with them for years) I know it's more of a lack of education than a lack of respect. My hope was that there might be some sort of resource for developers like WeeNudge is for designers that I could use to help explain things. The "spec work" section on WeeNudge is in the same vein. But if that doesn't exist, then I guess I'm barking up the wrong tree. e: However a car analogy might actually be my best bet.
|
# ? Sep 25, 2012 14:39 |
|
Tell her that she still has to pay a mechanic when her car breaks.
|
# ? Sep 25, 2012 16:45 |
|
How do you all handle defaults? Let's say you're building a database-driven application, it's got the usual suspects: Orders, Clients, Products, Users, etc. In my app, some of these things (eg. Orders) are manually created dozens of times a day, so it makes sense to fill in some default values for my poor users. Option 1) Store magic rows in your database. This involves adding some mechanism to detect which row is "the default record" in each table. Could be an IsDefault column on the table, could be the name of the record is "DEFAULT" or some other magic string. When creating a new record, find the default record and copy values. This is pretty hideous, as now, among other things, all my code needs to filter out that one bogus row. Option 2) Serialize the default to disk. This involves saving an object with default values to a file, which most languages can do easily. This fixes the above "magic" row in the database. When creating a new record, load the default from disk and copy values. This seems a little better, until you need to modify objects. Adding and removing properties becomes a nightmare. This is what we're doing now, and trust me, it's a nightmare. Option 3) Store defaults for all your objects in a new table. This involves creating a Defaults table which contains columns like OrderPaymentMethodDefault, OrderDeliveryMethodDefault, ClientCreditStateDefault, ClientCountryDefault, ClientCityDefault, etc. When creating a new record, consult the Defaults table and copy values. This is laborious, time-consuming work. Also, it doesn't play well with lists: the previous two options can be linked to other tables, so, for example, a new order can have a default client, or a new order can load a default set of products. --- From where I'm sitting, there doesn't seem to be any ideal options. What do y'all do? epswing fucked around with this message at 15:18 on Sep 26, 2012 |
# ? Sep 26, 2012 15:16 |
|
epalm posted:How do you all handle defaults? Are these things unique for each type of option, or are they per-user, or per-client or whatever? If they are per-user or per-client or etc. then I do not see why you would not use a database table to do this. If they are unique, then I guess I would probably either - use a database table or tables anyway, despite the fact that it will have only one row - do what you are doing and store defaults for new objects, to be loaded in the manner of a configuration file. What you have written makes it sound as though you are literally creating an instantiation of an object, with default values, and serialising it to disk, and if that is what you are doing then it sounds to me as though you are making things unnecessarily difficult. Why would you not just store the defaults for the object's attributes and create it using those values when the time comes when you need the object? (Option 1 offends my sensibilities, because not every row of the table represents the same kind of "thing", so I would not endorse that.)
|
# ? Sep 26, 2012 15:51 |
|
yaoi prophet posted:Tell her that she still has to pay a mechanic when her car breaks. Or for a more complete analogy (updating), compare it to paying someone to put on snow tires. It's not like the software "wears out," but rather that it doesn't match the requirements of a changing environment anymore.
|
# ? Sep 28, 2012 01:01 |
|
epalm posted:How do you all handle defaults? I write code that sets them. I can waste the next few hours getting over the shame of not doing it "properly" with some configurable, generic framework, and still come out ahead compared to actually building such a thing.
|
# ? Sep 28, 2012 16:00 |
|
I'm attempting to modernize a poorly-written program in Fortran (still, for anyone who reads this thread regularly), and the latest monstrosity goes something like this. I apologize in advance for the lack of indentation, but I don't even know how to parse the loop structure here.code:
|
# ? Sep 30, 2012 05:39 |
|
Grundulum posted:I'm attempting to modernize a poorly-written program in Fortran (still, for anyone who reads this thread regularly), and the latest monstrosity goes something like this. I apologize in advance for the lack of indentation, but I don't even know how to parse the loop structure here. Looking at what gets executed each iteration: 1. Code block 2 is always executed 2. Code block 1 is executed if the condition is true. 3. Code block 3 is executed if the condition is false. The one complication is that code block 1 is executed once before you reach the loop proper. There might also be some complication around the last time through the loop, but that's hard to tell without knowing what the exit conditions are. Does this help?
|
# ? Sep 30, 2012 05:51 |
|
Grundulum posted:I'm attempting to modernize a poorly-written program in Fortran (still, for anyone who reads this thread regularly), and the latest monstrosity goes something like this. I apologize in advance for the lack of indentation, but I don't even know how to parse the loop structure here. code:
|
# ? Sep 30, 2012 05:53 |
|
Or if you're going to do it that way just roll code block 3 up with code block 1.code:
|
# ? Sep 30, 2012 06:01 |
|
Jabor posted:Or if you're going to do it that way just roll code block 3 up with code block 1. Hmm, yeah, good point. I was just using the while true as a standin, thinking that the loop wasn't necessarily infinite and that Grundulum had just simplified, but if it's really an infinite loop, that's definitely cleaner.
|
# ? Sep 30, 2012 06:20 |
|
^ No, loop 2001 is infinite. Code block 3 contains more than a dozen opportunities to break out of the loop, but there isn't a limitation on how long we can stay in there. ^Jabor posted:Or if you're going to do it that way just roll code block 3 up with code block 1. That's very elegant, especially compared to the garbage I wasn't coming up with. It's going to mess with the "logical" progression of the various code blocks, since 1, 2, and 3 roughly represent events happening in chronological order (also code block 3 is roughly five times the size of code blocks 1 and 2). I don't see any way around it that adheres to recent best practices, though. Thanks to everyone who made suggestions, and so quickly!
|
# ? Sep 30, 2012 07:08 |
|
How should you deal with piracy? Obviously, you cannot stop it completely, but what should you do if you want to make money off of your software other than relying on the kindness of strangers. I'm not talking about a bug expensive thing like a CAD suite, but a little one or two dollar app.
|
# ? Sep 30, 2012 19:46 |
|
Don't worry about it, I guess. If people really, really want to pirate your one- or two-dollar app, they'll find a way to. Is the time/money invested in implementing some kind of piracy protection less than the profit you'd get from the people discouraged enough to buy your app? Who knows. And more importantly, will whatever piracy protection you implement be a detriment/annoyance to normal paid users?
|
# ? Oct 1, 2012 00:11 |
|
Sinestro posted:How should you deal with piracy? Obviously, you cannot stop it completely, but what should you do if you want to make money off of your software other than relying on the kindness of strangers. I'm not talking about a bug expensive thing like a CAD suite, but a little one or two dollar app. Make sure people think your prices are reasonable, and that you're responsive to feedback and criticism. Some people are going to pirate things regardless, yes, but antipiracy is never going to work. They never would have bought it in the first place.
|
# ? Oct 1, 2012 00:33 |
|
I'm writing an XSLT file and I'm trying to read an image file from the XML and display it:code:
What am I missing? VVVV Thanks. Looks like I've got some reading to do Elman fucked around with this message at 08:18 on Oct 2, 2012 |
# ? Oct 1, 2012 18:49 |
|
Elman posted:I'm writing an XSLT file Found your problem. Seriously, though, XSLT is not a simple text replacement. I haven't used it much, but you need something like that: XML code:
|
# ? Oct 1, 2012 19:25 |
|
I need to iterate over a result set twice (in Java). I cannot rerun the same query because it can potentially take a long time and results might have changed. Here are the things I have considered: 1) Load result set contents into some other data structure - this would lead to memory problems as queries can return many thousands of rows. 2) Use scrollable result sets - I do not know what kind of JDBC driver will be used, and for example Oracle uses in-memory processing and would cause memory issues: quote:Important: 3) Write result set contents to a file - this is the best solution I have been able to come up with but its really ugly. There really has to be something better than this crap. My google skills are failing however, anyone got any ideas?
|
# ? Oct 2, 2012 09:49 |
Possibly select into a temporary table (created for that specific instance of the query) first, then select from that, twice. There is no way you can re-design the operation so it won't need to handle the data twice?
|
|
# ? Oct 2, 2012 10:00 |
Yep, temp table sounds like the way to go. Depending on what database you are using, you can even create it using something like the CREATE TABLE ... SELECT really easily
|
|
# ? Oct 2, 2012 17:38 |
|
I don't think there's an XSLT thread (because as far as I can tell, XSLT is universally loathed), but I have an issue that I don't even know how to search for, especially because it involves extension functions to XSLT 1.0. If you have a string that you split using str:split(), this should return a nodeset of <token> tags containing the actual split. E.g., if you do str:split('1000/10000','/'), it returns <token>1000</token> <token>10000</token>. Which is all well and good, but when you set a variable this way, you get a legitimate nodeset, but you can't access it in any useful way. Example: <xsl:variable name="Limits" select="str:split('1000/10000','/')"/> This gives you a variable called $Limits that should have two children, so $Limits[1] should return 1000. Only it doesn't. Instead of the variable being the root, allowing you to use a predicate to access the child nodes, for some stupid reason, the variable is actually just the two nodes side by side, and they are unusable in that state as far as I can tell. This is using Xalan-J as the processor and inspecting the values in the debugger that Oxygen's XML/XSLT editor has. Is there any way around this, or do I just have to wrap this every time and use exslt:node-set() or xalan:nodeset() to convert it into a root node with two children? Because that is stupid and it sucks. Also, if there's a better thread for this question, please let me know and I will go there instead.
|
# ? Oct 2, 2012 19:10 |
|
I wrote a VBA macro that opens an Excel file, gets a value from a cell, and puts it into another Excel file. It does this repeatedly for lots of the input files. The way VBA handles opening files to get data is not so good, I think. Am I right in that a VBScript would be a lot faster? Can I do this process using VBScript inside a VBA macro?
|
# ? Oct 3, 2012 05:42 |
|
totalnewbie posted:I wrote a VBA macro that opens an Excel file, gets a value from a cell, and puts it into another Excel file. It does this repeatedly for lots of the input files. Can you post some code?
|
# ? Oct 3, 2012 07:51 |
|
This is the part of it that pertains to the file opening and closing:code:
Sorry if it doesn't come out right, have to do this on my phone at work. Full code at http://pastebin.com/feRBK5pv just slightly edited to make a bit more readable. The macro fully works as intended, for what it's worth. Edit: played around some more and I got past the issue I was having yesterday with the VBScript code (maybe it is not technically VBScript? I don't even know) so I will give this seemingly more efficient method more work. totalnewbie fucked around with this message at 15:09 on Oct 3, 2012 |
# ? Oct 3, 2012 14:01 |
|
Sizzler Manager posted:because as far as I can tell, XSLT is universally loathed I like for what I've used it for. I don't know the answer to you question though.
|
# ? Oct 3, 2012 16:05 |
|
Connecting web apps to "texting" question: If you were doing a dotnet web app, and you wanted it to communicate with people via text - how would you go about it? Please educate me. I googled a bit and found a third-party that does the connection (http://www.twilio.com/) so there's one way. So possible questions you could answer in no particular order: 1. It's an enterprise app, so we sell app, they communicate with their constituents using it. How would you do it? 2. If there is no way to do it other than dealing with someone else that has some kind of magical access to the phone networks (I know gently caress all about SMS and it shows!) - is Twilio good or do you recommend someone else? 3. If I wanted to skip the third party and just handle communications with each provider - what's the order of difficulty? I convert each "text" to email and email it to "subscribernumber@verizon.net" for verizon, but to ...I don't know something else at tmobil.com, etc. - how many different providers would I have to deal with? OR is there some kind of standard I should be looking at? VV e: thanks! "SMS Gateway" was the words I needed. I am old. pr0k fucked around with this message at 20:28 on Oct 3, 2012 |
# ? Oct 3, 2012 19:25 |
The proper way to inject SMS messages is to have a connection to the mobile network, either through a device with SIM card which then sends them in the traditional manner, or by getting access to some kind of internet service from the mobile providers. I believe an "SMS gateway" is what you should be looking for. A proper SMS gateway (service) will also let you receive messages. I would recommend against injecting through email. If you want to do commercial messaging the providers will want their share, and if you try to do it by email injection they will most likely just block you off when they catch onto your operation.
|
|
# ? Oct 3, 2012 19:37 |
|
This reads to me like base64 with a different "alphabet", but the only example I can find of data encoded like this doesn't decode to a file that works correctly for me. http://www.gedcom.net/0g/gedcom55/55gcappe.htm#S3 Normal base64 alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" Gedcom "Blob" alphabet: "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" So I'm wondering if my example file is broken or if there's a difference I'm missing aside from the alphabet? The example file is this: code:
|
# ? Oct 3, 2012 19:39 |
|
|
# ? May 30, 2024 02:15 |
|
Okay, well, today's results also positive. Code here: http://pastebin.com/PWs0J8t7 It is pulling the files over a LAN so I don't know if that is the bottleneck or what but they both take over just a minute to run on about 130 lines with about 100 files. Some lines end up having no file to open, also they are organized by year (by folder and filename) and a mix of xls/xlsx.
|
# ? Oct 3, 2012 19:44 |