Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<script>
document.write('<pre>');
function $(x){
var _ = {valueOf: function v(a){
document.writeln(x +'\n -> _.valueOf('+ JSON.stringify(a) +')');
}};
eval(x);
}
$('Object(_)');
@satyr
satyr / linkopen.ubiquity.js
Created March 11, 2010 13:07
linkopen (fork)
CmdUtils.CreateCommand({
names: ['open links', 'linkopen'],
description: 'Opens links from among the current page.',
icon: 'chrome://ubiquity/skin/icons/tab_go.png',
arguments: [{role: 'object', nountype: noun_arb_text}],
preview: function preview(pblock, {object: {text}}) {
var me = this, links = me._links(text);
if(!links.length) return void this.previewDefault(pblock);
CmdUtils.previewList(
const FFInfo = 'http://www.fileformat.info/'
, H = Utils.escapeHtml
CmdUtils.CreateCommand({
name: 'unicode info',
icon: FFInfo +'favicon.ico',
argument: {object_unicode: {
suggest: function ucnfo_suggest(txt){
var t = txt.replace(/[\x00-\x20]+/g, ''), c, sp
if(/^&\w{2,}/.test(t)) t = Utils.unescapeHtml(RegExp.lastMatch +';')
@satyr
satyr / zen4x.js
Created February 23, 2010 15:39
zEn4X
function zen4x(zc){
var word = /[-\w$]+/, char = /^[^]/, digits = /\d+/;
var kv = /([-\w$]+)(?:=([^\]]*))?\]?/, content = /{([^\}]*)}?/;
var zs = zc.trim().split(/\s{0,}([>+])\s{0,}/);
var root = <_/>, curs = [root], sep;
for(let i = -1, l = zs.length; ++i < l; sep = zs[++i]){
let [name] = word(zs[i]) || '';
if(!name) continue;
let lm = <{name}/>, n = 1;
for(let _, m; char.test(_ = RegExp.rightContext);) switch(_[0]){
exit unless `git config --get remote.origin.url` =~ /(\d+)\.git$/
system "cmd /c start http://gist.github.com/#$1"
puts $1
CmdUtils.CreateCommand({
name: 'sort tabs',
description: 'Sorts tabs in the current window.',
author: {name: 'satyr', email: 'murky.satyr\100gmail.com'},
license: 'MIT',
icon: 'chrome://ubiquity/skin/icons/favicon.ico',
arguments: {
object: CmdUtils.NounType('method', {
'by title': function(t) t.linkedBrowser.contentTitle,
'by host': function(t) t.linkedBrowser.currentURI.host,
@satyr
satyr / adblock+filter.txt
Created January 26, 2010 20:38
private filters for Adblock Plus
[Adblock Plus 1.1]
! Checksum: BlImKQME9/j2KtuDsTRkTw
@@|http://storehouse.quickvps.net/
@@|http://www.ustream.tv/
@@|http://acid3.acidtests.org/
@@|https://www.google.com/analytics/
@@|https://www.google.com/reader/view/|$document
/\bad(?:s|click)?\b/
/\banalytics(?=[./])/i
|http://*w3schools.com/banners/
@satyr
satyr / topsy_auto_more.user.js
Created January 26, 2010 11:00
topsy auto more
// ==UserScript==
// @name topsy auto more
// @namespace http://d.hatena.ne.jp/murky-satyr
// @include http://topsy.com/*
// ==/UserScript==
addEventListener('scroll', function f(){
function stop(){ removeEventListener('scroll', f, false) }
try {
let a = document.querySelector('#more-bucket-more a');
if(!a || /\b0\b/.test(a.textContent)) return stop();
@satyr
satyr / cases.ubiq.js
Created January 26, 2010 10:00
upper/lower/title/flipped case
function casecmd(fn) CmdUtils.CreateCommand({
name: fn.name +' case',
description: 'Makes text '+ fn.name +' case.',
icon: icon(fn('Aa')),
argument: noun_arb_text,
execute: function case_execute({object: {text, html}}){
if(!text) return;
var t = fn(text);
CmdUtils.setSelection(fn(html), {text: t}) || CmdUtils.copyToClipboard(t);
},
@satyr
satyr / power_indices.rb
Created December 14, 2009 05:16
Shapley-Shubik/Banzhaf power indices
# coding: utf-8
require 'mathn'
class PICalc
def initialize name, parties
@name = name
@parties = parties
@total = parties.values.inject :+
@perms = parties.to_a.permutation.to_a
end