javascript

Importing Images in Electron React Boilerplate

  • Posted on: 11 February 2017
  • By: davis

You'll need to do a few things to properly import images in electron-react-boilerplate

First, create a directory under app/ to store your image files (e.g. app/img). Then drop your images in the folder.

Here's the correct (and only!) way to import images correctly in electron-react-boilerplate:

TypeError: Cannot read property 'timeout' of undefined with Mocha and Fat Arrow Syntax

  • Posted on: 12 July 2016
  • By: davis

Don't do this: 

describe('Do Something', () => {
  it(`Should do stuff successfully`, (done) => {
    this.timeout(20000);
    // *this* binding refers to parent function scope in fat arrow functions
    // this will fail, no pun intended

    // do stuff here and include done() in the callback

Replace it with a normal function - fat arrow syntax will assign the "wrong" scope to timeout(), and you'll get an error like TypeError: Cannot read property 'timeout' of undefined

How I got the Shittalk Generator to 80kb pagesize

  • Posted on: 30 March 2016
  • By: davis

Lesson #1: Probably shouldn't have named it Shittalk Generator. It's hard to tell your family what it is. "Well... it's a script to shittalk people". Maybe I would have named it the Trash Talk Generator, in restrospect

You can track the actual commits I made on Github, you'll see the progression in pagesize.

Here are some notes:

Minify HTML (http://www.willpeavy.com/minifier/)

Bootstrap Buttons with Loading Progress Bars

  • Posted on: 16 November 2015
  • By: davis

Here's how to add loading bars to bootstrap buttons.

To start, you'll need the following files:

progress_bar.css

progress_bar.js

In your header, you'll need to include the above Javascript file (adapted from http://tutorialzine.com/2013/10/buttons-built-in-progress-meters/)

Retrieving RSS with Javascript and NoCache

  • Posted on: 30 March 2015
  • By: davis

I use Google Feeds API to power my RSS fetching for a couple applications. One inevitable problem with dynamically accessing RSS feeds is that they tend to be cached.

The easiest cache-busting Javascript trick, in my opinion, is to append your RSS Feed URI with ?nocache and a random value.

UPDATE 4/42015 - Removed the trailing '/' from the RSS URL below. The code will fail with Google Feed's API if you do not remove the trailing '/'. Alternatively, you may replace the ? with & if you wish to leave the slash.