Skip to content

Instantly share code, notes, and snippets.

@tsmsogn
Last active August 18, 2016 16:38
Show Gist options
  • Select an option

  • Save tsmsogn/4249402 to your computer and use it in GitHub Desktop.

Select an option

Save tsmsogn/4249402 to your computer and use it in GitHub Desktop.
JavaScript: Snippets
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
window.foo = window.foo || {}; // this.foo = this.foo || {};
foo.bar = foo.bar || {};
foo.bar.baz = foo.bar.baz || {};
(function(a) {
var b = a / Math.abs(a);
if (b === 1 || b === -1)
return b;
return 1;
})(0);
(function (w, r) {
w['r'+r] = w['r'+r] || w['webkitR'+r] || w['mozR'+r] || w['msR'+r] || w['oR'+r] || function (c) { w.setTimeout(c, 1000 / 60); };
})(window, 'equestAnimationFrame');
var content = "@abc@def @abc @あ @あ @あ  abcdefghijklmnopqrstuvwxyz @bcd\n@cde @ a @aaa@bbb @cde";
var matches = content.match(/@[^\s]+/g);
for (var i = 0; i < matches.length; i++) {
var count = matches[i].match(/@/g);
if (count.length == 1) {
var regex = new RegExp('(^|\\s)' + matches[i] + '(\\s|$)');
content = content.replace(regex, "$1" + matches[i] + "[objecId:" + i + "]$2");
}
}
var now = new Date();
var today = new Date(new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment