Skip to content

Instantly share code, notes, and snippets.

# Basic text search with relevancy for MongoDB.
# See http://blog.tty.nl/2010/02/08/simple-ranked-text-search-for-mongodb/
# Copythingie 2010 - Ward Bekker - [email protected]
#create (or empty) a docs collection
doc_col = MongoMapper.connection.db('example_db').collection('docs')
doc_col.remove({})
#add some sample data
doc_col.insert({ "txt" => "it is what it is"})
@afiore
afiore / map_datastructure.js
Created June 7, 2010 12:14
Parses a Javascript data structure (e.g the content of a mongodb collection) and infers a schema definition
/**
* Map_schema.js
*
* Parses a Javascript data structure (e.g the content of a mongodb collection)
* and populates a schema definition with its attribute names and types.
*
*/
function typeOf(value) {
var s = typeof value;
@afiore
afiore / Rakefile
Created May 16, 2010 17:12
Retrieves events from wikipedia's Day Of the Year section
# Wikievents:
#
# Retrieves all English Wikipedia's Day of the Year pages (http://en.wikipedia.org/wiki/Category:Days_of_the_year).
# Once downloaded the pages on disk, the script scrapes all events, births, deaths, and observances from each page and populates a mysql table
# called wikievents.
#
#
#
# USAGE:
# - set your mysql connection parameters in task :db_connect
file -b --mime-type /path/to/file.zip
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
post '/:name/:filename' do
userdir = File.join("files", params[:name])