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 ApplicationController < ActionController:Base | |
before_action :update_online_status | |
def update_online_status | |
now = DateTime.now | |
expire_time = now + 5.minutes | |
current_time_key = "online_users:#{now.minute}" | |
$redis.sadd(current_time_key, current_user.id) | |
$redis.expireat(current_time_key, expire_time) |
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
# Make it use C-a, similar to screen.. | |
unbind C-b | |
unbind l | |
set -g prefix C-a | |
bind-key C-a last-window | |
# Reload key | |
bind r source-file ~/.tmux.conf | |
set -g default-terminal "screen-256color" |
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 PdfMerger | |
def merge(pdf_paths, destination) | |
first_pdf_path = pdf_paths.delete_at(0) | |
Prawn::Document.generate(destination, :template => first_pdf_path) do |pdf| | |
pdf_paths.each do |pdf_path| | |
pdf.go_to_page(pdf.page_count) |
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
require 'spec_helper' | |
describe Users::OauthCallbacksController, "handle facebook authentication callback" do | |
describe "#annonymous user" do | |
context "when facebook email doesn't exist in the system" do | |
before(:each) do | |
stub_env_for_omniauth | |
get :facebook |
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
var win = window.open('foo.html', 'windowName',"width=200,height=200,scrollbars=no"); | |
var timer = setInterval(function() { | |
if(win.closed) { | |
clearInterval(timer); | |
alert('closed'); | |
} | |
}, 1000); |
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
finalRed= (red * 0.393) + (green * 0.769) + (blue * 0.189); | |
finalGreen = (red * 0.349) + (green * 0.686) + (blue * 0.168); | |
finalBlue= (red * 0.272) + (green * 0.534) + (blue * 0.131); |
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
rand(36**length).to_s(36) |
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
source 'https://rubygems.org' | |
gem 'active_model_serializers', git: 'git://github.com/rails-api/active_model_serializers.git' | |
gem 'ember-rails', git: 'git://github.com/emberjs/ember-rails.git' # so we get the pre version | |
gem 'rack-mini-profiler', git: 'git://github.com/SamSaffron/MiniProfiler' | |
gem 'vestal_versions', git: 'git://github.com/zhangyuan/vestal_versions' | |
gem 'message_bus', path: 'vendor/gems/message_bus' | |
gem 'rails_multisite', path: 'vendor/gems/rails_multisite' | |
gem 'simple_handlebars_rails', path: 'vendor/gems/simple_handlebars_rails' |
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
def get_linefunc(self, start_p, end_p): #just for 2nd euclidian space | |
x1, y1 = start_p[0], start_p[1] | |
x2, y2 = end_p[0], end_p[1] | |
a = 0 if ((x2-x1) == 0) else (y2-y1)/(x2-x1) | |
b = -1 | |
c = x1*a - y1 | |
return {'a':a, 'b':b, 'c':c} |
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
def initialize(options={}) | |
options.each do |key, value| | |
key = key.to_s | |
FriendRecommenderDB.class_eval do | |
attr_accessor key | |
end | |
send("#{key}=", value) | |
end | |
end |