Skip to content

Instantly share code, notes, and snippets.

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] }
@satyr
satyr / yats.ubiq.js
Created January 11, 2009 01:04 — forked from satyr/yats.ubiq.js
yet another twitter search <http://pcod.no-ip.org/yats/>
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}
@satyr
satyr / test2.js
Created January 23, 2009 10:08 — forked from Constellation/test2.js
<script>alert=0</script>
alert("test2");
@satyr
satyr / undo-closed-tabs.ubiq.js
Created February 20, 2009 15:47
Reopens tabs you've closed recently.
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}
@satyr
satyr / vacuum-and-reindex.ubiq.js
Created March 1, 2009 14:53
Performs VACUUM and REINDEX on your Firefox storage.
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)){
@satyr
satyr / x
Created March 5, 2009 14:53 — forked from dhou/x
//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';
// ==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);
// ==UserScript==
// @name OperaStyle_menuAccessKey.uc.js
// @namespace http://d.hatena.ne.jp/Griever/
// @include main
// ==/UserScript==
var menuAccessKey = {
HINTKEYS : new String('abcdefghijklmnopqrstuvwxyz0123456789'),
init : function(){
window.addEventListener('popupshown', this, false);
@satyr
satyr / x
Created March 23, 2009 10:02 — forked from cers/x
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;
});
}
});
// 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));