Skip to content

Instantly share code, notes, and snippets.

@iannono
iannono / gist:04ef1d7b383da2880926
Last active December 10, 2015 09:36 — forked from caok/gist:4af4eb264c180e96e821
Crontab的格式
名称 : crontab
使用权限 : 所有使用者
使用方式 :
crontab file [-u user]-用指定的文件替代目前的crontab。
crontab-[-u user]-用标准输入替代目前的crontab.
crontab-1[user]-列出用户目前的crontab.
crontab-e[user]-编辑用户目前的crontab.
crontab-d[user]-删除用户目前的crontab.
crontab-c dir- 指定crontab的目录。
crontab文件的格式:M H D m d cmd.
# Chinese (China) translations for Devise(3.2.2)
# by Kenrick-Zhou (https://github.com/Kenrick-Zhou)
# https://gist.github.com/Kenrick-Zhou/7909822
zh-CN:
devise:
confirmations:
confirmed: "您的帐号已经确认,您现在已登录。"
send_instructions: "几分钟后,您将收到确认帐号的电子邮件。"
send_paranoid_instructions: "如果您的邮箱存在于我们的数据库中,您将收到一封确认账号的邮件。"

How to install PhantomJS on Ubuntu

Version: 1.9.7

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@iannono
iannono / encrypt_and_decrype
Created November 1, 2014 08:58
type:== rails
before_save :encrypt_note
def encrypt_note
salt = SecureRandom.random_bytes(64)
key = encrypt_key || ActiveSupport::KeyGenerator.new(ENV["SECRET_KEY"]).generate_key(salt)
crypt = ActiveSupport::MessageEncryptor.new(key)
%w(client_note food medicines hydration md_appointments activity mood positive_thinking positive_action listener_note).each_with_index do |att|
val = if !new_record? and send("#{att}_changed?")
read_attribute(att.to_sym)
@iannono
iannono / common_gem
Last active August 29, 2015 14:08
env:== rails
** devise **
https://github.com/plataformatec/devise
rails generate devise:install
rails generate devise MODEL
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
before_action :authenticate_user!
rails generate devise:views users
rails generate devise:controllers [scope]
# username = "my_username"
# pwd = "my_password"
# target_path = "my_target_path"
# saving auth cookie
system %Q{wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data "username=#{username}&password=#{pwd}" -O - \
https://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=d08391e6-5fe2-4400-8b27-2dc17b413027}
(25..600).each do |i|

Capybara

save_and_open_page

Matchers

have_button(locator)
@iannono
iannono / notes_of_rails_best_practice.md
Last active December 22, 2015 15:19
Notes of rails best practice of codeschool
  • use scope
scope :trending, -> { |num = nil| where('started_trending > ?', 1.days.ago).
                                  order('mentions desc').
                                  limit(num) }
                                  
@tweets = current_user.tweets.unscoped.order(:status).limit(10)
#Model
@user.should have(2).children # check assosiation
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
expect { @user.save }.to change { User.count }.by(1) # or from(1).to(2)
expect { @user.save! }.to raise_error(ActivieRecord::RecordInvalid)
#More matchers
@person.should respond_to(:child?)