I want to re-compile static assets (SASS to CSS and Coffeescript to JS) whenever there’s change in my Flask app.

I also want to optionally set a flag to toggle whether that compilation happens or not.

I’m using Flask-Assets, and it only seems to trigger the compilation whenever the jinja template with the corresponding assets extension is loaded.

For example, js_all.js will only be created whenever the jinja template with the following is loaded.

{% assets "js_all" %}
    <script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}

Bizarrely, triggering the build manually was rather hard to search for.

Here’s my solution.

****Update****
You can use bundle.build() instead of asserts[‘js_all’].urls()

if reload_flag:
  assets = Environment(app)

  # Don't cache otherwise it won't build every time
  assets.cache = False
  assets.manifest = False

  js = Bundle('jquery.js', 'base.js', 'widgets.js',
              filters='jsmin', output='gen/packed.js')
  assets.register('js_all', js)

  js.build()

****

You can build bundles manually with .urls().

if reload_flag:
  assets = Environment(app)

  js = Bundle('jquery.js', 'base.js', 'widgets.js',
              filters='jsmin', output='gen/packed.js')
  assets.register('js_all', js)

  assets['js_all'].urls()

In the template:

<script type="text/javascript" src="/static/gen/js_all.js"></script>

It’s a lot less robust than using assets to automatically inject the resource url, but for me, I don’t want compilation to happen on production (I don’t even want the compilation tools on the production machines).

Hope this helps folks.
Let me know if there’s a better answer.

My Ergodox Ez came today!

ergodoxez

It’s my first mechanical keyboard and I love it! I’m especially tickled by the red light when you go into code mode.

It’s open hardware and open firmware, and feels well made in general.

I’ve been meaning to get a mechanical keyboard for ages, and finally pulled the trigger when a friend gotten one.

Check it out if you’re in the market for a mechanical keyboard.

The Saccharomyces Genome Database is a really nice tool to get yeast gene info. I used it for the first time this past week.

I had to retrieve the sequence of 50+ yeast genes and individually downloading 50+ fasta files seemed really tedious.

Eventually I figured out you could retrieve multiple genomic sequences using YeastMine.

The YeastMine template query feature accepts comma separated genes.

Screen Shot 2016-03-17 at 9.53.27 PM

The resulting genomic DNA sequences can then be exported to CSVs.

Screen Shot 2016-03-17 at 9.54.59 PM

Seasoned SGD users probably already knew about this feature, but it took me a while to figure out (I did not have any luck searching for this topic).

Hopefully this post will save someone some time!

Here’s some highlights from the rest of CES / my Vegas trip:

congee

There was congee at the hotel’s breakfast buffet! SO GOOD!

craps

First time playing craps, I won $10 and then immediately took my winnings and ran.

fishfordinner

Harry and I imagined having fish for dinner.

Overall, fun trip. Got to talk to a lot of people about 3D printing. Got to see some friends (great surprises).

No Elvis though.

 

I got into Vegas last night.

I was super excited the entire ride, both for CES and Vegas.

looking around

Even though it was night time, it’s really neat to see the Strip from the sky.

Everyone else on the flight also seamed headed towards CES.

talking

So, CES here we come!