Friday, December 23, 2022

Teaching Computer Science

I met a high school student last night who wants to go into computer science. I stopped teaching (part time) at Chapman when the twins were born because I just couldn't keep the high standard I require of myself. I put that time towards my kids. It has been a long time and two summers ago, during covid, I knew a freshman college student friend of the family who's college life had been disrupted and he was out of school for a year. In a conversation near a soccer field I had a God moment when he asked if he could apprentice on this side project I was working on. I knew how his mind worked from talking to him a number of times and decided to go for it because I knew he was a fast learner. We met on three zoom calls over the next week and I started at the beginning where I really finally learned to code. I remember it well so it wasn't hard to get him to that same place. After about 20 days of one hour zoom calls and a homework assignment, I learned the Rust programming language with him. It took another week or so. Rust was on my list and I wanted him to see how I approach learning a new language. After about 25 days since we had started I was able to give him an assignment on my side project. That code he wrote is still running in this system I've been building.

I love to teach and since that time I've been considering doing this again for a group of students. A team. I just don't have anyone to teach. Bring me four people who want to learn and I'll teach you. I might charge a small amount for my time, but it will be far less than I pay for my kids club soccer teams. I have helped college students enter this IEEE Game Sig contest. I could help a team of four submit a game for the 2023 or 2024 high school category. I'm serious. Ask me and if seems legit I'll do it. I've coached a number of winning teams in the first few years of this contest.

Tuesday, December 26, 2017

Datacap360 Channel gets 10,000 view

I started this Datacap Youtube channel at the end of 2016 and after more initial views than I expected I set a goal in July to have 10,000 views by the end of the year. The channel surpassed 10,000 views just before Christmas. Thanks to everyone for watching. I'm working on more Datacap videos and probably going to start a how to program (games focus) channel this year. https://www.youtube.com/c/Datacap360 The goal now is 100k views by the end of 2018. Merry Christmas everyone. Thanks, Wood

Monday, March 20, 2017

C# trick to launch runtime debugger

I have used this trick quite successfully many times to launch a debugger from a running application. It works really well for things that are hard to debug.  Things like DLLs that might be running under a different application, or display tasks that happen periodically and launching the application in the debugger might change the way the application runs and not cause the bug you are looking for.  It works by basically crashing the application with an exception which brings up the dialog to allow you to continue or debug.  You can have visual studio already loaded with the application and choose that instance of VS from the list.  It is a one liner that you add to your code.

So simple. In your C# code, simply add this line.

Debugger.Launch();

You can do this in any language, but I'm using c# at the moment so showing that. This is very handy.

Thursday, December 1, 2016

Mobile phone nirvana with Moto-G and Google Voice

I just went through a long process of changing phones and mobile carriers and now that I have everything lined up I wanted to publish the configuration I'm using.

First, I was on Sprint for years and used their tight integration with Google Voice. I loved it because I could make/answer calls and texts from my laptop or my tablet or my phone.  This was handy when I sat where I didn't have great mobile coverage (which was common at one cafe that I liked to work at) or was on an airplane. I would never be away from my text capability when flying which is actually quite handy on many occasions.

That said, having been a mobile developer I had a lot of reservations in moving to Sprint about eight years ago. The ease of changing a sim card to switch phones on a GSM network is a necessity as a developer. I had also been doing international travel and a GSM phone is a necessity. That was all in the past so I went with Sprint when AT&T was dropping my calls at home on a daily basis. The loss of GSM for my was by far the biggest concern though. When developing on Sprint phones (this was back in the J2ME days) we had to switch plans around to switch phones. Quite a pain. Eight years later I still missed GSM and wanted to get back. My phone, an HTC One, that I loved, was having battery life issues and my bank accounts have been strained lately. The idea of spending $500 for another phone, even if financed at 0% has always seemed absurd to me.  The Sprint choices seemed very limited at the low end.  I had heard of cheaper plans with Metro and T-Mobile as well as cheaper phones like ZTE.  In my searching I ran across the Moto-G on Amazon for $149 and used old gift cards to buy it.  I even got a 128GB microSDXC (The XC is meaningless and more about how dense it is than the fit. It seems all MicroSD cards fit the bill).  With that SD card, it means I have all my music 60GB on my phone which is the first time I've ever had that which is a bit of nirvana in itself.

Anyway, I moved my phone over to T-Mobile and completely lost my Google Voice integration. To say Sprint has the best Google Voice integration is an understatement.  No one does it better.  You can simply click a couple of buttons, turn it on and it works.  When you change your plan you have to re-set it up, but once you know that it's not hard to reconfigure each time. Overall, there is no fiddling to get Google Voice to work on Sprint.  That integration has been a life saver, but the GSM issue and the cheaper GSM phones was too much too keep me on their network.  I knew there had to be a way to get this working.

When I moved my phone over to T-Mobil it was super simple. I'm sure it would be just as simple to go to any carrier. That said, getting Google Voice to work right again was a ton of work and not well documented.  There is a "lite" integration where you get just voicemail, but that definitely wasn't going to work for me.

I kept coming up against the menu option on Google Voice to "migrate your number" to Google Voice.  This seemed drakonian and then I wouldn't have phone service, right.  Yeah, there was that, but sure enough that is what you have to do and the Google voice system doesn't do a good job of describing that process until you've already gone that route. If I move my number that everyone knows to Google Voice, then how am I going to get calls on my mobile phone?

So, the solution is that you need a new number on the carrier, no one needs to know this number.  You can get it before or after you migrate your number, but before is probably best so you can do the final setup once the migration is done.  I setup a second number on my line and had a sim-card just for that line.  I kept that sim in my pocket.  My personal number I kept in the phone so people could still call me during the migration.  That migration took about 45 hours for Google to complete, but during that time my phone worked properly and when I work up this morning I found it no longer had service.

I then swapped out the sim card, logged onto Google voice with my computer and set it up to forward all my calls to that second phone number. Done, right?  Not quite.  Everything worked with texting from Hangouts, you can't use the built in messenger because it still texts with the generic phone number, but hangouts is good when it comes to SMS.  I do wish it had a search though.

The next part was calling with the phone. I called T-Mobile and they said they could only setup the caller-id to be a different number if I was calling land lines.  This is great if the only person I call with a land line (my 80 year old dad who now has a mobile phone) actually had caller-id.  That still leaves out 99.999% of the people I called.  It was a big disappointment so I kept digging.  I found there was an actual Google Voice app and when I loaded that I found the menu item for which phone to use



If you choose to "Use Google Voice to make all calls" this will set your caller-id from this phone to be your Google Voice number.  This now works exactly like it did on Sprint with one added bonus.  On sprint my MMS messages when to the phones messenger while all my SMS messages went to Hangouts. I would invariably miss MMS messages because I wasn't always watching that other system.  I've already received one MMS photo on this new setup and that photo went to Hangouts as you would expect.

All in all, I would say I'm in phone Nirvana.  I have a very inexpensive phone with an easy to change network.  I have my Google Voice integration (not Nirvana if you like privacy because we all know that Google gives us up to the NSA, but that's another matter entirely so far the benefits out weigh big brother watching me and I'm sure Sprint gave me up to).  With Google Voice I can make calls from any computer or tablet and no one can tell I'm not on my mobile phone. The MMS system is fixed.  I'm pretty happy at this point. It took a lot of work, but I'm back to normal and better off than I was before. Now I can swap network providers and phone numbers and don't really care who they are as long as they give me a network.  It's nice to be free.

To save yourself some costs, migrate your mobile number directly to Google voice. The second number costs $20 and I messed this up. Also, I moved my phone number to T-Mobile which meant I needed a sim card for that and another sim card for that second number. It added $40 to the cost when it could have only cost $20 for the second number.  Just something to think about.

Hope this helped you.
Wood

Wednesday, August 3, 2016

Running VBScripts standalone with Command Prompt

Over the past few years I've had to do a bunch of little vbscripts to create custom actions for Datacap. Recently I found a problem with a script and a friend showed me a quick little way to run my script standalone.
Simply put the script in a file with a vbs extension and use the command line to run it with cscript command.  This was available on my default windows.  Now with my limited memory I'll hopefully remember this blog post so I can come back and 'remember' how to do it.

Now, the other issue that I haven't been able to solve is why 2.28 != 2.28.  It sure seems like a type problem, but I forced the types to Double and that didn't help.

Dim sCResult
Dim sExpression

sExpression = "(760.27 + 64.56) = 824.83"
sExpression = "(1.27 + 1.01) = 2.28"

'sExpression = "(1.27 + 1.01) = (1.27 + 1.01)"

wscript.echo(" Evaling: " & Trim(sExpression))
wscript.echo( Eval("1.27 + 1.01") )
wscript.echo( Eval("2.28") )
sCResult = Eval(Trim(sExpression))

wscript.echo("Eval returns: '" & sCResult & "' ")

sExpression2 = "CDbl((1.27 + 1.01)) = CDbl(2.28)"
wscript.echo("")
wscript.echo("")
wscript.echo( Eval("CDbl(2.28)") )
wscript.echo( Eval("CDbl(1.27 + 1.01)") )
wscript.echo(" Evaling: " & Trim(sExpression2))
sCResult2 = Eval(Trim(sExpression2))
wscript.echo("Eval returns: '" & sCResult2 & "' ")

Running VBScripts standalone with Command Prompt

Over the past few years I've had to do a bunch of little vbscripts to create custom actions for Datacap. Recently I found a problem with a script and a friend showed me a quick little way to run my script standalone.
Simply put the script in a file with a vbs extension and use the command line to run it with cscript command.  This was available on my default windows.  Now with my limited memory I'll hopefully remember this blog post so I can come back and 'remember' how to do it.

Now, the other issue that I haven't been able to solve is why 2.28 != 2.28.  It sure seems like a type problem, but I forced the types to Double and that didn't help.

Dim sCResult
Dim sExpression

sExpression = "(760.27 + 64.56) = 824.83"
sExpression = "(1.27 + 1.01) = 2.28"

'sExpression = "(1.27 + 1.01) = (1.27 + 1.01)"

wscript.echo(" Evaling: " & Trim(sExpression))
wscript.echo( Eval("1.27 + 1.01") )
wscript.echo( Eval("2.28") )
sCResult = Eval(Trim(sExpression))

wscript.echo("Eval returns: '" & sCResult & "' ")

sExpression2 = "CDbl((1.27 + 1.01)) = CDbl(2.28)"
wscript.echo("")
wscript.echo("")
wscript.echo( Eval("CDbl(2.28)") )
wscript.echo( Eval("CDbl(1.27 + 1.01)") )
wscript.echo(" Evaling: " & Trim(sExpression2))
sCResult2 = Eval(Trim(sExpression2))
wscript.echo("Eval returns: '" & sCResult2 & "' ")

Tuesday, July 12, 2016

WinForms C# ctrl-z for undo and redo

I have a personal application I built to help sort pictures. It works really well for me, but no where near commercial quality. Every so often I add a new little feature to it.  This time I'm adding undo and redo.  The control key for handling was a little different than I expected and I had to look it up so I thought I would add it for my own future reference.

        bool bUndoDown = false;

        // checking for ctrl key
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {

            switch (e.KeyCode)
            {

                case Keys.Z:
                    if (bUndoDown)
                        break;

                    if (e.Modifiers == (Keys.Control | Keys.Shift))
                    {
                        bUndoDown = true;
                        Console.WriteLine("redo pressed");
                    }
                    else if (Control.ModifierKeys == Keys.Control)
                    {
                        bUndoDown = true;
                        undodebugcnt++;
                        Console.WriteLine("undo pressed "+undodebugcnt);
                    }
                    break;
            }
        }


    private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (bUndoDown)
            {
                if (e.KeyCode==Keys.Z)
                {
                    bUndoDown = false;
                }
            }
        }

I originally thought I could get this to work with just the KeyPressed event, but had to do it a little deeper in the KeyDown and KeyUp events.

Monday, August 3, 2015

Windows 10 - IE Work around

I tried out Windows 10 at the Microsoft store a few days ago and really loved it so I installed it first chance I got time over the weekend.  I do really like the interface fixes.  I've mostly liked Windows 8 and have gotten used to the split interfaces for metro (now tablet) applications and desktop.  I've gotten used to the various touch screen gestures on my Surface Pro 3 and absolutely love my surface. Probably one of the best machines I have ever owned, but that's not saying much because usually I buy two year old machines for cheap, max out the ram and put in an SSD and limp along for a few more years.  The surface was a gift, one of the best ever, but not something I would have bought for myself.

Anyway, after the Windows 10 install everything was working well except there is one site I use a lot that requires IE and an Active X control.  The windows 10 browser is called Edge (even though the icon, a big "e" looks exactly like IE) and it will not run the plugin.  I've been trying to get the plugin to work to no avail.  I though IE had been uninstalled, but just went to try and install it and sure enough it's still there.  The site I need still works in IE so all is well again and I'm really liking the new interface.

The biggest improvement I've seen in Windows 10 is a much closer integration between the (metro) tablet interface and the desktop interface.  They mostly just look like they are one interface (more desktop than metro) and it works much more smoothly.   Well worth the upgrade and a huge improvement.

If you are looking for IE on windows 10, just search for "Internet Explorer" and it's the top hit.  Sometimes the top of the menu looked like a "header" item to me and I was ignoring it.  The top part that looks like a header is actually the closest item you are looking for.


Friday, July 24, 2015

Happy Birthday IBM BlueMix




I've written a few test applications with Bluemix over the past year and really liked the environment and capability it gives to rapidly build applications. I've also tried most of the competitive environments an this one is the best. What a great environment and year it has been. You should try it.

Friday, June 5, 2015

Datacap C# Smart Parameter parsing using MetaWord

I keep having to look up how to get a smart parameter in Datacap using both C# and VBScript. Figure it's time to leave myself a breadcrumb.

Here is the sample in C#, it comes directly from the vScanSample where I always look for it.
        public bool myact_set_folder(string sPath)      // set the folder to search for files
        {
            dcSmart.SmartNav localSmartObj = null;
            try
            {
                localSmartObj = new dcSmart.SmartNav(this);
                //If the parameter is a smart parameter, look up the actual path (returns the original path if it was not a smart parameter)
                mFolderPath = localSmartObj.MetaWord(sPath);
                RRLog.Write("Image source folder set to: " + mFolderPath);
            }
            catch (Exception ex)
            {
                RRLog.Write("myact_set_folder error: " + ex.ToString()); 
                return false;
            }
            finally
            {
                localSmartObj = null;
            }

            return true;
        }


Here is the VBScript Datacap custom action version to parse the smart parameter. This comes directly from one of my own custom actions I use for doing text searching.

   'Get the smart parameter for the FinderString
    sTmp = MetaWord(FinderString)
    If (sTmp = "") Then 'Field Value
        Set oChild = CurrentObj.FindChild(Right((FinderString), Len((FinderString))-1))
        If Not(oChild Is Nothing) Then
           WriteLog("Hostname from field")
           sTmp = oChild.Text
    Set oChild = Nothing
        End If
    End If
    ValueToSearch = sTmp
    WriteLog("ValueToSearch = " & ValueToSearch)

Hope I remember that I left myself this note here

Wednesday, April 15, 2015

c# getters and setters

I keep having to lookup the c# syntax for getters and setters.  Nothing to fancy, just figure I'll leave myself a bread crumb.


    private int iCurCell;
    public int CurCell
    {
        get { return iCurCell; }
        set { this.iCurCell = value; }
    }

Tuesday, April 14, 2015

Instantiate a prefab

I keep having to look up how to instantiate a prefab.  This is an easier place for me to look for it.

Put this as a method variable

// C# 

public Transform prefabMovePath;

Once you have that method variable in your Unity script, then you will see this.
Simply drag and drop the prefab you want to the script to instantiate to the PrefabMovePath in unity.


Since I'll probably forget that too, the way you create a prefab is pretty simple, build it up in the hierarchy/scene, then drag it from the hierarchy to the project.  It will have a blue cube icon.

Use this Instantiate code to create an instance of that prefab.

private Transform curMove;
void Start() 
{
    curMove = (Transform)Instantiate(prefabMovePath, new Vector3(0, 0, 0), Quaternion.identity);
}

Then, since that prefab has a script I need access to, use this when wanting to call code in the script that prefab is attached to.

        MovePath mp = curMove.GetComponent();
        mp.rotateLeft();

Friday, February 6, 2015

Using Unity Instantiate to create child objects

I'm building a tetris like board and was using Instantiate to create a group of tiles that were a move piece and when I moved the parent object, non of them moved.  It wasn't hard to fix, simply set the parent of the instantiated object.


            Transform ttmp = (Transform)Instantiate(goal_tile, goal_tile.position, goal_tile.rotation);
            tile.transform.position = new Vector2(
                (cellToCol(i) * tile_plain.rect.width) / tile_plain.pixelsPerUnit,
                (cellToRow(i) * tile_plain.rect.width) / tile_plain.pixelsPerUnit);
            ttmp.parent = transform;


Then in the update method, I can move the entire group of tiles like this



       Transform t2 = GetComponent();
       t2.position = new Vector3(t2.position.x + 0.005f, t2.position.y, t2.position.z);



In this case I'm getting the Transform associated with myself and adding a small amount to the x position. It doesn't do much because it just moves of the screen, but the game is getting closer bit by bit.

Thursday, January 29, 2015

Unity2D script to programatcally add a sprite

I'm create a grid of tiles. The tiles are sprites and I'm laying them out programmatically. Here is the code to generate one of the tiles.

public Sprite tile_plain; // assign this in unity by dragging a sprite to it void Start() { GameObject tile = new GameObject(); tile.AddComponent(); tile.GetComponent().sprite = tile_plain; tile.transform.position = new Vector2((i * tile_plain.rect.width)/tile_plain.pixelsPerUnit, 5f); }

Wednesday, January 28, 2015

Unity2D Screen size

Still messing with Unity 2D and wanted to make a note on now to find the screen size and the upper left coordinate. This will be something I need for every game.
using UnityEngine; using System.Collections; public class ScreenSize : MonoBehaviour { void Start() { float ScreenHeight = Camera.main.orthographicSize*2; float SceenWidth = Camera.main.aspect * camHalfHeight; // Set a new vector to the top left of the scene Vector3 topLeftPosition = new Vector3(-ScreenWidth/2, ScreenHeight/2, 0) + Camera.main.transform.position; } }

Tuesday, January 27, 2015

Unity 2D Units

I'm building a tile system to display a grid of sprits in my game. I'm old school and used to just using pixels so a 32 pixel wide sprite is 32 pixels wide. so when I do this to create a strip of sprites
(a public method variable)public Sprite tile_plain; int i; for (i=0;i<25;i++) { GameObject tile = new GameObject(); tile.AddComponent(); tile.GetComponent().sprite = tile_plain; tile.transform.position = new Vector2((i * tile_plain.rect.width), 5f);

Then only one sprite element shows up on the screen and the others, while they are there are off the screen. To do this, you have to divide by the pixels per unit identified in the sprite.
(a public method variable)public Sprite tile_plain; int i; for (i=0;i<25;i++) { GameObject tile = new GameObject(); tile.AddComponent(); tile.GetComponent().sprite = tile_plain; tile.transform.position = new Vector2((i * tile_plain.rect.width)/tile_plain.pixelsPerUnit, 5f);
This was a good Stackoverflow post (Unity 4.3 - understanding positions and screen resolution, how to properly set position of object?) on the topic.

Monday, January 26, 2015

Surface Pro 3 and Visual Studio network conflict

I've recently been using a surface pro 3 for my development.  I love it as it works great on planes and when I travel.  I had been having one issue with the network on sleep, it never returned and I had to continually reset it.  I also found that sleep had been replaced by hibernate and it took 20 seconds to come back to life every time I left it alone for a few minutes.  It turned out that Visual Studio 2013 installs Hyper-V.

This was a great explanation of the problem.
http://winsupersite.com/mobile-devices/surface-pro-3-tip-hyper-v-vs-connected-standby

I don't plan on using Hyper-V so I can turn it off. Basically I just ran a command prompt as administrator and used this command.
bcdedit /set hypervisorlaunchtype off

as this blog is mostly for my own note taking purposes, I'm going to return here if I need to run it again or I need to turn it back on

Here is how I'm going to turn it back on.
bcdedit /set hypervisorlaunchtype auto

Friday, January 23, 2015

Kids name printing

I now it's not software development, but my three toddlers are learning how to write and I found this really cool name tracing site.




Thursday, January 22, 2015

Board games for programmers

If you have a group of programmers, RoboRally is a really really fund game.  You create little five card instructuctions for your robot and send him off. Invariably, people put in bugs or run into other robots and cause hilarious effects.  I've played this many times with developer teams and everyone has fun.


Wednesday, January 21, 2015

Theory of fun

I've been revisiting this book on game design and really enjoying it. It will really help you understand what makes fun games fun.


 
Also, this book does a good job of talking about violence in video games and what it actually means. I don't know if it was in the book or not, but I remember reading this and coming up with a defense of violence in video games. Not that I condone violence, I like peaceful people, but the fact is that you can only complain about game violence if you've never played this children's classic.

.

Tuesday, January 20, 2015

How to configure a Unity project to use VisualStudio

I started a new 2D project to try and see if I could port an old game I did in Java called EmPathMe (http://www.woodsgoods.com/gaw, Good luck getting it to run).

When I went to launch a script in VisualStudio it complained there wasn't a .sln file so I had to figure it out again. I'm leaving myself this post so I don't have to figure it out again.

You select Assets/Import Package/Custom Package...
 
Then you navigate to the location where the VisualStudio Tools for Unity were installed (http://unityvs.com/). I installed them in the default location C:\Program Files (x86)\Microsoft Visual Studio Tools for Unity\2013. The debug only works well with VisualStudioPro and I have no idea how I'm going to pay for the pro version once my  That's one reason I'm setting this up so I can get the touch code working well before my trial license expires

 
Choose all the package assets.

 
Now you will have the Visual Studio Tools menu and you can generate the project files so you don't see the error about not having a .sln file when launching the Unity editor.


Monday, January 19, 2015

Unity 2D Tutorials

These tutorials on the new Unity 2D features have been very helpful.

http://unity3d.com/learn/tutorials/modules/beginner/2d/2d-overview

http://unity3d.com/learn/tutorials/modules/beginner/2d/2d-overview

Thursday, January 15, 2015

Bing rewards

I've recently switched to Bing as my search engine.  I tried it because they have a rewards program and after a few months I really don't see any difference.

Try Bing rewards, it makes search just a little more fun.

Bing rewards is running a 1,000,000 reward points give away. Sign up here.

Wednesday, January 14, 2015

Unity script referencing



I wanted my keyboard input script to retrieve a value from a grid generator script so it knew how far to move one of my game objects. It took me a while to figure it out even though it's simple so I figure it's best to leave myself a bread crumb so I don't have to search so much next time.

//this is how you get a reference and value out of another script
scriptholder = GameObject.Find("EmptyScriptHolder");
GridManager script = scriptholder.GetComponent<GridManager>();
print("Grid gap =" + script.stepsize);


This shows how to get a reference to the actual script, in this case it's my EmptyObject I use to hold scripts that are not associated with actual GameObjects.  I call it EmptyScriptHolder.  I then get the reference to the GridManager script.  This is the actual type name of the script.  Within that script is a method variable called stepsize.  Overall it's very simple to get a value out of another script once you know how to do it.

This site was very helpful even though it's documentation from a few versions back.
http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Tuesday, January 13, 2015

Hexagon grids

I'm not building a game that uses a hexagond grid right now, but have done it before and thinking about what it takes and found this great hexagon algorithm resource.

http://www.redblobgames.com/grids/hexagons/