This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
def change | |
create_table :test do |t| | |
t.jsonb :names, default: [] | |
t.jsob :profil, default: {} | |
t.timestamps | |
end | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'when run `rake` a task name default is run by default ' | |
task :default do | |
p 'I’m default' | |
end | |
desc 't0 task name 可以是 symbol或string' | |
task 't0' do | |
p 't0' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery的ajax数据中含有?? | |
此问题仅在 dataType指定为JSON,并且data为string是出现。解决办法, | |
1. 转移data | |
2. 使用object的data | |
3. 指定contentType | |
4. 不指定dataType | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
如果设置了 prefix_url为 http://test.com/api | |
如果此时 get '/', { name: 1} 则请求路径会变为 http://test.com?name=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :test do | |
task :lib => "test:prepare" do | |
$: << "test" | |
Rails::TestUnit::Runner.rake_run(["test/lib"]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ubuntu16.04 nginx安装 | |
wget http://nginx.org/keys/nginx_signing.key | |
sudo apt-key add nginx_signing.key | |
deb http://nginx.org/packages/ubuntu/ xenial nginx | |
deb-src http://nginx.org/packages/ubuntu/ xenial nginx | |
sudo apt-get update | |
sudo apt-get install nginx | |
vhost 实现多域名映射 | |
upstream 实现反向代理 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.format("%08x", int); | |
8即为指定长度 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calAVG(array, interval){ | |
if(!(Array.isArray(array))) throw '参数异常' | |
for(let ele of array){ | |
if(isNaN(parseFloat(ele))){ | |
throw '数组中有不能转换为数字的元素' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install rvm /安装rvm | |
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB | |
\curl -sSL https://get.rvm.io | bash -s stable | |
source /etc/profile.d/rvm.sh | |
rvm install version | |
# install nginx/安装nginx 要安装最新的nginx版本参照官网 http://nginx.org/en/linux_packages.html#stable | |
sudo apt-get update | |
sudo apt-get install nginx | |
#show nginx version/显示nginx的版本 | |
nginx -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
const fs = require('fs'); | |
const path = require('path'); | |
function MP(templateFile, options){ | |
let _this = this, | |
mp = {}; | |
//获取webpack root | |
let rootPath = path.dirname(module.parent.filename); | |
let tmpFilePath = path.resolve(rootPath, templateFile); |