include:  进来的都是 instance method extend:  过来的都是 class method 定义class method的方法:  def self.xx   def ClassName.xx   class SomeClass class << self def...
Rails Rails6由于gemlisten报错listenerror:unabletomonitordirectoriesforchanges
参考:  https://stackoverflow.com/questions/42225677/listen-error-unable-to-monitor-directories-for-changes echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo...
Ruby 记一次追踪rails内存泄露
1. 采用了 oink 工具,来测量不同的action对于内存的消耗, 运行2周之后, 查看日志,发现 内容如下 ---- MEMORY THRESHOLD ---- THRESHOLD: 75 MB -- SUMMARY -- Worst Requests: 1. Dec 03 10:26:15, 19091140 KB, managers/sessions#new 2. Dec ...
Ruby Buld_insert这个gem很好用啊
参考 https://github.com/jamis/bulk_insert 原来的一条一条的插入,大约需要5分钟: data.each do |row| (1990..1999).each_with_index do |year, index| OneDegreeCell.create longitude: row[0].to_i, latitude: row[1...
Ruby Rails Profiler另外一个人写的工具大全toolslist
参考:http://maratgaliev.com/profiling-ruby-rails/ 写的非常好
Ruby Profiler Ruby Prof.https:ruby Prof.github.io
ruby-prof Gemfile: gem 'ruby-prof' 然后在application.rb 中增加中间件 config.middleware.use Rack::RubyProf, :path => './tmp/profile' 就会生成好多文件,放到 ./tmp/profile文件夹下 /your_app/current/tmp/profile$ ls -call_s...
Ruby Csv读写文件csvreadwritefile
无语了,最近总遇到这个操作。发现自己从来没记录过。 所以写一下吧。 def save_to_csv(csv) CSV.open("C:/ruby/logs.csv", "w") do |row| row << %w[name location dishes time] end end def self.read_from_csv(cs...
Ruby Rails还没使用https:github.combhbrack Perftools_profiler
参考:https://github.com/bhb/rack-perftools_profiler https://github.com/tmm1/perftools.rb 的 rack集成版本</span>
Ruby 终于给我的个人博客增加了粘贴图片的功能pasteimagefromclipboardtoblog
这个想法有了好几天了。 过去苦于增加图片的不方便,所以写博客的时候往往只能用纯文字,很不尽兴。 最近这个需求越发的旺盛,所以就想办法弄了一下。 核心的是使用了     http://siwei.me/blog/posts/javascript-html  也就是 clipboardData 这个变量。 不过由于我的个人博客基于 refine...
Ruby Rails Profiler 非常好的一篇文章:
参考:https://www.toptal.com/ruby/hunting-ruby-memory-issues 说了一些工具,把概念讲的很明白
Go 从ruby到go:使用golang Migrate来代替gorm的migrate
golang-migrate 跟rails 几乎一样。 安装 go get -u -d github.com/golang-migrate/migrate/cmd/migrate go get -u -d github.com/golang-migrate/migrate 上面2个二选一 cd ~/go/pkg/mod/github.com/golang-migrate/ cd ~/go/...
Ruby Railsprofiler Oink,集成了memorylogic,查看rails项目占用的内存
参考:https://github.com/noahd1/oink Gemfile:  gem 'oink' Rails.application.middleware.use Oink::Middleware 之后重启rails, 看log (会发现每次请求url之后, 内存会上升。。。找到明显上升的地方即可) 106 Dec 03 08:20:59 main-production...
Ruby Railsprofiler Memorylogic10年前的东西,目前已经成为一个plugin
参考:https://github.com/binarylogic/memorylogic 专门为rails使用。每次请求都会在logger中增加某条请求的内存使用情况 用法 class Applicationcontroller  include Memorylogicend 然后查看日志就行。
Go Fromrailstogo,gorm
gorm : gorm.io 特别超级非常简单 安装 2044 go get -u gorm.io/gorm 2045 go get -u gorm.io/driver/mysql 一段代码: package main import ( "gorm.io/gorm" "gorm.io/driver/mysql" "fmt" "time" ) type Book st...
Ruby Profiler Memory_profiler查看rubyrails项目的内存使用情况
memory_profilerhttps://www.rubydoc.info/gems/memory_profiler/1.0.0 功能超级强大,还没使用。 Gemfile:  gem 'memory_profiler' 基本用法: 仅作用于rb脚本: ruby-memory-profiler [options] <script.rb> 或者这样: require...
Rails 超级重要!rubyorrailsprofiler Derailed_benchmarks:查看项目的内存
https://github.com/schneems/derailed_benchmarks 列出rails项目的静态内存(未运行时,仅查看某些gem占用的空间)和运行时内存(这个是我期望的) README写的特别好
Go 从ruby到gogo快速入门面试醒脑知识
array 数组,从声明开始,长度就是固定的。 slice 切片, 长度可以变化的数组( 声明的时候就不带长度) var my_slice []int my_slice = make( []int, 3 , 5)    3 : cap   5 : 长度,   [0, 0 ,0 ] (被初始化了) my_slice2 :...
Linux 查看内存使用的几个命令(linux操作系统级别)
pmap 有点用 $ sudo pmap 35854 -X 35854: puma: cluster worker 0: 23406 [20201102084205] Address Perm Offset Dev...
Javascript 模拟ruby的sleep:settimeout
这个可以 sleep(n_seconds){ return new Promise(resolve => setTimeout(resolve, n_seconds * 1000)) }, async init() { await sleep(3) } 这个也行: (注意 set...
Ubuntu 解决mysql莫名其妙重启的问题
昨天和今天发现mysql 莫名其妙的重启了。两个不同项目的数据库服务器都重启了  (ubuntu 16)  重启的特点是: 莫名其妙的重启,一个是10秒内连续重启5次,一个是6秒内连续重启3次(每次重启2秒钟) 时刻不一样。 过程: 1. 发现一些程序不运行了。 cannot connect to mysql ... 39916 2020-10-29 06:46:30 +...