text .ideavimrc

.ideavimrc
set rnu
set showmode
set surround

let mapleader = " "
let g:mapleader = " "

nmap <leader>gc :action GotoClass<CR>
nmap <leader>gf :action GotoFile<CR>
nmap <leader>gs :action GotoSymbol<CR>
nmap <leader>gd :action GotoDeclaration<CR>

nmap <leader>s :action FileStructurePopup<CR>
nmap <leader>e :action RecentFiles<CR>

nmap <leader>l :action ReformatCode<CR>
nmap <leader>r :action RenameElement<CR>

nmap <leader>u :action ShowUsages<CR>
nmap <leader>U :action FindUsages<CR>

nmap <leader>q :action QuickJavaDoc<CR>

nmap <leader>; $a;<ESC>

text [docker-compose systems setup] #docker

[docker-compose systems setup] #docker

readme.md
# Running docker-compose under systemd
1.  Place the systemd unit files in /etc/systemd/system
2.  Create each docker-compose in a subdir under /usr/local/docker/
3.  Enable the cleanup service:
```
systemctl enable docker-compose.timer
```
4.  For each of your docker-compose applications, enable and start it.  For example, to start the app in /usr/local/docker/traefik:
```
systemctl enable docker-compose@traefik
systemctl start docker-compose@traefik
```
docker-compose@.service
[Unit]
Description=%i service with docker compose
Requires=docker.service
After=docker.service

[Service]
Restart=always

WorkingDirectory=/usr/local/docker/%i

#remove our old containers
ExecStartPre=/usr/bin/docker-compose down -v
ExecStartPre=/usr/bin/docker system prune


ExecStart=/usr/bin/docker-compose up

ExecStop=/usr/bin/docker-compose down -v

[Install]
WantedBy=multi-user.target
docker-cleanup.timer
[Unit]
Description=Docker cleanup timer

[Timer]
OnUnitInactiveSec=12h

[Install]
WantedBy=timers.target
docker-cleanup.service
[Unit]
Description=Docker cleanup
Requires=docker.service
After=docker.service

[Service]
Type=oneshot
WorkingDirectory=/tmp
User=root
Group=root
ExecStart=/usr/bin/docker system prune -f

[Install]
WantedBy=multi-user.target

text params的输出

output from params
 Conekta.api_key = 'XX_XXXXX'
 => "XX_XXXXXX"
2.3.0 :196 > Conekta.api_version = '2.0.0'
 => "2.0.0"
2.3.0 :197 > def customer
2.3.0 :198?>       @customer ||= ::Conekta::Customer.create(
2.3.0 :199 >             {
2.3.0 :200 >                   name: 'Jon Snow',
2.3.0 :201 >                   email: 'jon-snow@test.conekta.com',
2.3.0 :202 >                   phone: '(321)98765421',
2.3.0 :203 >                   payment_sources: [
2.3.0 :204 >                         {
                 token_id: 'tok_test_visa_4242',
                 type: 'card'
              }
          ]
      }
    )
  end

  def charge
    {
        currency: 'MXN',
        amount: 8500,
        payment_method: {
            type: 'default'
        }
    }
  end

  def customer_info
    {
        customer_id: customer.id,
        name: 'Jon Snow',
        email: 'jon-snow@test.conekta.com',
        phone: '(321)98765421'
    }
  end

  def event_info
    {
        event_category: 'Musical',
        event_city: 'Ciudad de México',
        purchase_event_date_diff: 0,
        event_id: 1,
        event_name: 'Winter is Here',
        event_created_at: '2017-12-22T17:09:51.491Z',
        event_activated_at: '2017-12-19T17:09:51.318Z',
        owner_id: 2
    }
  end

  def line_items
    {
        name: 'VIP Ticket',
        description: 'Test Product',
        unit_price: 8500,
        quantity: 1,
        sku: '1212'
    }
  end2.3.0 :205 >                              token_id: 'tok_test_visa_4242',
2.3.0 :206 >                              type: 'card'
2.3.0 :207?>                         }
2.3.0 :208?>                   ]
2.3.0 :209?>             }
2.3.0 :210?>         )
2.3.0 :211?>     end
 => :customer
2.3.0 :212 >
2.3.0 :213 >     def charge
2.3.0 :214?>       {
2.3.0 :215 >               currency: 'MXN',
2.3.0 :216 >               amount: 8500,
2.3.0 :217 >               payment_method: {
2.3.0 :218 >                     type: 'default'
2.3.0 :219?>               }
2.3.0 :220?>         }
2.3.0 :221?>     end
 => :charge
2.3.0 :222 >
2.3.0 :223 >     def customer_info
2.3.0 :224?>       {
2.3.0 :225 >               customer_id: customer.id,
2.3.0 :226 >               name: 'Jon Snow',
2.3.0 :227 >               email: 'jon-snow@test.conekta.com',
2.3.0 :228 >               phone: '(321)98765421'
2.3.0 :229?>         }
2.3.0 :230?>     end
 => :customer_info
2.3.0 :231 >
2.3.0 :232 >     def event_info
2.3.0 :233?>       {
2.3.0 :234 >               event_category: 'Musical',
2.3.0 :235 >               event_city: 'Ciudad de México',
2.3.0 :236 >               purchase_event_date_diff: 0,
2.3.0 :237 >               event_id: 1,
2.3.0 :238 >               event_name: 'Winter is Here',
2.3.0 :239 >               event_created_at: '2017-12-22T17:09:51.491Z',
2.3.0 :240 >               event_activated_at: '2017-12-19T17:09:51.318Z',
2.3.0 :241 >               owner_id: 2
2.3.0 :242?>         }
2.3.0 :243?>     end
 => :event_info
2.3.0 :244 >
2.3.0 :245 >     def line_items
2.3.0 :246?>       {
2.3.0 :247 >               name: 'VIP Ticket',
2.3.0 :248 >               description: 'Test Product',
2.3.0 :249 >               unit_price: 8500,
2.3.0 :250 >               quantity: 1,
2.3.0 :251 >               sku: '1212'
2.3.0 :252?>         }
2.3.0 :253?>     end
 => :line_items
2.3.0 :254 > def process
2.3.0 :255?>       Conekta::Order.create(
2.3.0 :256 >             {
2.3.0 :257 >                   line_items: line_items,
2.3.0 :258 >                   currency: 'MXN',
2.3.0 :259 >                   customer_info: customer_info,
2.3.0 :260 >                   charges: [charge],
2.3.0 :261 >                   metadata: event_info
2.3.0 :262?>             }
2.3.0 :263?>         )
2.3.0 :264?>     end
 => :process
2.3.0 :265 > Conekta::Order
 => Conekta::Order
2.3.0 :266 > process
Conekta::ParameterValidationError: {"details"=>[{"debug_message"=>"Invalid datatype for \"line_items\" expecting at least normal Array.", "message"=>"\"line_items\" tiene un tipo inválido.", "param"=>"line_items", "code"=>"conekta.errors.parameter_validation.line_items.invalid_datatype"}, {"debug_message"=>"\"amount\" is not greater than 0.", "message"=>"\"amount\" no es mayor a 0.", "param"=>"amount", "code"=>"conekta.errors.parameter_validation.amount.number_is_not_greater_than"}], "object"=>"error", "type"=>"parameter_validation_error", "log_id"=>"5a4541c5b795b040fc42ff4f"}
	from /Users/eduardo/Documents/libraries/conekta-ruby/lib/conekta/requestor.rb:34:in `request'
	from /Users/eduardo/Documents/libraries/conekta-ruby/lib/conekta/operations/create.rb:7:in `create'
	from (irb):255:in `process'
	from (irb):266
	from /Users/eduardo/.rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'

text htaccess httpd

htaccess httpd

htaccess security lines or httpd.conf to protect your server in 2017
# prevent site being embedded in someone elses iframe
Header always set X-Frame-Options SAMEORIGIN

# supposedly aids XSS protection
Header set X-XSS-Protection "1; mode=block"

# this one is tricky,  set the TTL to be one hour (3600) when you start as you can permanently cache the DNS
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS

# secure cookies to HTTPS
Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure

# make charset utf-8
AddDefaultCharset utf-8

Header set X-Content-Type-Options: nosniff

#disable indexing of folders
Options -Indexes

# disable access to another of these file extensions - globally
<FilesMatch "(?i)\.(phar|log|psd|sh|bat|json|htaccess|conf|config|csv|env|project|iml|babelrc|webapp|lock|md|git|gitignore|gitattributes|buildpath|cache|unused|bak|sublime-project|sublime-workspace)$">
 Deny from all
 #satisfy all
</FilesMatch>
enable apache httpd start on boot
chkconfig httpd on
Move your site to an entirely new domain with .htaccess
RewriteEngine On

RewriteCond %{HTTP_HOST} kitibz [NC]
RewriteCond %{HTTP_HOST} www\.kitibz\.com [NC]
RewriteRule ^.*$ https://www.kitnaib.co.uk%{REQUEST_URI} [R=301,L]
Force both HTTPS and WWW. prefix using .htaccess even if behind an ELB or load balancer and if using a CDN
# force https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{SERVER_PORT} 80
# Optional: exclude certain conditions, e.g. local host:
RewriteCond %{HTTP_HOST} !^localhost [NC]
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# now force www
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{HTTP_HOST} !^www\. [NC]
# let's allow our CDN to not follow these rules too:
RewriteCond %{HTTP_HOST} !^cdn\. [NC]
# let's allow sitemap.xml to be hit without redirection:
RewriteCond %{HTTP_HOST} !^sitemap.xml [NC]
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Allow access to a folder based on domain name or url
order deny,allow
deny from all
allow from kitnaibdev.co.uk
allow from www.kitnaibdev.co.uk
Add and force trailing slash to URLs with htaccess
This two liner will perform a redirect to any folder to prevent 404s and duplicate content.

e.g.

/contact

will now redirect to:

/contact/


RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
.htaccess - DENY access to everything which matches the following extensions
#DENY access to everything which matches the following extensions
## (?i) means case insensitive
<FilesMatch "(?i)\.(phar|log|psd|sh|bat|json|htaccess|conf|config|csv|env|project|iml|babelrc|webapp|lock|md)$">
 Deny from all
</FilesMatch>

text Liferay邮件记录

从Liferay向收件人发送电子邮件时,可以轻松进行调试

email-logging.txt
com.liferay.util.mail.MailEngine
com.liferay.mail.service.impl.MailServiceImpl

text 计算解决相关滑动问题

计算解决相关滑动问题
div>icons 


点击滑动滑出


可能需要相关递归概念

text validate_jquery

validate_jquery
 function validatePhoneNumber(_input) {
      var flag = false;
      var phone = _input.val().trim(); // ID của trường Số điện thoại
      phone = phone.replace('(+84)', '0');
      phone = phone.replace('+84', '0');
      phone = phone.replace('0084', '0');
      phone = phone.replace(/ /g, '');
      if (phone != '') {
          var firstNumber = phone.substring(0, 2);
          if ((firstNumber == '09' || firstNumber == '08') && phone.length == 10) {
              if (phone.match(/^\d{10}/)) {
                  flag = true;
              }
          } else if (firstNumber == '01' && phone.length == 11) {
              if (phone.match(/^\d{11}/)) {
                  flag = true;
              }
          }
      }
      return flag;
  }

text 令牌认证

令牌认证登录

token
from:http://www.cnblogs.com/xiekeli/p/5607107.html
http://www.yobbo.wang/?p=88
用户身份验证:Token与Session
开放接口Api服务其实就是客户端与服务端无状态交互的一种形式,
这有点类似REST(Representational State Transfer)风格。
普通网站应用一般使用session进行登录用户信息的存储和验证(有状态),
而开放接口服务/REST资源请求则使用Token进行登录用户信息的验证(无状态)。
Token更像是一个精简版的session。Session主要用于保持会话信息,会在客户端保存一份cookie来保持用户会话有效性,
而Token则只用于登录用户的身份鉴权。所以在移动端使用Token会比使用Session更加简易并且有更高的安全性,
同时也更加符合RESTful中无状态的定义。

Token交互流程
客户端通过登录请求提交用户名和密码,服务端验证通过后生成一个Token与该用户进行关联,并将Token返回给客户端。
客户端在接下来的请求中都会携带Token,服务端通过解析Token检查登录状态。
当用户退出登录、其他终端登录同一账号、长时间未进行操作时Token会失效,这时用户需要重新登录。

Token生成原理
服务端生成的Token一般为随机的非重复字符串,根据应用对安全性的不同要求,会将其添加时间戳
(通过时间判断Token是否被盗用)或url签名(通过请求地址判断Token是否被盗用)后加密进行传输。
一般Token内容包含有:用户名/appid,密码/appsecret, 授权url,用户自定义token(用户自定义签名),时间戳,
有效期时长(秒), 系统签名(sign)等。

Api接口服务调用流程:
服务端access_token可以存储在session或者redis等内存数据库中,键名(key)为user_id,键值为access_token。
客户端获得access_token后,保存到file或redis等内存数据库中。不推荐保存到session或数据库中,
保存到session数据容易丢失,保存到数据库因为涉及IO读写,性能较低。

对于敏感的api接口,需使用https协议
http叫超文本传输协议,使用TCP端口80,默认情况下数据是明文传送的,数据可以通过抓包工具捕获到,因此在interner上,有些比较重要的站点的http服务器需要使用PKI(公钥基础结构)技术来对数据加密!这也就是https了;
https叫安全的超文本传输协议,使用TCP端口443,他的数据会用PKI中的公钥进行加密,这样抓包工具捕获到的数据包也没有办法看包中的内容,因为他没有密钥,当然篡改也就没有什么意义了,安全性大大提高,
要解密数据的话就要用到PKI中的私钥。所以一些安全性比较高的网站如:网上银行,电子商务网站都需要用https访问!

微信的access_token的有效期目前为2个小时,需定时刷新,重复获取将导致上次获取的access_token失效。

Token Auth的优点

Token机制相对于Cookie机制又有什么好处呢?

1.支持跨域访问: Cookie是不允许垮域访问的,这一点对Token机制是不存在的,前提是传输的用户认证信息通过HTTP头传输.
2.无状态(也称:服务端可扩展行):Token机制在服务端不需要存储session信息,因为Token 自身包含了所有登录用户的信息,
只需要在客户端的cookie或本地介质存储状态信息.
3.更适用CDN: 可以通过内容分发网络请求你服务端的所有资料(如:javascript,HTML,图片等),
而你的服务端只要提供API即可.
4.去耦: 不需要绑定到一个特定的身份验证方案。Token可以在任何地方生成,只要在你的API被调用的时候,
你可以进行Token生成调用即可.
5.更适用于移动应用: 当你的客户端是一个原生平台(iOS, Android,Windows 8等)时,Cookie是不被支持的
(你需要通过Cookie容器进行处理),这时采用Token认证机制就会简单得多。
6.CSRF:因为不再依赖于Cookie,所以你就不需要考虑对CSRF(跨站请求伪造)的防范。
7.性能: 一次网络往返时间(通过数据库查询session信息)总比做一次HMACSHA256计算 的Token验证和解析要费时得多.
不需要为登录页面做特殊处理: 如果你使用Protractor 做功能测试的时候,不再需要为登录页面做特殊处理.
8.基于标准化:你的API可以采用标准化的 JSON Web Token (JWT). 这个标准已经存在多个后端库
(.NET, Ruby, Java,Python, PHP)和多家公司的支持(如:Firebase,Google, Microsoft).

text 编辑git配置

terminal
go to folder that contains git
change the url git@bitbucket.org:wintermelon to https://bitbucket.org/wintermelon

sudo nano .git/config

text 编辑主机文件

terminal
sudo nano /etc/hosts

control + o = save
control + x = exit