Skip to content

Instantly share code, notes, and snippets.

View valueof's full-sized avatar
👋

Anton valueof

👋
View GitHub Profile
XPCOMUtils.defineLazyGetter(DebuggerController, "_isRemoteDebugger", function() {
// We're inside a single top level XUL window, not an iframe container.
return !(window.frameElement instanceof XULElement) &&
!!window._remoteFlag;
});
XPCOMUtils.defineLazyGetter(DebuggerController, "_isChromeDebugger", function() {
// We're inside a single top level XUL window, but not a remote debugger.
return !(window.frameElement instanceof XULElement) &&
!window._remoteFlag;
@valueof
valueof / notabs.js
Created October 13, 2012 18:12
A reporter that discards all warnings about mixed tabs and errors
/**
* notabs.js
*
* A reporter that discards all warnings about mixed tabs and errors.
* This file was based on our default reporter so output is the same.
*
* Usage:
* jshint myfile.js --reporter=notabs.js
*/
function PC_start() {
// Also available: gc, stackwalk, jank, adb, copyProfileOnStop
let features = ["js"];
this.entries = 1000000;
this.interval = 1;
this.profiler.StartProfiler(this.entries, this.interval, features, features.length);
dump("[LOG] features: " + this.profiler.GetFeatures([]) + "\n"); // [LOG] features: stackwalk,jank,js
}
@valueof
valueof / gist:3744450
Created September 18, 2012 17:25
0++

SpiderMonkey:

> 0++;
SyntaxError: invalid increment operand

V8:

@valueof
valueof / gist:3184261
Created July 26, 2012 20:18 — forked from hzr/gist:3183910
Check for Opera bug with nested redirected calls
var hasWorkingNestedRedirectedCalls = (function () {
function f(a) { return function() { return a.apply(this, arguments); }}
var g1 = f(function(a) { return a; });
var g2 = new g1(g1);
return typeof g2 == "function";
})();
@valueof
valueof / view.fatarrows.js
Created June 6, 2012 00:50
Backbone view that initializes a third-party JavaScript app, attaches a couple of listeners and sends a signal back to the parent page: with and without fat arrows.
var Lounge = Backbone.View.extend({
initialize: function (options) {
// ...
Bus.listen('window.inViewport', () => {
this.states.inViewport = true;
this.trigger('inViewport');
});
Bus.listen('window.scrollOffViewport', () => {
@valueof
valueof / gist:2837820
Created May 30, 2012 17:33
Without running this code could you tell me its output?
Object.defineProperty(Object.prototype, "foo", {
set: function (v) {
console.log("hello:", v);
},
configurable: true}
);
var obj = { foo: "bar" };
var obj2 = {};
@valueof
valueof / README
Created March 14, 2012 23:32
Unfinished GitHub patch helper written in JavaScript/Node
I started writing this program but then got bored and decided to
re-write it in Go. This is my unfinished JavaScript variant.
See https://github.com/antonkovalyov/r2go for more information.
Array.prototype.join = function () {
return "LOL, UMAD?";
};
(function () {
"use built-ins";
console.log(['Hello', 'World'].join(', ')); // Hello, World
}());
package main
import (
"template"
"fmt"
)
func main() {
tmpl := template.New(nil)
tmpl.SetDelims("{{", "}}")