Posts

Showing posts with the label web

pygameweb - 0.0.4 - Northern Rockhopper Penguin

Image
pygameweb is the source code for the pygame website at https://www.pygame.org/ Northern Rockhopper Penguin (photo by Brian Gratwicke) #52 Adding ability to deploy through travisci. And docs. #46 Wiki readability. Wiki tools on left out of reading line. Twitter card for releases. For nicer view when posting to twitter. Wiki table of contents improvements. builds docs for pygame, when something lands on pygame github master branch. project release feeds bugfix. Only show one recent release for each project. Some projects release a few times in a row. Wiki, nicer pre code handling. Wiki code uses inline colors, so copy/paste works with colors too. use https for login and register buttons, even when on http (see Why can't we turn off HTTPS? ). Ask more bad robot web crawlers not to be bad. See a full diff of changes since last release .

Internet protocol 6, 6, 6.

June 6th, 2012 is ipv6 launch day.  http://www.worldipv6launch.org/ You can now go to http://www.pygame.org/ with version 6 of the internet protocol.

Why Firefox 13 'load tabs on demand' is bad UX.

With the new firefox 13, on start-up it does not reload all of the tabs at once. Theoretically this means firefox loads faster.  Since it only needs to load one website when you restore, not all of them. This is a great example of a UX/UI app experience that seems good for users, but is in fact bad.  This comes up quite often when optimizing applications, and I have even done this style of optimization in the past.  So I'm using this as a case study in why doing this is not good from a UX perspective. The Scenario. I have 8 tabs, and I'm using most of them. Old firefox behaviour. Firefox loads, I go away whilst it loads itself, then loads all 8 tabs. I wait .  It takes a while to load - but some stuff can be loaded at the same time, in parallel.  If they are fast pages it is pretty much instant, and I can get to work. If they are slow pages, then I have to wait once until they are all loaded.  I can go off and do something el...

SQL Injection via field names, and table names.

About a year ago I had to implement a system where the table name could be configured for an application.  Why would you want to do that?  Lots of reasons really, like if you have a table generator via a web interface.  In this case, the system integrates with other systems, and users need a way to specify where the data would go in an existing database.  So I merrily went ahead to try and put the table name in a prepared statement... but ERROR!  Unfortunately the sqlite database does not do table names or column names via prepared statements (like postgresql does for example).  The documented solution by sqlite is to escape them correctly with the provided functions.  Unfortunately python does not expose these SQL escaping functions - since most people should be using prepared statements. Here are some WONTFIX, closed, invalid bugs also mentioning table names, and column names not being a problem.  One of them is six years old. (closed wontf...

CherryPy - I love it because it's pyhon.

Image
CherryPy moved to bitbucket a while ago, and also got a website refresh. I love cherrypy, since I can use it with python 3 - not legacy python. I love cherrypy, because I can just use python objects. I love cherrypy because it has a clever name. I love cherrypy, because it just works. I love cherrypy, it is minimal. I love cherrypy.

Vintage in Paris

Image
Our Vintage in Paris app has been published on the Nokia app store ! The process was pretty simple, since it was a very technically basic but content heavy app. The main difficulty in this app was walking around the streets of Paris taking pictures, and researching really good places to find Vintage. Why a Vintage in Paris app? Finding cool second hand and retro clothes is a hobby of mine, and my partners.   It's always fun finding interesting old styles, rummaging through clothes racks.  Especially in other countries, and especially when you find a bargain. There's something special about wandering down some back alley, and finding an old shop stuffed to the rafters with old stuff.  It's like taking a journey back in time to some fantastical version of Paris you may have in your head.  If you like Art Deco stuff, then Paris is the place to get it. What was the signup to the Nokia store like? I have been signed up as a Nokia de...

jquery.shitsound.js - a shit sound player for web browsers

Yesterday, I made the first release of shitsound. jquery.shitsound.js is a shit sound player for web browsers. Listen (demo): http://rene.f0o.com/~rene/shitsound Source code: https://www.bitbucket.org/illume/shitsound Used like this: $.snd.init({}, function () { // we are ready to play sounds! Brilliant. $.snd.play('hello'); }); shitsound only does a few things with sound:: play, stop, stopAll jquery.awesound.js might do: changing volume, pitch, playing with a different tempo, playing in stereo, 3d sound, etc. jquery.shitsound can not do any of this fancy stuff. It can just play sounds, and stop playing them. shitsound detects which implementation to use at init time. html5, using the html5 audio tag. embed, for using the embed tag. soundmanager1, for old flash 7. soundmanager2, for modern flash (8,9,10+). empty, pretend implementation that does nothing. It currently requires jquery, since I use jquery. However it could quite ...

shadertoy.py opengl shading language toy shader

A couple of months ago I made a python port of the WebGL shadertoy . The shadertoy website is written in JavaScript and the opengl shading language. Here is the python port: http://rene.f0o.com/~rene/stuff/shadertoy.py Maybe it'll be useful for someone learning shading languages through python. Or not. It's a fun demo anyway. Press the 'Anykey' to change between shader. You'll find the 'Anykey' on your keyboard. If the Anykey you press is Escape, then the program will 'quit'. Requires 1 tsp of pygame, and a cup of pyopengl.

You are using the wrong #templating system for #html.

Use javascript + json + DOM for html templating. Front end developers know how to use this technology. They know this technology very well, so will be way productive. No weird new template language to learn and install on every single project. No dependency on a rapidly changing server side backend... or database, or 3rd party API required. No taking the html, and turning it into [$%%WEIRD TEMPLATE LANG%%$$] step. Instead you can use javascript, json and the DOM. Being able to use the templating system either via the browser, or via the server side means there is no dependency between the front end and the back end. Front end developers just need an example json file to work from. Then the back end developer just needs to create the json file. It does mean you are dependent on a DOM+javascript implementation on the server side if you want to do things like server side caching, and supporting Agents(browsers, bots etc) that do not use javascript on the client side. Just json files....

Validation through html forms.

Continuing on from a previous article I wrote earlier in the year... ' Using a html form as the model ', this post describes using validation. With html 5 comes a whole bunch of validation you can use in your forms. This makes a html form even more useful as a schema than the html 4 forms. Since you can use types like email, telephone, time, date, and such. You can also use things like minimum, and maximum length. As well as the ever useful 'required' field. You can read about html 5 forms here .

uh0h, I made a logo. What do you think?

Image
Made a quick little logo for a website called... Tried a few different versions... showed my girl friend a few, and stuck with this one in the end. Made it with a simple DejaVu Sans Mono Bold font. Ya for the DejaVu font project. Modified the zero(0) a bit, then inverted the colors (ya! negative space). Played around with the letter spacing... applied an old school guassian blur filter to the right side, resized for web... and done! What do you think? The brief is 'something quick for yet-another-culture blog/zine called uh0h... as in uh oh I dropped a hammer on my foot.'. update: Added some results in this image below. Which is updated with a pygame/freetype script. The idea is that the results in the image can be updated without the rss feed getting updated. Hoping to clean the script up and add it to pywebsite. The same technique seems to be used by some wordpress blogs with their 'comments:3' image links - so I think it will be useful for all sorts of things ...

The secret to my web development productivity...

Image
Can you see the secret to my web development productivity in this photo? No it's not the red cup of coffee. It's not the pieces of sticky tape on my laptop. Follow the cable from my laptop... and have a look under the desk. ... ... I'll wait whilst you have a look before telling you the answer. ... That's right!!! ... it's a joypad. Using python and pygame, I've made a little app which listens for joystick events, and then deploys the website I'm working on. With a mash, kick or prod of my foot, up goes my website. Deployed. Deploy is just a fancy word for 'upload my website, do database migrations, restart app servers, run tests, rollback if there are failures... etc'. For 5 british pounds, $7.8 USD, or 5.74 euros, you can get one of these joypads delivered to most places these days. It's giving me too much pleasure pressing it every time I want to upload a new version of the website. Most live updates EVER today - and I have the joypad to tha...

Genshi templates - header/footer templates, and including templates.

Image
How to include a Genshi template inside of another genshi template? Use "py:match" inside the template you want to include into other pages (eg. a sitelayout.html). Then you can use "xi:include" in the pages you want the files included in. (eg. best_picture_of_my_cat_today.html) Now, it's not a "simple include this template here" kind of thing. The py:match can find various parts of the file, and then replace them how they like. For example, a page layout template will match the header and footer with "py:match". It is best explained with examples, and in the documentation: pylons genshi example Includes section of the genshi documentation where it explains "xi:include". Genshi documentation where it explains py:match . Hopefully this explains the genshi way of including a template into a template.

My fling with engine X.

Image
Projects that have X in the name are cool. Engines are cool (especially steam powered ones). Spelling engine 'ngin' gains 17.5 l33t points too. All combined, this makes the name nginx super schwet! I've been using nginx for a while now, and have found it quite good so far. Been moving a couple of websites to it, fooling around with it a lot. So far I've been able to use it for everything I've tried. Some of my apache configs are fairly long... so that is saying quite a bit. On my low memory (512MB) server it has saved quite a bit of memory - even though I've only moved over a couple of websites. Along with the cherrypy memory reduction work I did recently, my server has a bit more room to breathe... (and for me to waste memory on hosting other websites! ya!). Nginx has a good reputation as being rock solid - so I hope it holds true for me. Then perhaps I can get rid of apache completely (on this one server). I've tried to replace apache with other...

mini languages that non programmers can understand

Image
There are hopefully a number of mini text based programming languages that non-programmers can understand. But what are they? One that I've used in the past is something like this: Which would parse into a python/javascript data structure like this: {name: 'Bob', gender: 'male/female', age:'22' } It's suprisingly common in things like search engines. Grandmas who occasionally check their email might not get it (but many do I'm sure!)... but I think a lot of others do. For things like search it is ok, if people know the magic 'terms'. If they do not know the terms, then they can just enter text to search normally. The mini language is used by advanced users. This is quite good for single line free form data entry. Since people only need to know the concept that you have 'key:value'. It's slightly easier than using urls, since separators can be different things. csv files Next up are comma separated files - csv. For example: ...

Using a html form as the model.

Image
I've mentioned this technique before, but I think it is worth repeating more clearly. Without any other code clouding the main message: ' All you need is love html . A HTML form can describe a model of your data quite well. This lets you go from HTML form design to a working Create Read Update Delete (CRUD) system. A CRUD can be thought of as a nice admin interface to edit your data (or a CMS if you prefer that acronym). For example: <form action='savepage' method='post'> title:<input type='text' name='title'> <br>textarea: <textarea name='content'></textarea> <input type='submit' name='submit'></form> That's all you need to create a CRUD. Things like validation can be defined in the html easily enough then implemented in your code to be checked server side, and client side. Parse the form to get the model, and go from there. The benefits are simplicity, and that designer...

structuring modules/packages and the cdb database for websites and python packages

Image
Integrated modules are nice, but so are modular packages. How can we have both? That is, keep all things for a module(or sub package) in one directory, but also have a nice integrated system built on top of that? Often for one package I will have a file layout like so: /setup.py /[package_name] /[package_name]/[package_module].py /[package_name]/tests/[package_module]_test.py /[package_name]/examples/[package_module].py /[package_name]/docs/[package_module].py Then each module has its tests, docs, and examples all mixed in the one directory. This is nice if you want to have all of the tests together, and all of the docs, and examples together. However then all of the modules are mixed in together. Meaning it is harder to separate them, and keep one module in its own directory. Having everything for one thing together is nicer for developers I think. Using namespace packages through setuptools distribute is one way. There is a draft pep around to put namespace packages into python...

hashing urls for authorisation, and pywebsite.signed_url

Image
Using a hash with a salt is one way of validating urls. With it you can tell that it is quite likely the url was generated by someone with a secret. That is, generated by someone authorised to make that url. This post describes using this technique with the hmac python module applied to urls(and object method calls). Generating thumbnail urls is a good example. If you have a url which can generate a thumbnail of an image at a specified size that is pretty cool. Except then you can have someone generating images at all sorts of other weird sizes by exploiting the width, and height parameters (eg making 100,000 pixel wide thumbnails). Or perhaps you want to limit it to a certain set of images. You could always code in your thumb nail generating routine which variables are valid... but this has problems. First it makes your routine less flexible. Separating authorisation is always a nice idea. Another way (with HMAC like using pywebsite.signed_url) is to generate the urls and add ...

Spam detection on websites?

Assume you have a user content site - or you're using software that can somehow get spam links inserted into it. How do you find out if your website has spam put on it? It seems a common enough problem these days... people putting spam links on websites. Surely there must be a service or piece of software to detect such a thing? I can think of a few ways to go about writing one fairly easily (using existing spam detection tools... but applying them to a spiders crawl of your website). It would be much nicer if there's already a tool which does such a thing though.

cherrypy file upload

A common thing to do with web applications is to upload files. People want to upload their pdfs, upload their images, their word documents etc. With cherrypy you can upload files using a few different ways... This http://tools.cherrypy.org/wiki/DirectToDiskFileUpload method for uploading files with cherrypy seems a pretty good way *1 . This tool lets you upload a file directly to disk... which is handy if you're uploading a very large file. This means the webserver doesn't need to write it all into memory, and that it doesn't need to copy the file when it's finished uploading. *1 However there are some security, and usability issues with this cherrypy tool(as currently written). Can you spot what they are?