Skip to content

Instantly share code, notes, and snippets.

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])
file -b --mime-type /path/to/file.zip
@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
@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;
# 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 - ward@tty.nl
#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 / pagesnap
Created June 21, 2010 02:06
Save a webpage (and its linked assets) into a single HTML file.
#! /usr/bin/env php
<?php
/***
* PageSnap
*
* Script for archiving a HTML page (and associated media assets) into a single file.
*
* Requires:
*
We couldn’t find that file to show.
@afiore
afiore / index.html
Created January 4, 2011 22:02 — forked from mbostock/.block
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://github.com/simplegeo/polymaps/raw/v2.2.0/polymaps.min.js"></script>
<script type="text/javascript" src="http://github.com/mbostock/polymaps/raw/586fbb0346548a5559b6edea8aab76ac51334da5/lib/crimespotting/crimespotting.js"></script>
<style type="text/css">
@import url("http://github.com/simplegeo/polymaps/raw/v2.2.0/examples/example.css");
html, body {
/* vim:ts=2:sts=2:sw=2:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
/* vim:set ts=2 sw=2 sts=2
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,