Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

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)

Adbot
ADBOT LOVES YOU

Cat Plus Plus
Apr 8, 2011

:frogc00l:

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.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
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 :engleft:

raminasi
Jan 25, 2005

a last drink with no ice

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.

Cat Plus Plus
Apr 8, 2011

:frogc00l:

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.

Above Our Own
Jun 24, 2009

by Shine
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.

Opinion Haver
Apr 9, 2007

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 :engleft:

gcc used to invoke nethack under certain conditions, IIRC.

Gimpalimpa
Jun 27, 2004
Title text?
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.

kedo
Nov 27, 2007

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? :)

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

edit: oh god, posted this in the wrong thread. sorry!

Acer Pilot fucked around with this message at 01:50 on Sep 25, 2012

Strong Sauce
Jul 2, 2003

You know I am not really your father.





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.

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? :)

: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.

kedo
Nov 27, 2007

Strong Sauce posted:

: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.

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. :downs:

Opinion Haver
Apr 9, 2007

Tell her that she still has to pay a mechanic when her car breaks.

epswing
Nov 4, 2003

Soiled Meat
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. :smith:

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. :negative:

What do y'all do?

epswing fucked around with this message at 15:18 on Sep 26, 2012

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

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.)

tarepanda
Mar 26, 2011

Living the Dream

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.

Zhentar
Sep 28, 2003

Brilliant Master Genius

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.

Grundulum
Feb 28, 2006
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:
5702 continue

  code block 1

2001 continue

  code block 2

  if(condition 1) goto 5702

  code block 3

  goto 2001
How can this be turned into a proper nested loop structure?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

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:
5702 continue

  code block 1

2001 continue

  code block 2

  if(condition 1) goto 5702

  code block 3

  goto 2001
How can this be turned into a proper nested loop structure?

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?

het
Nov 14, 2002

A dark black past
is my most valued
possession

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:
5702 continue

  code block 1

2001 continue

  code block 2

  if(condition 1) goto 5702

  code block 3

  goto 2001
How can this be turned into a proper nested loop structure?
This is ugly and off the top of my head, but I think should work? If block 3 can't affect condition 1 you can remove the didnt_exec_block_3 nonsense
code:
first_iter = true
didnt_exec_block_3 = true 

do while true
  if ((didnt_exec_block_3 AND condition 1) OR first_iter) then
    
    code block 1

    first_iter = false

  endif

  didnt_exec_block_3 = true

  code block 2

  if not condition 1

    code block 3

    didnt_exec_block_3 = false

  else

    didnt_exec_block_3 = true

  endif

end do

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Or if you're going to do it that way just roll code block 3 up with code block 1.

code:
first_iter = true

do while true
  if (first_iter OR condition1) then
    code block 1
    first_iter = false
  else
    code block 3
  endif
  
  code block 2
end do

het
Nov 14, 2002

A dark black past
is my most valued
possession

Jabor posted:

Or if you're going to do it that way just roll code block 3 up with code block 1.

code:
first_iter = true

do while true
  if (first_iter OR condition1) then
    code block 1
    first_iter = false
  else
    code block 3
  endif
  
  code block 2
end do

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.

Grundulum
Feb 28, 2006
^ 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.

code:
first_iter = true

do while true
  if (first_iter OR condition1) then
    code block 1
    first_iter = false
  else
    code block 3
  endif
  
  code block 2
end do

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!

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.
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.

tarepanda
Mar 26, 2011

Living the Dream
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?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

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.

Elman
Oct 26, 2009

I'm writing an XSLT file and I'm trying to read an image file from the XML and display it:

code:
<img src='<xsl:value-of select="producto/@img"/>'/>
This returns an error at the start of the value-of tag. Doing <img src="foo.jpg"/> works fine of course, and the value-of returns foo.jpg just fine when I use it separately. Yet when I use both together it doesn't work.

What am I missing? :saddowns:

VVVV Thanks. Looks like I've got some reading to do :shobon:

Elman fucked around with this message at 08:18 on Oct 2, 2012

Cat Plus Plus
Apr 8, 2011

:frogc00l:

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:
<xsl:template match="producto">
    <img src="{@img}"/>
</xsl:template>

IMlemon
Dec 29, 2008
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:
Because all rows of any scrollable result set are stored in the client-side cache, a situation, where the result set contains many rows, many columns, or very large columns, might cause the client-side Java Virtual Machine (JVM) to fail. Do not specify scrollability for a large result set.

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?

nielsm
Jun 1, 2009



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?

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
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

MacGowans Teeth
Aug 13, 2003

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.

totalnewbie
Nov 13, 2005

I was born and raised in China, lived in Japan, and now hold a US passport.

I am wrong in every way, all the damn time.

Ask me about my tattoos.
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?

Titan Coeus
Jul 30, 2007

check out my horn

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.

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?

Can you post some code?

totalnewbie
Nov 13, 2005

I was born and raised in China, lived in Japan, and now hold a US passport.

I am wrong in every way, all the damn time.

Ask me about my tattoos.
This is the part of it that pertains to the file opening and closing:

code:
FileFound:Set DataInput = Workbooks.Open(FilePath, , 1)
IssueYear = DataInput.Sheets(1).Range("AR5").Value
IssueMonth = DataInput.Sheets(1).Range("AV5").Value
IssueDay = DataInput.Sheets(1).Range("AZ5").Value
DataInput.Close (0)
ActiveCell.Value = IssueMonth & "/" & IssueDay & "/" & IssueYear
GoTo NextFile

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

Zhentar
Sep 28, 2003

Brilliant Master Genius

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.

pr0k
Jan 16, 2001

"Well if it's gonna be
that kind of party..."
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

nielsm
Jun 1, 2009



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.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



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:
.HM.......k.1..F.jwA.Dzzzzw............A....1.........0U.66..E.8
.......A..k.a6.A.......A..k.........../6....G.......0../..U.....
.w1/m........HC0..../...zzzzzzzz..5zzk..AnA..U..W6U....2rRrRrRrR
.Dw...............k.1.......1..A...5ykE/zzzx/.g//.Hxzk6/.Tzy/.k1
/Dw/.Tvz.E5zzUE9/kHz.Tw2/DzzzEEA.kE2zk5yzk2/zzs21.U2/Dw/.Tw/.Tzy
/.fy/.HzzkHzzzo21Ds00.E2.UE2.U62/.k./Ds0.UE0/Do0..E8/UE2.U62.U9w
/.Tx/.20.jg2/jo2..9u/.0U.6A.zk
Which supposedly should decode to a PICT image of a flower.

Adbot
ADBOT LOVES YOU

totalnewbie
Nov 13, 2005

I was born and raised in China, lived in Japan, and now hold a US passport.

I am wrong in every way, all the damn time.

Ask me about my tattoos.
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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply