Search ProofOfProgress Blog
Saturday, May 7, 2016
TSQL Can be done on stack overflow?
Friday, April 22, 2016
Having trouble invoking static methods in VB.net
Static Methods. AKA: "shared" in vb.net termonology. Here is the paste bin: http://pastebin.com/RC9p74sE
Update: I was being stupid. The static methods were throwing an error because I was writing the statements within the class, but NOT within a function. Fix here:http://pastebin.com/2MsCzaMm
CodeEval VB.Net Sample Code Bug Fix
Reason: The sample code for VB.NET has a typo in it. GetCommandLneArgs should be: GetCommandLineArgs
Module Challenge
Sub Main()
Dim test As String
Using fileStream As New System.IO.StreamReader(System.Environment.GetCommandLneArgs()(1))
Do Until fileStream.EndOfStream
test = fileStream.ReadLine
'test' represents the test case, do something with it
...
...
Loop
End Using
End Sub
End Module
Thursday, April 7, 2016
Entity Data Model Wizard Shortcut
Tuesday, April 5, 2016
Get Class Of Active Window AHK
So, I was reading all through the documentation looking for a:
WinGetActiveClass
Since there is a WinGetTitle
And a WinGetClass
Turns out:
WinGetClass's behavior IS to get the class of the active window.
This sample code will display the class name of the active window
when you press the enter key:
enter::
{
;theClass = class of active window.
WinGetClass, theClass, A
msgBox %theClass%
}
Friday, March 25, 2016
Friday, March 18, 2016
Close Properties Panel Shortcut Visual Studio
Close Solution Explorer Shortcut Visual Studio
Close ToolBox Visual Studio
Monday, March 14, 2016
Stood Vector
Tuesday, March 1, 2016
Delete Character
Monday, February 29, 2016
Enforce classes have same static method c++
All my classes must have a method called unitTest in DEBUG mode. This is because I don't want my test code in a separate library.
Separation of concerns is nice and all. But I think that separation also makes it more likely that your test library code will decay.
This might be what I need: http://stackoverflow.com/questions/9346076/static-template-functions-in-a-class
Basically, extend from a header-only class that defines no implementation. And have the function within that class be templated.
Something like:
public:
template< typename T>
static double foo( vector arr );
In the header, without any implementation.
Can you extend from a class with no implementation? I bet you can. Need to look into that.
Maybe I need a "pure virtual function"? https://blogs.msdn.microsoft.com/oldnewthing/20131011-00/?p=2953
But that specifies type... Do I need a "pure virtual template function"? That sounds fancy and over complicated.
Yes, you can. http://stackoverflow.com/questions/8919566/are-pure-virtual-methods-allowed-within-a-template-class
Monday, February 15, 2016
Ownership of pointers in c++ and borrow boxes
Sunday, February 14, 2016
Overload = operator c++
Are structs initialized to zero?
object lifetime of structs c++
myStruct getStruct(){
myStruct val;
return val;
}
Will the instance of myStruct be killed immediately after leaving the function scope?
Turns out, this works with structs.
Pretty sure it would not work if it were a class.
Also strange is that it seems like...
All the members of a struct are initialized?
Rather than having whatever random data was there before hand?
Or maybe I am just lucky... Might want to explicitly init values
by specifying a constructor.
+= operator overloading a struct
deathNote operator_-(const deathNote &a){
this->apples = a.apples + this->apples;
this->chocolate = a.chocolate + this->chocolate;
this->paper = a.paper + this->paper;
return (*this);
}
operator+ must take zero or one argument
struct deathNote{
uint32_t apples;
uint32_t chocolate;
uint32_t pages;
deathNote operator+(const deathNote &a, const deathNote &b){
deathNote ret_val;
ret_val.apples = a.apples + b.apples;
ret_val.chocolate = a.chocolate + b.chocolate;
ret_val.pages = a.pages + b.pages;
return ret_val;
}
};//struct
//ERROR: operator+ must take zero or one argument.
//The fix? One parameter is implied via the "this" pointer.
//WORKING OVERLOADED OPERATOR:
deathNote operator+(const deathNote &a){
deathNote ret_val;
ret_val.apples = a.apples + this -> apples;
ret_val.chocolate = a.chocolate + this -> chocolate;
ret_val.pages = a.pages + this -> pages;
return ret_val;
}
Saturday, February 13, 2016
Use structs when 16 bytes or under
✓ CONSIDER defining a struct instead of a class if instances of the type are small and commonly short-lived or are commonly embedded in other objects.
X AVOID defining a struct unless the type has all of the following characteristics:
- It logically represents a single value, similar to primitive types (int, double, etc.).
- It has an instance size under 16 bytes.
- It is immutable.
- It will not have to be boxed frequently.
I think I'll name my structs with lowercase letters.
Constant class... But things like "float", "unit" and other built-in primitive value types
have lowercase letters. So I'll name my structs with lowercase letters.
How much is 16 byes?
1BYTE == 8BITS.
ARGB pixel = 32bits. Each channel is 8Bits. AKA: 32 bit color is 4Byte color.
How many pixels in 16 bytes?
Four. (4+4+4+4 == 16)
So, think of a struct as 4 pixels worth of data or less.
Invalid use of destructor foo as type
Bad Code:
~MyClass::MyClass(){
}
Good Code:
MyClass::~MyClass(){
}
My Blog List
-
Goodbye to All That (2014)11 years ago
-
Pen To Paper13 years ago
-
Moving!14 years ago
-
-