Skip to content

Instantly share code, notes, and snippets.

@kibyegn
kibyegn / functional testing
Created March 24, 2011 07:18
Devise functional testing with rspec
#account_configurations_controller_spec.rb
require 'spec_helper'
describe AccountConfigurationsController do
include Devise::TestHelpers
before (:each) do
@user = Factory(:user)
@user.confirm!
sign_in :user, @user
@kibyegn
kibyegn / billing plans.rb
Created November 3, 2011 09:37
Billing Plans
I'm building a billing plan into my rails app. I have 3 different plans (free, pro, enterprise) and want to be able to assign users to a plan and enable them to switch between plans. I'm trying to figure out what would be the best way of doing this.
1. Create a BillingPlan model with the 3 plans and the fields such as whether a feature is available in that plan or not. example {:free => {:analytics => false, :pdf_reports => false, :users => 1}, :pro => {:analytics => true, :pdf_reports => true, :users => 3}} So if say I want to see if the current user is able to download pdf reports, i just pull his plan_id and check if pdf_reports field is true or false. If I want to edit the plans I would update the plans in the database.
2. Another way I thought possible is to have a billing_plan field which holds the users plan. Then the plan variables store them on a YAML file and then load the yaml file in the config folder and load it up inside an initializer thereby making the data in the YAML file available as a
@kibyegn
kibyegn / terminator-config
Created June 14, 2012 08:04 — forked from jacaetevha/terminator-config
save this file to ~/.config/terminator/config
[global_config]
enabled_plugins = CustomCommandsMenu, InactivityWatch, TestPlugin, ActivityWatch, TerminalShot, LaunchpadCodeURLHandler, APTURLHandler, MavenPluginURLHandler, LaunchpadBugURLHandler, LayoutManager
title_transmit_bg_color = "#832527"
[keybindings]
[profiles]
[[default]]
scrollback_lines = 4000
[layouts]
[[default]]
[[[child1]]]
source 'http://rubygems.org'
##############################
# Rails and DB
##############################
# gem 'rack', '1.2.1'
gem 'rails', '3.2.0'
group :assets do
gem 'sass-rails', " ~> 3.2.3"
@kibyegn
kibyegn / resque.rake
Created June 20, 2012 12:45 — forked from denmarkin/resque.rake
My rake task for clearing Resque queues and stats
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
#!/bin/bash
# Requirements: sed, grep, curl, pkill
# User configuration
LOCAL_INSTALL="/usr/lib/sublime-text-2" # Must be user-writable
REPO="dev" # "dev" for dev releases, or "2" for beta releases
TARGET_BUILD="Linux 32 bit" # can be one of "Windows", "Windows 64 bit", "OS X", "Linux 32 bit", "Linux 64 bit"
# Check if sublime text is running
Rails new app Cheat sheet
1. Install RVM
$ \curl -L https://get.rvm.io | bash -s stable --ruby
2. Install Ruby
$ rvm install ruby
$ rvm --default use ruby-2.3.3
3. Install Javascript runtime
@kibyegn
kibyegn / server.md
Last active December 8, 2016 09:28 — forked from jtadeulopes/server.md
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo reboot

Configure timezone

@kibyegn
kibyegn / readme.md
Created May 2, 2018 07:26 — forked from yosukehasumi/readme.md
DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

  1. Setup
  2. Swapfile
  3. NGINX
  4. ElasticSearch
  5. RVM
  6. Rails
  7. Postgres
  8. Capistrano