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.
{
"libs": "[{\"start\":4294967296,\"end\":4294979584,\"offset\":0,\"name\":\"/Users/akovalyov/Source/m-c/obj-x86_64-apple-darwin12.4.0/dist/Nightly.app/Contents/MacOS/firefox\",\"breakpadId\":\"0C7E05F5A08D3968AAFF4EC6D90CCBB80\"},{\"start\":140735650410496,\"end\":140735650414592,\"offset\":0,\"name\":\"/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa\",\"breakpadId\":\"1F77945CF37A3171B22EF7AB0FCBB4D40\"},{\"start\":140735473885184,\"end\":140735475036160,\"offset\":0,\"name\":\"/usr/lib/libobjc.A.dylib\",\"breakpadId\":\"90D31928F48D3E37874F220A51FD9E370\"},{\"start\":4294995968,\"end\":4295008256,\"offset\":0,\"name\":\"/System/Library/Frameworks/ExceptionHandling.framework/Versions/A/ExceptionHandling\",\"breakpadId\":\"47FF83ED0C07308CA3752A2189DB10560\"},{\"start\":4295024640,\"end\":4295110656,\"offset\":0,\"name\":\"/Users/akovalyov/Source/m-c/obj-x86_64-apple-darwin12.4.0/dist/Nightly.app/Contents/MacOS/libmozglue.dylib\",\"breakpadId\":\"9C919817F4B537CDA1AE3C178520D34C0\"},{\"start\":
@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;