Arthur

Pemberton

Full-stack web applications developer


Welcome to my blog

As I discover new things in my field and solve troublesome problems, I will attempt to document my finds here.

MySQL server has gone away

On October 28, 2019, by Arthur Pemberton, 0 Comments

I have a Django project where I was utilizing bulk_create to load a fairly large dataset, and this was some times resulting in the error MySQL server has gone away. Reading though the documentation on this error, https://dev.mysql.com/doc/refman/8.0/en/gone-away.html I see that one of the possible causes for this is “you send a query to the server that is incorrect or too large” Turns out, I just needed to use the batch_size parameter of bulk_create. The  success of a website depends on web design, this is why is very important to look for the help the experts from Best Website Hosting

In my case, a batch of 56,000 records was triggering the error, so for safety, I switched to using bulk_created(..., batch_size=(10**4)).

Improving Xapian backed Haystack searches in Django

On January 9, 2019, by Arthur Pemberton, 0 Comments

I recently switched a Django project utilizing Haystack from Whoosh as the engine to Xapian. The performance significantly improved, but I was left with some deficiencies in the search results — this turned out to be due to the default settings.

Here are the necessary settings to improve the search result quality:

import xapian

HAYSTACK_XAPIAN_FLAGS = (
    xapian.QueryParser.FLAG_PHRASE |
    xapian.QueryParser.FLAG_BOOLEAN |
    xapian.QueryParser.FLAG_LOVEHATE |
    xapian.QueryParser.FLAG_WILDCARD |
    xapian.QueryParser.FLAG_PURE_NOT |
    xapian.QueryParser.FLAG_PARTIAL
)
HAYSTACK_XAPIAN_STEMMING_STRATEGY = 'STEM_ALL'

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'xapian_backend.XapianEngine',
        'PATH': root.path('data/xapian')(),
        'FLAGS': HAYSTACK_XAPIAN_FLAGS,
    },
}

Before these settings, I was having problem with queries being apparently case sensitive, at least when using AutoQuery, and failing partial searches. These changes improve case insensitivity and stemming, which still having almost 100x better performance than Whoosh.

Hopefully this helps someone out there looking for solutions.

Adding version numbers to your static files

On June 12, 2016, by Arthur Pemberton, 0 Comments

When I started with Django, the version at the time was 1.5. Back then, we prepended STATIC_URL to our static assets to reference them in our templates. With recent release, best practice is to you use the static [1]. I often find myself wanting to append a version number to my static files, at least my CSS and JS files to ensure that browser see my new versions when I push an update. In this post, I make use of the `static` tag and its URL building to easily append a version number.

Read More

Request specific URLs in Django

On September 17, 2015, by Arthur Pemberton, 0 Comments

Do you have a need to use different URL pattern sets based on specifics of an HTTP request? Recently, I needed to choose from a predefined URL pattern (ie. URLConf module) based on the domain name of the request, ie. HTTP_HOST. The URL patterns themselves are not dynamically set, just dynamically chosen.
Read More

Bets in the NBA

On April 24, 2014, by Arthur Pemberton, 0 Comments

If youre looking for an exciting way to bet the NBA odds, now you can bet on the winners and losers of each game for each of the NBAs 29 teams by going to DraftKings . Now you can bet on the winner of each game that matters as the season unfolds in an interactive sportsbook. Enter your team to make a deposit for the right to wager. Dont have enough to bet, no problem. Just open a new account or make an easy wager by setting up a wager on a favorite to win. After the season, you will be able to check back to see if your favorite team has beaten its odds and earned some cash back.

The Top 7 Strategies To Improve Your Sports Betting Skills

If you want to bet the lottery and win big, we have all the wagers and picks you need. Bet on the winners and losers, and make your wager into money. Dont worry, the bookmakers always give you your money back!

Enjoy the game with us and tell your friends. Our wagers are fast and easy to use so go check them out! Our wager betting service is supported by sportsbooks in almost every region of the world including USA, UK, Canada and Australia, as well as most of Europe.

Finance and betting options to suit every betting player

Our unique betting and financing features will get you up to speed in no time. To find out more, select the site below and click on ‘get started’. We offer an extensive range of betting and betting tools and a wide variety of financial services.

Why choose us?

All of our premium casino slots games are all hand tested and built using the latest online casino technologies. We offer the most robust casino slots software with the highest customer satisfaction. We offer the highest payouts in the industry so you never have to wait for luck to come your way. All of our casinos are listed in the leading casinos and casino slots directory.

All of our slots games are built using the latest online casino technologies. We

Varying Django Settings By Environment

On October 21, 2013, by Arthur Pemberton, 0 Comments

If you’ve progressed beyond the exploration phase in your Django journey, you’ve probably come to the point where, at the least, you would like to use one database during your development, and another, once published to your production system. You may even want to

Read More