I’ve heard the slogan a bunch of times and just never really got around to it. I saw Reset The Net and others but after watching a Google IO video that covered it really well I decided to SSL up my sites. Here’s the super quick rundown… it really wasn’t as hard as I’d feared. (more…)
Tag: web
Embedding Tweets
Twitter’s update comes with a handy new feature: embedding tweets, and even better, with shortcodes, but it does come with a fairly big caveat. From the docs:
WordPress.com and WordPress VIP blogs have this functionality immediately, and Jetpack users will get it with their next update
So we’ve gotta go back to using full HTML code. Here’s an example:
Twitter have enabled support for embedding tweets.Handy… dev.twitter.com/blog/tweets-an…
— cerealkillers (@cerealkillers) December 13, 2011
The code for which looks like this:
<blockquote class="twitter-tweet"><p>Twitter have enabled support for embedding tweets.Handy... <a href="http://t.co/t2zjwuqN" title="https://dev.twitter.com/blog/tweets-and-buttons">dev.twitter.com/blog/tweets-an…</a></p>— cerealkillers (@cerealkillers) <a href="https://twitter.com/cerealkillers/status/146571451753971714" data-datetime="2011-12-13T12:45:31+00:00">December 13, 2011</a></blockquote> <script src="//platform.twitter.com/widgets.js" charset="utf-8"></script> |
Hopefully shortcode support won’t be too far behind in a normal WordPress installation, but for now, just follow the instructions in the docs and you’ll be all set.
ASync Shell Commands from Tornado
I’ve been using Tornado at work for a bunch of web interface stuff and found I needed to call shell commands that might block for a while. To avoid blocking Tornado itself, I looked around the web for a while trying to find a nice way of going about it. I found this:
https://gist.github.com/489093 – by Philip Plante
which worked but meant lots of replicated code in every handler. I’ve also modified the example to use Tornado’s newer gen way of doing things.
I’ve put my version here: https://gist.github.com/1370533 and is embedded below:
# Adapted from here: https://gist.github.com/489093 # Original credit goes to pplante and copyright notice pasted below # Copyright (c) 2010, Philip Plante of EndlessPaths.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # Modifications Copyright (c) 2011, Stephen Willey of cerealkillers.co.uk # License remains as above # Modifications allow it to be included once in multiple handlers. Save it # as async_process.py and put it in the path somewhere. Use it like this: # # from handlers.base import BaseHandler # # import tornado.web # from tornado import gen # from async_process import call_subprocess, on_subprocess_result # # class ShellHandler(BaseHandler): # @tornado.web.asynchronous # @gen.engine # def get(self): # self.write("Before sleep<br />") # self.flush() # response = yield gen.Task(call_subprocess, self, "ls /") # self.write("Output is:\n%s" % (response.read(),)) # self.finish() # import logging import shlex import subprocess import tornado def call_subprocess(context, command, callback=None): context.ioloop = tornado.ioloop.IOLoop.instance() context.pipe = p = subprocess.Popen(shlex.split(command), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) context.ioloop.add_handler(p.stdout.fileno(), context.async_callback(on_subprocess_result, context, callback), context.ioloop.READ) def on_subprocess_result(context, callback, fd, result): try: if callback: callback(context.pipe.stdout) except Exception, e: logging.error(e) finally: context.ioloop.remove_handler(fd) |
WordPress Child Themes
The site you’re looking at is styled with a child theme. WordPress introduced child themes in version 2.7 and they’re great. It means that you can cleanly modify an existing theme, and if the original writer publishes an update, your changes will simply be applied on top of theirs. The CSS file for the theme I’m using now looks like this:
/* Theme Name: Ari Cerealkillers Child Theme Description: Minor modifications to Ari Author: Stephen Willey Author URI: http://cerealkillers.co.uk/about Version: 0.1 Template: ari */ @import url("../ari/style.css"); ul.really_simple_twitter_widget li { padding-bottom:5px; border-bottom:1px dotted #CCCCCC; margin-bottom:5px; } ul.really_simple_twitter_widget li:last-of-type { padding-bottom:0px; border:none; margin-bottom:0px; } .widget_sociallinks { width:100px; } ul.sidebar li.widget_sociallinks { float:left } ul.sidebar li.widget_sociallinks a.lfp { background:url(images/lfp-icon.png) 0 0 no-repeat; } .wp_syntax { border:none !important; } |
You can see that all I’ve done is add some styling to the ‘Latest Tweets’ widget on the right, and set a fixed width for the social links on the left (it helps them appear in a nice grid on mobile devices). If elmastudio (whose themes are fantastic) publish a change, I can just update through the admin interface and all should be well.
Child themes. Use ’em. They’re great. Find more info on the codex here
Too Many Things To Try
Having a really short attention span and a wide range of interests makes for lots and lots of things to try. Now I just need to figure out what to do with some of these:
- processing and toxiclibs for visualisation stuff
- CoffeeScript, Brunch, Backbone.js, ICanHaz.js and Moustache.js for web bits and pieces
- More and more interesting stuff for Android tablets
- Arduino for the real world bits – maybe some high speed photography…