Consoles
 

Archive for the ‘Uncategorized’ Category

Large files with NGINX, GZip, and SSL

by Jeff, November 19th, 2009 at 02:47pm - No Comments »
Posted in: Engineering, Infrastructure, Uncategorized

I ran into an interesting issue today when deploying a crappy password change app I wrote as an exercise in rails. It turns out that by default, NGINX has a gzip buffer size of 4 * 4k/8k, with the bit size depending on what platform the service is running on.

As a result,

4 * 4k = 16384 bytes (16KB)
4 * 8k = 32768 (32KB)

After gzip, when converted to be plain text, the amount of data returned to the browser nearly doubles (about 52KB in the case of larger). The default javascript library included by rails for AJAX (prototype.js) is 127k, which led me to find this limit.

And so, getting to the point, the limit applied to the gzip buffer needs to be increased within NGINX’s config files for each site that will use a file larger than these pre-set sizes. You can do so using the following:

gzip_buffers 16 8k

This will set the buffer size to 16 * 8k, or 128KB — the uncompressed size of the library, eliminating the issue.

In the future if you find NGINX truncating large files for no apparent reason, this is likely why.

*EDIT* — In NGINX versions post 0.7.28, the default limit of gzip_buffers has been increased to 32 * 4 or 16 * 8 (rounding out to 128K, as noted above) depending on platform. It may be wise to double check any configs you may have to ensure you are not explicitly setting a lesser value, or upgrade NGINX if needed.

  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Tumblr
  • Twitter

Integrating Lighthouse and Instant Messenger in Ruby

by David Czarnecki, October 7th, 2009 at 04:45pm - No Comments »
Tagged As: , , , ,
Posted in: Engineering, Uncategorized

The Introduction to the Lighthouse API mentions something you might do with the Lighthouse API is “Accessing and creating tickets through your Instant Messenger client.”. How easy is it to do this? Surprisingly easy.

You will need to download and install the Lighthouse API gem and the Net::TOC gem.

Run this in an irb session.


require 'net/toc'
require 'lighthouse'
require 'sanitize'
include Lighthouse

Lighthouse.account = 'shaft'
Lighthouse.token = 'hesonebadmotherfushutyourmouth'

Net::TOC.new("someaimaccount", "someaimpassword") do |msg, buddy|
project = Project.find(Sanitize.clean(msg).to_i)
buddy.send_im("Here is some information about your project: #{project.name}")
end

You should then be able to add ’someaimaccount’ to your AIM buddy list and send a project ID and have it return the project name.

And boom goes the dynamite!

You’ll of course need to change the Lighthouse account and token as appropriate (or use username and password for logging in). msg is a little weird and although it’s a string, it’s HTML, so you need to strip out any tags before doing anything. And of course you’d want to add in some way of parsing the input from the user into some DSL (Domain Specific Language) for interacting with your fancy new Lighthouse AIM bot.

Happy hacking!

  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Tumblr
  • Twitter

Mocking HTTP request and response with Python and Mox

by David Czarnecki, October 1st, 2009 at 09:55am - No Comments »
Tagged As: , , , , ,
Posted in: Engineering, Python, Uncategorized

I recently started integrating with some web services in Python and wanted to be able to test all the requests and responses with valid and invalid data. However, I need to be able to do this without actually hitting the web service when testing. And of course I don’t want to change my web service code to conditionally do things if running in a test environment. Enter mocking and Mox.

One of our engineers, Tim, has written an excellent post on his adventures as a Ruby programmer getting up to speed on testing and mocking in Python using Mox. You should read it.

Back to my issue with mocking the HTTP request and response.

Here is what I came up with. I first created a MockResponse class that adds a read() method to the string class.

</code>

class MockResponse(str):
'''
Mock response class with a method called read which will be used similar to the response from an HTTP request to a URL
'''
def read(self):
return self

And here is a test in which I mock out the request and response for the urllib2.OpenerDirector.open method. I don't so much care what the request string is passed to the open call, so I use IgnoreArg(). And I return the XML that would be returned by the actual web service to indicate the username and/or password were incorrect.


def test_logging_in_to_network_with_bad_username_and_password(self):
my_network_service = MyNetworkService('foo', 'bar')
self.mock(urllib2.OpenerDirector, 'open')
urllib2.OpenerDirector.open(mox.IgnoreArg()).AndReturn(MockResponse('''
< ?xml version="1.0" encoding="UTF-8"?>
<login>
<status>
<id>30000</id>
<message>ACCT_LOGIN_FAILED</message>
</status>
<accountid>7</accountid>
</login>
'''))
self.replay_all()

self.assertEqual(False, my_network_service.login())
self.mox.UnsetStubs()
self.mox.VerifyAll()

If there's a better way, I'd love to hear your suggestions.

  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Tumblr
  • Twitter

Major League Gaming + Agora Games = Crazy Delicious

by David Czarnecki, August 18th, 2009 at 03:22pm - No Comments »
Tagged As: , ,
Posted in: Business, Gaming, News, Online Communities, Uncategorized

Major League Gaming acquires Agora Games

I’m just going to parrot the MLG news post here.

MAJOR LEAGUE GAMING ACQUIRES AGORA GAMES

Deal brings online, multi-platform development expertise to fast-growing competitive gaming property

NEW YORK CITY—AUGUST 18, 2009—Major League Gaming today announced that it has acquired Troy, NY-based Agora Games. Known for both its technical expertise and elegant product development, Agora has built some of the leading video game community applications in the industry. Together, Agora and MLG will work both to enhance MLG’s online offerings, as well as to expand the services that both companies currently offer to the game publishing community.

“Cross-platform video game competition is what MLG is all about,” said Matthew Bromberg, president and CEO of Major League Gaming. “We already operate the largest online competitive gaming property in the world. Agora is the leading developer of multi-player communities in the world. Coming together with Agora allows us to double-down on our biggest strength.”

Over the last four years, Agora has developed some of gaming’s highest profile, most ambitious community websites for titles including Guitar Hero, Transformers, Call of Duty World at War, and Dance Dance Revolution. Their technology currently tracks game play statistics for over 25 million players around the world. Founder Michael DelPrete will remain as president of the wholly-owned subsidiary. Agora will continue to operate out of its Troy, NY office. Terms of the deal were not disclosed.

“MLG has shown the world that competitive video gaming is both a great live sports experience and can be the basis for a thriving online business,” said Michael DelPrete, founder of Agora Games. “We share a vision of the marketplace, and we’re confident the combination will better serve our existing customers and open up new opportunities to expand our offerings.”

The acquisition presents significant opportunities for game publishers. Agora has become the go-to technology developer for handheld and web-based extensions of video game experiences. Major League Gaming has proven its ability to build massive audiences around exciting new competitive social experiences. Together, Agora and MLG will partner more deeply with publishers and developers looking for deeper engagement, more ever-green experiences, and greater unit volume.

ABOUT MAJOR LEAGUE GAMING
Major League Gaming is the largest professional video game league in the world. MLG is the dominant media property exclusively targeting the approximately 40 million consumers in North America who have a passion for playing video games as a competitive social activity, while giving sponsoring brands access to this highly influential demographic. We represent the best professional gamers and give millions of aspiring players around the world an opportunity to compete, improve their skills, and socialize through our thriving online community and live Pro Circuit competitions.

  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Tumblr
  • Twitter

wiredump_dev = STDERR

by David Czarnecki, August 11th, 2009 at 11:12am - No Comments »
Tagged As: , ,
Posted in: Uncategorized

If you are ever debugging SOAP web services from Ruby and wondering what information is going across the wire to/from the web service, wiredump_dev = STDERR, may be your best friend.

def some_method_that_uses_a_soap_web_service
storage = SOAP::WSDLDriverFactory.new(STORAGE_WSDL).create_rpc_driver
...
storage.wiredump_dev = STDERR
response = storage.DoSomething(...)
end

When the DoSomething web service method is called, the Ruby SOAP library will print out the request and response to STDERR.

It is invaluable. Trust me!

Follow-up (8/13/2009): A friend pointed me at Handsoap, a library for creating SOAP clients in Ruby, which is an alternative to SOAP4R. It apparently does not suck. YMMV.

  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Tumblr
  • Twitter