Skip to content

Instantly share code, notes, and snippets.

@pjkelly
pjkelly / connections.md
Last active August 29, 2015 13:57
The table below shows the number of connections per server supported by current browsers for HTTP/1.1 as well as HTTP/1.0.
2
Browser HTTP/1.1 HTTP/1.0
IE 6,7
# mongoid 3.x
#
# As discussed in: http://blog.mongolab.com/2014/02/mongodb-driver-tips-tricks-mongoid-3
#
production:
sessions:
default:
# The standard MongoDB connection URI allows for easy replica set
# connection setup.
# Use environment variables or a config file to keep your
machine:
environment:
CODECLIMATE_REPO_TOKEN: mytoken
NODE_ENV: ci
node:
version: 0.10.26
dependencies:
pre:
- npm install -g codeclimate-test-reporter
test:

Ron,

We've been doing some thinking about things that will help optimize the auction clock, especially at the end of auctions, and wanted to run some stuff by you. Because all client browsers and computers are different, we need a way to make sure that all clients are keeping the correct time based on the server. To achieve this, we have historically been sending down a message from the server to all clients with the current time on the server.

A few problems have occurred with this approach. One is that, since we moved you from a custom web sockets implementation to Pusher, you are now being charged based on the number of messages sent to the clients. This means that our messages to each connected client will add up very quickly, and we want to avoid that for you. The second problem is that the constant pusshing of information can be a drain on resources for the server, especially when it is unnecessary for the auction to be updating so frequently when the auction is weeks, days, even hours, away from exp

// Load environment variables
require('dotenv');
// Cluster Initialization
var cluster = require('cluster');
// Code to run if we're in the master process
if (cluster.isMaster) {
@pjkelly
pjkelly / sublime-user-settings.json
Created June 7, 2014 04:11
Sublime User Settings
{
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": false,
"folder_exclude_patterns":
[
"log",
"tmp",
"backups",
"dump",
@pjkelly
pjkelly / circle.yml
Created September 18, 2014 04:40
whs.saba.do auto-deploy
test:
override:
- bundle exec jekyll
deployment:
production:
branch: master
commands:
- '[[ ! -s "$(git rev-parse --git-dir)/shallow" ]] || git fetch --unshallow'
- git push git@heroku.com:mrsabado-production.git $CIRCLE_SHA1:master -f
- curl -sSfL --retry 5 http://whs.saba.do > /dev/null
@pjkelly
pjkelly / copy.rb
Created May 14, 2015 18:08
Copy a local file to server w/ Cap 3
desc "Copy a file"
task :copy do
on roles(:web) do |host|
# localfile.html would be in the root of your repo in this case.
upload! 'localfile.html', current_path.join('public/localfile.html')
execute :chmod, '775', current_path.join('public/localfile.html')
end
end
module Columnizer
def columnize(k=3)
result_set = []
n = self.index(self.last)
r = (n + 1).to_f / k.to_f
(0..n).each do |z|
x = (z.to_f * r).ceil
x = x - n while x > n
result_set << self[x]
end
var amountVisible = function(element) {
var scroll_top = $(window).scrollTop();
var scroll_bottom = scroll_top + $(window).height();
var element_top = element.offset().top;
var element_bottom = element_top + element.height();
if (element_bottom > scroll_top && element_bottom < scroll_bottom) {
return element_bottom - scroll_top;
} else {
return scroll_bottom - element_top;
}