Chatinator for Twitch.tv

I wanted to learn C# and .NET. I sat and thought for a long while what project I could do that would keep my interest long enough to produce a result others would actually use. I took a break from brainstorming to watch one of my favorite twitch.tv streams, Wyld. He ran a giveaway on his chat using one of the current bot tools out there. The winner was chosen at random from the chat and posted to the chat. Problem was there was so much traffic in the chat that most people did not see the winner. Then it came to me, there are no good programs to display results from chat polls, giveaways, and the like on stream. So I sat down and started working on Chatinator for Twitch.

Everything related to it can be found on GitHub Project Page
The installer can be found on my blog page for Chatinator

Creating Life – A study into HTML5 Canvas, Webworkers, and Life Simulation: Part 1

Let me start off, I am no pro in any of the following you are about to see. I have spent the past few weeks trying to learn about HTML5 and some of the cool new things its brings. First off, you can see a demo of all my work on GitHub.io. I should tell you right now, I think it will only function on chrome. I know there are some styling issues on Firefox and the last time I tried running it in firefox it didn’t run at all.

All of the source code can be viewed an GitHub. Please feel free to clone the project and see what you can figure out on your own.

So what is it? Well, its a pond with 4 map types. Empty (dark dark blue), resources (dark blues and purples), materials (lighter blues and purples), and organisms (green and red). The organisms can either be producers (green), or consumers (red). Producers convert resources to materials. Consumers eat the materials. There are 3 type of each resource, and 3 types of each material. Each resource converts to exactly 1 corresponding material, and each organism will only desire 1 type. Producers are designed to work together, sharing resources and materials in a simple attempt to keep the entire pack alive. Consumers are greedy, not caring at all about the heard in general. Each mitosis that occurs has a chance of mutation. Mutations change color as well as a variety of attributes about that organism.  Some configurable options include goal resources on board as well as organism spawn rates.

The application which runs the simulation is separated into three primary pieces. The UI, the worker, and the drawer. The UI is the master controller. It start, stops, and communicates with the webworker. It asks for data from the worker, and when it receives a reply, it renders it to the screen as well as passes it along to the drawer. The Webworker does all the heaving lifting. This includes processing the flow of the pond, the spawning of resources, and the life and death of organisms. Anything pertaining directly to the pond other than the rendering is done in the webworker. The drawer does the canvas drawing. This includes the pre and post filtering.

The first technical aspect I want talk about is how I figured out how to quickly send >25000 datapoints from a Webworker to the UI Thread. In order to do this, we can not use any of the classic javascript types. Objects, arrays, strings, ints, and floats all are copied (duplicated) on each message. This is fine for small bits of data, but for a huge dataset, this can add significant overhead, especially since we want to send this data as many possible times per second as our renderer can handle (On my PC, this is about 12-13 FPS). In order to not have a full copy occur we must use one of the transferable object types. One of these types happen to be a type compatible with ImageData. The following snippet of code shows both how a large array of data could be converted to a transferable datatype, transferred from the webworker to the UI, and then quickly applied to the canvas. For sake of simplicity, I am only showing relevant code to this idea, without any of the other application logic and organization.

Next Time I will talk about in depth the different flow algorithms that are implemented so far, as well as a couple that are up and coming.

Extracting the icons from an EXE in PHP on Linux

For a project I am working on I wanted to add the ability to see an EXE’s built in icon file in a web application. I am running a Debian Linux / PHP5 stack and figured out a way to extract a png out of a Windows EXE. To accomplish this I am using icoutils to extract an ico file from the exe, then search for the target size icon I want and extract a png from that ico file. The script is commented and should be pretty easy to understand and edit to fit your needs. Help with icoutils can be found on the wrestool and icotool man pages. The gist is below:

jQuery.flipper: A jQuery plugin for retro clock-like animations, and more!

After a little bit of searching around on the web for a javascript solution to create a flip-down animation for a clock a wanted to build, I decided to build my own. I started from this flip-down clock animation css3 example/test page. I have a github repo here which documents all the options and usages. I also have two examples, one that demonstrates all the options and one that shows off the queueing feature.

Again, Important links:

Please feel free to clone the repo and make your own transitions, or maybe improve upon my current transitions.

TPM: Ticks Per Minute PHP Class

I have been writing a couple PHP CLI scripts, some that are long running. I wanted a simple way to keep a running average of how many times certain actions were taking place. In comes TPM. A very small and simple class that keep tracks of “ticks” per minute for you.

Hope you find it useful!

Perl Script to automatically put emails into a MySQL Database

I have written/highly modified a perl script to take piped in emails and insert them into a MySQL database. I accomplish this by having my MTA pipe them to this script. You can download the script from this Github Repo, or you can download it directly from here.

This script requires that you have Perl installed with the following Modules:

  • DBI
  • Email::MIME
  • Email::Address
  • HTML::Strip

To use this script, first replace the following items in the script:

  • _DATABASE_ The name of the Schema/Database
  • _SERVER_ The host of the MySQL Server. ex: localhost, 192.168.0.10, etc
  • _USER_ The user of the MySQL database
  • _PASSWORD_ The password of the MySQL user

Place the script on your server and make sure it is accessible and executable by your MTA. Set your MTA to pipe incoming emails to this script. That should be all that is needed.

GitHub Repo: https://github.com/mrkmg/email2mysql
Original Script: http://www.blazonry.com/perl/mail2mysql.php

Chive Project Debian Package

I put together a .deb to install the Chive Project MySQL Administration Package automatically. It is based off of the phpMyAdmin deb package. I have made a github project for the deb package.

Installation is simple.

  • Download the “chive1.1-0.deb
  • From the terminal, run
    sudo dpkg -i chive1.1-0.deb
  • In your preferred browser, navigate to http://localhost/chive

Important Links.

Cronic, fixing excessive cron emails

Earlier today I found a very very useful program to help cut down in the massive amount of spam system administrators receive from cron emails. I decided to create a simple installer for it. Check out cronic at http://habilis.net/cronic/. To install automatically to your system, just run this command as root.

wget https://mrkmg.com/install_cronic.sh -qO - | sh

There is no error checking in the installer, use at your own risk.

 

install_cronic.sh for your reference if you do not want to trust running a shell script from the internet.

#!/bin/sh
mkdir /tmp/cronic
echo "Downloading Cronic from habilis.net"
wget http://habilis.net/cronic/cronic -qO - > /tmp/cronic/cronic
echo "Installing Cronic into /var/local/cronic/cronic"
mkdir -p /var/local/cronic/
cp /tmp/cronic/cronic /var/local/cronic/cronic
chmod 755 /var/local/cronic/cronic
echo "Linking Cronic into /usr/bin"
ln -s /var/local/cronic/cronic /usr/bin/cronic
echo "Cronic is installed and ready to be used. Checkout"
echo "http://habilis.net/cronic/ for more information."
echo "Installer created by Kevin Gravier <[email protected]>"

Simple Floating Clock for Linux CLI (tclock)

I found a very nice and easy to use script to place a floating clock on your CLI in linux.

wget https://gist.github.com/raw/2713194/cb9eb0426dc81f3411c7bb2e592963378bb3b2d7/tclock.sh
chmod 755 tclock.sh
./tclock.sh&

I also made a simple installer

wget https://mrkmg.com/install_tclock.sh -qO - | sh

Update to AxelFE, no more console

Quick update to AxelFE, no more console! Everything is now contained and run in the GUI. Check out the new version. https://mrkmg.com/?page_id=79