Skip to content

Instantly share code, notes, and snippets.

View markmarkoh's full-sized avatar

Mark DiMarco markmarkoh

View GitHub Profile
{"video", [{count: 1}, {count: 1}, {count: 1}, {count: 1}]}
function() {
emit(this.time - (this.time % 86400), {count: 1});
}
require 'rubygems'
require 'mongo'
def db
$db ||= Mongo::Connection.new("localhost", 27017).db("logs")
end
def logs
$logs ||= db.collection("flex")
end
require 'model'
require 'time'
@s = Chart.count_all_activity
@s.find().to_a.each do |f|
puts "#{f['_id']} (#{Time.at(f['_id'])}) : #{f['value']['count']}"
end
mark@stats:~/$ ruby test.rb
...more results...
1260835200.0 (Tue Dec 15 00:00:00 +0000 2009) : 316.0
1260921600.0 (Wed Dec 16 00:00:00 +0000 2009) : 1874.0
1261008000.0 (Thu Dec 17 00:00:00 +0000 2009) : 516.0
1261094400.0 (Fri Dec 18 00:00:00 +0000 2009) : 642.0
...more results...
mark@stats:~/$
%html
%head
%title Stats Server
%meta{"http-equive" => "Content-Type", :content=>"text/html; charset=utf-8"}/
<script type="text/javascript" src="/flot/jquery.js"></script>
<script language="javascript" type="text/javascript" src="/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="/flot/jquery.flot.selection.js"></script>
%body
=yield
:javascript
$(document).ready(function () {
var d = #{@activity_data};
var options = {
xaxis: { mode: "time"},
selection: { mode: "x"}
};
var plot = $.plot($("#activity_placeholder"), [d], options);
$("#activity_placeholder").bind("plotselected", function (event, ranges) {
require 'rubygems'
require 'sinatra'
require 'haml'
require 'model'
set :port, 80
get '/' do
protected!
[[1256774400000, 702], [1256860800000, 938], [1256947200000, 36]]
<script type="text/javascript">
document.write(unescape("%3Cscript src='http://press9formoreoptions.com/static/p9.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var p9 = P9fmo("GROUP-TOKEN");
} catch(err) {}
</script>