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
require 'digest/md5' | |
# usage: run this in the root directory of your iTunes Music folder, or wherever, and pipe the output to a file | |
# next, pipe the output of that file through `sort` to a new file | |
# now, use the next script on that file | |
ls = Dir['**/*'] | |
ls.each_with_index do |f, i| | |
STDERR.puts ls.length - i if (i % 100 == 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
function(seq, req) { | |
var min = 0, term, count, row | |
, i, top = parseInt(req.query.top), match = []; | |
while (row = getRow()) { | |
term = row.key[0]; | |
count = row.value; | |
if (match.length < top) { | |
match.push([term, count]); | |
} else { | |
if (count > min) { |
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
require 'rubygems' | |
require 'garb' | |
# couchrest is only required because it makes the dates to_json into | |
# something javascript can parse. | |
require 'couchrest' | |
class OpenStruct | |
def to_json | |
table.to_json | |
end |
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(ks, vs, rr) { | |
// values are discarded by reduce | |
// todo: configurable key function, for complex queries | |
var fk, lk; | |
function uniqCount(keys) { | |
var count = 0, obj = {}; | |
for (var i=0; i < keys.length; i++) { | |
if (!obj[keys[i]]) { | |
count++; | |
obj[keys[i]] = true; |
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
<!DOCTYPE html> | |
<html> | |
<!-- This should be the simplest possible jQuery based CouchApp. Install by uploading to a design document in Futon or putting in _attachments/index.html and running `couchapp push` --> | |
<head><title>Tiny CouchApp</title></head> | |
<body> | |
<h1>Tiny CouchApp</h1> | |
<ul id="databases"></ul> | |
</body> | |
<script src="/_utils/script/jquery.js"></script> | |
<script src="/_utils/script/jquery.couch.js"></script> |
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
rainPain = function(temp, cip) { | |
if (temp < 39) { | |
console.log ("too cold!") | |
} else if (temp<80 && cip){ | |
console.log("ouch") | |
} else { | |
console.log("time to walk the dogs") | |
} | |
} | |
rainPain(75, true) |
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
<!DOCTYPE html> | |
<html> | |
<head><title>Tiny CouchApp</title></head> | |
<body> | |
<h1>Tiny CouchApp</h1> | |
<form id="new_message"> | |
<label for="message">Message:</label> | |
<input type="text" name="message" value=""> | |
<p><input type="submit" value="Save →"></p> | |
</form> |
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
// Copyright Chris Anderson 2011 | |
// Apache 2.0 License | |
// jquery.couchLogin.js requires jquery.couch.js | |
// | |
// Example Usage (loggedIn and loggedOut callbacks are optional): | |
// $("#mylogindiv").couchLogin({ | |
// loggedIn : function(userCtx) { | |
// alert("hello "+userCtx.name); | |
// }, | |
// loggedOut : function() { |
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
# usage: | |
# git log | ruby not_in_svn.rb | less | |
# license: Apache 2.0 | |
# copyright: J Chris Anderson 2011 | |
# this might be too trivial to copyright | |
def print_if_no_match buffer, regex | |
text = buffer.join("\n") | |
unless text.match(regex) | |
puts text |
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
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011) | |
Copyright 2004 Free Software Foundation, Inc. | |
GDB is free software, covered by the GNU General Public License, and you are | |
welcome to change it and/or distribute copies of it under certain conditions. | |
Type "show copying" to see the conditions. | |
There is absolutely no warranty for GDB. Type "show warranty" for details. | |
This GDB was configured as "x86_64-apple-darwin".Attaching to process 44141. | |
2011-09-24 15:04:57.694 daz[44141:f803] Registering custom .ini file /Users/jchrisa/Library/Application Support/iPhone Simulator/5.0/Applications/696D756A-2862-4778-A48A-E63A9E7FDAF8/daz.app/app.ini | |
2011-09-24 15:04:57.697 daz[44141:f803] Couchbase: Starting CouchDB, using runtime files at: /Users/jchrisa/Library/Application Support/iPhone Simulator/5.0/Applications/696D756A-2862-4778-A48A-E63A9E7FDAF8/daz.app/CouchbaseResources (built Sep 21 2011, 14:55:44) | |
Eshell V5.8 (abort with ^G) |