Skip to content

Instantly share code, notes, and snippets.

(function() {
var max = 10000;
var pi = Math.PI;
(function() {
var a = new Array(max);
console.time('native');
for (var i = 0, len = a.length; i < len; i++) {
a[i] = pi;
// strict check
//
function strict() {
'use strict';
var isStrict = (function(){return !this}());
console.log(isStrict);
}
function nonStrict() {
@os0x
os0x / array.js
Created November 16, 2010 15:41 — forked from Constellation/array.js
function EXArray() {
var result = [];
result.__proto__ = EXArray.prototype;
for (var i = 0, len = arguments.length; i < len; ++i) {
result[i] = arguments[i];
}
return result;
}
// どうせなら仕様の範囲内で
// ==UserScript==
// @name AutoPatchWork for Opera
// @author os0x, edvakf
// @namespace http://ss-o.net/
// @description Automatically loads the next page and inserts into current page when you reach the end of the page. like AutoPagerize.
// @license The MIT License
// @version 0.2
// @include *
// @released 2010-07-07
// @updated 2010-07-07
@os0x
os0x / gist:369663
Created April 17, 2010 16:42 — forked from azu/gist:369595
// IEでも動くように(実質的には弄ったのはtest4のexecのみ)
var r = [];
var test = new Date*1;
for(var i=0;i<10000;i++){
var src = "http://example.com/lab/test.js"
src.substring(0,src.lastIndexOf('/')+1)
}
r.push(new Date-test);
var test2 = new Date*1;
// ==UserScript==
// @name fldr_show_fc2_images.user.js
// @namespace http://d.hatena.ne.jp/os0x/
// @description Make fc2 images viewable on LDR/Fastladder
// @include http://reader.livedoor.com/reader/
// @include http://reader.livedoor.com/public/*
// @include http://fastladder.com/reader/
// ==/UserScript==
// via http://gist.github.com/48621
@os0x
os0x / gist:215871
Created October 22, 2009 09:55 — forked from edvakf/gist:215821
function insertSITEINFO(callback,thisObject){
if (Set.DISABLE_IFRAME && window.parent !== window) return;
var src = (Set.SITEINFO_SERVER) ? Set.SITEINFO_SERVER + 'get?url=' + encodeURIComponent(location.href) : 'http://ss-o.net/json/wedataAutoPagerizeSITEINFO.js';
var sc = document.createElementNS(HTML_NAMESPACE, 'script');
sc.type = 'text/javascript';
window.AutoPagerizeCallbackSiteinfo = function(res){
callback.call(thisObject,res);
window.AutoPagerizeCallbackSiteinfo = null;
sc.parentNode.removeChild(sc);
var ev = document.createEvent('Event');
@os0x
os0x / addDefaultPrefix.js
Created September 10, 2009 03:44 — forked from cho45/dollarX.js
$X on XHTML and Cross Browser
// XPath 式中の接頭辞のない名前テストに接頭辞 prefix を追加する
// e.g. '//body[@class = "foo"]/p' -> '//prefix:body[@class = "foo"]/prefix:p'
// http://nanto.asablo.jp/blog/2008/12/11/4003371
function addDefaultPrefix(xpath, prefix) {
var tokenPattern = /([A-Za-z_\u00c0-\ufffd][\w\-.\u00b7-\ufffd]*|\*)\s*(::?|\()?|(".*?"|'.*?'|\d+(?:\.\d*)?|\.(?:\.|\d+)?|[\)\]])|(\/\/?|!=|[<>]=?|[\(\[|,=+-])|([@$])/g;
var TERM = 1, OPERATOR = 2, MODIFIER = 3;
var tokenType = OPERATOR;
prefix += ':';
function replacer(token, identifier, suffix, term, operator, modifier) {
if (suffix) {
@os0x
os0x / HTMLStringToDOM.js
Created August 8, 2009 14:55 — forked from snaka/HTMLStringToDOM.js
シンプルな HTMLPaser / scriptを削る正規表現はjAutoPagerizeから
function HTMLStringToDOM(str){
var html = String(str).replace(/<script(?:[ \t\r\n][^>]*)?>[\S\s]*?<\/script[ \t\r\n]*>|<\/?(?:i?frame|html|script|object)(?:[ \t\r\n][^<>]*)?>/gi, ' ');
var htmlDoc = document.implementation.createHTMLDocument ?
document.implementation.createHTMLDocument('HTMLParser') :
document.implementation.createDocument(null, 'html', null);
var range = document.createRange();
range.selectNodeContents(document.documentElement);
htmlDoc.documentElement.appendChild(htmlDoc.importNode(range.createContextualFragment(html),true));
return htmlDoc;
}
// ==UserScript==
// @name favlevel
// @namespace http://www.hatena.ne.jp/hitode909/
// @description show favotter level
// @include http://twitter.com/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function(){
var getLoginUser = function() {