- 写一个简单的 NPM package
- 用 mocha 写测试
- 用 CoffeeScript 写 NPM package
- 实现 JS 类 (练习原型链)
| # be sure to comment out the require 'capistrano/deploy' line in your Capfile! | |
| # config valid only for Capistrano 3.1 | |
| lock '3.2.1' | |
| set :application, 'my-cool-application' | |
| # the base docker repo reference | |
| set :name, "johns-stuff/#{fetch(:application)}" |
| # based on http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html | |
| module Auth | |
| extend ActiveSupport::Concern | |
| included do | |
| helpers do | |
| def session | |
| env['rack.session'] | |
| end |
| # Access number | |
| cat production.log | grep "^Processing" | wc | awk '{print $1}' | |
| # Each IP access number | |
| cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq -c | |
| # Independent IP number | |
| cat production.log | grep "^Processing" | awk '{print $4}' | uniq | wc | awk '{print $1}' | |
| cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq | wc -l |
| ENV['RACK_ENV'] = 'test' | |
| require 'bundler/setup' | |
| require 'test/unit' | |
| gem 'minitest' | |
| require 'timecop' | |
| require 'grape' | |
| require 'logger' | |
| Grape::API.logger = Logger.new('/dev/null') |
| cat production.log | grep duration | awk 'a=$7,gsub(/[a-z=]/,"",a) {print a, $1, $2}' | awk '{if ($1 > 500) print $1, $2, $3}' |
The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.
Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.
| <?xml version="1.0" encoding="UTF-8" ?> | |
| <opml version="1.0"> | |
| <head> | |
| <title>寸志 subscriptions in Digg Reader</title> | |
| </head> | |
| <body> | |
| <outline text="Framer Blog" title="Framer Blog" type="rss" xmlUrl="http://framerjs.tumblr.com/rss" htmlUrl="http://framerjs.tumblr.com/" /> | |
| <outline text="粉丝日志" title="粉丝日志" type="rss" xmlUrl="http://blog.fens.me/feed/" htmlUrl="http://blog.fens.me" /> | |
| <outline text="AngularJS" title="AngularJS" type="rss" xmlUrl="http://blog.angularjs.org/feeds/posts/default" htmlUrl="http://blog.angularjs.org/" /> | |
| <outline text="blog.izs.me" title="blog.izs.me" type="rss" xmlUrl="http://blog.izs.me/rss" htmlUrl="http://blog.izs.me/" /> |
#Simple Authentication with Bcrypt
This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.
The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).
You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault
##Steps
| # MODEL | |
| class Case < ActiveRecord::Base | |
| include Eventable | |
| has_many :tasks | |
| concerning :Assignment do | |
| def assign_to(new_owner:, details:) | |
| transaction do |