Skip to content

Instantly share code, notes, and snippets.

View adamcharnock's full-sized avatar

Adam Charnock adamcharnock

View GitHub Profile

We have been covering some fairly complex Redis topics here so far, so I thought it would be nice to do a good ol’ getting started guide. This should get you on your feet with Python and Redis on Ubuntu Linux. So, fire up a terminal window and get going!

Getting Redis installed & running

This guide uses Redis 2.0.3, but you can see if there is a newer version at redis.io:

apt-get install build-essential

wget http://redis.googlecode.com/files/redis-2.0.3.tar.gz
tar -zxf redis-2.0.3.tar.gz
#!/bin/bash
if [[ ! -n "$1" || ! -n "$2" ]]
then
echo "Usage: `basename $0` environment port"
exit 1
fi
declare -i date
declare -i lastsave
import re
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone
from metaphone import dm as double_metaphone
# get the Redis connection
from jellybean.core import redis
import models
# Words which should not be indexed
DROP TEMPORARY TABLE IF EXISTS siteswith30days;
CREATE TEMPORARY TABLE siteswith30days SELECT r2.siteid, COUNT(*) as totalrows FROM rawdata AS r2 GROUP BY siteid HAVING totalrows > 6*24*30;
SELECT
r.*,
(r.winddirection % 1024) * (360/1024) AS winddirectiondegrees,
0.8669 * (r.windpulsecount/600) + 0.32 AS windspeed,
s.postcode,
s.anemometerheight
FROM
rawdata AS r
<?xml version="1.0" encoding="UTF-8"?>
<!-- Only the settings with values not equal to defaults are in this file. If you want to see the
full list of available settings, check the amstock_settings.xml file in the amstock folder. -->
<settings>
<margins>0</margins>
<!-- <max_series>10</max_series> -->
<redraw>true</redraw>
<max_grid_count>30</max_grid_count>
<equal_spacing>false</equal_spacing>