Skip to content

Instantly share code, notes, and snippets.

View DmitryBaranovskiy's full-sized avatar

Dmitry Baranovskiy DmitryBaranovskiy

View GitHub Profile
@DmitryBaranovskiy
DmitryBaranovskiy / gitpoint-logo.svg
Last active August 1, 2017 03:26
GitPoint Logo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DmitryBaranovskiy
DmitryBaranovskiy / gist:b1d843c769fea29c8f49
Created July 8, 2014 07:48
Anything to anything map using events
function assign(key, value) {
eve.on("{}↔︎{}", function (f) {
if (this == key) {
eve.stop();
f(value);
}
});
}
function get(o) {
var res;
// This gist is based on eve (https://github.com/adobe-webplatform/eve), but really any event based API will do
// Idea is to recreate backbone-like model, but on events only
// Model here is a hash-map, but it shouldn’t be. You could implement any structure this way.
function model(id) {
var modelid = ["model", id],
name = function () {
return modelid.concat.apply(modelid, arguments);
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function commonCase() {
// common case
el.animate({x: 10}, 1000, callback);
// API
var anim = new Anim;
anim.timing.iterationDuration = 1000;
var f = anim["function"] = new KeyFramesAnimFunction;
f.property = "x";
f.frames = new AnimFrameList;
@DmitryBaranovskiy
DmitryBaranovskiy / svgwg.md
Created March 26, 2012 07:02
Raphaël Findings

Dear SVG WG,

While developing Raphaël I came across different issues with SVG API as a developer and in this letter I am going to share my experience of these issues and, more importantly, my approach to solve them with Raphaël API.

Start with easy one.

getBBox() — doesn’t take transformations into account. I guess there are cases when this is useful, but it would be nice to have ability to get bounding box of the object after transformation as well. Also I added x2 & y2 as a returning values. This made developer life a bit easier.

Transformations

var text = "Tweet…"
text.replace(/(^|\s)(?:#([\d\w_]+)|@([\d\w_]{1,15}))|(https?:\/\/[^\s"]+[\d\w_\-\/])|([^\s:@"]+@[^\s:@"]*)/gi, function(all, space, hashtag, username, link, email) {
var res = '<a href="mailto:' + email + '">' + email + "</a>";
hashtag && (res = space + '<a href="http://search.twitter.com/search?q=%23' + hashtag + '">#' + hashtag + "</a>");
username && (res = space + '<a href="http://twitter.com/' + username + '">@' + username + "</a>");
link && (res = '<a href="' + encodeURI(decodeURI(link.replace(/<[^>]*>/g, ""))) + '">' + link + "</a>");
return res;
});