|
Avenging Dentist posted:Get rid of the newlines in the regex (obviously don't do this in the post ). aw super, that did the trick. I feel dumb now.
|
# ? Mar 4, 2008 21:19 |
|
|
# ? May 15, 2024 03:40 |
|
I was hoping someone could enlighten me on a PHP/SSL problem I am experiencing. I have narrowed this down to one very simple PHP command that works through firefox, but fails via the php cli. Esentially, I can't load any url that starts with https: / # cat t.php <? echo "HTTPS:\n".file_get_contents('https://www.google.co.uk/ig?hl=en'); ?> / # Simple command to go get a web page. If I load it through firefox, I get the google webpage. If I go to a command line and run 'php t.php' I get: Warning: file_get_contents(): SSL: No such file or directory in t.php on line 2 Warning: file_get_contents(): Failed to enable crypto in t.php on line 2 Warning: file_get_contents(https://www.google.co.uk/ig?hl=en): failed to open stream: Invalid argument in t.php on line 2 If I change it to http: it loads just fine on the command-line and via firefox. I'm assuming I've either compiled PHP incorrectly and/or I am missing something glaringly obvious. My searches through google haven't been successful, but I think that's mainly due to my inexperience with PHP; I've only been working with this for a couple weeks. I don't really know what to search google for beyond the error code s themselves. I am Running HP/UX 11.11 with php 5.2.5 and apache 2.0.58. / # uname -a HP-UX bob B.11.11 U 9000/800 2002324811 unlimited-user license /# php -v PHP 5.2.5 (cli) (built: Feb 27 2008 13:58:33) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
|
# ? Mar 4, 2008 23:37 |
|
Yea, you probably managed to compile the CLI version of PHP without SSL support, but mod_php (which is often a separate package in package managers) with. I don't remember if phpinfo() gives meaningful output when run via CLI, but if it does, that should make it explicit - it would list the build args and all the modules it's got set up.
|
# ? Mar 5, 2008 03:01 |
|
Who loves pthreads? You, I hope!! I could wax poetic about my complaints with my operating systems class, but suffice it to say that I'm a bit lost when it comes to the pthread part of the current assignment. The assignment is to write a server for a subset of HTTP - technically, we do this three times: once using fork(), once using pthreads, and once using select() to handle concurrent queries. Since, strangely, he hasn't said word one about pthreads in class, I'm rather lost on this. So we would like the server to be able to handle an arbitrary number of queries at the same time, so I would like to do something like code:
code:
Oh god, tell me what to do so I can go back to writing Java ( )
|
# ? Mar 5, 2008 05:01 |
|
e: this was some very wrong information, ignore
KaeseEs fucked around with this message at 12:22 on Mar 5, 2008 |
# ? Mar 5, 2008 07:47 |
|
Mercurial question, couldn't think of a better place to ask: I'm setting up Mercurial to mirror an SVN repository with hgsvn. I'm on OS X. I installed mercurial with the usual sudo make install, and it seems to have installed the modules to /usr/local/lib/python-2.5/site-packages. With my PYTHONPATH set to that directory, I'm able to run 'hg' without it failing import, so that seems to be working. But when I run hgimportsvn, it fails: code:
code:
Anyone used hgsvn on OS X before and have some suggestions?
|
# ? Mar 5, 2008 18:17 |
|
I normally run "sudo python setup.py install" when I install Mercurial. I don't know if the Makefile differs, but the local site-packages directory is in /Library/Python/2.5/site-packages/ on 10.5, and I believe it lives inside the Python.framework folder on 2.4.
|
# ? Mar 5, 2008 18:27 |
|
Milde posted:I normally run "sudo python setup.py install" when I install Mercurial. I don't know if the Makefile differs, but the local site-packages directory is in /Library/Python/2.5/site-packages/ on 10.5, and I believe it lives inside the Python.framework folder on 2.4. That worked. Thanks!
|
# ? Mar 5, 2008 20:17 |
|
bitprophet posted:Yea, you probably managed to compile the CLI version of PHP without SSL support, but mod_php (which is often a separate package in package managers) with. I don't remember if phpinfo() gives meaningful output when run via CLI, but if it does, that should make it explicit - it would list the build args and all the modules it's got set up. I run php -m from the command line and I get: / # p -m [PHP Modules] ctype ... openssl ... [Zend Modules] / # That leads me to believe I have openssl compiled properly, I think. Since the apache/php combo works, perhaps Apache loads some kind of environment variable that I do not have set at the shell. "SSL: No such file or directory" is so incredibly non-descriptive, I have no clue what to look for. I wish I could print more detailed error message about what it is expecting.
|
# ? Mar 5, 2008 20:53 |
|
In Assembly, I need to print out the string "The sum of the integers is" And after hauling rear end doing messed up packed binary addition in Assembly, I can't do this WAAGH HALP
|
# ? Mar 6, 2008 03:27 |
|
Careful Drums posted:In Assembly, I need to print out the string What kind of assembly? What architecture? Are you using a library, or pure assembly code?
|
# ? Mar 6, 2008 03:45 |
|
You need to answer csammis's questions but generally your assembler should have some way to store a string constant as a variable in memory. Now all you have to do is send that variable as an argument to whatever function you are using to print. If your using 16 bit x86 DOS you can just call int 21h. quote:INT 21 - DOS 1+ - WRITE STRING TO STANDARD OUTPUT Here's a tiny example, but be advised that this isn't the best way to do it since it's old school DOS. code:
Janitor Prime fucked around with this message at 10:36 on Mar 6, 2008 |
# ? Mar 6, 2008 10:34 |
|
I have no clue about graphics programming so I don't know what keywords to google for. I have a set of rectangles I need to draw onto a 2D plane and I need to find out which rectangles are actually visible and which are hidden by other rectangles and don't need to be drawn (I have a Z-order on the rectangles). Since I'm pretty drat sure that this is a problem that was solved at least 40 years ago I don't want to invent my own algorithm. What keywords can I google for? What standard algorithms exist?
|
# ? Mar 6, 2008 19:00 |
|
If you're actually drawing filled rectangles, and you have a strong z-ordering, then a very simple, fast, and easy to optimize algorithm is to simply draw all of them, starting from the back and moving to the front. This is the simplest kind of fragment rendering, imposes almost no overhead when there are few overlaps, and can be implemented in very small code with no conditionals that only has to consider one rectangle at a time. If you just want to find out which rectangles are visible, there are a few things you can do. Possibly the best is to render them as above into an off-screen buffer somewhere, each with a separate color, then check all the pixels in your buffer to determine which colors are visible. Other algorithms exist, but tend to have higher complexity in the number of objects in exchange for not being pixel-bound as the rendering approach is, and are usually only worthwhile when you have more complicated objects than rectangles.
|
# ? Mar 6, 2008 19:15 |
|
ShoulderDaemon posted:If you're actually drawing filled rectangles, and you have a strong z-ordering, then a very simple, fast, and easy to optimize algorithm is to simply draw all of them, starting from the back and moving to the front. This is the simplest kind of fragment rendering, imposes almost no overhead when there are few overlaps, and can be implemented in very small code with no conditionals that only has to consider one rectangle at a time. The good news is that the average screen is so small that more than like 100 rectangles are probably not visible at the same time unless the user is an rear end in a top hat Asperger headcase who gives each rectangle exactly one pixel of screen space in which case a single redraw probably takes half an hour. However I still need to find out which 100 rectangles to draw and which 999.900 not to draw. quote:Possibly the best is to render them as above into an off-screen buffer somewhere, each with a separate color, then check all the pixels in your buffer to determine which colors are visible. This is actually really cute. Thanks for the suggestion.
|
# ? Mar 6, 2008 19:57 |
|
Alan Greenspan posted:I want to be able to handle up to 1 million rectangles. At this many geometry elements, you're not going to be able to do much better than the offscreen drawing mechanism, and caching the result. You're far more geometry-dominated than pixel-dominated, so many of the common alternative algorithms are going to be worse than the naive algorithm. If the rectangles move around, especially if they only move by small amounts, then there may be some updateable structures that will work marginally better than the naive method, but frankly at this point you'll have the most luck with naive drawing to an offscreen buffer, and making your drawing code as small and condition-free as you can, so you can run out of cache and avoid stalling.
|
# ? Mar 6, 2008 20:09 |
|
Does anyone know how to dynamically add an image to a pdf form using an xfdf or fdf or similar technique? I would like to be able to generate a bunch of server side data including a photo, but I have to be able to create the information at run time. We use xfdfs to populate forms at runtime, but I cannot for the life of me figure out how to add an image at run time at all.
|
# ? Mar 6, 2008 20:45 |
|
I'm making a bash script where I need to echo $VARIABLE number of something on a line, let's say Xs. Like this, the unknown command is [?]: alice=5 bob=7 echo "Alice [?]" echo "Bob [?]" ...and get this output: Alice XXXXX Bob XXXXXXX
|
# ? Mar 7, 2008 20:53 |
|
Is there a better method to put a struct into a buffer in c using sprintf instead of referencing each of the doubles seperately? This method seems to defeat the idea of using a structure.... code:
odi3 fucked around with this message at 05:21 on Mar 8, 2008 |
# ? Mar 8, 2008 05:18 |
|
Unless you want to use C++, the only way I can think of would be to use preprocessor macros. Something likecode:
|
# ? Mar 8, 2008 05:50 |
|
Avenging Dentist posted:Unless you want to use C++, the only way I can think of would be to use preprocessor macros. Something like Couldn't you just write a function? Unless you want to sprintf other stuff as well -- like: code:
|
# ? Mar 8, 2008 07:04 |
|
Is there an algorithm for exhaustively generating all unordered subsets of a particular set? Basically, if you imagine a set of 6 elements, each of which can be an integer 0-9, then there are 5005 unique, unordered sets (eg. { 0 0 0 0 0 1 } and { 1 0 0 0 0 0 } are identical). I'd like to generate all 5005 of these, without wasting any time generating duplicates (obviously, I could walk through generating all 1,000,000 ordered sets -- but then I'd just feel silly!). Is anyone aware of an algorithm which does this?
|
# ? Mar 8, 2008 07:16 |
|
Wuhao posted:Is there an algorithm for exhaustively generating all unordered subsets of a particular set? Sounds like you want the power set (the set of all subsets of a set). It's relatively nontrivial, your best bet is a dynamic programming approach where you memoize the sets you've already generated so that you don't generate duplicates.
|
# ? Mar 8, 2008 19:08 |
|
more falafel please posted:Sounds like you want the power set (the set of all subsets of a set). It's relatively nontrivial, your best bet is a dynamic programming approach where you memoize the sets you've already generated so that you don't generate duplicates. He doesn't want power set, he wants the code:
Edit: Completely untested Perl: code:
ShoulderDaemon fucked around with this message at 20:06 on Mar 8, 2008 |
# ? Mar 8, 2008 19:23 |
|
ShoulderDaemon posted:Easy. All I've done is generated the sets in a sorted order, by building them piece-by-piece and never adding an element to a set if there is already a higher element in that set.
|
# ? Mar 8, 2008 19:59 |
|
Incoherence posted:I thought about that, but wouldn't that fall down when there are duplicate elements in the input set? Well, then it's not an input set, it's an input list, and you can do it by explicitly passing around the list of remaining elements, and chopping off prefixes of it. Or just keep the list out of band, and use an input set of integers from zero to (length of list)-1, then use those as indexes into the list. Edit: The only time you can't do this is if there isn't a strong ordering you can impose on the input, which means the input has to be nonfinite, and hence the only length that terminates is length 0, so it doesn't matter. ShoulderDaemon fucked around with this message at 20:08 on Mar 8, 2008 |
# ? Mar 8, 2008 20:03 |
|
ShoulderDaemon posted:Well, then it's not an input set, it's an input list, and you can do it by explicitly passing around the list of remaining elements, and chopping off prefixes of it. Or just keep the list out of band, and use an input set of integers from zero to (length of list)-1, then use those as indexes into the list. code:
Now that I look at it, you could solve that by not recurring on c, since b will necessarily return a superset of c. In other words, you'd need to add to ShoulderDaemon's algorithm that if the current element is equal to the previous element, don't recur.
|
# ? Mar 9, 2008 06:50 |
|
axolotl farmer posted:I'm making a bash script where I need to echo $VARIABLE number of something on a line, let's say Xs. I totally misread this and thought that you wanted to print the number of characters in a string. Which is actually awesome because I learned how to find out the length of a string in bash (it's ${#var_name} btw). All that you need to do is code:
|
# ? Mar 9, 2008 07:38 |
|
Incoherence posted:You're not solving the problem: if your input set is {0, 1, 1, 2, 3} and you want all subsets of length 3, {1, 2, 3} using the first 1 is the same as {1, 2, 3} using the second 1. Oh. I'd assumed that if you wanted to specify an input collection with duplicates, then that meant you wanted to break order invariance for the duplicated elements, because why else would you bother to have a representation of the input that even allowed duplicates? Transforming the input to a complete integer range and never passing around big partial collections seems far more reasonable, because you don't have to worry about sorting or uniqueness or any of that mess. If you want the same behavior as if the input collection doesn't allow duplicates, but you still want to provide duplicates of some elements for some reason, then I'd just prefilter the input collection to remove them, which we can trivially do for a max of n ln n complexity cost (I think you can do n, but it's too late at night for me to be sure). Considering the rest of the algorithm is massively more complex by sheer size of output, there's no reason at all to try to do anything clever. The trivial construction involves a size n lookup table, but that's dwarfed by everything else and it's not like we're using memory for anything but the stack anyway.
|
# ? Mar 9, 2008 10:44 |
|
Plastic Jesus posted:I totally misread this and thought that you wanted to print the number of characters in a string. Which is actually awesome because I learned how to find out the length of a string in bash (it's ${#var_name} btw). That was exactly what I needed. That get lenght of a string thing will be very useful for me too. I did that by stringlength=`echo $string | wc -l`
|
# ? Mar 9, 2008 16:25 |
|
What's the best or most flexible language to use for *nix scripting? Trying to write scripts in bash is quickly becoming an exercise in frustration.
|
# ? Mar 10, 2008 07:08 |
|
Most *nix installs have Perl installed by default, so that might be your best choice.
|
# ? Mar 10, 2008 07:23 |
|
Perl tends to be the standard, yeah. I see a lot of scripts written in Ruby, of all things, these days too though, and Python support is pretty ubiquitous these days so that may be a good choice. Use whichever one you like so long as you know it's available to you.
|
# ? Mar 10, 2008 11:44 |
|
I'll go with Perl for the moment, as I've been meaning to learn it for years.
|
# ? Mar 10, 2008 13:05 |
|
If anybody can offer suggestions and ideas on this it'd be very much appreciated. Situation: I've got a Python script that uploads a file to a certain site, waits for and then processes the reply into a specified format. This part works fine. Problem: I now need a to create a front end for this script. I want a user to be able to visit a web page, select a file just like you would if visisted WaffleImages or such, and have the results processed. Steps that need to be completed:
Anything, and I mean anything, you guys have to offer would be greatly appreciated. Any tutorials, recommendations, suggestions etc. would be recommended. Please also suggest methods to accomplish what I've mentioned. Also, what would be the best way to approach the XML part? I've been looking around but nothing in terms of 'Python on XML' documentation has been low level enough to help a newbie Note: I posted this here 'cause I felt it was to broad for the Python thread or any of the others.
|
# ? Mar 11, 2008 09:55 |
|
Are there any good books or documents (preferably free, but if it's great I don't mind paying) on programming style and writing clean and easy to maintain code? This is a bit vague, but I'd like to work on this as I think it's the weakest aspect of my programming abilities and I'd like to improve it. I have trouble separating code into different files to make it more readable and maintainable and I have an absolutely terrible habit of trying to write everything in one file. I'm not sure if this is just from a lack of experience, but I hope someone has a few suggestions on this topic.
|
# ? Mar 11, 2008 17:16 |
|
The Practice of Programming by Kernighan and Pike is an excellent tome on style and methodology. It's short, concise and well written. A very accessible book with broad coverage with summaries at the end of each Chapter. http://plan9.bell-labs.com/cm/cs/tpop/ If anything you will gain most experience from reviewing your own code and others, and asking people to do the same for your code (don't forget to write more code). A book will encourage you to think in a good way, but it will take time for the new practices to become standard. P.s. feel free the resurect the last book thread
|
# ? Mar 11, 2008 17:22 |
|
Adding a link to the Cavern Reading List in the OP
|
# ? Mar 11, 2008 20:59 |
|
What's the easiest way to go about making a toolbar button for the Windows Explorer? Creating a new toolbar is also an option, but probably overkill since I only want to add a single button.
|
# ? Mar 11, 2008 22:34 |
|
|
# ? May 15, 2024 03:40 |
|
Avenging Dentist posted:What's the easiest way to go about making a toolbar button for the Windows Explorer? Creating a new toolbar is also an option, but probably overkill since I only want to add a single button. I don't think you can add a single button, you'll need to make a toolbar with only one button. Tutorial here: http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx I've never created a toolbar, but every other shell extension I've done has been a world of pain. You program will run in explorer's process space, you'll probably want to shut down explorer and then run it from your debugger. To shut down explorer: * On XP, or classic menu in Vista: Click on the Start button -> shut down -> and then on the "Shutdown Windows" dialog box, hold down Ctrl+Alt+Shift and press the Cancel button. * On Vista: Click on the Start button -> hold down Ctrl+Shift -> right click on either an empty area on the menu or on the power buttons -> pick the menu option "Exit Explorer".
|
# ? Mar 11, 2008 23:11 |