This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function detectWebkitRequestFileSystem(e, t) { | |
return new Promise(function(e) { | |
if (!window.webkitRequestFileSystem) | |
return e(null); | |
window.webkitRequestFileSystem(window.TEMPORARY, 1, e.bind(null, !1), e.bind(null, !0)) | |
} | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Incognito trick | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Prevent sites detecting if you're in incognito by calling the success callback of webkitRequestFileSystem even if it's failing. | |
// @author You | |
// @run-at document-start | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
// Monkey patch `webkitRequestFileSystem` to call success callback even if the request failed | |
(function(webkitRequestFileSystem) { | |
window.webkitRequestFileSystem = function(type, size, successCallback, errorCallback) { | |
webkitRequestFileSystem(type, size, successCallback, successCallback); | |
} | |
})(window.webkitRequestFileSystem); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var incognito = function(require, module, exports) { | |
"use strict"; | |
function isWebkitRequestFileSystem() { | |
return !!window.webkitRequestFileSystem | |
} | |
function isFirefoxIndexedDB() { | |
return !!window.indexedDB && /Firefox/.test(window.navigator.userAgent) | |
} | |
function isIE10PlusOrEdge() { | |
if (document.documentMode) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hack for monkey patching $scope.$watch | |
this.$scope.$watch = ((originalWatchFn) => { | |
const scope = this.$scope; | |
// tslint:disable-next-line | |
return function(watchExpression, listener, objectEquality) { | |
// tslint:disable-next-line | |
const wrappedCB = function () { | |
console.log(watchExpression, arguments[0], arguments[1]); | |
listener.apply(null, arguments); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def record_factory(cls_name, field_names): | |
# ... | |
def __hash__(self): | |
try: | |
return hash(self.id) | |
except AttributeError: | |
raise TypeError('unhashable type {}'.format(cls_name)) | |
def __eq__(self, other): | |
try: | |
return hash(self) == hash(other) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def record_factory(cls_name, field_names): | |
# ... | |
def __hash__(self): | |
try: | |
return hash(self.id) | |
except AttributeError: | |
raise TypeError('unhashable type {}'.format(cls_name)) | |
# ... | |
cls_attrs = dict(__slots__ = field_names, | |
__init__ = __init__, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def record_factory(cls_name, field_names): | |
# ... | |
def _asdict(self): | |
return {k: getattr(self, k) for k in self.__slots__} | |
cls_attrs = dict(__slots__ = field_names, | |
__init__ = __init__, | |
__iter__ = __iter__, | |
__repr__ = __repr__, | |
__hash__ = __hash__, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nt = namedtuple('X', 'a b') | |
mydict = {} | |
dict[nt(1, 2)] = 5 | |
dict[nt(1, 2)] | |
# 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> hash(nt(1, 2)) | |
3713081631934410656 | |
>>> hash(nt(1, {'a': 5})) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: unhashable type: 'dict' |