This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.
Please make sure that your Gemfile in your rails application includes unicorn.
var select_function = function(event, ui) { | |
if ($(this).data("event-name") == undefined) { | |
$(this).data("event-name", $(this).attr("name")); | |
} | |
if(ui.item) { | |
var hidden_location; | |
// currently only care if there's a child, not checking the childs type | |
if ($(this).children().size() == 0 ) { | |
hidden_location = $('<input type=hidden></input>') | |
hidden_location.attr("name", $(this).data("event-name")) |
----------------------------- | |
logrotate | |
----------------------------- | |
modify /etc/logrotate.d/apache2 with content | |
##### | |
/var/log/apache2/*.log { | |
daily | |
missingok | |
rotate 20 | |
compress |
# Copy and paste this to the rails console to test your email settings | |
class MyMailer < ActionMailer::Base | |
def test_email | |
@recipients = "[email protected]" | |
@from = "[email protected]" | |
@subject = "test from the Rails Console" | |
@body = "This is a test email" | |
end | |
end |
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
=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') |
If your introduction to object-oriented programming was like mine, somewhere early on day 1 you learned about “message passing.” You were told that doing something like | |
account.deposit(50) | |
meant that you were sending the deposit message to the account object. Of course, if you were learning about a statically typed language, you soon figured out that account.deposit(50) was synonymous with calling the deposit method on the account object. The whole static typing system was there to make sure that the deposit method was there and was called. So by the end of day 1 of object-oriented programming, we all stopped talking about passing messages and started talking about calling methods. | |
The concept of message passing would make more sense if we could say account.deposit(50), and the BankAccount class was then free to do something else with the message besides simply calling the deposit method. Perhaps the BankAccount class could call some method other than deposit, or perhaps it could decide to do nothing. I |
var ngAppElem = angular.element(document.querySelector('[ng-app]') || document); | |
window.injector = ngAppElem.injector(); | |
window.inject = injector.invoke; | |
window.$rootScope = ngAppElem.scope(); | |
// getService('auth') will create a variable `auth` assigned to the service `auth`. | |
var getService = function getService(serviceName) { | |
inject([serviceName, function (s) {window[serviceName] = s;}]); | |
}; |
# | |
# CORS header support | |
# | |
# One way to use this is by placing it into a file called "cors_support" | |
# under your Nginx configuration directory and placing the following | |
# statement inside your location block(s): | |
# | |
# include cors_support; | |
# | |
# A limitation to this method is that Nginx doesn't currently send headers |
#!/bin/bash | |
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/` | |
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'` | |
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'` | |
token=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | sed -n '/Token/{p;}' | cut -f4 -d'"'` | |
file="somefile.deb" | |
bucket="some-bucket-of-mine" | |
date="`date +'%a, %d %b %Y %H:%M:%S %z'`" |