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 () { | |
var setupRegularResize, setupIframeResize, e; | |
function bind(a, b) { | |
return function () { | |
return a.apply(b, arguments); | |
}; | |
} | |
setupRegularResize = (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
// Run this in your JS console while on box.com | |
$("#files_tab").after( | |
'<li id="teambox_tab" class="current">' + | |
'<a id="teambox_tab_link" href="https://teambox.com?embedded=1" onmousedown="return false;">Teambox</a></li>' | |
); | |
$(".body .main").html( | |
'<iframe src="https://teambox.com?embedded=1" style="border: none; width: 720px; height: 100000px"></iframe>' | |
); |
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
Resource Cache mechanism, for projects and people | |
Resource Cache is a key-value auto-expiring cache, where we pass | |
the path for a base model + a resource owned by it + modifiers. | |
Structure | |
--------- | |
Each cacheable entry is called with two or three parameters: |
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
/*global I18n*/ | |
(function ($) { | |
var PostedAt = {} | |
, moment = this.moment; | |
// Format dates in a human way. Read the code. | |
moment.fn.humanFormat = function () { | |
// ensure that we are on utc | |
var utc = this.clone().utc() |
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
date = Time.parse("2012-08-15") | |
(8+15).times do | |
users = User.where("created_at > ? AND created_at < ?", date, date + 1.day); 0 | |
puts [ | |
date.to_date.to_s, | |
users.count, | |
users.select {|u| Array(u.settings["steps"]).length === 0 }.count, |
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
// Load personal notes as a sidebar item | |
// find personal project | |
var project = Teambox.collections.projects.detect(function (p) { return p.get('permalink') === 'tb-personal-project-' + Teambox.models.user.id }); | |
if (project) { | |
Teambox.views.sidebar.apps_list.addApp( | |
"project_" + project.get('permalink') + "_pages", | |
"Personal notes", | |
"#!/projects/" + project.get('permalink') + "/pages", |
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
$("#talker2_link").remove() | |
Teambox.views.sidebar.apps_list.addApp("talker2", "New Group Chat", "#", "key"); | |
$("#talker2_link a").click(function (e) { | |
e.preventDefault(); | |
if (this.open) { | |
$(".chat_container").remove(); | |
$(".content_wrap").css("bottom", "0px"); | |
this.open = false; | |
} else { | |
var height = 250; |
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
~/code/rabl[master]: rake test:setup test:full | |
*** Setting up for padrino_test tests *** | |
The source :rubygems is deprecated because HTTP requests are insecure. | |
Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not. | |
Resolving dependencies... | |
Using rake (10.0.4) | |
Using i18n (0.6.4) | |
Using multi_json (1.7.2) | |
Using activesupport (3.2.12) |
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
# Possible anomaly: If the org was created long ago but only active recently, project_recent will always be low | |
# Proposed solution: Build a semirecent_activity field and use that for projections, which will track 6-12 months | |
def days_ago(o); (Time.now - o.created_at) / 1.day; end | |
def projected_recent(o); (o.total_activities / days_ago(o)).to_i * 14; end | |
# Get active subscriptions with a chargify id (to exclude cancelations and manual subscriptions) | |
ss = Subscription.where(state: nil).reject { |s| s.payment_gateway_id.nil? }; 0 | |
# Get orgs. Tweak the filters to restrict your results list | |
oo = ss.map { |s| Organization.find_by_subscription_id s.id }.compact; 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
class Array | |
# Takes %(apple apple strawberry orange orange apple) and returns { apple: 3, orange: 2, strawberry: 1 } | |
def occurrences | |
r = {} | |
group_by {|i| i}.each{|k,v| r[k] = v.count} | |
sorted = {} | |
r.sort_by {|k,v| -v}.each {|i| sorted[i[0]] = i[1] } | |
sorted | |
end | |
end |