Answer by Chase Seibert for How to form a string from 2 values
Here is a way to combine two values, and print them out.string_value = 'BOF'float_value = 0.0print "%s:%s" % (string_value[-1], float_value)>>F:0.0
View ArticleAnswer by Chase Seibert for Why is my input field uneditable?
What you want to do is install Firebug, and examine the DOM element in that. It will show you any customized CSS properties, and you can check/uncheck them one by one. You will likely find the one...
View ArticlePython raw_input() replacement that uses a configurable text editor
I'm trying to implement a replacement for raw_input() that would use a configurable text editor like vim as the interface to to the user.The ideal workflow would be like this:Your python script is...
View ArticleAnswer by Chase Seibert for Per-request cache in Django?
Years later, a super hack to cache SELECT statements inside a single Django request. You need to execute the patch() method from early on in your request scope, like in a piece of middleware.from...
View ArticleMixing implicit and explicit JOINs
I am having a problem with Hibernate generating invalid SQL. Specifically, mixing and matching implicit and explicit joins. This seems to be an open bug.However, I'm not sure why this is invalid SQL. I...
View ArticleJava REST client without schema
GoalJava client for Yahoo's HotJobs Resumé Search REST API. BackgroundI'm used to writing web-service clients for SOAP APIs, where wsimport generates proxy stubs and you're off and running. But this is...
View ArticleHow do you use Django URL namespaces?
I'm trying to get the hang of Django URL namespaces. But I can't find any examples or documentation.Here is what I have tried.urls.py:from django.conf.urls.defaults import *urlpatterns = patterns('',...
View ArticleConfigure Django to find all doctests in all modules?
If I run the following command:>python manage.py testDjango looks at tests.py in my application, and runs any doctests or unit tests in that file. It also looks at the __ test __ dictionary for...
View ArticleAnswer by Chase Seibert for How are anonymous inner classes used in Java?
I use them sometimes as a syntax hack for Map instantiation:Map map = new HashMap() {{ put("key", "value");}};vsMap map = new HashMap();map.put("key", "value");It saves some redundancy when doing a lot...
View ArticleAnswer by Chase Seibert for is distinct an expensive query in django?
This is not just a Django issue; DISTINCT is slow on most SQL implementations because it's a relatively hard operation. Here is a good discussion of why it's slow in Postgres specifically.One way to...
View ArticleAnswer by Chase Seibert for Local file access with JavaScript
If the user selects a file via <input type="file">, you can read and process that file using the File API.Reading or writing arbitrary files is not allowed by design. It's a violation of the...
View ArticleAnswer by Chase Seibert for For Django models, is there a shortcut for seeing...
An exists() method in the QuerySet API is available since Django 1.2.
View ArticleAnswer by Chase Seibert for RegEx for Javascript to allow only alphanumeric
Use the word character class. The following is equivalent to a ^[a-zA-Z0-9_]+$:^\w+$Explanation:^ start of string\w any word character (A-Z, a-z, 0-9, _).$ end of stringUse /[^\w]|_/g if you don't want...
View ArticleConvert iCal to HTML or plaintext in Java
I'm looking for a Java API to convert ICS (aka iCal) attachments to nicely formatted HTML or plaintext for display purposes. Ideally, it would be able to handle:Converting dates to a specified...
View ArticleAnswer by Chase Seibert for Using ALTER to drop a column if it exists in MySQL
There is no language level support for this in MySQL. Here is a work-around involving MySQL information_schema meta-data in 5.0+, but it won't address your issue in 4.0.18.drop procedure if exists...
View ArticleAnswer by Chase Seibert for java: Rpc/encoded wsdls are not supported in...
RPC/encoded is a vestige from before SOAP objects were defined with XML Schema. It's not widely supported anymore. You will need to generate the stubs using Apache Axis 1.0, which is from the same...
View ArticleAnswer by Chase Seibert for How do I get Pyflakes to ignore a statement?
Here is a monkey patch for pyflakes that adds a # bypass_pyflakes comment option.bypass_pyflakes.py#!/usr/bin/env pythonfrom pyflakes.scripts import pyflakesfrom pyflakes.checker import Checkerdef...
View ArticleAnswer by Chase Seibert for Help with div - make div fit the remaining width
<div class="a"><div class="b"><a href="#">click here to be amazed!</a></div><div class="c">this is some awesome text</div></div><STYLE>.b,.c...
View ArticleLightweight Java Object cache API [closed]
QuestionI'm looking for a Java in-memory object caching API. Any recommendations? What solutions have you used in the past?CurrentRight now, I'm just using a Map:Map cache = new HashMap<String,...
View ArticlePer-request cache in Django?
I would like to implement a decorator that provides per-request caching to any method, not just views. Here is an example use case.I have a custom tag that determines if a record in a long list of...
View Article