To make your server more secure, it's a good idea to disable root login and password authentication.
Open /etc/ssh/sshd_config
- Make sure ssh with pub key is enabled
RSAAuthentication yes
PubkeyAuthentication yes
To make your server more secure, it's a good idea to disable root login and password authentication.
Open /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
Short summary of the official doc
:ruby puts RUBY_VERSION
. If it does NOT output error message, this vim has ruby support. Remember this version number. It will be used later.If you find that your cronjobs are not launched at the specified time, chances are it's a timezone issue.
The timezone of cron is specified in /etc/timezone
, according to cron's man page:
The daemon will use, if present, the definition from /etc/timezone for the timezone.
If you change the timezone of the machine but has NOT restart cron, cron will still use the old timezone. In order to make your timezone effective, restart cron sudo service cron restart
.
require 'houston' | |
require 'gcm' | |
module Pusher | |
APN = Houston::Client.production | |
APN.certificate = File.read(File.expand_path('path/to/push_cert.pem', __FILE__)) | |
# Apple has hard limit on the payload of push notification. The maximum size allowed for a notification payload is 256 bytes; | |
# If you have other fields in the notification, you need to tweak this value to fit your needs. Be careful about this. | |
MAX_ALERT_LENGTH = 140 |
If you see *403 Forbidden* when running your app with Apache, it's because Apache is too strict on permissions. Set the following in virtual host config. | |
``` | |
<Directory "/home/your_app/public"> | |
Options FollowSymLinks | |
AllowOverride None | |
Order allow,deny | |
Allow from all | |
Options -MultiViews | |
# Uncomment this if you're on Apache >= 2.4: |
require 'bcrypt' | |
class User < ActiveRecord::Base | |
include BCrypt | |
def password | |
@password ||= Password.new(password_hash) | |
end | |
def password=(new_password) |
I found many misleading guides on how to install SSL certificate so that both http and https can work for the same site. Below are the step by step instructions
sudo a2enmod ssl
/etc/ssl/certs/example.com.crt
. Other directory may work, but I prefer this./etc/ssl/private/example.com.key
. Other directory may work, but I prefer this.<VirtualHost *:443>
DocumentRoot /path/to/project
ServerName example.com
If you use grocer for sending push, you may have notificed that one bad token can cause connection to drop and all subsequent tokens are not sent. And it fails silently... More on this here.
One workaround is to use this pull request (it's not merged in yet). After each push, you call
reply = pusher.read_reply
, which will try to get feedback from Apple. And if the connection is already dropped, it will reconnect. This is exactly what we want. e.g.
If you see this error when cron job runs a ruby script:
'require': cannot load such file ...
And you are using bundler e.g. require 'bundler/setup'
. It's probably because the directory where cron runs the script is not correct, resulting in bundler fails to load gems.
Simply changed the directory to fix it, i.e.
* * * * * /usr/local/bin/ruby -C /home/example/scripts example_script.rb >>/home/example/log/cron.log 2>&1
I recently came accross this error while working on a rails app
ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: '\xF0\x9F\x98\x84' for column ...
A bit search shows that this error is famously known. You can see more details from here and here.
In short, this error happens because Mysql uses 3 bytes for utf8 character by default. So when a 4-byte character is sent, it crashes.
Solution: use encoding utf8mb4 and collation utf8mb4_unicode_ci