This file contains 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
First, install nginx for mac with "brew install nginx". | |
Then follow homebrew's instructions to know where the config file is. | |
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self | |
2. Copy it somewhere (use full path in the example below for server.* files) | |
3. sudo nginx -s reload | |
4. Access https://localhost/ | |
Edit /usr/local/etc/nginx/nginx.conf: |
This file contains 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 the function as soon as it's called, but prevent further calls during `delay` ms | |
// Example: function.throttle(200) will only run function() once every 200 ms. | |
// Useful, for example, to avoid constant processing while typing in a live search box. | |
Function.prototype.throttle = function(delay) { | |
var fn = this | |
return function() { | |
var now = (new Date).getTime() | |
if (!fn.lastExecuted || fn.lastExecuted + delay < now) { | |
fn.lastExecuted = now | |
fn.apply(fn, arguments) |
This file contains 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
/** | |
* Show a notice when Mac's stupid scroll happens | |
* http://micho.biz/mac-osx-lion-horizontal-scroll-event/ | |
*/ | |
Global.preventStupidMacScroll = function () { | |
var self = this, | |
broken_browser = navigator.userAgent.match(/Macintosh/), | |
hide = Teambox.models.user.get('settings').hide_scroll_notice; | |
if (!broken_browser || hide) { |
This file contains 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
$(document).on("click", ".comment a", function(e) { | |
if ($(this).text().indexOf("@") !== -1) { | |
e.preventDefault(); | |
var email = $(this).text(); | |
(new Teambox.Views.Dialog({ | |
header: "User " + email + ". <a href='/become/" + email + "'>Become</a>" | |
, content: "<iframe src='/reports/users/" + email + "' style='width: 100%; height: 800px;'></iframe>" | |
})).open(); | |
} | |
}); |
This file contains 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
/** | |
* Adds a Like button to tasks, so users can like them. | |
* | |
* By default there are no votes enabled in the project. To enable: | |
* | |
* project.metadata('apps').set({ votes: true }); | |
* project.metadata('apps').save(); | |
* | |
*/ |
This file contains 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 |
This file contains 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 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 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 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", |
NewerOlder