Skip to content

Instantly share code, notes, and snippets.

View JaysonMandani's full-sized avatar
🚀
Build. Launch. Repeat.

Jayson Mandani JaysonMandani

🚀
Build. Launch. Repeat.
View GitHub Profile
@JaysonMandani
JaysonMandani / nodejs
Created January 6, 2013 04:28
Sample Nodejs
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
@JaysonMandani
JaysonMandani / gist:4465269
Created January 6, 2013 04:52
Test gems in different platforms
# Test gems on Macintosh OS X
group :test do
gem 'rspec-rails', '2.9.0'
gem 'capybara', '1.1.2'
gem 'rb-fsevent', '0.4.3.1', :require => false
gem 'growl', '1.0.3'
end
# Test gems on Linux
group :test do
@JaysonMandani
JaysonMandani / gist:4465943
Created January 6, 2013 08:00
Remapping backslash symbol
xmodmap -e "keycode 94 = backslash bar"
@JaysonMandani
JaysonMandani / gist:4466122
Created January 6, 2013 08:48
RSpec sample for static pages
require 'spec_helper'
describe "Static pages" do
subject { page }
shared_examples_for "all static pages" do
it { should have_selector('h1', text: heading) }
it { should have_selector('title', text: full_title(page_title)) }
end
@JaysonMandani
JaysonMandani / gist:4466664
Created January 6, 2013 11:34
RVM Bundler Integration with advance setup
# RVM Bundler Integration
$ rvm get head && rvm reload
$ chmod +x $rvm_path/hooks/after_cd_bundler
# Then run these:
$ cd ~/rails_projects/sample_app
$ bundle install --without production --binstubs=./bundler_stubs
__________________________________________________________________
@JaysonMandani
JaysonMandani / gist:4504304
Created January 10, 2013 18:01
Node.js parses the url
// Include http module,
var http = require("http"),
// And url module, which is very helpful in parsing request parameters.
url = require("url");
// Create the server.
http.createServer(function (request, response) {
// Attach listener on end event.
request.on('end', function () {
// Parse the request for arguments and store them in _get variable.
// This function parses the url from request and returns object representation.
sudo apt-get build-dep tmux
git clone https://github.com/ThomasAdam/tmux.git
cd tmux/trunk
./autogen.sh
./configure --prefix=/usr/local
make

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key