Skip to content

Instantly share code, notes, and snippets.

View Aupajo's full-sized avatar

Pete Nicholls Aupajo

  • Christchurch, New Zealand
View GitHub Profile
@Aupajo
Aupajo / jsp_tag_parser.rb
Last active August 29, 2015 14:10
JSP tag parser in Ruby using Parslet
class JSPTagParser < Parslet::Parser
rule(:java) { (str('%>').absent? >> any).repeat.as(:java) }
rule(:jsp) { java.as(:code) }
rule(:jsp_with_tags) { str('<%') >> jsp >> str('%>') }
rule(:text) { (str('<%').absent? >> any).repeat(1) }
rule(:text_with_java) { (text.as(:text) | jsp_with_tags).repeat.as(:text) }
root(:text_with_java)
end
@Aupajo
Aupajo / autochain.md
Last active August 29, 2015 14:10
Autochain

Like autotune for your objects.

class Autochain
  attr_reader :subject

  def initialize(subject)
    @subject = subject
  end
@Aupajo
Aupajo / mutable_chain.md
Last active December 7, 2016 02:34
Mutable Chain

MutableChain

class MutableChain
  attr_reader :subject

  def initialize(subject)
    @subject = subject
  end
@Aupajo
Aupajo / calendar.md
Created November 6, 2014 20:47
Proposed Almanack JSON

Event source

An event source will always have the following properties:

{
  "name": "Event source",
  "type": "static"
}
@Aupajo
Aupajo / candidacy.js
Last active August 29, 2015 14:06
Woto application
var Candidacy = function(applicant) {
this.applicant = applicant;
};
Candidacy.SCORE_DIMENSIONS = [
'creativity',
'socialMediaEngagement',
'freshGraduate',
'passionate',
'workEthic'
@Aupajo
Aupajo / designer.html
Created July 17, 2014 22:15
designer
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../speech-mic/speech-mic.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@Aupajo
Aupajo / config.rb
Created July 7, 2014 00:56
Revolving asset host in Middleman
activate :asset_host
# Will generate asset1.example.org...asset4.example.org deterministically
set :asset_host do |asset|
"//asset%d.example.org" % (asset.hash % 4 + 1)
end
require 'time'
june_first = DateTime.new(2014, 6, 1)
june_second = DateTime.new(2014, 6, 2)
june_first > june_second # => false
(june_first..june_second).max == june_second # => true
(june_first..june_second).min == june_first # => true
# Range#max and #min return nil if the first value in range is larger than the last value.
require 'redis'
require 'benchmark'
hash = {}
array = nil
redis = Redis.new
n_values = 720
redis.del redis.keys("demo:*")

Ideas:

  • Remove vendor/assets from Sprockets environment
  • Spin up a browserify process that can compile a specific JS when asked
  • Add a require lookup mechanism that can understand bower/npm manifest
  • Add browersify hook to compile JS as a Sprockets post-processor

Goal:

what I'd like to do: use a combination of bower, npm, or vendor/assets for front-end deps, use browserify for JS compilation, use sprockets for CSS and asset hashes