This file contains 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
String fun(String fpath, List mods, Closure sorter){ | |
def r = new File(fpath).text.trim().split(/\r?\n/)*.tokenize('\t') | |
mods.each{ r.(it.maximumNumberOfParameters==2?'eachWithIndex':'each') it } | |
[r.head(), *r.tail().sort(sorter)]*.join('\t').join('\n') | |
} | |
print fun('data.csv', [ | |
{ it[0..3] = it[0, 2, 1, 3] }, | |
{ a, i -> if(i){ [0, 3].each{ a[it] = a[it].toInteger() }; ++a[3] } }, | |
]){ it[0] } |
This file contains 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
const Name = 'yats', | |
Yats = 'http://pcod.no-ip.org/yats/', | |
Base = ''+ <div class={Name}><base href={Yats}/><style><![CDATA[ | |
h2 {margin:0; padding:0} | |
img {width:16px; height:16px; border:none} | |
ol {margin:2px 0; padding:0} | |
li {float:left; clear:left; width:100%; padding:0 0 4px 0} | |
li div {float:left; padding-right:2px} | |
h2, p {clear:left; font-size:84%} | |
kbd {text-decoration:underline; vertical-align:top} |
This file contains 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
alert("test2"); |
This file contains 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
const Name = 'undo-closed-tabs', | |
SS = Cc['@mozilla.org/browser/sessionstore;1'].getService(Ci.nsISessionStore), | |
Style = <style>{<><![CDATA[ | |
@, @* {margin:0; padding:0} | |
@button {border-width:1px; | |
font:bold 112% "Consolas",monospace; vertical-align:top} | |
@li {list-style-type:none} | |
@img {width:16px; height:16px} | |
@span.url {display:inline-block; white-space:pre; font-size:88%} | |
@img, @span {vertical-align:middle} |
This file contains 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
const noun_storage_file = { | |
_name: 'storage_file', | |
suggest: function(txt, htm, cb, sx){ | |
if(sx || !txt) return []; | |
return matchSuggs(this.list, txt); | |
}, | |
list: (function({directoryEntries}, ls){ | |
while(directoryEntries.hasMoreElements()){ | |
var f = directoryEntries.getNext().QueryInterface(Ci.nsIFile); | |
if(f.exists() && f.isFile() && /\.sqlite$/.test(f.path)){ |
This file contains 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
//Twitter search + Google search | |
//Migrated to Ubiquity from Greasemonkey script: http://userscripts.org/scripts/show/43451 | |
//houyr@twitter | |
//function cmd_ | |
function pageLoad_twitterSearchPlusGoogle(doc) { | |
var href = doc.location.href; | |
var q = (/^https?:\/\/(?:www\.)?google\..*\/.*[&?]q=([^&]*)(?:&|$)/(href)||0)[1]; | |
if(!q) return; | |
var lang = (href.match(/[&?]hl=([^&]*)(?:&|$)/)) ? href.match(/[&?]hl=([^&]*)(?:&|$)/)[1] : 'en'; |
This file contains 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 Appjet Gist Sync | |
// @description Syncs Appjet publishing to Gist posting/updating | |
// @namespace http://d.hatena.ne.jp/murky-satyr | |
// @name$pace http://d.hatena.ne.jp/youpy/ | |
// @include http://appjet.com/app/*/ide | |
// ==/UserScript== | |
if(top !== self) return; | |
const {URL} = document, [AppID] = /\d+/(URL); |
This file contains 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
CmdUtils.CreateCommand({ | |
name: "example", | |
takes: {"search term": /.*/}, | |
preview: function(pblock, input) { | |
CmdUtils.previewGet(pblock, "http://google.com/search", {q: input.text}, function(data){ | |
pblock.innerHTML = data; | |
}); | |
} | |
}); |
This file contains 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
// 1. Should also work for <img>, <form>, <link>, etc. | |
// 2. Should also work for html string, DOM, and XML. | |
// 3. Should return the same (type of) object it received. | |
function absolutifyUrls(data, baseUrl) { | |
switch(typeof data){ | |
case "string": | |
return data.replace( | |
/\b(href|src|action)=([\"\']?)(?!https?:\/\/)(\S+)\2/ig, | |
function au_repl(_, a, q, path)( | |
a + "=" + q + Utils.url({uri: path, base: baseUrl}).spec + q)); |
OlderNewer