Search found 718 matches

by Sc4Freak
Sat May 21, 2011 11:32 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

Just use Boost. It's a header-only library so if you don't want people to go download Boost then just copy the headers you need and include them in your project.
by Sc4Freak
Fri May 20, 2011 12:15 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

So does anyone else when they go into a code file to make a change make their goal to add the minimum number of code lines possible? Or even better refactor the internal stuff to reduce the number of lines while still making the change? I always feel good about it when I run the final diff and I cu...
by Sc4Freak
Sat May 14, 2011 4:50 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

"gooey"
by Sc4Freak
Sun May 01, 2011 7:22 am UTC
Forum: Coding
Topic: c++ closures
Replies: 15
Views: 2965

Re: c++ closures

handle_connection is a non-static member function, so boost::bind needs an object of type Server to bind it on, eg.

bind(&Server::handle_connection, this, sock)

You should also use the using directive to reduce the number of namespace qualifiers, because that's almost unreadable as it is.
by Sc4Freak
Sun May 01, 2011 3:15 am UTC
Forum: Coding
Topic: c++ closures
Replies: 15
Views: 2965

Re: c++ closures

Unless you're using C++0x and have access to lambdas, the only easy way of doing it is to copy the necessary data into a struct and pass it to your handler.
by Sc4Freak
Fri Apr 29, 2011 11:21 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

RT: Does anyone else find it hard to code on anything but the tools you're accustomed to? Yes. These days I use C# mostly, and I use Visual Studio 2010 as my IDE. VS+Resharper gives me context-sensitive syntax highlighting, realtime code analysis, autocompletion, and refactoring tools. My tools mak...
by Sc4Freak
Fri Apr 29, 2011 11:17 pm UTC
Forum: Coding
Topic: Running C# visual 2010 Express on a mac?
Replies: 10
Views: 4226

Re: Running C# visual 2010 Express on a mac?

Dropbox isn't going to help much if he can't access the internet from Windows. :P
by Sc4Freak
Thu Apr 28, 2011 11:56 pm UTC
Forum: Coding
Topic: Help with OpenGL
Replies: 17
Views: 2465

Re: Help with OpenGL

Learn to use it with C++, it's more fun that way. Also, for whatever reason the complexity of your average OpenGL program, for me at least, is much easier to deal with in C++ than C#. Apparently C# doesn't even have multiple inheritance! It's fairly widely understood that multiple inheritance is ge...
by Sc4Freak
Thu Apr 28, 2011 1:39 pm UTC
Forum: Coding
Topic: Help with OpenGL
Replies: 17
Views: 2465

Re: Help with OpenGL

I have two recommendations: 1. Learn C. If you don't understand C, you can't efficiently code for OpenGL. Knowing C well will even improve your C# programming. You should read this article . If you read that article, don't forget to also read the thousands of comments which basically crucify the au...
by Sc4Freak
Tue Apr 26, 2011 11:13 pm UTC
Forum: Coding
Topic: C# auto-implemented properties
Replies: 5
Views: 1203

Re: C# auto-implemented properties

It's because you can break client code by changing a public field to a public property. Consider the following: class Foo { public int Count; } void Mutate(ref int count) { ++count; } Foo f = new Foo(); Mutate(ref f.Count); If you change Count to a property, this code will fail to compile. There are...
by Sc4Freak
Tue Apr 26, 2011 1:10 am UTC
Forum: Coding
Topic: How do you code a "Secure Delete" [C++]
Replies: 11
Views: 3895

Re: How do you code a "Secure Delete" [C++]

You seem to think this can't be done, but there are programs to do it, (As someone noted, Eraser) I was just wondering how to incorporate that into my own program without calling a third party exe. And they don't work . On an SSD that doesn't support TRIM, there is no way to perform a secure-erase ...
by Sc4Freak
Mon Apr 25, 2011 12:25 pm UTC
Forum: Coding
Topic: How do you code a "Secure Delete" [C++]
Replies: 11
Views: 3895

Re: How do you code a "Secure Delete" [C++]

Short answer is "you can't". Not in a reliable way that works 100% of the time, at least. On Windows: files exist on a filesystem. Filesystems are contained in a volume. Volumes exist on one or many partitions. Partitions sit atop physical devices. And physical devices live on the actual h...
by Sc4Freak
Mon Apr 25, 2011 8:01 am UTC
Forum: Coding
Topic: Is Common Lisp inherently slow or is it just my environment?
Replies: 12
Views: 3696

Re: Is Common Lisp inherently slow or is it just my environm

Dispose can be used for releasing managed resources, too. You're thinking of finalizers, which should only be used to release unmanaged resources. For example: class Foo : IDisposable { public Foo() { MobileDevice.Hibernate += HibernateHandler; } void HibernateHandler(object sender, EventArgs e) { /...
by Sc4Freak
Sun Apr 24, 2011 10:33 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

There are cases where you want the break to happen somewhere in the middle of the loop rather than at the beginning or end. while(true) { string x = get_input(); x.to_lowercase(); if(!valid(x)) break; frobnicate(x); } string x = get_input(); x.to_lowercase(); while(valid(x)) { frobnicate(x); x = get...
by Sc4Freak
Sun Apr 24, 2011 5:03 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

It's probably undefined. The draft standard I have on hand says: §9.4.2 If a static data member is of const integral or const enumeration type, its declaration in the class definition can specify a constant-initializer which shall be an integral constant expression (5.19). In that case, the member c...
by Sc4Freak
Sat Apr 23, 2011 11:39 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

Because in general, you want to keep syntax to a minimum. There's no point introducing a new language keyword (which might conflict with existing identifiers in people's code, by the way) when it doesn't really provide anything useful. A "forever" keyword doesn't save you any typing, doesn...
by Sc4Freak
Sat Apr 23, 2011 12:08 am UTC
Forum: Coding
Topic: Inherit from an int
Replies: 5
Views: 1152

Re: Inherit from an int

size64_t doesn't really make sense. The standard says that size_t must be large enough to hold the size of any array (or something like that). Practically this means that size_t is 4 bytes on 32-bit systems and 8 bytes on 64-bit systems. A hypothetical "size64_t" would have no use on 32-bi...
by Sc4Freak
Fri Apr 22, 2011 6:32 am UTC
Forum: Coding
Topic: Intentionally making compile time long
Replies: 40
Views: 7108

Re: Intentionally making compile time long

Well what do you actually want this application to do? #include <Windows.h> int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBoxA( NULL, "Welcome to WinMain", "WinMain", MB_OK); return 0; } This'll pop up a message box th...
by Sc4Freak
Fri Apr 22, 2011 6:05 am UTC
Forum: Coding
Topic: Intentionally making compile time long
Replies: 40
Views: 7108

Re: Intentionally making compile time long

Yes. In Windows there are two types of applications: console and Win32*. Console applications automatically spawn a command prompt when they run; Win32 applications do not. If you're using Visual Studio, you have a choice of which you want when you create a new project. If you go to File > New > Pro...
by Sc4Freak
Wed Apr 20, 2011 2:41 pm UTC
Forum: Coding
Topic: Intentionally making compile time long
Replies: 40
Views: 7108

Re: Intentionally making compile time long

std::cout << c.prev.prev.value << std::endl; // Should print 98[/code]To compile this, the compiler has to generate 101 separate classes (as creating "c" means creating all 101 total objects, all of different classes). Now, this will still probably compile pretty quickly, given optimisati...
by Sc4Freak
Sun Apr 17, 2011 3:06 am UTC
Forum: Coding
Topic: Why don't ALL computer programs have customizable controls?
Replies: 25
Views: 3547

Re: Why don't ALL computer programs have customizable contro

Software engineering is far more than simply writing code. What about design? Testing? QA? Internationalization? Maintenance? Every feature has a cost that extends beyond the mere effort required to write the code to implement it, and you must dedicate your time and resources wisely to maximize your...
by Sc4Freak
Sat Apr 16, 2011 2:02 am UTC
Forum: Coding
Topic: A compilation of best programming practices ?
Replies: 17
Views: 4344

Re: A compilation of best programming practices ?

Advice about how static members / methods should be avoided at all cost :? how goto/break are the devil incarnate :? In a language like Java/C#, methods should be static unless otherwise necessary. If you don't need an instance to call a function, then making the method static limits the amount of ...
by Sc4Freak
Sat Apr 16, 2011 12:04 am UTC
Forum: Coding
Topic: Why don't ALL computer programs have customizable controls?
Replies: 25
Views: 3547

Re: Why don't ALL computer programs have customizable contro

The answer to these sorts of questions is always invariably the same: because there's no demand for it, or the engineering resources required to implement it don't exceed the benefit. Every feature takes time, money, and resources to implement. You have a limited development window, in which you mus...
by Sc4Freak
Thu Apr 14, 2011 8:06 am UTC
Forum: Coding
Topic: Macro Ethics
Replies: 17
Views: 2899

Re: Macro Ethics

Because saving ten measly keystrokes is not a valid reason to be sacrificing the safety, maintainability, and readability of your code.
by Sc4Freak
Fri Apr 08, 2011 11:49 pm UTC
Forum: Coding
Topic: How bad are singletons?
Replies: 24
Views: 3661

Re: How bad are singletons?

Example . . . In a game, there should only be 1 Physics engine running. ...Why? A physics engine is exactly something that shouldn't be a singleton. It's not an error to have more than one physics engine running. A possible use case might be to separately simulate two different "worlds" i...
by Sc4Freak
Thu Apr 07, 2011 10:18 pm UTC
Forum: Coding
Topic: How bad are singletons?
Replies: 24
Views: 3661

Re: How bad are singletons?

A singleton isn't where you just happen to have one instance of a class. It's when a class enforces the fact that there will only ever be a single instance. To write a singleton, you have to do extra work to ensure that only a single instance is ever created. But if you don't need to limit yourself ...
by Sc4Freak
Thu Apr 07, 2011 10:55 am UTC
Forum: Coding
Topic: C++: Instances of Functions
Replies: 20
Views: 1977

Re: C++: Instances of Functions

Short answer: you can't. Almost every well-designed callback will have some way to pass user data to the callback (usually in the form of a void*). But since glutKeyboardFunc doesn't provide this, and since it takes a function pointer (instead of a templated function object like you see in the C++ s...
by Sc4Freak
Thu Apr 07, 2011 4:58 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

In Python, I believe that assignment never "copies", it only binds a name to an object. Things like integers appear to have "value semantics" (as opposed to "reference semantics") because they're immutable. But since lists are mutable, you can use the variable "a&q...
by Sc4Freak
Wed Apr 06, 2011 11:02 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

I guess svn might be compressing the files, but I don't know if it does that by default.

And svn stores a bunch of stuff in the hidden .svn folders when you check out. These folders contain caches and metadata, so if you want to revert your working copy you don't need to contact the server.
by Sc4Freak
Tue Apr 05, 2011 8:51 am UTC
Forum: Coding
Topic: C++: Instances of Functions
Replies: 20
Views: 1977

Re: C++: Instances of Functions

CEGUI

Don't try to write your own GUI library unless you have to. GUIs are notoriously hard to get right. CEGUI is popular, stable, and extensible. Not much point trying to write your own.
by Sc4Freak
Sun Apr 03, 2011 12:37 pm UTC
Forum: Coding
Topic: Question about GPL
Replies: 1
Views: 569

Re: Question about GPL

You don't need to do anything, unless you decide to distribute your code (in which case you'll need to release it under GPL). You don't generate and distribute a binary for your website code, and the HTML pages served by your code are "output" rather than "derivative works".
by Sc4Freak
Fri Apr 01, 2011 11:20 pm UTC
Forum: Individual XKCD Comic Threads
Topic: 0880: "Headache"
Replies: 158
Views: 44810

Re: 0880: "Headache"

Depends on your browser. Running buttery smooth in IE9. It was unusably slow in FF3.6 for me; FF4 might be better.
by Sc4Freak
Tue Mar 29, 2011 11:56 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976792

Re: Coding: Fleeting Thoughts

Because not all of us enjoy using an outdated form of user interaction from the 70's, and prefer to use a development environment that is more than just a fancy text editor. It depends on your circumstances and the type of work you're doing, but for languages like C#, Java, and C++, using a real IDE...
by Sc4Freak
Mon Mar 28, 2011 4:59 am UTC
Forum: Coding
Topic: C++: Instances of Functions
Replies: 20
Views: 1977

Re: C++: Instances of Functions

This is probably the most encapsulated solution I think you might have that the other way around. :P Inheritance is the strongest form of coupling that's possible in C++ and in terms of breaking encapsulation, it's second only to friend classes. If you just want to print something when your button ...
by Sc4Freak
Sat Mar 26, 2011 9:34 pm UTC
Forum: Coding
Topic: C++: Instances of Functions
Replies: 20
Views: 1977

Re: C++: Instances of Functions

Boost.Signals2 #include <iostream> #include <boost/signals2.hpp> using namespace std; using namespace boost::signals2; void FooHandler(int a, int b) { cout << "FooHandler: " << a << " " << b << endl; } int main() { signal<void (int, int)> fooEvent; fooEvent.connect(FooHandler); ...
by Sc4Freak
Sat Mar 26, 2011 1:48 am UTC
Forum: Coding
Topic: Hexidecimal translations
Replies: 6
Views: 987

Re: Hexidecimal translations

Fastest would probably just be to use a lookup table. unsigned char lookupTable[256] = {0}; // initialize lookup for(char c = '0'; c <= '9'; ++c) lookupTable[c] = c-'0'; for(char c = 'A'; c <= 'F'; ++c) lookupTable[c] = c-'A'+10; for(char c = 'a'; c <= 'f'; ++c) lookupTable[c] = c-'a'+10; inline uns...
by Sc4Freak
Fri Mar 25, 2011 3:00 am UTC
Forum: Coding
Topic: Prank Code
Replies: 40
Views: 6542

Re: Prank Code

Code: Select all

#include <stdio.h>

#define SIX 1 + 5
#define NINE 8 + 1

int main()
{
    printf("6x9=%d\n", SIX * NINE);
}

Outputs:

Code: Select all

6x9=42
by Sc4Freak
Wed Mar 23, 2011 2:10 am UTC
Forum: Religious Wars
Topic: Mіcrosoft Platform Vs. All
Replies: 111
Views: 19173

Re: Mіcrosoft Platform Vs. All

Indeed. UAC is closer to sudo than anything else. For security reasons, certain actions (eg. modifying system files) requires administrative privileges. UAC allows a standard user to temporarily grant himself administrative priviliges by entering in the username/password of an administrator account....
by Sc4Freak
Mon Mar 21, 2011 11:07 am UTC
Forum: Religious Wars
Topic: PC != Windows
Replies: 190
Views: 135611

Re: PC != Windows

The AMD Opteron is an x86 CPU, so I don't think you'll see any benefit from installing an OS compiled for a RISC architecture. :P I think AMD processors are RISC with some kind of translation for x86. I am not sure whether or not the core RISC is accessible, regardless. Apparently CISC and RISC are...
by Sc4Freak
Mon Mar 21, 2011 11:03 am UTC
Forum: Coding
Topic: Most horrible program you've written recently
Replies: 2
Views: 1141

Re: Most horrible program you've written recently

I know it's made in jest, but you shouldn't embed paths into your programs like that. :P If you want to open a URL, you should use the ShellExecute function and pass it your URL: ShellExecute(NULL, "open", s.c_str(), NULL, NULL, SW_SHOWNORMAL); Not only do you not hard-code in paths (since...

Go to advanced search