Ruby's Array and Array.wrap的区别

hash = {cgg: 11, cbq: 22} pry(main)> Array(hash) [ [ :cgg, 11 ], [ :cbq, 22 ] ] pry(main)> Array.wrap(hash) [ { :cgg => 11, :cbq => 22 } ] Array(nil) [] Array(11) => [ 11 ] Arr...


安装指定rails的版本

mkdir tolk_server cd tolk_server echo "source 'https://rubygems.org'" > Gemfile echo "gem 'rails', '4.2.11'" >> Gemfile # echo "gem 'rails', '6.0.1'" >> Gemfile bundle install bund...


2019 01-16
SQL 转换 elasticsearch

select * from visits where visitable_id=22362 or os is not null; { "query": { "bool": { "must": [{ "term": { "visitable_id": "22362" } }], "must"...


rails 安装指定的版本

$ mkdir myapp $ cd myapp $ echo "source 'https://rubygems.org'" > Gemfile $ echo "gem 'rails', '5.0.0.1'" >> Gemfile $ bundle install bundle exec rails new bundle exec rails new . --we...


rails-5-2-credentials

辑编rails的credentials EDITOR=vim bundle exec rails credentials:edit 系统中使用credentials.yml.enc vi config/initializers/rollbar.rb Rollbar.configure do |config| # Without configuration, Rollbar is...


mackup configuration_files备份文件的问题

在mackup上,估计很多人也碰到同样的问题 applications_to_sync 不工作 mackup的文件坑了。 下面的方法可以支持备份指定的文件。 第一步 vi .mackup/custom-env-file.cfg [application] name = custom-env-file [configuration_files] .gitignore_global ....


yarn 笔记之快速应用

yarn 的安装 brew install yarn 或者 npm install --global yarn 更多安装方式 yarn --version 设置淘宝源 # 查看源 $ yarn config get registry https://registry.yarnpkg.com # 设置源 $ yarn config set registry 'https:...


添加阿里云服务器的swap分区

阿里云默认没有开启swap分区!小内存测试服务器常爆机! Cannot allocate memory - identify Cannot allocate memory - convert -size 240x240 xc:'rgb(142,125,214)' -pointsize 140 -font 查看 swap 空间大小 $ sudo swapon -s Filename ...


ruby使用transpose生成hash

irb(main):001:0> header = ['key1', 'key2', 'key3', 'key4'] => ["key1", "key2", "key3", "key4"] irb(main):002:0> values = ['val1', 'val2', 'val3', 'val4'] => ["val1", "val2", "val3", "va...


sinatra-console

bundle exec irb -I. -r api.rb ref: https://coderwall.com/p/rqfeug/rails-console-equivalent-for-sinatra


Let’s Encrypt免费的https证书

申请Let's Encrypt 免费https证书脚本。他的证书有效期只有90天,但是可以用自动化脚本继约,所以还是不很错的选择。 1. letsencrypt.sh证书的生成 1.1 目录的生成 cd ~ git clone https://github.com/lukas2511/letsencrypt.sh sudo mkdir -p /etc/letsencrypt.sh s...


subl 全局基本配置

"trim_trailing_white_space_on_save": true, "tab_size": 2, "translate_tabs_to_spaces": true, "ensure_newline_at_eof_on_save": true


2016 06-16
Linux 查看端口占用情况

lsof -i:port 例子: lsof -i:3000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME node 3385 grayson 24u IPv4 0x3361f519169d57bf 0t0 TCP *:hbci (LISTEN) node ...


Sql join解图


2015 12-23 SQL
根据IP选择ruby source

开发必备翻墙。但生产服务器是放在国内,那么问题就来啦! Gemfile中的source写哪里的? source 'https://rubygems.org' source 'http://ruby.taobao.org' 切换国外的时候跑 https://rubygems.org 切换国内的时候跑 http://ruby.taobao.org 难道还要每次手工改不成? ...