Skip to content

Instantly share code, notes, and snippets.

URI templates

URI template syntax

But we have RFC6570, why another one?

Current implementation have more questions than answers:

  1. It describes only template expansion, not matching. While URI matching is more common task (routing) - any template standard which doesn't describe matching will fail
  2. The RFC6570 modifiers sometimes is pointless and create more pain than gain for developers
class Cache
attr_reader :limit, :store, :queue
def [](key)
heat(key) if result = store[key]
result
end
def []=(key, value)
@Ptico
Ptico / password.js
Last active December 23, 2015 04:59
var Password = {},
utils;
function getOptionNum(target, defaults, rest) {
if (typeof(defaults) == 'undefined') defaults = 0;
var val = (typeof(target) == 'undefined') ? defaults : target;
if (val > rest) val = rest;
require 'spec_helper'
describe Aequitas::Violation, '#resource' do
subject { object.resource }
let(:object) { described_class.new(rule, resource) }
let(:rule) { mock('Rule') }
let(:resource) { mock('Resource') }
it { should equal(resource) }
@Ptico
Ptico / deploy.rb
Last active December 16, 2015 00:19 — forked from Lightpower/gist:5347055
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
@Ptico
Ptico / abstract.rb
Created December 11, 2012 16:40
A tribute to abstract classes
module Abstract
def abstract(meth, args=[])
define_method(meth.to_sym) do |*params|
raise NotImplementedError, "method ##{meth} should be implemented with arguments (#{ args.join(', ') })"
end
end
end
class Hello
extend Abstract
@Ptico
Ptico / widget.js
Created August 30, 2012 16:10
bee.js widget proposition
define(["bee/widget", "app/models/transport", "app/modules/cargo-log"], function(Widget, Transport, CargoLog) {
"use strict";
var Transports = new Widget({
root: "#transports-sidebar",
extends: [CargoLog],
init: function() {
this.transports = [];
@Ptico
Ptico / class-test.js
Created April 15, 2012 01:20
Just an experiment with JS object model and ES5 functions
var Hello = Class({
attrReader: "val",
initialize: function(val) {
this.val = val;
},
publicFn: function() {
console.log(this.val);
this.privateFn();
App = {};
// Another sandbox functions
/**
* Creates namespace in sandbox by string definition
* If part of namespace already defined - keep it untouchable,
* else - create empty object.
*
* App.namespace("Hello.World");
var Baby = (function() {
function Baby(name) { // Constructor
this.name = name;
}
Baby.prototype = { // Public
introduce: function() {
alert("Hello! My name is " + name);
},
play: function() {