pushState and replaceState bug in Chrome

Filed in: Development

Today I noticed that pushState and replaceState cause the reload button and favicon to flicker although no page load (or reload) has occurred.

This bug in Chrome was first reported in July 2010 but still exists in the latest version for OS X. The reload button/throbber doesn’t flicker in Chrome for iOS but the favicon changes to the default (greyscale globe).

I’ve created a demo on JS Bin that reproduces the conditions to observe this behaviour, and a brief (silent) screencast that displays the behaviour. View in 1080p to see exactly what is going on.

Ignore files when deploying from wercker

Filed in: Development

arrow from wercker to heroku

wercker doesn’t currently have provide a feature to ignore files when deploying.

As I deploy to Heroku using a git push I can use a .gitignore file to ignore files when deploying from wercker.

I have two ignore files, .gitignore is for my app repository, and .deploy.gitignore is for ignoring files during the deploy stage.

As part of my build I overwrite .gitignore with .deploy.gitignore. When wercker creates the deploy repository it ignores any files that match the rules in the ignore file.

I use the following step in my wercker.yml:

- script:
    name: "app init"
    code: |-
      cd /pipeline/build
      cp operations/.deploy.gitignore .gitignore

/pipeline/build is where wercker puts your code so we have to cd there as the default working directory is $HOME.

And that’s it. Don’t want any .pyc files being pushed to your deployment platform, add *.pyc to your .deploy.gitignore. Add as many rules as you see fit.

How to install lessc on wercker

Filed in: Development

lessc on wercker

Want to compile your LESS assets on werker?

The wercker/python box does not have a LESS compiler available. To install lessc you must first install npm but when I tried to execute curl http://npmjs.org/install.sh | sh on wercker the script reported some errors (which I didn’t record and now can’t reproduce).

Use the following script to install lessc on wercker:

box: wercker/python
  build:
    steps:
      - script:
        name: "install lessc"
        code: |-
          curl https://npmjs.org/install.sh | sudo bash
          sudo npm install less -g

lessc can also be installed locally (not using sudo) if you prefer. In this case as the box is short lived using sudo should be fine.

box: wercker/python
  build:
    steps:
      - script:
        name: "install lessc locally"
          curl https://npmjs.org/install.sh | npm_config_prefix=~/local sh
          ~/local/bin/npm install less
#         ~/node_modules/.bin/lessc -v

Also available as a GitHub Gist.

HTTP 400 errors when using run_every in IronWorker Python

Filed in: Python

Say you have a small script like the following:

import sys
from iron_worker import IronWorker
from iron_worker import Task

worker = IronWorker()
task = Task(
    code_name="HelloWorld", 
    scheduled=True, 
    run_every=sys.argv[1])

response = worker.queue(task)
print response

If you want to schedule the job to run every minute you could call python schedule.py 60. This will unfortunately return an HTTP 400 response.

The reason is that the run_every parameter is being passed as a string. A simple fix is to convert to an int:

task = Task(
    ...
    run_every=int(sys.argv[1]))