Skip to content

Instantly share code, notes, and snippets.

View valueof's full-sized avatar
👋

Anton valueof

👋
View GitHub Profile

Keybase proof

I hereby claim:

  • I am valueof on github.
  • I am antonkovalyov (https://keybase.io/antonkovalyov) on keybase.
  • I have a public key whose fingerprint is 6BF4 15DC BC53 1C0C 9418 480B 0882 526B 2DC7 2A98

To claim this, I am signing this object:

var iframe = document.querySelector('#myid')
window.addEventListener('message', function (ev) {
var message = ev.data.split(':')
if (message[0] === iframe.id) {
iframe.style.height = message[1] + 'px'
iframe.style.width = message[2] + 'px'
}
})
<!doctype html>
<style>body {background-color: red; height: 500px; width: 500px;}</style>
<script>
window.addEventListener('message', function (ev) {
var message = ev.data.split(':')
if (message[0] != 'yo') {
return
}
<iframe id="myid" src="embed.html" onload="var i=document.querySelector('#myid'),a=i.id,s='style';window.addEventListener('message',function(e){var m=e.data.split(':');if(m[0] == a)i[s].height=m[1],i[s].width=m[2]});i.contentWindow.postMessage('yo:'+a,'*')">
@valueof
valueof / user.behaviors.clj
Last active January 4, 2016 18:49
LightTable Configuration
;; https://gist.github.com/antonkovalyov/8663025
{:+ {
;; The app tag is kind of like global scope. You assign behaviors that affect
;; all of Light Table here
:app [(:lt.objs.style/set-skin "light")]
;; The editor tag is applied to all editors
:editor [:lt.objs.editor/no-wrap
(:lt.objs.style/set-theme "solarized-light")
@valueof
valueof / gist:6033987
Created July 18, 2013 23:34
Which approach to cloning objects is faster? (Assuming there are no circular references, get/set, etc.)
// Candidate 1
JSON.parse(JSON.stringify(obj));
// Candidate 2
var desc = {};
Object.keys(obj).forEach(function(key) {
desc[key] = Object.getOwnPropertyDescriptor(obj, key);
});
Object.create(Object.prototype, desc);
@valueof
valueof / gist:6025748
Created July 18, 2013 00:19
profiles
This file has been truncated, but you can view the full file.
{
@valueof
valueof / gist:5111400
Last active December 14, 2015 15:58
M.a.a.d City / Code Version
Original lyrics: http://rapgenius.com/Kendrick-lamar-maad-city-lyrics
If Node peeps and Crock all got along
They'd probably gun me down by the end of this song
--
Seem like the whole codebase go against me
Every time I run my tests I hear
BUG BUG BUG BUG
@valueof
valueof / bind.js
Created February 27, 2013 00:29
Destructuring with bound functions, yay/nay?
function bind(obj) {
let bound = {};
for (let key in obj) {
bound[key] = typeof obj[key] === "function" ? obj[key].bind(obj) : obj[key];
}
return bound;
}
@valueof
valueof / original.js
Last active December 14, 2015 05:28
[Code Review] Trying to wrap my head around promises. Here's my attempt at rewriting one somewhat nested function. I'm not sure how to stop propagation from within a promise callback so, for the rewritten version, I changed `this.controller.isActive` to reject the promise if `isActive` is `false`. I don't really know if this code even works, I w…
ProfilerPanel.prototype = {
stopProfiling: function () {
this.controller.isActive(function (err, isActive) {
if (err) {
Cu.reportError("ProfilerController.isActive: " + err.message);
return;
}
if (!isActive) {
return;