Gotta love stackoverflow.
The Big Programming Thread - Page 325
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
HardlyNever
United States1258 Posts
Gotta love stackoverflow. | ||
|
nunez
Norway4003 Posts
On July 20 2013 01:54 RoyGBiv_13 wrote: Here is the git source tree for "sed", the GNU stream editor. Scanning through the code, you'll want to look for process_files function under the execute.c, this is where the magic happens. In the early stage of processing the files, it buffers only one line at a time, malloc'ing 50 bytes for processing as per "INITIAL_BUFFER_SIZE". Later when writing back to the file, it has a buffer of 8kB, defined as FREAD_BUFFER_SIZE in order to quickly scan through a file to find where it is supposed to append each change in the file it is supposed to make. Note that this is not strictly for file streams, and is meant for any generic stream (pipe, socket, or file pointer). You can use malloc directly for a lot of very clever memory management techniques. For example, In game design, you know that the maximum buffer size you will need, and are worried most about the worst case, so malloc'ing the entire size at the beginning of the program could save you time during a critical loop later. My personal favorite clever use of malloc I saw a customer of mine use when doing some network optimizations. They were building a crypto stream cipher, and needed a large amount of unbounded variable memory to work on (>40MB), but couldn't pay the CPU tax when the time was needed to run the cipher. Sometimes, the network requested faster than the cipher, but sometimes slower. They malloc'd a large space near the beginning of the board initialization for the initial heap, and as the cipher got to a threshold limit in the heap, it would add another page onto the heap during a brief moment the CPU was not running the cipher because it was accessing the network peripheral on the chip. They found that where they were calling malloc() from, even within the same loop, had a large performance impact, because there is only one task allowed "inside" the kernel at a time, and adding a page to the heap requires asking the kernel for the page. When the cipher was running, it was inside the kernel, as it had to access physical registers directly. cheers, gonna peep it this weekend. | ||
|
Release
United States4397 Posts
For MySQL cmd prompt, when I first set up database and tables, it was fine. Then I exited now, I can't seem to access anything. I log in as root ( <path> -u root;) but when I type SELECT current_user(), i see current_user() When I try to access a database, i receive ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'publications' how do i get privileges back on root? Resolved | ||
|
darthfoley
United States8004 Posts
Bless your souls <3 | ||
|
Release
United States4397 Posts
When I use the correct user and password combination in the config.inc file, I get: #1045 access denied for user 'root'@'localhost' (using password: yes) but I use a blank password, I am able to log in but I get a warning that tells me to set a password(which would lock me out of my own server) | ||
|
Yoshi-
Germany10227 Posts
On July 20 2013 14:11 Release wrote: Also, on phpMyAdmin, When I use the correct user and password combination in the config.inc file, I get: #1045 access denied for user 'root'@'localhost' (using password: yes) but I use a blank password, I am able to log in but I get a warning that tells me to set a password(which would lock me out of my own server) It wants you to set up a password for the mysql account "root". The config.inc is used to connect to the mysql server. You could either do this by running a query like:
Or use the "mysqladmin" commandline. And after you have changed it, you can change it in the config file. | ||
|
Deleted User 101379
4849 Posts
On July 20 2013 18:15 Yoshi- wrote: It wants you to set up a password for the mysql account "root". The config.inc is used to connect to the mysql server. You could either do this by running a query like:
Or use the "mysqladmin" commandline. And after you have changed it, you can change it in the config file. It's better to use the MySQL specific user management commands. SET PASSWORD FOR 'root'@'%' = PASSWORD("foo"); | ||
|
Yoshi-
Germany10227 Posts
On July 20 2013 18:23 Morfildur wrote: It's better to use the MySQL specific user management commands. SET PASSWORD FOR 'root'@'%' = PASSWORD("foo"); Both queries are pretty much the same, it doesn't matter which one you use. They are equivalent. | ||
|
Deleted User 101379
4849 Posts
On July 20 2013 18:34 Yoshi- wrote: Both queries are pretty much the same, it doesn't matter which one you use. They are equivalent. Yes and no. A simple UPDATE query requires a "FLUSH PRIVILEGES" afterwards, which is easy to forget and then you wonder why your new password doesn't work. It's safer to get used to the specific commands for that as well as adding/removing users and all that. | ||
|
Yoshi-
Germany10227 Posts
On July 20 2013 18:45 Morfildur wrote: Yes and no. A simple UPDATE query requires a "FLUSH PRIVILEGES" afterwards, which is easy to forget and then you wonder why your new password doesn't work. It's safer to get used to the specific commands for that as well as adding/removing users and all that. Following that "you could potential forgot something" logic, than GRANT would be the best way since you don't need to use the hashing function. All those commands do pretty much the exact thing, it is quite ridiculous to discuss which one is better, they are all the same. | ||
|
Release
United States4397 Posts
I set the password with SET PASSWORD FOR 'root'@'%' = PASSWORD("foo");and to access mysql with command prompt, I now have to use the password that I set. But now, on phpMyAdmin, I get: #1045 access denied for user 'root'@'localhost' (using password: no) Nvm it's working now. | ||
|
Shield
Bulgaria4824 Posts
http://harmful.cat-v.org/software/OO_programming/ Most notably Edsger Dijkstra. I don't care about the others that much. | ||
|
phar
United States1080 Posts
| ||
|
tec27
United States3702 Posts
e.g.: Rob Pike: https://plus.google.com/101960720994009339267/posts/hoJdanihKwb Joe Armstrong's is from Coders At Work, which is an excellent book i've recommended here before, and has many other people in it that also dislike OOP. John Carmack's criticism is in the same vein as the "Stop Writing Classes" presentation linked in the "See Also" section. | ||
|
Deleted User 101379
4849 Posts
“Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function.” — John Carmack Sometimes OOP is just the wrong tool for the job. In my life, i went from "OOP is bad, avoid it at all costs" via "OOP is great, use it for everything" to "OOP is good, procedural is good, functional is good, but the correct mixture of all 3 is the best". | ||
|
CptCutter
United Kingdom370 Posts
On July 21 2013 08:09 darkness wrote: Why do people critisise OOP? http://harmful.cat-v.org/software/OO_programming/ Most notably Edsger Dijkstra. I don't care about the others that much. “Implementation inheritance causes the same intertwining and brittleness that have been observed when goto statements are overused. As a result, OO systems often suffer from complexity and lack of reuse.” — John Ousterhout Scripting, IEEE Computer, March 1998 made me chuckle ^_^ | ||
|
Frigo
Hungary1023 Posts
I'm not saying that you should force your Golden Saw on everything either, just because it is better for a particular problem than your Golden Hammer. Don't be stupid and revert to procedural programming just because OOP isn't perfect. Use the correct tool for the correct job. To do that, you need to have a diverse toolbox, and knowledge of how, when, how not and when not to use one of its particular items. And the most important rule: your best tool is your brain, you should learn how to use it. ---- “Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function.” — John Carmack Yes Mr. Carmack, except if it needs several input parameters that it passes to other functions, has repeatedly recalculated subproblems, has multiple results or we want to unit test its dependencies without actually calculating it. If any of these hold, you are better off with a Method Object. So that "sometimes" is pushing it a little bit. | ||
|
Release
United States4397 Posts
The best thing about OOP imo is readability. 1 line per anything in the main (although sometimes it is better to expand. In theory, you could have 1 line for the entire program) | ||
|
zhr
Finland12 Posts
On July 22 2013 23:40 Frigo wrote: ... ---- “Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function.” — John Carmack Yes Mr. Carmack, except if it needs several input parameters that it passes to other functions, has repeatedly recalculated subproblems, has multiple results or we want to unit test its dependencies without actually calculating it. If any of these hold, you are better off with a Method Object. So that "sometimes" is pushing it a little bit. Function is often the most elegant implementation. http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197 I like other quotes on that page as well, especially this: “The phrase "object-oriented” means a lot of things. Half are obvious, and the other half are mistakes.“ — Paul Graham This stuff is not really new (to 90-00s anyways). It is no problem to have some virtual interfaces in C for example (obviously you wouldn't have them everywhere like in java). People just have to understand that OOP doesn't solve all your problems, and overused causes lots of problems not unlike those caused by goto. | ||
|
Kiante
Australia7069 Posts
On July 23 2013 07:33 Release wrote: The cool thing about OOP is that you don't have to use it. Completely up to the programmer. The best thing about OOP imo is readability. 1 line per anything in the main (although sometimes it is better to expand. In theory, you could have 1 line for the entire program) I don't really understand what you're trying to say here. Could you flesh this out, and maybe give us an outline of your experience that makes you a valid commenter on the subject? | ||
| ||