|
ShoulderDaemon posted:Untested, but this should work. I don't know if there's a shorter way; this is just the first solution that I thought of. Good call with the st_dev and st_ino. I'm already using the stat struct on one of the files, so I can keep the stat struct info around for the other one (that is static during program execution.) Thanks.
|
# ? Oct 24, 2008 21:30 |
|
|
# ? May 13, 2024 22:27 |
|
Time for a horrifying Lua question! code:
Without those asserts, it fails later, in some os.execute() lines that actually matter. I'm trying to track down what causes os.execute() to eventually simply stop working. What could it be? I do not know! Unfortunately, duplicating it involves a few thousand lines of code, five gigabytes of data files, and running the program for several hours. Partially due to its unpredictability I haven't been able to isolate it in any useful fashion. I've gotten it to fail immediately after an os.close() call with moderate reliability. I don't know if that helps in any way, since obviously there isn't one in the critical segment of this example. The return value is invariably -1 during this failure mode. I don't know if that helps either. Once it fails once, it continues failing forever in the same manner until Lua exits (this means I can't just retry until it works) and, obviously, I don't know why. Increasing the number of open files in ulimit doesn't help (I've increased it by a factor of 100 without any change). I'm running on an updated Ubuntu 64, Lua 5.1.4. Help? Does anyone at least have ideas on how to track it down? Remember that it takes hours to duplicate ZorbaTHut fucked around with this message at 04:56 on Oct 28, 2008 |
# ? Oct 28, 2008 04:44 |
|
ZorbaTHut posted:Time for a horrifying Lua question! You could be leaking zombie processes, which would explain why trivial fork-and-exec tasks are failing and also why the problem immediately goes away when you kill the parent lua process.
|
# ? Oct 28, 2008 04:58 |
|
ShoulderDaemon posted:You could be leaking zombie processes, which would explain why trivial fork-and-exec tasks are failing and also why the problem immediately goes away when you kill the parent lua process. I came up with another thing to test, including this. First, "ps -A | wc -l" doesn't show any process leakage, and neither does top. So, no zombie leakage. That said, on a hunch I added a little instrumentation to see how long os.execute took. At the beginning of my program, it was 0.04 seconds. It's up to 0.19 and rising. So . . . there's some leak going on. I'm pretty sure I'm looking at digging into the Lua source.
|
# ? Oct 28, 2008 05:22 |
|
I have been getting frustrated with the sort times in tables for Eclipse's SWT GUI interface. I found some code that claims nlog(n) complexity, and it still takes about 2 seconds to do 1,000 elements. Doesn't that seem like a long time? I'm wondering if the sorting algorithm is the weak point in SWT or if some of the SWT stuff gets in the way. Hmm does anybody even use SWT? Maybe I should run off to the Eclipse forums for this one.
|
# ? Oct 28, 2008 14:04 |
|
Rocko Bonaparte posted:I have been getting frustrated with the sort times in tables for Eclipse's SWT GUI interface. I found some code that claims nlog(n) complexity, and it still takes about 2 seconds to do 1,000 elements. Doesn't that seem like a long time? I'm wondering if the sorting algorithm is the weak point in SWT or if some of the SWT stuff gets in the way. I did some SWT at my last job...you might want to disable updates on the table while you're sorting. If I remember correctly, the table tries to redraw itself with every reorder operation. The reason for that is that SWT is loving retarded. I hate the Eclipse platform with every fiber of my being
|
# ? Oct 28, 2008 15:48 |
|
csammis posted:I did some SWT at my last job...you might want to disable updates on the table while you're sorting. If I remember correctly, the table tries to redraw itself with every reorder operation. The reason for that is that SWT is loving retarded. I hate the Eclipse platform with every fiber of my being I suspect that everybody learns to hate a GUI library with sufficient time.
|
# ? Oct 28, 2008 17:00 |
|
Rocko Bonaparte posted:SWT doesn't seem so bad from a developer point of view It's from my own developer point of view that I despise it - in its effort to support everything under the sun, it gets really awkward on some platforms. Couple that with SWT crippling the ability to extend widget classes and you can easily get stuck doing some unfortunate things in a system of high GUI complexity. Creating a TextBox from a Composite because I want the ability to underline text - sign me right the hell up
|
# ? Oct 28, 2008 18:29 |
|
Let's say I have a handful of functions that are functional (side effect free), and the first argument to all of these functions refers to the same thing (an object, or id, whatever represents the main concept they operate on). Should these functions be bundled together into an instantiatable class? I actually already asked this some time ago but I can't find the original thread and I think I described it a little differently.
|
# ? Oct 28, 2008 21:03 |
|
Triple Tech posted:Let's say I have a handful of functions that are functional (side effect free), and the first argument to all of these functions refers to the same thing (an object, or id, whatever represents the main concept they operate on). Since they share a concept, and in fact operate on the same object, I vote yes. Pass the operated-on object into the constructor of the class, then have all the functions operate on this->object.
|
# ? Oct 28, 2008 21:19 |
|
I was told this was a stupid idea because it didn't relate to state at all. Like, the functions don't necessarily change the concept, or anything else for that manner (again, functional, stateless). I'm trying to see if there's like an OOP rule of thumb that will tell me who was right here. e: spelling Triple Tech fucked around with this message at 22:24 on Oct 28, 2008 |
# ? Oct 28, 2008 21:39 |
|
Triple Tech posted:I was told this was a stupid idea because it didn't relate to state at all. Like, the functions don't necessarily change the concept, or anything else for that mannner (again, functional, stateless). http://en.wikipedia.org/wiki/Cohesion_(computer_science) I agree with csammis, incidentally.
|
# ? Oct 28, 2008 22:00 |
|
How is PHP's security when it comes to MySQL statements? If I have a form that has has a text field on it, and I insert the value from it into a MySQL table, is it possible for someone to add malicious things into the text or will PHP protect you from this?
|
# ? Oct 28, 2008 22:29 |
|
ryo posted:How is PHP's security when it comes to MySQL statements?
|
# ? Oct 28, 2008 22:53 |
|
I have an awk/sed question. I tried to search to see if there was an awk or sed thread, but search is still not working, so forgive me if I'm rehashing old questions. I'm writing a bash shell script that is trying to break up a string into two components. The string is a Windows OR *ix style filename with full path prepended. eg. /aaa/bbb/ccc ddd/eee.txt -or- c:\aaa\bbb\ccc ddd\eee.txt I want to wind up with $filename and $pathname having the filename(eee.txt) and the directory respectively. dirname and basename covers the *ix style filenames, it's the windows ones that are giving me gyp. So far, I've found that filename=`echo ${data} | sed 's/.*\\\//'` will reliably retrieve the filename in the case of a Windows-style filename. However, I'm drawing a blank as to the best, most efficient way of capturing the prepended directory into a variable. Can anyone offer any solutions/advice?
|
# ? Oct 28, 2008 23:37 |
|
Wardhog posted:
since you already have filename, you can just lop it off: dirname=${data%$filename}
|
# ? Oct 29, 2008 01:47 |
|
covener posted:since you already have filename, you can just lop it off: You haven't exactly solved my problem, as dirname won't handle Windows-style filenames, but you've suggested another course of action that's looking promising. Thanks! dirname won't cope with c:\aaa\bbb\ccc\ddd\eee but it WILL cope with c:/aaa/bbb/ccc/ddd/eee and sed is pretty good at changing all occurrences of \ to / and back again Wardhog fucked around with this message at 03:14 on Oct 29, 2008 |
# ? Oct 29, 2008 02:51 |
|
Triple Tech posted:I was told this was a stupid idea because it didn't relate to state at all. Like, the functions don't necessarily change the concept, or anything else for that manner (again, functional, stateless). I would say it depends on the pattern of use - if you're always going to be using several of them at around the same time, so you can instantiate the class and then use it over and over, put them in a class. If you'd end up with a common pattern of "Manipulator m(object); m.some_function()" then just put them in a namespace instead. It might make most sense to add them directly to the object, though.
|
# ? Oct 29, 2008 05:19 |
|
csammis posted:It's from my own developer point of view that I despise it - in its effort to support everything under the sun, it gets really awkward on some platforms. Couple that with SWT crippling the ability to extend widget classes and you can easily get stuck doing some unfortunate things in a system of high GUI complexity. Particularly, I see: code:
|
# ? Oct 29, 2008 06:17 |
|
ryo posted:How is PHP's security when it comes to MySQL statements? Just don't rely on any sort of escaping mechanism; there's a lot of PHP tutorials out there (including those on php.net) that recommend the use of obsolete or insecure functions to prevent SQL injection. Here's a helpful list of bad ideas:
What you actually want to use to prevent SQL injection is a prepared (sometimes called 'parameterized') query, which you can do by using the MySqlI ('improved') library of PHP5. There's a nice overview here, and some simple examples here.
|
# ? Oct 29, 2008 07:15 |
|
Wardhog posted:You haven't exactly solved my problem, as dirname won't handle Windows-style filenames, but you've suggested another course of action that's looking promising. I didn't mean /usr/bin/dirname, just chose a variable that matches your "filename": code:
|
# ? Oct 29, 2008 12:22 |
|
Triple Tech posted:I was told this was a stupid idea because it didn't relate to state at all. Like, the functions don't necessarily change the concept, or anything else for that manner (again, functional, stateless). Eh, I wouldn't worry about that. Some people say instance methods should only be the ones that change state, but I think it's OK for them to be instance methods if they just depend on the state or the identity of the object.
|
# ? Oct 29, 2008 12:50 |
|
Rocko Bonaparte posted:Sorry to bug you again on this, but it looked like the example I was trying out already does shut off redraw for the table while it's sorting. I was looking at the code from: http://www.java2s.com/Code/Java/SWT...enerFactory.htm That's some pretty code...it's completely recreating the table every time you click on a column header to sort, no wonder it's slow as poo poo. Use a TableVIewer instead, it provides a sorted view onto the underlying table that doesn't require the table to get torn down constantly.
|
# ? Oct 29, 2008 13:50 |
|
csammis posted:That's some pretty code...it's completely recreating the table every time you click on a column header to sort, no wonder it's slow as poo poo. Use a TableVIewer instead, it provides a sorted view onto the underlying table that doesn't require the table to get torn down constantly.
|
# ? Oct 29, 2008 15:33 |
|
Rocko Bonaparte posted:Is jface stuff included in Eclipse SWT, or would I have to install it separately? I always run into jface stuff when I was searching for information on SWT, but I never quite pieced it together. I'm fairly sure it's included, but I don't know for sure. I wasn't involved in setting up our package dependencies. e: I guess I don't know what you mean by "included" - it's not the same jar as the basic SWT stuff, if that's what you're getting at.
|
# ? Oct 29, 2008 16:20 |
|
This is an amazingly simple question (I hope) but I can't seem to find relevant info for it on Google. My site displays a user's webpage that they've specified in their account info. When they type in a full URL (http://www.example.com) it works perfectly, but when they type in a partial URL (https://www.example.com), the link directs to http://www.mypage.com/www.example.com. I can parse out URL's and change them based on the user's input, but I'm just hoping there's something easy I can do to prevent this.
|
# ? Oct 29, 2008 20:39 |
|
Stephen posted:My site displays a user's webpage that they've specified in their account info. When they type in a full URL (http://www.example.com) it works perfectly, but when they type in a partial URL (www.example.com), the link directs to http://www.mypage.com/www.example.com. That is not a partial URL, that is just a host name. Just tell your users to gently caress off until they have learned to write URLs! Vanadium fucked around with this message at 19:14 on Jun 7, 2014 |
# ? Oct 29, 2008 21:37 |
|
Vanadium posted:That is not a partial URL, that is just a host name. Just tell your users to gently caress off until they have learned to write URLs! Hah! I wish. So I guess I just write a PHP function to parse the URLs before they're displayed? Edit: In any case, here's what I did that worked: php:<? function parseURL($url) { //This function will parse a URL for proper use in an <a> link //Parameters: URL string //Output: Formatted URL string if(!stripos($url, 'http://')) { $url = 'http://'.$url; } return $url; } ?> Stephen fucked around with this message at 21:50 on Oct 29, 2008 |
# ? Oct 29, 2008 21:38 |
|
Stephen posted:function parseURL($url) I hate your function name, and by extension you and puppies and kids on my drat lawn, because it doesn't parse the URL. It verifies it ~>
|
# ? Oct 29, 2008 21:56 |
|
csammis posted:I hate your function name, and by extension you and puppies and kids on my drat lawn, because it doesn't parse the URL. It verifies it ~> Let us not forget that it will fail on the following: https://example.com example.com.[url]http://[/url] ftp://example.com
|
# ? Oct 29, 2008 22:01 |
|
Avenging Dentist posted:Let us not forget that it will fail on the following:
|
# ? Oct 29, 2008 22:19 |
|
...and mailto: ...and java script: ...and relative URLs [edit] which may be beyond the scope of your function's use in this one case [/edit] fischtick fucked around with this message at 22:26 on Oct 29, 2008 |
# ? Oct 29, 2008 22:24 |
|
fischtick posted:...and mailto:
|
# ? Oct 29, 2008 22:25 |
|
Stephen posted:This is why I was hoping there was something built-in that I could use, since I always miss this kind of poo poo. Fortunately I never have to verify anything other than http: or https: URI schemes have to match [-+.a-zA-Z0-9]+, and colon is not a valid hostname character ([-.A-Za-z0-9]+, ignoring internationalization), so if you're willing to require absolute URLs, you can just prepend http:// if the URL doesn't match ^[-+.a-zA-Z0-9]+:.
|
# ? Oct 29, 2008 22:43 |
|
rjmccall posted:URI schemes have to match [-+.a-zA-Z0-9]+, and colon is not a valid hostname character ([-.A-Za-z0-9]+, ignoring internationalization), so if you're willing to require absolute URLs, you can just prepend http:// if the URL doesn't match ^[-+.a-zA-Z0-9]+:. Good job, you just broke URLs for everything with an explicit port.
|
# ? Oct 29, 2008 22:44 |
|
Avenging Dentist posted:Good job, you just broke URLs for everything with an explicit port. Hey, I knew I was forgetting some valid use for colons. Yeah, probably just go with a heuristic, or demand more user intelligence.
|
# ? Oct 29, 2008 22:48 |
|
If your webpage is delivered by anything but http, you do not deserve to get linked to anyway.
|
# ? Oct 29, 2008 23:00 |
|
Seriously, though, a quick google for "php parse url" returns parse_url, which splits a URL into its component parts (scheme, hostname, etc). Try feeding https://www.example.com into that and find out if it returns a blank scheme, defaults to "http" or chokes. Then the correct way to do this (in fact, the correct thing to do even if you hadn't noticed a specific problem) is to use that function to split the url's into parts and then rebuild them into a canonical form.
JoeNotCharles fucked around with this message at 23:52 on Oct 29, 2008 |
# ? Oct 29, 2008 23:17 |
|
Stephen posted:Hah! I wish. So I guess I just write a PHP function to parse the URLs before they're displayed? I don't know poo poo about php but: http://www.php.net/function.parse_url can you just use that and check some fields for validity?
|
# ? Oct 29, 2008 23:18 |
|
|
# ? May 13, 2024 22:27 |
|
Help me program better! Right now I'm coding things in Notepad++ (PHP, HTML, JS), then just transfer files to my server with SSH Secure Shell FTP. I have to think there's a more efficient way to do this. also, I want to be able to code on my Ubuntu laptop that is similar to what I'm doing. Point me in the right direction!
|
# ? Oct 30, 2008 02:12 |