Skip to content

Instantly share code, notes, and snippets.

View andrewk's full-sized avatar

Andrew Krespanis andrewk

View GitHub Profile
@andrewk
andrewk / gist:4129315
Created November 22, 2012 03:30
snapshot of the formatting section of Flippa's SASS styleguide

= Flippa CSS Styleguide =

== CRITICAL: Regenerating Stylesheets for deployment ==

If you edit any stylesheets in app/stylesheets, you must run the following command from the project's root:

$> bundle exec compass compile

== Basic Formatting ==

@andrewk
andrewk / gist:7460371
Last active December 28, 2015 06:49
Rails doesn't expect {{, }}, or encoded versions to be an XSS vulnerability, so doesn't do anything about them in user input. If your page has AngularJS sections (ngApp) which have user input, you need to protect yourself from the attack vector added by AngularJS. This is a VERY basic, alpha implementation. It works as advertised, but has room f…
# =========== lib file ===================
class XssScrubber
def angular_xss_filter(unknown)
case unknown
when Hash
angular_xss_filter_hash(unknown)
when Array
angular_xss_filter_array(unknown)
when String
@andrewk
andrewk / skynet.js
Last active January 3, 2016 20:58
Current state of the API for the scheduling and compensation client of a distributed, open source home automation platform I'm developing. Requesting early feedback as this is the code users will most often interact with and one of the areas in greatest need of flexibility.
// scheduling supports all formats offered by later.js (http://bunkat.github.io/later/)
// Scheduled device event
schedule('blinds', 'open').at('10:00am').execute();
schedule('blinds', 'closed').at('5:00pm').execute();
// Scheduled compensation triggers
every('5 minutes')
.if(env.tooHot
.respond(turnOnFans)
@andrewk
andrewk / gist:8909787
Created February 10, 2014 03:16
Notes on emergency.vic.gov.au/map performance for country users

Firstly thank you. FireReady and the emergency.vic site are an incredible resource, especially yesterday sitting here in the Macedon Ranges watching events unfold in Gisborne and considering when and where we might evacuate. So to everyone involved, thank you and congratulations on delivering a rock-solid resource.

A couple of notes on the site and why I pointed people to the text version...

Cold Cache Tests

While the server response has remained fast, that's only the start of the loading as the JS fires and brings in all the map tiles etc. Right now over my iinet ADSL1 connection 1.2km from the centre of Kyneton (Telstra infastructure), the page response has finished in 786ms, but the page takes 15.07 seconds to finish loading resources, the last of which are all the map tiles. Most of these map tiles are pre-loads by Google, with all the tiles in view finishing within 7 seconds. 90 requests in total. The memory heap for this page was 43.8mb (Chrome 32, OSX)

Keybase proof

I hereby claim:

  • I am andrewk on github.
  • I am andrew (https://keybase.io/andrew) on keybase.
  • I have a public key whose fingerprint is E618 A31B 9576 26C4 428B 4274 AEA5 8AC2 20E7 E99C

To claim this, I am signing this object:

@andrewk
andrewk / Makefile
Last active August 29, 2015 13:57
Welcome to 2014, where apparently we need all this bullshit.
.PHONY: setup test
setup:
mkdir test
mkdir test/specs
mkdir test/fixtures
mkdir assets
mkdir assets/js
mkdir assets/css
mv test-main.js ./test/
@andrewk
andrewk / Nested DOM structure as FlightJS components
Last active August 29, 2015 13:59
Response to request for modelling nested DOM as flight components - https://gist.github.com/djreimer/10687904
- I wrote this on the train after a long day with a heavy head cold. I haven't run it,
but regardless of likely errors I think it expresses the design well enough.
- Segment and ConditionSet look close to identical, but that's likely due to the simplified
nature of the outline you provided
- I don't like attaching components to classes unless they're `js-`, as it's coupling
your styling and behaviour layers. We excelusively use data attributes for JS-DOM coupling
and I've quickly grown fond of the approach.
@andrewk
andrewk / Makefile
Last active August 29, 2015 14:04
Sass include paths - bower vs npm
# watch assets for changes in development, using bower deps
watch:
sass -I assets/scss -I bower_components --watch assets/scss:public/css
# watch assets for changes in development, using npm deps
watch:
sass $(foreach d, $(shell find . -name 'node_modules' -type d), -I$d) -I assets/scss --watch assets/scss:public/css
# and what does that `find` call look like in reality?
@andrewk
andrewk / component-registry.js
Created July 30, 2014 04:38
Handling attaching Flight components to DOM nodes in async-injected content
define(function(require) {
'use strict';
var defineComponent = require('flight/lib/component');
return defineComponent(ComponentRegistry);
function ComponentRegistry() {
this.components = [];
this.defaultAttrs({
@andrewk
andrewk / mov2gif
Created August 8, 2014 01:23
Animated screenshot for github PRs
#!/bin/sh
# Convert movie (screencast) to lofi animated gif for embedding in github PR's, emails etc.
#
# Requires: ffmpeg, gifsicle
# Screencasts are easily captured in Quicktime Player: File > New screen recording
if [ -z "$1" ]
then
echo "Usage: mov2gif input.mov 700 > output.gif"