Sunday, October 18, 2015

Millisecond Timer

   So a while back I discovered that windows can't do microsecond accurate timers (at least not in a straight forward way). Windows is not real time operating system so events are triggered differently for different computers. There are ways like the MicroLib I found on the internet a while back but it is very resource hungry using up almost 100 percent of one of my cores. This is because it is essentially polling a stopwatch and seeing if the number of ticks is equal to or greater than the specified Tick which is calculated per computer. I have tried to modify it to be less resource hungry but my attempts failed. I recently found some code which utilizes the windows multimedia api to achieve a more accurate millisecond but it was only accurate down to the millisecond and cant achieve for example 16.7 milliseconds. I then thought hey I can put the two together. This millisecond timer can achieve closer to the specified millisecond like 16.7ms which is the duration of a frame in a 60FPS game. Now this isn't perfect but I'd think this is as good as it gets (for me its exactly what I needed). If there are better methods/alternatives please comment or if you have any suggestions or improvements.

Code (VB.NET):

Sunday, September 6, 2015

Transparent JPG

[Update 7] TransparentJPG.Dll quality default is now 80 and smoothing default is now 20. Progressive mode for the JpegEncoder is enabled potentially resulting in smaller file sizes. TransparentJPG has an added parameter for subsampling detail level. Options are 0 low (Default), 1 (medium), 2 (High). 2TJPG.exe has the added parameter as well.

[Revert 1] Changed back to using the LibJpeg.Dll. Smoothing is available again. Updated source below as well as the download and Latest Builds. The source for the version that is not reliant on LibJpeg.Dll will still be provided for reference.

[UPDATE 6] Removed the dependency for the LibJpeg.Dll which means that smoothing feature which helped save some space is now gone :( . I did so because I was given a 6Kx4K image to convert to TJPG and the converter (2TJPG.exe) kept crashing. I debugged it and found that LibJpeg was the problem. I am guessing that lib doesn't support images with such large resolutions? Either way I had to address the issue so I went and resorted to using Microsoft's built in encoder. It is slightly faster now due to not implementing the smoothing feature but file sizes will be slightly larger. The below has also been updated and contains (2TJPG.exe, TJPGviewer.exe, TransparentJPG.Dll). So essentially encoding will be different but decoding stays the same. The converter has also been updated in that it no longer supports the "Smoothing" parameter.

[UPDATE 5] Changed the color of the background squares of TJPGviewer.exe to a lighter shade(Grey) as well as made them 3x3 instead of 4x4 making them look less obtrusive.

[UPDATE 4] Optimized the code for saving TJPGs as well as removed all dependencies to LockBitmap.Dll(Removed from package). Also removed the CType to Byte() since it seemed redundant to the Decode method. Also provided SRC to TransparentJPG.DLL below.

[UPDATE 3] Changed the default values for conversion tool to quality=75 and smoothing=25. Also added a Decode method in TransparentJPG.Dll to get the pixel data, width and height of TJPG file. Also cleaned up the LoadTJPG function so that it doesn't rely on the LockBitmap.Dll though other things still need it, I will get to them soon.

[UPDATE 2] Fixed an issue with the converter (2TJPG.exe) where it would error and crash when given file paths that are valid and saying they aren't. Fixed version is provided in the "Latest Builds" link below.

[UPDATE 1] Added averaging when applying the mask to make the other bits of the alpha "useful" as well as provide a bit of compensation for rounding errors that jpeg compression might have. This has no impact on the encoding and only the decoding so file sizes are not affected though there is technically an impact on the resulting image visually it isn't noticeable and so negligible.
Moved all newer builds to a new location so people can grab this independent of the package I provided below:
Latest Builds:

     While working on my game I needed a way to import images and in my game people can share these images among each other via P2P. These images are almost always going to be grouped with tens if not hundreds, if not thousands of other images so I needed to pick an image file that is small in size. My next requirement was that the images needed to have transparency as a capability. Jpeg while small in size isn't capable of transparency. PNG has transparency but is much larger in size due to it being a lossless format. Another requirement was it needed to be compatible, I needed to work with an already existing format that most computers already know how to use so it wouldn't add time and complexity over compatibility. There exists much better solutions today but they are all either proprietary or there are no libs for them in use for .net which I need.

     I first thought hey I'll just take the pixel data from an image and limit it to 6 bits per channel then compress the whole thing which gave rise to a format I called TZI. While TZI proved to be a more acceptable format to my game than PNG I thought why don't I try a lossy attempt.

     I looked at Jpeg and I already knew the complexity behind its compression so I wasn't going to mess with the inner workings of Jpeg. Instead I thought of a hack about way to add transparency as another level on top of Jpeg. I did this by simply creating a mask via the images Alpha channel. I then removed all transparency from the image. The mask was then appended under the original image (with the alpha turned off). What you get then is an image with no transparency on top and a greyscale image of the Alpha channel on the bottom. I couldn't stop there, people randomly running into this image and viewing it as a typical Jpeg would be confused and the image shown isn't even in its intended form. And so I had to change its header so that people don't mix it with Jpeg files (even though this is essentially what this is). To reconstruct the original intended image I made an application which views the TransparentJPG files.

     The image is loaded in memory. The alpha mask is applied and then the image is essentially cropped to half its height. There is actually more detailed aspects going on behind the scenes and the workings is a bit different from how I explained it but I figure just a gist of how it works is good enough and easier to understand.

Code (VB.Net):

Code-not LibJpeg.Dll reliant (VB.Net):

Converter and Viewer Tools:


Now because of the added height as well as the transparency bit the images will never be smaller than their original non-transparent JPG version (with the same quality etc).

    Here is an exact representation of an image with its header unchanged after the mask has been generated:

    Intended Image:

    Here is another example of how the images are encoded without the header change:

    Intended Image:

Friday, August 14, 2015


[UPDATE 3] Removed the unnecessary function ClearBits() and its calls to result in >3x performance increase on adding bits (benchmark times updated).

[UPDATE 2] Changed out arithmetic operators for bit-wise operators as well as omitting the use of Math.Floor for a result of ~20 percent speed increase in setting bits (benchmark times updated).

[UPDATE 1] Fixed a bug where the 8th bit added is always set to True(1).

I previously made a class called TBitArray with the purpose of storing individual bits. At the time I didn't know that .Net already had a BitArray class which I could use so I made mine. I then thought well if I have an array I might as well make a list version as well. At the time I never got around to it. Then time passed and I started work on my encoding schemes. I needed to store bits that would resize as needed but I was lazy and instead stored each bit as a byte (yeah waste of space I know). This time I am working on a potential image format for my game. For this format everything is encoded and decode by bits and so again I needed something that would resize as needed. This time though I actually got to working on it. I know that one can resize the BitArray that is built into .Net but I did some benchmarks and well its VERY slow. So with speed and dynamic size in mind I set out to create a BitList class to make my life easier for this and potentially future projects. And I am sharing it here for those who may want to use it. I will provide the benchmarks first to show the difference. If anyone has any suggestions please leave a comment :)

As you can see BitList is much faster at adding bits when size is unknown and where size needs to be changed dynamically.
If you know exactly the number of bits needed please use the built in BitArray instead as you can see it is much faster at setting bits.

This class was made for my purpose of adding bits and not the constant manipulation of bits in memory. So if you need to constantly add bits this might be for you. The bit manipulation implemented is only for light use as it is slower than bit manipulation with BitArray, though slow it is still reasonably fast. Just use it where appropriate is all I'm saying.

Note: This class only implements the functionality that I myself needed, it does not provide other functionality that a typical List(Of T) has. If you need them you may implement them yourself or I might add this when my needs apply. I guess this is much closer the a queue then a list but too lazy to rename it lol. I could have also used a BitArray to store the lookup table but anyone who wants to do that is free to.

Code (VB.Net):

Saturday, August 8, 2015 with keyboard support

So my little brother's friend found this 'mod' for but he didn't know how to use it. I took a look and it linked to some survey site which automatically if anyone knew anything about these things online and running into surveys etc... its all crap. So instead I decided to make an app that allows one to play with keyboard.


Info: made in .NET via VB. Uses E, S, D, F for movement, and R to enable/disable keyboard movement support (and shows/hides the mouse cursor).

Saturday, August 1, 2015

Cleaning up a Yamaha PSR-310 keyboard

So I recently got a used keyboard because I wanted to learn piano eventually. The one I got was very dirty and there were scratch marks, the keys were stiff as well as stuck, and the lowest C key didn't even work. I thought hey lets clean this up and thus started my overnight project (started at ~12:30AM).

First I had to disassemble the keyboard of course:

The thing was nasty inside:

Is that semen?

There was a bit of rust

So I got to sanding

The membrane was nasty as all hell, cleaned it with a dirty shirt, I think it has to go in the trash now

SOOOO much better :)

Rubber pads are nice and clean as well

Now to get to the keys

As you can see its pretty nasty on the outside too

Black keys are cleaned though still wet

Put the membrane back into the keypad frame

Placed the rubber pads on aswell

Now to address the original issue, Time for some lube

Lubed highest key and first key pair and assembled

Onto the second




Finally placed the key assembly back into the keyboard enclosure

Consequently the lowest C key now works AWESOME lol. Completed ~5:30 AM.

I used soap, bleach, and alcohol as cleaning solutions.
Cotton swabs for fine cleaning and lubricating.
Regret using toilet paper to clean, as well as using my dirty shirt.

Thursday, May 28, 2015

[Release] JSXviewer 0.5b source

I don't know if I will ever get back to this but I decided that the program should be open a while back. It didn't really get that much attention and no one looked into improving/changing/rewriting/finishing/etc it. So I will post here in case people didn't know. The src is in and isn't commented as much as it should but here it is, do with it what you will lol.
Please if you have any suggestions or other feedback let me know in the comments.

Tuesday, April 21, 2015

[Planned] XwitchBot3

    Welp I haven't worked on/updated XwitchBot2 in forever but I do want to get back to it but I don't think anyone is using the plugin system to the extent I wanted, I don't think anyone besides myself has made any plugins for it. I don't plan on removing the plugin system or anything like that, if anything I want to expand it even more. I will be planning on potentially a third version of XwitchBot, one that is hopefully more polished then XwitchBot2. Now this is planned, whether or not it will ever be completed is another matter completely as I will be working on this in private if/when I am. I just wanted to say that I have been thinking about how XwitchBot's development has been, or lack thereof and wanted to stop neglecting it lol.

    Of course every reversion of XwitchBot has had a GUI overhaul and I think XwitchBot3 will be no different in that it too will most likely get a GUI overhaul. I'm picturing something similar to steam's UI but its not concrete yet a concept. There are other features that I think will benefit XwitchBot like possibly implementing some form of scripting. I don't know if I will be using an already available language or Frankenstein my own if I do plan on implementing one, of course implementing an existing one sounds much more practical.

    While this will be a reversion many aspects will be reused from XwitchBot2 just like how many aspects of XwitchBot2 were from XwitchBot. Things like I said the plugin system are there to stay, and the TwitchAPI from XwitchBot2 will still play a big part. I don't know what this blog post will ultimately amount to if anything but it's just ideas that I have been thinking about and of course if this comes to fruition XwitchBot3 is free, and will always be free like its always been.

UPDATE 8: Just another screenshot after fixing some UI alignments with some actual channels

UPDATE 7: Worked on the UI for each channel, some things are working now, still need to move several things around and implement others. Added donate button and home button that will eventually link to XwitchBot3 page but here is what it looks like so far:

UPDATE 6: Redoing the UI. It will be similar to XwitchBot2 versions but with adjustments to accommodate the new features. It isn't complete but much has been done. Currently it can connect to Twitch, Login using OAuth, Join channels. It cannot display messages or send them yet.

UPDATE 5: Got multichannel fully implemented and working, it also keeps track of the users in each channel. Added several MessageTypes for ease of plugin creation. Added proper parsing of initial twitch userlist (irc 353) and also added a type to tell the bot when the userlist ends (irc 366). Bot can only see registered users in the chat so the number of people shown on the bot vs the number of people on the stream will differ. Added MessageType (irc 421) for unknown commands so the bot notifies the user of any mishaps. Added parsing for originating channel of a message because the bot now has to keep track of messages from multiple channels. I will be implementing the ACTION aka /me MessageType and also the Points system as well as the AccessLevel system (differently levels have permissions to do different things). I also plan on slightly modifying the UI but only slightly since V2 UI is good enough.

UPDATE 4: Worked a bit on the YoutubeRequest class again. Added a bit more of the iframe API, I don't think ill add anymore of the API. Added a check for songs that don't start. Once a song is set to be played, and failed to start playing within 5 seconds the song will be skipped and the next song will be set to play. The duration to wait and see if the song starts can be changed (in milliseconds) in the constructor. There are 2 added events to the YoutubeRequest class. A polling event which presents the player's status such as song duration in seconds, the percentage of the song thats been buffered, the current position in seconds of the song, if the video is muted, and the current song's volume, as well as the current players state (is it playing, paused, etc), this polling is triggered every half second.

UPDATE 3: Well I will be changing some changes from UPDATE 2. In UPDATE 2 I planned on having the IRCclient be able to have multiple instances meaning each IRCclient establishes its own connection to the twitch server. I originally thought that because twitch's IRC is broken it couldn't join different channels through just one connection. From the website each tab I'd imagine creates a new connection and so I went to do it that way. Today though I remember a few of my friends who use HexChat to connect to twitch chat and I think I remembered them saying they can connect to different channels and so I went and tested. I can indeed connect to different and multiple channels. So I will be changing the bot in that respect. There will only be one instance of the IRC client again but It will be modified to handle multiple channels. I have also improved the message buffers and made the Message Structure simpler. The UserList is now moved inside of the IRCclient Class (it cant manage multiple channels yet, but will get to it). Because the PONG reply to PINGs is always the same (PONG I made it so that it replies only that and removed all parsing of the PING messages. When a PING is received a predefined byte array containing (PONG will be sent. Added more exception handling. Date/Time of messages in timestamps are set when the messages are received compared to previously where the Date/Time were set when the message was displayed in the chat. Sent message structure also has Date/Time now instead of setting the time when the message is displayed (this might be more accurate but timestamps might be out of order when displayed, I might change it back to how it was depending on how it turns out).

UPDATE 2: Reworking the core of the bot today. I made the IRCclient for the bot more robust. Put the message formatter (made because twitch's IRC protocol is broke as all hell) inside of the IRCclient class so that each instance of the IRCclient has its own formatter. Put the received message buffer and sending message buffers inside of the IRCclient class so that each IRCclient instance has its own buffers for the ability for multiple instances of an IRCclient (for multiple connections ex: connecting to multiple channels). Each IRCclient instance will have their own configuration (Server, Port, Channel, Nick, OAuth, etc). UserList parsing will also be available to each IRCclient instance so that it doesn't bunch users from all channels. Going to be moving the IRCclient class to Core class so plugins can access the IRCclient class (instead of making their own, which is a waste of time). Added PONG priority which will hold off on sending normal message so that PINGs are replied with PONGs sooner than later. Will be making a base class for the plugins interface so instead of implementing the XBPlgn interface, you inherit the XBextension class (you can still implement the interface if you want). Will be adding a database to the core of XwitchBot to keep records of things for the bot and for plugins as well (if needed). There will only be one instance of the database so that there is no conflicting records between plugins and the bot itself.

UPDATE 1: Worked on YouTubeRequest. Made a new class that implements more of the youtube player iframe API. It can play, pause, stop, seek, set volume, get duration and get the buffered percentage. I plan on reworking the plugin interface, and move the plugin system out of the bot and into the points system I will be implementing. The flow looks like this:
That way people can decide which plugins require points to use without programming each plugin to do so. I do plan on a UI overhaul but haven't yet thought of anything concrete.

Tuesday, March 10, 2015

Quick and Dirty .Net BigDecimal Implementation

[UPDATE 8] Added Conversion, Constructors, Comparisons, Operations for types Short, UShort, Byte, SByte.

[UPDATE 7] Added Ceiling, Floor, Truncate functions as well as fixed the Mod function. Added Ctype to/from byte arrays.
[TODO 3] Implement a BigDecimal rounding function that can round to a specified decimal place.

[UPDATE 6] Added a Random function which returns a random BigDecimal number with the specified number of significant digits.
[TODO 2] Fix modulus of negative numbers.

[UPDATE 5] Fixed constructors for Decimal, Double, and Single as arguments.

[UPDATE 4] Providing the new source code below.

[UPDATE 3] I rewrote the entire thing and improved the speed by ~5x to 10x. Removed all string manipulation hacks for calculations and added several other things for ease of use in code. I compiled it to a dll for ease of use.
Reference the BigDecimal.Dll,
     "Import TizzyT"
     Optionally you can also "Import TizzyT.BigDecimal"
     Dim bigNumber as BigDecimal = "51316561513854163416165416163163165613.1473415424496255785965457458965348754854856"
     Dim bigNumber as New BigDecimal("51316561513854163416165416163163165613.1473415424496255785965457458965348754854856")
The constructors accepts these types as the parameter:
String, BigInteger, Decimal, Double, Integer, Long, Single, UInteger, ULong.
Supported Operators: /, *, -, +, ^, Mod, =, <, >, <=, >=, <>
There are no BitWise operators.

[TODO 1] Add e constant calculation function and Phi calculation function. Add pre-calculated values to the first 65535 digits for Pi and e (and other constants in the future) for fast lookup and only calculating when needed. Fix potential rounding issue in the divide function. Support parsing and simple calculations with imaginary numbers. Raising to decimal powers.

[UPDATE 2] Added Pi function which (calculates Pi to the specified decimal place).

[UPDATE 1] Added square root function (calculates the square root to a specified decimal place).

    Now many of us I'm sure have gone to Wolfram Alpha and have done some calculations and get very precise answers. I thought why cant I just make a calculator that runs on the computer instead of relying on a website. The problem here is that I typically write in .Net and as far as I know in .Net there isn't yet a BigDecimal implementation though I hear something called Rational Number will be in the future (correct me if I'm wrong). .Net as of 4.5 does include BigInteger though and I figured "hey I can surely manipulate that to do decimals". So by playing with powers of 10 and some string manipulation I threw together this quick and dirty BigDecimal implementation. It does most of the basic arithmetic operations (add, subtract, multiply, divide) and also includes modulus and a limited power operator (only decimals to integer powers allowed).
It also has most of the basic comparison operators (=,<>,>,<,>=,<=).

     I didn't implement a way to do powers (exponents) of decimal numbers to decimal numbers as I don't know of any way to do arithmetic that are to the power of a decimal number. This is one of many things Wolfram Alpha and other tools are still useful for. I did however add a power operator where you can raise a decimal number to an integer power. Again this was a quick and dirty implementation by use of an already existing BigInteger and some string manipulation so this is more of a workaround then a full and proper implementation. With all that said this works as it is intended and I just thought I'd share this for those who want to have such capabilities and/or not want to make their own or use one that others have made (for what ever reason). Below is the source in, feel free to critique it constructively or even suggest improvements/additions/corrections/other changes (they are always welcome) in the comments, even link to other/better implementations for others to learn from (including myself lol).

     Here is a brief and simplified explanation of how the operators work (take note of the number of digits after the decimal places, trailing zeros after the decimal are omitted).
How Addition is done:
     ex: 2.5 + 3.56
     250 + 356 = 606
     606 * 10^-2 = 6.06
How Subtraction is done:
     ex: 3.56 - 2.5
     356 - 250 = 106
     106 * 10^-2 = 1.06
How Mulitplication is done:
     ex: 1.23 * 2.34
     123 * 234 = 28782
     28782 * 10^-4 = 2.8782
How Division is done:
     ex: 2.75 / 1.23
     27500 / 123 = 223.5772...
     223.5772... * 10^-2 = 2.235772...
How Modulus is done:
     ex: 81.913 mod 1.89
     81913 mod 1890 = 643
     643 * 10^-3 = 0.643
How Powers is done:
     ex: 3.86 ^ 3
     386 ^ 3 = 57512456
     57512456 * 10^(-2 * 3) = 57.512456

Here is an example of what this BigDecimal can do:

Wolfram Alpha would show:

This will give:

New Source:

Old Source:

Free for non commercial use. All changes to source must be provide here.

Sunday, February 15, 2015


Here is a little app that will help rename files with the wrong or missing extension by getting its signature. You must know the signature before hand and the extension you wish to append to the file.


The program relies on a file called "sig.txt" to know what extensions and signatures to name and look for.
The format of the list is {extension}={signature}.
example for a .zip file: "zip=504B0304" without quotes.

 ExtensionBySignature.exe [Input Directory(s)]
 ExtensionBySignature.exe /n [Input Directory(s)]

 Every session is saved in a log upon completion.

 /n , /N = NonDestructive mode (files will not be renamed but the log file will stay the same)

Note: Multiple input directories can be used, just make sure to space them from one each other and use quotes where appropriate. If a file already has an extension and the program is going to rename it, the new extension is appended to the end (keeping the old extension in the file name) for future reference in case knowledge of what the previous extension used is needed.


Wednesday, February 11, 2015


Well here is something to kinda parse the syscon communication (not everything is parsed). It sorts out the packets and is able to output read and write operations to a file.
Apparently these dumps may contain the QA token and so be very careful with those files.


PS: Brought about by zecoxao's request for the parser.

Tuesday, January 20, 2015

XMB Wave

     Here is a XMB wave video that I edited from the original to look a bit better (imo) and also to higher the resolution (1080). It might be used for video backgrounds or something, I just thought I'd leave it here.


Here is the original to which I edited:

1) This is the Blue XMB only.
2) The blue is more subtle than the one from the original video.
3) Made the sparkles smaller.
4) Wave is sharper.
5) Banding is corrected.

Thoughts about original video:
1) The video is a lower resolution then I would have liked.
2) The banding was pretty bad.
3) The video is not truly seamless but instead it kind of looks seamless (actually an overlay where 2 wave states are similar).
4) Bit rate was too low hindering the overall quality of the video (to be expected due to it being used for Dreamscene so I guess it's understandable).

Wednesday, January 7, 2015

Project Euler Problems

     The same friend of a friend that got me motivated to make the SudokuGen also showed me this website with these challenge problems and since I have nothing to do these days and am bored anyways, I thought I'd start solving them.


     One of my friend's friend (I just met him recently) shared some code with me which turned out to be a Sudoku puzzle generator in Java. I don't really know or like Java but it gave me motivation to try my hand at making my own. My algorithm is different from his and I don't really know much about Sudoku generation but enough trial and error and my method works pretty well now. The one big difference from what his has and mine doesn't is backtracking, mine just retries from scratch if it hits a dead end. After improving my algorithm a bit I then went to tackle adding backtracking but that was giving me more of a headache then it should've so I just gave up lol. After this one I have learned a bit and I might plan on making another one using a slightly different algorithm but it should allow me to implement backtracking easier.

As always leave any feedback or suggestions in the comments

Got around to commenting my SudokuGen code (VB.Net) and modified a couple things as well:

Finally here is the source to my Sudoku puzzle generator (VB.Net/Java), on my computer it generates 1000 Puzzles in about 45 seconds, it is by no means fast but fast enough for practical purposes I imagine.

Here are 1000 Sudoku solution outputs :

Tuesday, November 18, 2014


   I looked around on the internet to see if there was any way for me to store individual bits in an array. The BitArray class exists but it states that it uses booleans to represent bits. I then went to look at how large booleans are. MSDN says it varies and on several threads the size ranges from 2-4 bytes. I haven't done any testing to see how much the actual size of booleans when used in the BitArray class but I went a head and threw together this TBitArray class anyways. Bits are stored in a byte array but each bit in the array is given an index instead of each byte given an index. 8bits = 1byte array, 9bits = 2byte array, 16bits = 2byte array, 17bits = 3byte array etc...

As always this might not be the best approach or implementation, if you have any issues or suggestions please leave a comment.

Sunday, October 12, 2014

XwitchBot2 [BETA] Release

This is the BETA release for XwitchBot2. It implements most if not all intended functionality (at least ones I remembered). Plugins will come slow and the Raffle plugin included is a dummy plugin to test plugin system. If any issues are found please comment.

Only the ZIP file is needed.

UPDATE - Oct 14, 2014:
Fixed a bug in Chat menu option not reverting to dark gray.
Fixed a bug in the plugins selection menu that causes crash.
Fixed a bug in several basic twitch IRC commands that causes crash.
Fixed a bug in plugins command processing that causes crash.
Fixed a bug preventing application from closing properly when expected.
Corrected message username to display "XwitchBot" instead of the current Nick when expect.
Added Restore option to system tray icon.
Added Command Line Argument to set bot's OAuth.
Added Command Line Argument to set owner's OAuth.
Added Command Line Argument to set server.
Added Command Line Argument to set server port.
Added Command Line Argument to auto connect.
Added Functional "Retarded" plugin, with dummy UI.
Changed Title name to state "Nick" and "Channel".

To make plugins use the Core.dll although this is only BETA the Core.dll might change before final version (though unlikely).
Here is a screenshot:

Here is a basic starting point for making a plugin:
Start a new project.
Select Class Library.
Create a new User Control in the project, call it UI.
Set the Size property to 842, 488.
Lock the control.
Add a Panel to the form.
Change the Panel's Dock property to Fill.
In the <YourPluginName>.vb file follow the below example

Sunday, August 10, 2014

McCollough Effect

Made a little program because I got bored. It induces the McCollough Effect.
While the wiki says you should look at each image several seconds at a time it didn't specify so I just used 5 seconds intervals.
You will first be shown a black and white image with horizontal and vertical grating for 10 seconds. You will then be shown a red with horizontal grating, then a green one with vertical grating each being shown for 5 seconds for a total of 3 minutes. The same black and white image from the beginning will be shown again at the end. If the Effect was successful the image should look slightly different now.
To exit the application at any time press escape.
PS: The application runs in full screen.


Thursday, August 7, 2014


Here is an application requested by Ada and maybe a few other on IRC. At first I didn't want to do it since I am lazy and didn't know anything about it. After they linked me to the page I thought I can do this though I cant test etc. I eventually started it and here is the completed app (though I personally never tested but Ada has tested and says its working). It generates a GVD file used for PlayView on the PlayStation3 and possibly other devices.

PS: Thanks Ada for explaining the GVD structure etc.

Download for those on XP :

Usage: Normally run the executable and follow onscreen
             Drag image into CMD when asked.

             Running the application and the image as argument also works

             Generated GVD will be created in the same directory as the source image.

             Images must be 3840x2160 for now, might make custom later.

As always if you have problems or suggesting please leave a comment.

Tuesday, June 3, 2014

XwitchBot2 Started

Update: Starting over. I goofed and messed up the bot lol but not all is lost I can bring over many of the things from this version. I will be working slowly to ensure no memory leaks and no UI hangups occur. I will also improve on the plugin system giving it more control etc.

For those still using XwitchBot, I am working on XwitchBot2 at the moment. I will post updates on its progress here. The idea is that XwitchBot while pretty functional in itself lacks some capabilities and making plugins is easy but not extremely easy. The UI could also use some work.
 Core = DONE
 Plugin interface = DONE
 Chat UI = DONE
 UserList = DONE
 Options UI = DONE
 Plugins UI = DONE
 Donation UI = DONE
 About UI = DONE
 TwitchAPI = DONE
 IRC component = DONE
 Plugin Manager = DONE
 MessageProcessor = DONE
 Greetings = Redone ~95%
 ProgrammableKeySupport = DONE
 InChat Basic Twitch Commands = DONE
 Timestamps = DONE
 OAuthGeneration Helper = DONE
 ....if more components are added I will update this list including their progress.
The percentages here indicate how close a component is to intended functionality and not an indication of completeness.

UPDATE 8/11/2014
Thought I would upload a video showing what the bot is like at the moment. Its not complete but its very close to it. So here is a video of it doing its thing:

Welp thats that, should be done soon, if me getting kicked out doesn't get in the way.

UPDATE 8/10/2014
Separated the bot and core for use with plugins and implemented the plugin manager.

UPDATE 8/9/2014
Removed the Staff and Admin lists in chat (find them unnecessary).
Fixed random disconnect (had the close events in the paint event handler :P, put it in the mouseclick event now)
Added a reconnect feature just in case of the connection is cut (will not work if internet connection itself is lost or unavailable)
Made the Setup page only show upon start up (no more disconnect feature)
Forgot to mention I implemented all basic IRC commands available to twitch (/timeout /ban etc)
Cleaned up some things.

UPDATE 7/23/2014 (much done today)
I got to DONE status for many of the components on the list and progressed further in some others as well.
Currently working on improving the IRC component though. It's still 100% functional so its DONE status will remain as it. I am making it more robust and processing received messages. I will also be removing the staff and admin areas in the chat as I find them unnecessary.

UPDATE 6/26/2014 (IRC component in place and tested):

UPDATED UI, It is far from complete but here is a sample of the working UI thus far:

[OLD]Well the bot is nearing completion and here is what it looks like for those curious:

Friday, May 30, 2014

Custom OAuth

If you are logged into Twitch/Justin an OAuth will be generated for that account. To ensure nothing goes wrong check
Twitch/Justin or simply go and logoff, you will be asked to login to the account you want to generate an OAuth for.

user_read: Read access to non-public user information, such as email address.
user_blocks_edit: Ability to ignore or unignore on behalf of a user.
user_blocks_read: Read access to a user's list of ignored users.
user_follows_edit: Access to manage a user's followed channels.
channel_read: Read access to non-public channel information, including email address and stream key.
channel_editor: Write access to channel metadata (game, status, etc).
channel_commercial: Access to trigger commercials on channel.
channel_stream: Ability to reset a channel's stream key.
channel_subscriptions: Read access to all subscribers to your channel.
user_subscriptions: Read access to subscriptions of a user.
channel_check_subscription: Read access to check if a user is subscribed to your channel.
Note: chat_login will be part of the scope.

While working with the Twitch API I noticed that scopes are like the creditials an access card has. At first I figured any generated OAuth key should have complete access to my own room (channel) but I was sadly mistaken. An OAuth key must be generated with the specified creditials and this is absolute. So comes the next task, how do I go about generating OAuths with the proper/needed scope? The most common and known OAuth generator only generates OAuths for IRC login for chat with only the scope "chat_login". I thought is there a way to modify this generator so that it will request a new key with the added scopes. I looked on the documented page and it states that you can specify the scope in the URL. I went back to the generator and load and behold at the end of that URL was "&scope=chat_login". The TwitchAPI documentation says I can add scopes seperating them with a plus sign "+" and so I tested it. I changed the end of the url to "&scope=chat_login+channel_subscriptions" because getting subscription info was my main goal at the time. I pressed enter and it gave me a new OAuth. I checked the new OAuth with the twitchAPI to see if it had indeed the scope I needed.

If you look at line 14, as you can see the needed scope is indeed there. Mission accomplished lol. The next thing I want to do now is make it easy for people to create their own custom OAuth key using the existing key generator. I do not know of an existing easy to use method of making OAuth keys and so I will present my own here.
Finally here is the code snippet of the OAuth generator used here (HTML + JavaScript):

Friday, March 14, 2014


   I was asked to make a bot for twitch and so I did. It is called Xwitchbot (pronounced switch bot). I wouldn't call it a very good bot personally but it works. It provides some message handling, and is plugin based. Included is a single plugin that I made called Raffle2. As the name implies its used to hold raffles on twitch chats. To make plugins for this bot simply implement the interface "Globals.dll".

XwitchBot Files:
XwitchBot Download:

Plugin Interface:

Keep in mind that this is the first ever plugin based application I have ever made so it might lack some common practices etc. I am also mostly self taught and the implementation might not be optimal. All in all it works and I just wanted to share.

The system is as follows. The main application loads the plugins in a pool of shared resources. That pool holds the IrcClient, message handler, and plugins as well as plugin resources. The IrcClient, MainUI, and PluginManager/Messagehandler are all on separate threads. Plugins can be on their own separate threads too if they are made so.

Here are some signatures and their description of the functions available in Globals.dll to make creating plugins easier.

Public Shared Function GetToSend() As String
Returns the first element in the list of messages to be sent to the server, and removes it from the list.

Public Shared Function GetRecvMsg(Optional ByVal RemoveOnGet As Boolean = True) As String
Returns the first element in the list of messages received by the server,
if RemoveOnGet is true remove the message from the list.

Public Shared Function GetConsoleMsg(Optional ByVal RemoveOnGet As Boolean = True) As String
Returns the first element in the list of messages to be shown as output,
If RemoveOnGet is true remove the message from list.

Public Shared Function ParseMessage(ByRef sourceInfo As Message, ByVal Input As String) As String
Returns a string replacing all fields with their respective information. sourceInfo is the Message where this function will get the required information from.

Public Shared Sub AddResource(ByVal newResource As Resource)
Adds a new Resource to the pool of resources.

Public Shared Sub AddResource(ByVal newResourceOrigin As String)
Adds a new Resource to the pool using a name.

Public Shared Sub RemoveResource(ByVal Origin As String)
Removes a Resource from the pool with the specified name (Origin)

Public Shared Sub RemoveResourceAt(ByVal index As Integer)
Removes a Resource from the pool at the specified index location

Public Shared Sub AddResourceElement(ByVal ResourceIndex As Integer, ByVal Type As String, ByVal Name As String, ByVal Value As Object)
Adds a resource element  to a resource in the pool at a given index location. Type, Name, and Value as specified.

Public Shared Sub AddResourceElement(ByVal ResourceOrigin As String, ByVal Type As String, ByVal Name As String, ByVal Value As Object)
Similar to the other but instead adds a resource element to a resource of a specified name (Origin)

Public Shared Sub RemoveResourceElementAt(ByVal ResourceIndex As Integer, ByVal ElementIndex As Integer)
Removes a resource element givent a resource index and the element index.

Public Shared Sub RemoveResourceElement(ByVal ResourceOrigin As String, ByVal Name As String)
Similar but removes a resource element with a specified name at the resource with the specified Origin

Public Shared Sub SetResourceElement(ByVal ResourceIndex As Integer, ByVal ElementIndex As Integer, ByVal Value As Object)
Given a resource index and a resource element index, change the value of the element.

Public Shared Function GetResourceElement(ByVal ResourceIndex As Integer, ByVal ElementIndex As Integer)
Returns the value at a specified resource element index at a resource index

Public Shared Sub AddToSend(ByVal msg As String)
Adds a message to the list of message to send to the server

Public Shared Sub AddToRecv(ByVal msg As String)
Adds a message to the list of messages that are received by the server

Public Shared Sub AddToConsole(ByVal msg As String)
Adds a message to the list of message that will be shown on the output

Public Shared Sub SetCurrentChan(ByVal newChan As String)
Sets the current channel the bot is in "Does NOT actually change the channel is in, used for message handling"

Public Shared Function GetCurrentChan() As String
Gets the current channel the bot is currently in "Does NOT actually get the channel the bot is currently in, used for message handling"

Public Shared Function GetResourceIndexOfOrigin(ByVal Origin As String) As Integer
Returns the index of a resource of a given name (Origin)

Public Shared Function GetElementIndexOfName(ByVal Name As String) As Integer()
Returns the resource index and element index for an element with a specific name

Public Shared Function GetElementIndexOfName(ByVal ResourceIndex As Integer, ByVal Name As String) As Integer
Returns the index of a resource element in the resource at the specified index

Public Shared Sub StopPluginManager()
Stops the plugin manager built into the bot and is used by default.

Public Shared Sub StartPluginManager(ByVal Owner As String, ByVal Server As String)
Starts the plugin manager built into the bot and is used by default.

Public Shared Sub StopConnectionClient()
Stops the IrcClients connection to the server

Public Shared Function StartConnectionClient(ByVal Server As String, ByVal Port As String, ByVal Nick As String, ByVal Channel As String, ByVal Pass As String, ByVal JoinMsg As String) As Boolean
Starts the IrcClients connection to a server, the return boolean indicates a successful or failed connection attempt.

The plugin must implement 3 things:
    ReadOnly Property Name() As String
    Function ProcessMessage(ByVal InputMessage As GlobalResources.Message) As Boolean
    Sub Config()

Messages are sorted into 2 types:
1) PRIVMSG (private message that is properly formatted in a way this bot can understand by default)
2) NS (non-sense/not-supported)

NS messages are not discarded, they are passed to all plugins (unless a plugin stops the chain) just like every other message, the difference is their type will be NS and a plugin would have to manually process that message in its raw form.

Messages that have been processed have a structure of the following:
    Public Structure Message
        Dim Type As MessageType
        Dim Nick As String
        Dim User As String
        Dim Host As String
        Dim Target As String
        Dim Message As String
        Dim Owner As String
        Dim Server As String
        Dim Raw As String
    End Structure

Message is where the message itself (what the user specifically send) is stored.
Raw is the message exactly as it was received by the bot with all heading information intact.

ResourceElements have the following structure
    Public Structure ResourceElement
        Dim Type As String
        Dim Name As String
        Dim Value As Object
    End Structure

Resource has the following structure
    Public Structure Resource
        Dim Origin As String
        Dim Resources As List(Of ResourceElement)
    End Structure

Here is the starting source for making a plugin:

For a complete source of Globals.dll :

Here is the source to my Raffle2 Plugin:

Source for UserList plugin:

And finally my horrible source for the bot itself:

As always if anyone has any issues or improvements please leave a comment :)