Author Archive
Why is the amount of text I can type in my combo box limited by its width?
by CyberShadow on May.26, 2010, under Random
Once in a while you’ll stumble upon a combo box which doesn’t allow you to type past the right edge of the control. When normally typing more text would just scroll the contents, you’ll just get back an annoying beep. The amount of text you can enter is actually bound by the on-screen width of the text – thus, you may be able to enter 125 “i” characters, but only 25 “W” characters.
The cause of the problem is that the combo box was not created with the CBS_AUTOHSCROLL style:
- CBS_AUTOHSCROLL
- Automatically scrolls the text in the edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is allowed.
Visual Studio’s resource editor has a different name and description for this property:
- Auto
- Automatically scrolls text to the left when the user types a character at the end of the line.
The perfect experience / level curve
by CyberShadow on May.16, 2010, under Code
I was recently tasked to create a required-experience-per-level table for a game – that is, create a table which indicates how many experience points the player must earn to progress to a certain experience level. The requirement to reach the next level must continuously increase (the “double derivate” must be non-negative). Of course, it is easy to come up with a function to satisfy that requirement alone, but what about generating a level curve that’s also aesthetic? I mean, it’s much nicer to look forward to reaching 15000 points than, say, 16384.
So, I wrote a small program to attempt to generate experience ranks with the following properties:
- Continuous acceleration
- Smoothness (calculated as “roughness”, using the sum of squares of the “triple-derivate”)
- Roundness (100 is more round than 150, 150 is more round than 160, 160 is more round than 165 etc.)
- Emphasis on the roundness of the last level
The qualifying factor here is smoothness vs. roundness. (continue reading…)
Setting shared Google Talk / Gmail status programmatically
by CyberShadow on May.08, 2010, under Code
There are a few ways to programmatically set the Google Talk / Gmail status via XMPP, however they have some problems if you are signed in into the same account with Google Talk or Gmail chat:
- You need to keep the program running – otherwise, the status will revert when the connection is closed;
- Other logged-in applications will not see the status change.
Enter Google’s Shared Status Messages XMPP extension. Here’s a short Python script which uses the extension to set the status from the command line (needs xmpppy):
#!/usr/bin/env python
USERNAME = "thecybershadow" # don't include @gmail.com
PASSWORD = "hunter2"
RESOURCE = "gmail.com"
import sys
if len(sys.argv) < 2:
print 'Usage: python gstatus.py <show> [<status>]'
print ' <show> is either "default" or "dnd"'
print ' <status> is the status string (optional)'
exit()
import warnings
warnings.filterwarnings("ignore") # silence DeprecationWarning messages
from xmpp import *
cl=Client(server='gmail.com',debug=[])
if not cl.connect(server=('talk.google.com',5222)):
raise IOError('Can not connect to server.')
if not cl.auth(USERNAME, PASSWORD, RESOURCE):
raise IOError('Can not auth with server.')
cl.send(Iq('set','google:shared-status', payload=[
Node('show',payload=[sys.argv[1]]),
Node('status',payload=[sys.argv[2] if len(sys.argv)>2 else ""])
]))
cl.disconnect()
Announcing: RABCDAsm
by CyberShadow on May.05, 2010, under Code
RABCDAsm (Robust ABC (ActionScript Bytecode) [Dis-]Assembler) is a collection of utilities including an ActionScript 3 assembler/disassembler, and a few tools to manipulate SWF files.
This package was created due to lack of similar software out there.
Particularly, I needed an utility which would allow me to edit ActionScript 3 bytecode (used in Flash 9 and newer) with the following properties:
- Speed. Less waiting means more productivity. rabcasm can assemble large projects (>200000 LOC) in under a second on modern machines.
- Comfortably-editable output. Each class is decompiled to its own file, with files arranged in subdirectories representing the package hierarchy. Class files are #included from the main file.
- Most importantly – robustness! If the Adobe AVM can load and run the file, then it must be editable – no matter if the file is obfuscated or otherwise mutilated to prevent reverse-engineering. RABCDAsm achieves this by using a textual representation closer to the ABC file format, rather than to what an ActionScript compiler would generate.
Read more on the project’s homepage on GitHub.
WordPress “Pixel” theme – fixed background mod
by CyberShadow on Apr.23, 2010, under Random, Website
I love fixed backgrounds. So, I made a version of Sam‘s Pixel theme with a fixed background (which you can see on the blog already). It even supports IE6 (well, almost) – thanks, ie7-js!
Note: I re-exported the background from the original PSD as a PNG, since it’s too beautiful to be degraded by JPEG compression artifacts. The PNG is about 350kb in size – so, if that bothers you, convert it to JPEG and edit style.css accordingly.
TimeTracker – minimalistic time-tracking
by CyberShadow on Apr.21, 2010, under Code
Starting with a new hourly-paid freelancing job, I needed some software to track the amount of time I spend working. I tried a few time tracking programs out there, but they all turned out to be bloated and clumsy (not to mention not open-source), so I decided to roll my own. (continue reading…)
Ctrl+Tab and Ctrl+Shift+Tab in Eclipse
by CyberShadow on Apr.19, 2010, under Random
The Eclipse IDE doesn’t use the overwhelmingly common Ctrl+Tab and Ctrl+Shift+Tab shortcuts to switch editor tabs. Not only that, it doesn’t even allow you to bind these keys to the classic Ctrl+Tab behavior (switch to the tab left/right of the current one). However, Ctrl+PageUp/Down seem to be hard-coded to switching tabs the good-old way, so it’s just a matter of remapping Ctrl+(Shift+)Tab to those keys.
Here’s my AutoHotKey solution:
#IfWinActive ahk_class SWT_Window0
^Tab::Send ^{PgDn}
#IfWinActive ahk_class SWT_Window0
^+Tab::Send ^{PgUp}
ColorCalc – command-line calculator for colors
by CyberShadow on Apr.04, 2010, under Code
If you’re one of the few crazies like me who prefer doing web development using command-line tools, you might appreciate this simple command-line calculator which can operate on RGB colors. It supports the 4 basic arithmetic operations and grouping using parens. (continue reading…)
EnvMan – FAR plugin to manage your environment
by CyberShadow on Apr.02, 2010, under Code
Ever had to deal with annoying conflicts between various command-line utilities sharing the same name? Ever wanted to use different versions of the same command-line software package? Tired of manually editing the environment or using “development environment command line” batch files? Then this plugin is for you! (continue reading…)
Converting classic WinAMP skins to HTML/CSS
by CyberShadow on Feb.24, 2010, under Code
I wrote something that cuts up images from WinAMP classic skins to allow using them (with CSS) in web pages.
It allows variable content width/height, using the bitmap font in the “gen” title bar, and uses mouse “hover” effects.
Source: http://github.com/CyberShadow/WSZ2Web
Download: http://github.com/downloads/CyberShadow/WSZ2Web/wsz2web.zip
Examples: http://thecybershadow.net/misc/skins/