Proof Of Progress

Search ProofOfProgress Blog

Wednesday, August 9, 2017

Duel Boot and 0Byte Flash Drive

Trouble shooting duel booting with ubuntu flash drive on Windows10 machine. Doing this so I can get the .a files from the Nvidia Cuda toolkit and take them back to windows to compile OpenCL using CGO. A bit backwards, but seems like the solution for now. http://www.tomsguide.com/answers/id-2034007/laptop-booting-bootable-usb-drive-solved.html

Tuesday, August 8, 2017

CGO GoLang - First Time

I am not sure how CGO works, but for
whatever reason I need to OMIT including
implementation files for "go build" to
work. The code I am about to post will
fail if I add ncludes, giving an error
about "multiple inclusions"
--------------- main.go (start)--------------------
package main

/*
#include "whatever.h"

*/
import "C"
import "fmt"

//:It works, but I don't know why.
//:Removed include "whatever.c" and build works,
//:but not "go run". Linker just assumes that
//:existance of whatever.h means existance of
//:a whatever.c

//:03_CG_IS_NOT_GO.pdf suggests you can do
//:a forward declaration like so in golang code:
//:func myPrint(i C.int);

func main(){
    DoFoo();
}

//export myprint
func myprint(i C.int) {
 fmt.Printf("i = %v\n", uint32(i))
}

func DoFoo() {
 C.NotWorking()
}
--------------- main.go (end)----------------------

--------------- whatever.h (start)-----------------
#pragma once
#ifndef HEADER_DOT_H
#define HEADER_DOT_H
    extern void NotWorking();
    extern void myprint(int i);
    
    // Will get linker error if you uncomment
    // this. When commented out, " go build "
    // works, but "go run" fails.
    //
    // Go build is assuming that a 
    // "whatever.c" exists, even though I
    // do not mention it anywhere.
    //
    // XXX XXX #include "whatever.c" XXX XXX
    
#endif
--------------- whatever.h (end)-------------------

--------------- dontassume.c (start)---------------
#ifndef WHY_IS_THIS_NOT_WORKING
#define WHY_IS_THIS_NOT_WORKING

extern void myprint(int i);

void NotWorking() {
 int i;
 for (i=0;i<20;i++) {
  myprint(i);
 }
}


#endif

--------------- dontassume.c (end)-----------------

File Structure:
[Folder: export_func ]
   / dontassume.c
   / main.go
   / whatever.h

(  We have a folder called "export_func"    )
(  with the files, "dontassume.c" ,         )
(  "main.go", and "whatever.h" directly in  )
(  that folder.                             )

When you CD into export_func and run
$ go build
The result is an executable called
export_func.exe.

You can then run it via:
$ ./export_func.exe

Note: I am running go 1.8.1 on Windows 10.

If I #include dontassume.c in any of the
source files, the build will fail giving
me this erronious output:
JMIM@DESKTOP-JUDCNDL MINGW64 /g/MY_GOPATH/src/bitbucket.org/JMIM/JM_CGO/TEST01/export_func (master)
$ go build
# bitbucket.org/JMIM/JM_CGO/TEST01/export_func
C:\Users\JMIM\AppData\Local\Temp\go-build112659030\bitbucket.org\JMIM\JM_CGO\TEST01\export_func\_obj\main.cgo2.o:main.cgo2.c:(.text+0x0): multiple definition of `NotWorking'
C:\Users\JMIM\AppData\Local\Temp\go-build112659030\bitbucket.org\JMIM\JM_CGO\TEST01\export_func\_obj\_cgo_export.o:_cgo_export.c:(.text+0x0): first defined here
C:\Users\JMIM\AppData\Local\Temp\go-build112659030\bitbucket.org\JMIM\JM_CGO\TEST01\export_func\_obj\dontassume.o:dontassume.c:(.text+0x0): multiple definition of `NotWorking'
C:\Users\JMIM\AppData\Local\Temp\go-build112659030\bitbucket.org\JMIM\JM_CGO\TEST01\export_func\_obj\_cgo_export.o:_cgo_export.c:(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

Thursday, July 27, 2017

Argh.

Accidentially posted all of my Vulkan notes for today in pTimeToFlash, which is a private blog to keep track of my progress. Will not make this mistake tomorrow. Add shortcut to AHK script for this blog URL.

Tuesday, June 28, 2016

LendingClub.com Account number confirmation does not match.

Lending Club Telling Me: https://www.lendingclub.com/account/externalAccountV2.action Account number confirmation does not match. When they are identical. 1 strike for lending club. Go onto prosper.com Possibly because I got account today. But then I should get an error that is either ambiguous or correct. Not false.

Saturday, May 7, 2016

TSQL Can be done on stack overflow?

http://data.stackexchange.com/stackoverflow/query/edit/483660 This will make learning T-SQL easier.

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

On CodeEval.com: Compiler error around this location, the compiler hasn't implemented the error message, nor error recovery, so the compiler will probably crash soon.
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

Can't seem to find the shortcut mapping command for: "Entity Data Model Wizard" within visual studio. I wish there was some type of "Echo all commands" in visual studio like there is in 3DSMax. Then I could see what commands were issued to open what windows. Tried getting the actual class of the window using Auto Hot Key. While it gave me some information, none of it that I could use to identify the window I want. Sucks because I know I should be able to wire this window to a hotkey. Once that window is already open though, you have a lot of shortcut options. http://stackoverflow.com/questions/23528347/keyboard-shortcuts-in-edmx-designer

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

Mixin is not Composition.

http://naildrivin5.com/blog/2012/12/19/re-use-in-oo-inheritance.html

Friday, March 18, 2016

Close Properties Panel Shortcut Visual Studio

There is a shortcut for opening the properties panel in visual studio. But there is not a paired shortcut to CLOSE IT! This is really annoying. I have shortcuts to open all of the panels I use in visual studio. But I can't use any shortcuts to close them. I get that, with a mouse, the opening is much slower than the closing... But it would be nice if we could at the very least, close the ACTIVE PANEL with a shortcut. NOT close the active document. I see the shortcuts for that. I can close all documents. I just can't close the explorer, toolbox, and properties panels with a shortcut. Really annoyed.

Close Solution Explorer Shortcut Visual Studio

There is a shortcut for opening the solution explorer. But there is no shortcut for closing it. Very annoying for someone trying to set up hotkeys!

Close ToolBox Visual Studio

There is a shortcut for opening the toolbox, but not for closing it, what gives?

Monday, March 14, 2016

Stood Vector

Stood Vector: How I heard someone pronounce std::vector on the internet. Figured one day someone might hear it, not know what was meant, and try to google it. Now there will be relevant google results.

Tuesday, March 1, 2016

Delete Character

Having Delete Be FF or 7F is pretty neat. Origins in punch cards where you could punch out all the bits on a given line to delete/ignore that line if it was a mistake. https://en.wikipedia.org/wiki/C0_and_C1_control_codes#Device_Control

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

Trying to wrap my head around ownership of pointers in c++. Trying to establish rules to make good software. Here are some ideas. 1. Only one object has ownership of any given object. 2. If an object owns another object, when delete[] is called on the parent, it should be called on the child. 3. If an object does NOT own another object, when we delete[] the parent, the other object referenced from within the parent should not be deleted. 4. Any object should either OWN every object it references, or NOT-OWN every object it references. This is to simplify it. So we know exactly what needs to be done to children when delete[] is called. 5. Don't give out references to stuff you don't own. If a class does NOT own the object, it should not be allowed to give out a reference to it. The object that wants the reference should go to the source. ANALOGY: I can't give library book to stranger. The stranger needs to go to the library to get the book I have. Not the best analogy. Since the book they get from the library would also be the book I have. Because we are talking about reference types, not value types. 6. What about classes that absolutely must own some things, but not others? Classes that need mixed ownership must have a "borrow box" or "sandbox" or whatever you want to call it. It is an object OWNED by the parent, so it can be deleted by the parent when the parent is deleted. HOWEVER, the "borrow box" container never owns anything inside it. So when it is destroyed, none of it's contents are deleted. Again, with the rule of not giving out things you don't own... Borrow boxes should never be passed around. A borrow box should not simply be a wrapper you wrap individual objects in. So that you can pass the wrapper around. That wouldn't solve the problem. It would just add another step. The borrow boxes should be taylored to each and every individual class that needs one. No other classes should know about the borrow boxes. So why even have them then? Is it simply a formality that makes the code easier to read? Is it simply a way to avoid individually flagging ownership? It seems like a good idea. But I need more time to think about it. Is it worth the extra -> jump every time you need to reference it?

Sunday, February 14, 2016

Overload = operator c++

I thought I had it... Now all the sudden I am getting the error: error: conversion from 'uint32_t {aka unsigned int}' to non-scalar type 'deathNote' requested... what did mess up??? Solution here: http://www.tutorialspoint.com/cplusplus/assignment_operators_overloading.htm Though I noticed I am having trouble using it with initialization and assignment all in the same line.

Are structs initialized to zero?

Research says that you shouldn't rely on this. Best to include a parameter-less constructor that zeros out all of the member values. The only downside being that it's not longer a POD type by C standards.

object lifetime of structs c++

I know when you want to return a class instance from a function you need to use the new keyword and assign it to a pointer. Is it the same rule for structs? I want my structs on the stack, not the heap. So I'd like to not mess with pointers. But I am afraid doing:
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.