参考:https://stackoverflow.com/questions/7905808/is-it-ok-not-to-call-threadjoin join的目的是为了让当前主thread等待子thread,然后返回对应的结果. 一旦多线程用熟悉了的话,是不需要join的. 不过需要注意一点:  一旦主进程结束, 子进程就跟着结束(起码在ruby中是这样) 其他语言也是一...
Elixir 7.keywordlist,map
参考:https://elixir-lang.org/getting-started/keywords-and-maps.html key word list: 1. 是个list 2. 元素是 :atom, xx 这样的形式。 list = [{:one, 1}, {:two, 2}][one: 1, two: 2] list[:one] #=> 1 list[:two] #...
微信 使用微信jssdk的方式(签名)
太坑了。  百度根本就搜不到合适的链接,使用 微信jssdk, 微信文档等, 完全搜不到。 google 第一页就可以。   地址在:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115 1. 登录微信公众账号,配置: 1. ip白名单 , 2. 域名。 3. 下载 .txt...
Vuejs 让rails和vue处于同一域名,同一个端口的配置方式
两种方式:  1. 使用thin cluster: 特别简单, 参考:https://stackoverflow.com/questions/49779575/running-frontend-and-backend-on-the-same-port 但是这种办法的本质上, rails是处于其他端口的。 然后在nginx上做代理转发 upstream backend { ...
Ruby 多个进程共享对象(默认是无法这样做的)
参考: https://stackoverflow.com/questions/16538732/share-variable-through-ruby-processes?noredirect=1&lq=1 https://en.wikipedia.org/wiki/Inter-process_communication
Reactnative 7.视图中的component
每个extends React.Component的class, 都是一个component ,可以直接用在 jsx里。  非常类似于 .jsp,   .vue,  Rails 中的partial.  例如,我 自定义一个这样的component screens/ViewComponent.js import React, { Compo...
Rails Oracle的tableprimaryid一定要指定,否则会出现typeerror:nilisnotasymbolnorastring
参考:  https://stackoverflow.com/questions/40623598/rails-typeerror-nil-is-not-a-symbol-nor-a-string-when-updating 一个项目, 数据库使用了 oracle,  table 主键 是  cid ,  不是 id ,  所以在 做 up...
Ruby 当对某个数据库的表段时间频繁操作时,需要使用lock
如题。 1. transaction  2. lock  一个都不能少。
Rails Oracle的操作经验
1. 所有的列,名在rails中都会被转换成小写.  2. 所有的属性,查询, 也都要换成小写 3. 会出现 nil is not a symbol nor a string 的问题, 在save的时候.  解决办法:  看一下这个表的 primary key 是不是id  self.primary_key = 'cid'   ...
Linu 在无法联网的ubuntu上使用git,apt,rbenv,gems的方式(可累死我了)
对于军工企业,很多机器是不允许联网的.  所以我们需要知道如何安装. git 代理: 在 .bashrc中设置 http_proxy, https_proxy 还需要在 .gitconfig中设置: [http] proxy = http://192.168.1.118:8888 sslverify = false [https] ...
Rails 使用定制化的 table_name,column_name
参考:https://medium.com/codeando-con-ruby/non-standard-activerecord-857f0b430ff4 class Photo < ActiveRecord::Base self.table_name = 'tbl_photo' alias_attribute :title, :str_title alias_att...
Ruby 使用rubyxl读取excel文件
参考: https://github.com/weshatheleopard/rubyXL gem install rubyXL 放弃了.原因是有的文件读不出来,直接使用csv文件更好.
Linux Crontab的调试,启动thin服务器debugcrontab Easdfrbenvexport
参考:https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log 日志默认位置 在 /var/log/syslog 中。 grep CRON 。 如果没有安装MTA的话(例如 mail 程序,则基本看不到报错内容,只能看到一个cron运行的title) 安装sendmail $ apt-get install s...
Ruby 优雅的把字符串的中间变成省略号
原理:     "abc"[0,1] # => "ab" "abc"[-2..-1]  # => "bc"    获得某个字符串的后面几位也可以写成: "abc".chars.last(3).join("") (参考:https://stackoverflow.com/questions/2174767/extracti...
Ruby Ckeditor设置编辑器高度
<%= f.cktext_area :zh_content, ckeditor: { height: 1000} %>
Rails Decimal与float,小数的不准确问题
参考:  https://stackoverflow.com/questions/8514167/float-vs-decimal-in-activerecord 看这个例子: > "%.47f" % (1.0/10) => "0.10000000000000000555111512312578270211815834045" 这个就是 不要在 现金中使用 float...
Ruby Cas的相关问题:singlesignout,与gateway
cas 服务器端: https://github.com/rubycas/rubycas-server/  (内容多) 文档都在代码里.wiki中也有很多. 配置文档见 config.example.yml 这里也有配置:https://github.com/rubycas/rubycas-server/wiki/Installation 这里说了gateway的用法:https:...
Rails 直接执行rawsql.查询mysql的基本数据
参考: https://stackoverflow.com/questions/10836805/how-can-i-iterate-through-a-mysql-result-set ActiveRecord::Base.connection.exec_query  用这个。  不要用 ...execute.   例如: irb(main):006...
Ruby 把string转换成datetime
# 这个是 Rails的 model.to_json 后,产生的默认的日期格式 my_string = '2019-06-29T16:35:45.000+08:00' DateTime.strptime(my_string, "%Y-%m-%dT%H:%M:%S.%L%z") 
Ruby 使用googleauthenticator(f2a)otp
注意:  OTP:  One Time Password, 仅仅使用一次的密码.  (例如: 仅仅在登陆的时候使用) 这个不太好搜索。  直接搜索 google authenticator, 绝大部分都是app的使用方法 直到我搜索到了 wiki pedia.  给出了三个链接:  1. https://github.c...