Showing posts with label tech-valley. Show all posts
Showing posts with label tech-valley. Show all posts

Wednesday, January 6

Custom URL Shortener/ID Encoder in Transact-SQL (T-SQL)

Recently I've been working on some public-facing web applications where I needed to expose non-sequential IDs to end users in email as both text and links. In a corporate intranet, or even client-serving extranet, environments, with help desk & administrative support available, I'd probably just use GUIDs all over the place, and let the help desk field the aggravation and educate the users on the cutting and pasting of, and pronouncing, GUID. (I'm evil, I know.)

Now in situations where user aggravation directly and/or substantially affects revenue or productivity, and the ability to leverage help desk type support is at a minimum, I decided to start encoding IDs, not unlike the hash a URL shortener like bit.ly gives you. (e.g. bit.ly/5tB2x5, where 5tB2x5 is your encoded or hashed value.)

I found a fairly simple to implement algorithm on Jonathan Snook's site. I initially encoded, or compressed, IDs in a C# port of Snook's work, and stored the result in SQL Server, as I had a bug in my decompression/decoding method and needed to lookup the values up.

I then found myself with a need to create these encoded ID values inside of stored procedures. I ported the work once again, this time to T-SQL. Again, encoding worked, but decoding failed. I was stymied until the keen eye of Patrick Muldoon, via Tech Valley Ruby Brigade, noticed a character set issue -- the decoding routine was not making the distinction between capital and non-capital letters, resulting in bad decoding. COLLATE to the rescue!

bad:

SET @currPos = CHARINDEX(@currentCharacter, @BigString)


good:

SET @currPos = CHARINDEX(@currentCharacter, @BigString COLLATE Latin1_General_CS_AS)


Thanks Patrick!

Complete T-SQL code for encoding:

CREATE PROCEDURE [dbo].[ShortenID]
@idToShorten numeric(18,0),
@shortenedID varchar(20) OUT
AS

BEGIN
SET @shortenedID = 'NULL ID'

IF @idToShorten < 1
RETURN

DECLARE @ShortChars varchar(100) = '8A2aBb95CcDdeFfGgHhJjK6kLMm3NnOPpQqRrSsTtUuV7vXxYyZ4z'
DECLARE @charBase int = LEN(@ShortChars)
DECLARE @currentCharacter char

DECLARE @shortened varchar(20) = ''

WHILE @idToShorten > 0
BEGIN
SET @currentCharacter = SUBSTRING(@ShortChars, (@idToShorten % @charBase), 1)
SELECT @shortened = @currentCharacter + @shortened
SET @idToShorten = FLOOR(@idToShorten/@charBase)
END

SELECT @shortenedID = @shortened
END


Complete T-SQL code for decoding:

CREATE PROCEDURE [dbo].[ExplodeShortID]
@shortenedID varchar(20),
@idExploded numeric(18,0) OUT
AS

BEGIN
SET @idExploded = -1

IF LTRIM(RTRIM(@shortenedID)) = ''
RETURN

DECLARE @ShortChars varchar(100) = '8A2aBb95CcDdeFfGgHhJjK6kLMm3NnOPpQqRrSsTtUuV7vXxYyZ4z'
DECLARE @charBase int = LEN(@ShortChars)
DECLARE @currentCharacter char
DECLARE @currPos int = 0

DECLARE @exploded numeric (18, 0) = 0

DECLARE @lenShortenedID int = LEN(@shortenedID)
DECLARE @i int = @lenShortenedID
DECLARE @pow int = 0;
DECLARE @someInt int = 0

WHILE (@i > 0)
BEGIN
SET @someInt = (-1 * ( @i - LEN(@shortenedID) ))
SET @currentCharacter = SUBSTRING( @shortenedID, @someInt+1, 1 )
SET @currPos = CHARINDEX( @currentCharacter, @ShortChars COLLATE Latin1_General_CS_AS)
SET @pow = POWER(@charBase, @i-1)
SET @exploded = @exploded + (@currPos * @pow)

SET @i = @i - 1
END

SET @idExploded = @exploded
END

Monday, November 9

Apprenda closes $5M round

Congratulations to Tech Valley startup, creator of SaaSGrid, Apprenda, on closing a five million dollar ($5M USD) round of financing! Along with seed-round investor High Peak Ventures, Apprenda has brought New Enterprise Associates (NEA) on-board for some major VC firepower!

Apprenda is located about 15-20 minutes north of Albany, and uses some verrrrry cool .NET technology to automagically convert your single-tenant apps to multi-tenant without you having to change your code or data model. SaaSGrid also facilitates granular monetization of your offering.

Congrats Apprenda team!

Thursday, October 29

Next Leg of the MSDN NE Roadshow is on!

THE MSDN Northeast Roadshow team of Jim O’Neil and Chris Bowen will be making another stop in Albany, NY:

MSDN Events Presents >
The MSDN Northeast Roadshow - "Don't Fear the Coder" Tour

Thursday, November 12, 2009
9:30 AM - 3:30 PM Eastern Time
Welcome Time: 9:00 AM

Rensselaer Polytechnic Institute
1623 15th St
Biotech Building
Albany, New York 12180

Lunch Included

The Agenda: Clever Hacking, Slashed Efforts, and Killer Applications
Topics Include:
• Something WCF This Way Comes
• RIA Window – Expression, Silverlight, and MVVM
• "Help!" – Grasping at Lifelines
• LINQ De-crypted
• Tales from the Webside - ASP.NET WebForms, AJAX, and More

Register today for the Roadshow (seating is limited), and we’ll see you soon! http://go.microsoft.com/?linkid=9693448

/MSFT announcement

A quick .02: seating's really not that limited at this event. Not once, not ever. But that's mostly thanks to the use of RPI's biotech auditorium, which can seat a good number of people.

Saturday, October 17

It's On! Tech Valley Code Camp 2009

Tech Valley Code Camp 2009 is slated for November 7th at SUNY Albany. Thanks to Griff Townsend for getting the site updated after it languished in my overly-busy hands.

Wednesday, October 14

Need attendees! Capital Region Business Council meetup

A new Meetup.com group, the Capital Region Business Council, is a bit light on attendees for an event this Saturday:

I wanted to get some feedback. I was hoping for a few more attendees and I will be soliciting new memebers aggresively this week. I have been traveling on Business last week and into this week so I apologize for the slow start. The event might need to be rescheduled to have a maximum amount of attendees. I did plan to have it at The Desmond and it is quite costly to go there. I am going to have the event Catered by My Favorite Caterer out of Albany. This event will be great. Please send me feedback of an Establishment or Location anyone might know of. I am looking for additional people as well who might want to be involved with the group planning. There are so many wonderful people with amazing talents within our group already. I look forward to meeting each and every one of you.

Sincerely,

Michael Velardi
President and Founder
Capital Region Business Council

Job: High Availability Linux/Python Guru

Email me and I can put you in touch: ...@badera.us

Description: SOFTWARE ENGINEER
Our Client is seeking a Software Engineer responsible for creating complex data processing and presentation tools that integrate tightly with some of the industry's biggest game franchises. You would function as a member of our team of backend and application engineers and business specialists to expand our game service platform.

Requirements:

• Experience delivering large, complex, highly available software systems

• Ninja skills in Python

• Knowledge of design patterns, SOA, refactoring and unit testing

• Experience with web application servers, web development frameworks, proxy servers and relational databases

• Experience with Linux

• Interest in working on-site at our office in Troy, NY

The ideal candidate will have:

• Experience with MySQL or Postgres

• Experience with other web technologies (Ruby, CSS, Javascript, HTML)

• Experience with NGINX and HAProxy

• Exposure to ESB technologies (MSMQ, RabbitMQ, HornetQ, etc.)

• Experience working with Agile development methodologies (XP, Scrum)

• An understanding of system optimization issues

• Familiarity with system monitoring tools (Monit preferred)

• A detail-oriented, organized thought process and be able to act decisively under stressful conditions.

• A proactive mindset and be able to multitask and prioritize requirements.

• A self-motivated work process and posses excellent communication skills
Benefits:

• Work with an experienced, successful, intelligent team

• Competitive salary, health benefits, and retirement plan

• Be an integral part of a growing, fast-paced company where your work will make a true impact

Wednesday, October 7

Going dark for a few days

Probably won't be blogging much for the next couple weeks. A lot of deliverables and other obligations.

Tuesday the 13th I'll be presenting "Twitter API & OAuth 101 - What's this twit all about?" at TVUG @ VersaTrans in Latham.

Twitter -- it's all over the place, from mainstream media to grade school classrooms. We can't escape it if we tried. A large part of the success and popularity of Twitter is thanks to its open APIs and rich ecosystem of third-party applications. Learn how you too can take advantage of Twitter's APIs for fun and profit, while getting a look at OAuth, an evolving authorization protocol that's come to dominate the Web 2.0 and open API world.

Andrew Badera, CEO of Higher Efficiency, Inc., CTO of multiple startups, is a lifelong geek and longtime technology consultant with 13 years experience on Microsoft platforms. With a focus on
integration, enterprise service bus (ESB) technology and service-oriented architectures (SOA), Andrew finds Twitter and its APIs to be a rewarding distraction.


Tuesday-Friday of next week, I'll also be doing a training class on ActiveVOS (a BPM/workflow product). I haven't done a vendor training class since training on an IBM ECommerce product back in 1999 down in the Research Triangle area in North Carolina. (Incidentally that's also the trip where a gay gentleman became my best friend, plied my underaged-self with liquor, and spent his time, in and out of class, hitting on me. Gross. Is that what it feels like to be female?)

Tuesday, September 29

Job: Mid-level .NET Developer in Saratoga, NY

A friend has "a client in Saratoga that needs a solid mid – to senior level developer – must be .Net C# and SQL. 4-6 years of experience. This person needs to be independent and take ownership of one of the products."

Pay range is decent for upstate NY -- email me a...@b... for details.