|
furtheraway posted:I understand that we're supposed to keep language specific questions in their related threads, but I don't see any current threads on shell scripting or sed. If I'm wrong, feel free to ridicule me. It might be simpler (and possibly faster) to just 'cut' twice instead of sed: code:
|
# ¿ Feb 29, 2008 03:38 |
|
|
# ¿ May 2, 2024 21:44 |
|
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 |
|
What is the most efficient way to find the location in an integer of a specific byte value? For instance, suppose that I have an integer of 0x43001928, how do I find the byte position of the value 0x00? Obviously I could just cast to a char pointer and walk the bytes, but it seems like there is a faster (no matter how marginally faster) way to do this. Specifically I have a large buffer from which I need to find strings of bytes in a specific range (pretend that range is 0x00-0x3f). A comparison of every byte is easy but non-optimal so I'm casting to an unsigned integer pointer, allowing me to look at 4 bytes in one instruction. However, I need to know if the last 1, 2, or 3 bytes in that integer are in my approved range, otherwise I'll skip over them when I increment my pointer. That sounds confusing, so assume the following (and ignore endianness as a concern for now): code:
code:
code:
Is there a mathematical or logical operation that I'm missing here? I don't mind inlining IA86 asm if necessary. I considered the following: code:
Suggestions? Does any of this make any sense at all?
|
# ¿ Mar 15, 2008 15:53 |
|
Alan Greenspan posted:Undocumented source code is available This rules, thanks.
|
# ¿ Mar 15, 2008 17:26 |
|
black candy posted:The performance concern here is that your method appears to require misaligned loads from puc. I don't know the details for x86, but most hardware hates this. You may want to consider making only aligned loads to keep 64 bits of the buffer in memory, search for the sequence within those bits, and if not found slide the 'window' forward by 32 bits. Well I'll be damned. I always assumed that because data didn't have to be aligned (and since x86 doesn't even have standard length opcodes) that it didn't matter. But I just found this: Intel Architecture Software Developer’s Manual Volume 1: Basic Architecture posted:Words, doublewords, and quadwords do not need to be aligned in memory on natural boundaries...However, to improve the performance of programs, data structures (especially stacks) should be aligned on natural boundaries whenever possible. The reason for this is that the processor requires two memory accesses to make an unaligned memory access; whereas, aligned accesses require only one memory access. A word or doubleword operand that crosses a 4-byte boundary or a quadword operand that crosses an 8-byte boundary is considered unaligned and requires two separate memory bus cycles to access it; a word that starts on an odd Just to think out loud here- I can keep puc pointing to the beginning of what appears to be a series and only cast pui onto 4-byte boundaries, correct? This will complicate things a little, as the series of interest are of a fixed size so my AND masks will have to be variable when checking the series end. But that's not a big deal. God I love it when I get direct, usable information about questions. Thanks guys.
|
# ¿ Mar 16, 2008 11:24 |
|
Dauq posted:If you say you're looking into asm as well, the x86 asm code has instructions specifically for finding bytes in strings. I thought about this, but the byte of interest will be part of an integer (and in a register already), not a string of characters. On a related note, does anyone know if Microsoft's implementation of things like strlen() and strchr() make use of the REP SCAN instructions? I suppose that if I wasn't so lazy I'd just open in up in IDA right now. But I am.
|
# ¿ Mar 22, 2008 18:14 |
|
hey wiz posted:If he used an on change event, why not deselect all other check boxes before selecting the current one? Because that's really confusing for the user.
|
# ¿ Apr 6, 2008 04:10 |
|
clockwork automaton posted:Actually, that's perfectly fine. The way I figure it there is an easier way to do what I am doing, I'm just being stubborn and not seeing it. Can't you just do strchr('\n') (or strstr("\r\n") on windows)? Ohhhhhhhhh. I misread. Then, yes, seconding the idea that you may be approaching the problem wrong. vvvvvvvvvvvvvvv Plastic Jesus fucked around with this message at 17:50 on Apr 9, 2008 |
# ¿ Apr 9, 2008 13:51 |
|
clockwork automaton posted:It's okay though, because I figured it out. It was an issue with user space memory and kernel space memory all I had to do was use strcpy and it was saved. I've responded to you here.
|
# ¿ Apr 21, 2008 17:10 |
|
Factor Mystic posted:This is kind of a programming related question: Is there any way to identify the function called in a compiled module? Example, given this output from Process Monitor, can I find out what the functions are? Do you want to know which functions an application is using in a DLL? dumpbin (which comes with Visual Studio) will dump imports for you. If you don't have VS installed, periscope can do the same thing.
|
# ¿ May 3, 2008 12:37 |
|
bitprophet posted:Given that the X11 terminal looks and behaves like complete rear end, there's no reason to use it unless you're just using it to launch a GTK app like e.g. Wireshark. alias wireshark='open -a /Applications/Wireshark.app' There is no reason to use xterm/iterm/anydamnedterm on OS X.
|
# ¿ Jul 10, 2008 02:22 |
|
GT_Onizuka posted:Except for, you know, using terminal applications. I meant that there's no reason to use anything other than Terminal.app
|
# ¿ Jul 10, 2008 05:43 |
|
Can anyone recommend a spell checker for source code? I'll need it mostly for checking C sources, but hopefully there's something multi-language.
|
# ¿ Jul 14, 2008 19:21 |
|
Mustach posted:Just use realloc() You can't re-use a pointer passed to realloc (that's why it returns a pointer) and your call to sprintf() could still overflow buff. Also, this is very silly stuff. The dude asking the question isn't splitting the atom, he's creating a string. I have no idea why this is so confusing to people, but it scares the hell out of me to think that people get such basic things wrong. code:
|
# ¿ Sep 6, 2008 14:26 |
|
What are good papers/books that offer an introduction to financial market analysis algorithms? I'm mostly interested in analyzing historical trends, but I know absolutely nothing about this area of research and will happily read anything pertinent to the field.
|
# ¿ Sep 20, 2008 04:03 |
|
The B Man posted:Check out Fama 1970 and Fama 91, they're both an overview of market efficiency which will basically tell you that technical analysis (ie some sort of algorithm) has not and will not yield profit. I'm not sure exactly what you're looking for but you can't do any sort of futuristic prediction. If you want to analyse past data you're be better off looking at statistical methods for doing so. No, I'm not trying to open my own quant shop. I'm mostly looking to learn about software and mechanisms are used by analysts to evaluate markets and trends. I'm also specifically wanting to analyze interactions/dependencies between index fund components, in particular when these dependencies contradict overall market performance.
|
# ¿ Sep 20, 2008 14:51 |
|
tripwire posted:In c, how should I be declaring strings, and when should I make them dynamically allocated? How should I return strings from functions? Which of the following makes sense inside a function: C doesn't have garbage collection, so no worries there. You can use a char array when you won't be using the string outside of the current function. You can pass a char array to another function to fill in, but you can't return a char array from a function. Also, the stack size is limited in compiler-specific ways. As a rule of thumb I don't have more than 512 bytes worth of local variables (the actual limit is something like 3k for VS8 but I'm weird). Finally, you can't use char arrays when you don't know the required buffer size at compile-time. Use heap-based buffers when you don't know how large of a buffer you'll need until run-time, you need large buffers or if you need the string to persist outside of function scope (e.g. when you need to return a string). You will very rarely want to declare a local string static. Finally, you shouldn't cast with malloc() in c.
|
# ¿ Sep 24, 2008 19:49 |
|
tripwire posted:Thanks for the helpful responses everyone. One thing I want my progrma to do is store a file into a buffer on the heap, and my difficulty was not knowing the size of the file beforehand. Use fseek() to move to the end of the file, then ftell() to get the size of the file. Then just malloc(), fseek() back to the beginning of the file, and read it all in one shot.
|
# ¿ Sep 25, 2008 15:23 |
|
ante posted:I'm writing a program that injects a Dll into another process in C. I've got the injector and the dll working fine, I just can't actually figure out how to call the dll's functions. Considering the way that most hits on google gloss over this point, I get the impression that it's really easy using LoadLibrary or GetModuleHandle or something. What are you trying to do after injection? Are you attempting to hook calls to another DLL or just execute on your own code? You can't really force a process to call your DLL's functions (well, except DllMain()).
|
# ¿ Oct 1, 2008 16:25 |
|
|
# ¿ May 2, 2024 21:44 |
|
ante posted:I'm trying to pass variables to a function in my Dll. One way or another I need to get my program and the injected Dll communicating. There isn't any real way to force the host process to execute anything in your DLL (outside of hooking). You get a chance to do whatever you want in your DllMain(), but after that your DLL won't be doing anything unless explicitly called by the host process. I guess that I still don't understand precisely what you're trying to do.
|
# ¿ Oct 4, 2008 13:49 |