During the summer, Rackspace Blacksburg set on a consistent schedule of office-wide tech talks. These talks ranged in subject from conference presentations to new technologies to managerial styles. Above are some of the talks that have been given in the last couple months that I have had a chance to record and post to the Racksburg YouTube channel.
I’ll admit it: I’ve been completely sucked into webscript.io. Webscript.io is a site that allows for small Lua scripts to be hosted on user-selected URLs. A coworker and I have spent the last two weeks designing new dashboards for our Rackspace team, scraping websites, and throwing small scripts back and forth. The number of written lines of Lua between the two of us has easily broken into the thousands.
While working on a recent script, I ran into a situation where JSON would need to be input and parsed. Unfortunately, the built-in webscript.io
JSON.parse function does not have any sort of decent error handling. If there is a problem, your script 500s and the user receives a blank response.
There are a lot of incredibly in-depth Lua JSON libraries, but keeping with webscript.io’s spirit of “small scripts”, I was hesitant to import any of them in their entirety. All I needed from these libraries was validation - is this string valid JSON, or are there missing brackets and broken syntax?
This led to the creation of a Lua JSON Validator. The module does exactly as described above: takes a string as input and returns true or false if it’s valid JSON.
To use the module, you simply need to import it via a
local validJson = require "amussey/lua-json-validator/validJson" if validJson(jsonString) then -- interact with valid JSON else -- report invalid JSON end
A series of test cases are also provided with the module.
To view the source code, visit the github repo:
As always, pull requests on the repo or comments on this post are welcome!
I had the opportunity to film the Racksburg (Rackspace Blacksburg) response to the ALS Ice Bucket challenge from Graham Weston last week. Awesome to see so many participating Rackers!
While constructing the Github Team Pull Request Highlighter, I ran into the need to translate color codes back and forth between hex (
#ff0000) and RGB/RGBA (
rgba(255, 0, 0, 1)).
hexToRgb returns an object with r, g, and b properties.
var color = hexToRgb("#1fbcff"); color.toString(); // rgb(31, 188, 255) color.r; // 31 color.g; // 188 color.b; // 255
hexToRgb can also accept an
alpha value has a second parameter. This allows the output of
var color = hexToRgb("#1fbcff", 0.5); color.toString(); // rgba(31, 188, 255, 0.5) color.r; // 31 color.g; // 188 color.b; // 255 color.alpha; // 0.5
rgbToHex returns a hex string in the format
#ffffff. It can accept a wide variety of inputs.
rgbToHex(31, 188, 255); // #1fbcff rgbToHex("rgb(31, 188, 255)"); // #1fbcff rgbToHex("rgba(31, 188, 255, 0.5)"); // #1fbcff
rgbToHex can also accept the color objects produced by
var color = hexToRgb("#1fbcff"); rgbToHex(color); // #1fbcff var color2 = hexToRgb("#1fbcff", 0.5); rgbToHex(color2); // #1fbcff
The repo for this library is available here (or click here if you want save time and go directly to the library).
A little over a year ago, I posted about a secret project I had been working on: the official iOS and Android app for Get Drunk Not Fat. There have a been a couple big updates since then, but today I have another to show off.
The latest interface update inherits the flat-UI style of iOS 7, along with a more appealing color scheme. Along side that, the performance has been improved, so you should see all around speed ups on your device.
While working with videos for a couple blogs, I’ve run across performance issue while embedding multiple videos on a page. Once you get past 2-3 embedded videos on a page (something that isn’t terribly challenging if that’s a primary focus of the site), the scroll speed slows to a crawl and over-all user performance begins to deteriorate.
Here’s how the page appears with and without the library:
This requires no modification to the existing code (unless you’re adding custom styling to the iframes). All you need is to embed the script:
If you run into any bugs or problems, let me know in the comments or on the github page!
I was inspired by a Tech Talk given by Brad Gignac a couple months ago at Rackspace on custom Web Components, so while looking at a way to cleanly parse out Markdown inside of an HTML document, I turned to custom HTML5 tags. To my dismay, I couldn’t find anybody implementing something like this for markdown.
To fix this issue, I’ve put together a small library to implement a
<markdown> tag. Since these custom elements require a dash to be included, I’ve had to use
The library is available for download on github. If you would like to see an implementation example, read on after the break.
I’ve spent a lot of time in the last couple months learning my way around building Chrome extensions, resulting in a couple useful extensions for day-to-day work. One of the most vital pieces of knowledge was understanding how to modify the DOM when something in the popup of an extension was clicked or modified. This involves a series of somewhat confusing message passes from the popup to the background script to a content script on the page. The following explains that process.