Skip to content

Instantly share code, notes, and snippets.

View y00rb's full-sized avatar
📚
Probably learning something new...

YangBo y00rb

📚
Probably learning something new...
View GitHub Profile
/* eslint-env browser */
const PionEvents = window.PionEvents = {
WEBSOCKET_OPEN: 'WEBSOCKET_OPEN',
WEBSOCKET_ERROR: 'WEBSOCKET_ERROR',
WEBSOCKET_CLOSE: 'WEBSOCKET_CLOSE',
MEDIA_START: 'MEDIA_START',
MEDIA_STOP: 'MEDIA_STOP',
PEER_ENTER_ROOM: 'PEER_ENTER_ROOM',
PEER_LEAVE_ROOM: 'PEER_LEAVE_ROOM',
@y00rb
y00rb / .vimrc
Created December 24, 2016 03:50
Vim config file within Vundle
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-scripts/molokai'
@y00rb
y00rb / .vimrc.after
Created December 24, 2016 02:00
my vim config file
runtime macros/matchit.vim
color Tomorrow-Night-Bright
set background=dark
set guifont=Monaco:h13
"colorscheme solarized
let g:solarized_termcolors = 256
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
let g:ruby_path = system('rvm current')
@y00rb
y00rb / gist:a6d9f3d43fadfa825461
Created October 4, 2015 08:59
How upgrade vim as system default
# mercurial required - install if you don't already have it.
$ brew install mercurial
# install Vim
$ brew install vim
# if /usr/bin is before /usr/local/bin in your $PATH,
# hide the system Vim so the new version is found first
$ sudo mv /usr/bin/vim /usr/bin/vim72

With Heroku's JRuby support you may have already seen that you can run TorqueBox Lite on Heroku. But, that only gives you the web features of TorqueBox. What about scheduled jobs, backgroundable, messaging, services, and caching?

With a small amount of extra work, you can now run the full TorqueBox (minus STOMP support and clustering) on Heroku as well! I've successfully deployed several test applications, including the example Rails application from our Getting Started Guide which has a scheduled job, a service, and uses backgroundable and messaging.

This example uses TorqueBox 3.0.2, but the instructions may work with other TorqueBox versions.

Steps Required

  1. Create a JRuby application on Heroku, or convert an existing application to JRuby. Make sure your application works on JRuby on Heroku before throwing TorqueBox into the mix.
  2. Add th

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh [email protected]

Add ssh fingerprint and enter password provided in email

@y00rb
y00rb / invoice.rb
Created July 7, 2014 09:16
how to organize getting fat models.
# app/models/invoice.rb
class Invoice < ActiveRecord::Base
has_many :items
end
# app/models/invoice.rb
class Item < ActiveRecord::Base
belongs_to :invoice
end
@y00rb
y00rb / signin.rb
Created July 7, 2014 09:04
SignIn service object
class SignIn < PlainModel
attr_accessor :email
attr_accessor :password
validate :validate_user_exists
validate :validate_password_correct
def user
User.find_by_email(email) if email.present?
end
@y00rb
y00rb / plain_model.rb
Created July 5, 2014 15:35
no inherite model, it is basic class
class PlainModel
include ActiveModel::Model
include ActiveSupport::Callbacks
include ActiveModel::Validations::Callbacks
define_callbacks :save
def save
if valid?
run_callbacks :save do
@y00rb
y00rb / Invite.rb
Created July 5, 2014 15:19
Better ActiveRecord
class Invite < ActiveRecord::Base
belongs_to :user
def accept!(user)
self.user = user
self.accepted = true
Membership.create!(:user => user)
save!
end
end