Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, October 28, 2013

Fun with EXCON

I took a bit of time to revisit a fun script I wrote some time back.  I felt it was time to improve on this and build a full parser and encoder using TCL.  Scripting is such a great way of manipulating and playing around with strings.  TCL is my natural choice at the moment.  So the final script I ended up is this.

This will accept a file path and attempt to read the contents.  It will print the output on stdout and can read a long list of EXCON instructions or encode ASCII text into EXCON.  One note on the parser code (which is just the old script).  It will always clear the binary buffer after every line.  The script also does not support the fancy ! instruction call to simply print out the binary value in the buffer by the previous command.

Sunday, September 8, 2013

TCL and the Blasted Dates!

So, I've had a programming task to do on TCL that involves things that I don't normally use.  This one was basically to take the first Sunday of a specific Month and Year.  After some time of researching and testing, I figured it out.  This entry is just for archival purposes.

% clock format [clock scan {Sunday} -base [clock scan "2013-05-01" -format {%Y-%m-%d}] -format {%A}] -format {%Y-%m-%d}

Base sets the base time for clock and the format for the return can be tweaked to whatever you want.  It's also worth taking note that -format parameter on clock scan only works on TCL 8.5 and above.

Sunday, May 19, 2013

Mono Journey Update

I've been pinging ideas to one guy I know who's knowledgeable in .Net and he brings up a good point. Porting the methods function by function into C# won't do the job because .Net and Win32 API are just very different beasts.  Instead he advised me to look into the code and discard the platform invokes.  I think I may do just that.

Wednesday, May 15, 2013

Dabbling on Mono and SyntaxBox

My friend and I were working on a few programming projects on the side and he spoke about his sources being in .Net.  Ugh.  Okay, I guess that makes Mono my only option.  And, unfortunately, SyntaxBox, the control he's using, isn't really 100% managed code.

So, what I did was pull in the mono packages that I would use.  I didn't know what to apt-get, so I just got these:

sudo apt-get install mono-xbuild
sudo apt-get install monodevelop
sudo apt-get install mono-gmcs

These seem to get most of the stuff including the soft debugger.  Then I installed subversion to checkout the source.  I also poked at previous efforts on getting it to run on Mono.  Correcting the cases is just the start of it and I got to the exact same crash point.

Looking at the source code for this crash: System.EntryPointNotFoundException: GetDC made me realize that the code was depending on a bunch of Windows dlls for its Native functions.  There's a slew of them, but all of them can be found on NativeMethods.cs.  If I'm going to have any chance of porting this, I'd need to write the code for these.  (Wonder if Wine's implementation gives clues...)

There's a first time for everything, and I always wanted to dabble in Mono.  Should be interesting.

Sunday, March 17, 2013

Python scripts crashing with setLocale?

There are instances when I get Linux servers that have misconfigured locales and I don't have time to really fiddle around and fix these issues.  So I get these python scripts crashing out on me like with this locale.setlocale(locale.LC_ALL,'') and going locale.Error: unsupported locale setting with no real solution in sight.

One way to move forward is to do:

export LC_ALL=C

Tuesday, February 19, 2013

VIM tip

Coding using vim?  Once the syntax highlighting goes bonkers, type in... :e

Sunday, January 6, 2013

Reading Oracle Exception Errors

Something I've never really been accustomed to is deciphering Oracle's cryptic feedback.  Those OCI_NO_DATA errors are downright frustrating, but at least I know better now.  Always have exception handlers (exception when no_data_found) your blast triggers.  And learn how to read Oracle's line numbering!


Saturday, December 1, 2012

*UPDATE* Star Wars: The Old Republic - Free to Play - Script Helper

*UPDATE*
The script has been updated to handle multiple running SWTOR processes.  The launcher was updated to also run the server side process that runs the game (although it still freezes on the splash screen).  This update will get the appropriate SWTOR.EXE process' arguments and terminate the running copy.

I wrote a bash script that will help with those pesky arguments when getting the game to run on Wine.  Run the launcher, and click Play.  Then run the script and copy the arguments.  Paste it on Play on Linux and then enjoy the game.  The script is quick and dirty.  As usual, no explicit warranty.



Wednesday, June 20, 2012

POSIX Thread Memory Leaks.

For years, I've been hunting down some nasty memory leaks in the applications I've been using.  The code for the most part is inherited and I haven't been able to wrap my head around it.  This latest discovery though after reading some documentation and code has given me something to chase.

Tracking down memory leaks from multi-threaded applications is a nightmare, but I'm seeing some rational logic behind it now based on this IBM article on POSIX threads.
And I quote:
If you create a joinable thread but forget to join it, its resources or private memory are always kept in the process space and never reclaimed. Always join the joinable threads; by not joining them, you risk serious memory leaks.


Well, I'll be damned!

Thursday, June 16, 2011

Programming 101 Note

I've had the displeasure of having to sift through someone else's code and trying to fix some really serious kinds of bugs that has spawned from very, very poor programming practices. I've dealt with this code structure many times in the source and I just really want to vent out.

Code like the one below should not be tolerated at all times.

try {
//some code here.
} catch { }

Please, if you're a programmer, DO NOT DO THIS!

Tuesday, February 15, 2011

Git sucks...

For a while I've been using cvs and then moved to subversion for my programming needs. Two years ago, give or take... the team I work with decided to move to Git and it's been a love/hate relationship ever since.

For the most part, every time I try to use git's much praised branching abilities have been met with tragic consequences. For the past year, I've kept an ultra conservative work style with git that has worked for me for the most part.

Lately, I've been trying to expand the work to use more of git and like always, it's been a real pain. This much touted feature on branching has always, and I emphasize always, lead me to conflict resolutions even if the files I have a conflict to resolve does not involve any of the commits from other programmers. As the branch I create get more complicated, the more time I spend trying to merge the work I do with the current code snapshot. This is utterly stupid.

It does not end there. Git seems to literally drop what it's doing when coming across errors while moving to a new remote branch creating a totally weird branch snapshot. I've had years worth of commits disappear in the source tree I'm working on leaving me wondering what the hell just happened. Then I have to roll up my sleeves and try to fix the mess that git left behind.

Git works when I am just trying to code something and commit. Anything else, it's been a tragic mess. Git sucks... for me.