每当我想列出目录中的内容时,我就会不断地做"ls -ahl".我有没有办法让-ahl在我执行"ls"时传递默认args,或者我应该在bash_profile中创建一个像"alias lsa = ls -ahl"这样的别名?
我的网站有大约15个高分辨率背景图像,每个重约500 MB.我想知道将它们存储在Amazon S3而不是我自己的Web服务器上是否有优势.似乎页面应该加载更快,如果我的服务器本地,但不确定
在我构建的几乎每个应用程序中,我都创建了某种用户日志表来记录我的实际USERS(不是访问者,但有帐户的人)在网站上执行的各种活动.这主要用于客户服务问题,以便我可以提取用户访问过的页面和操作的记录.
这方面的缺点是UserLogs表的大小.它变得无比巨大.我不确定其他人是否通常会将INDIVIDUAL(不像Google Analytics这样的汇总)用户行为记录到数据库中,但如果是,我想知道是否存在任何形式的SaaS来帮助卸载此任务?我基本上需要一个RESTful API,它允许我快速安全地存储和检索单个用户活动.
任何人都知道或者我是唯一有这个问题的人吗?
我们在日志中看到了这个非常罕见,非常奇怪的错误.当某些人(我相信大多数人都在Safari上)试图访问我们网站上的各种页面时,他们会收到错误而无法继续.当我检查日志时,我会看到其中包含的URL undefinedpageWebRequestEvents.js.
我已经四处寻找,但似乎无法找到任何可能导致它们的原因或原因.这个网站上有非常小的javascript,成千上万的人没有看到这个错误(包括我们 - 我们不能复制)所以任何建议都表示赞赏.
这是一个非常奇怪的.我试图做一个简单的rake db:test:clone或创建,无论我做什么,从清除gemset到尝试各种database.yml配置,我得到最奇怪的错误:
LINE 1: CREATE DATABASE "tdt_test"0.0
Run Code Online (Sandbox Code Playgroud)
有没有人见过这样的事情呢?WTF是"0.0!?" 我正在运行Rails 3.2,RSpec和pg gem 0.14.1
04:15 PM ~/projects/dmvcs (feature/helpdesk) => RAILS_ENV=test rake db:create
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require': iconv will be deprecated in the future, use String#encode instead.
Notice: for 10x faster LSI support, please install http://rb-gsl.rubyforge.org/
PG::Error: ERROR: syntax error at or near "0.0"
LINE 1: CREATE DATABASE "tdt_test"0.0
^
: CREATE DATABASE "tdt_test"0.0
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:654:in `async_exec'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:654:in `block in execute'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:653:in `execute'
/Users/jlippiner/.rvm/gems/ruby-1.9.3-p194@dmvcs/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in …Run Code Online (Sandbox Code Playgroud) unit-testing rspec-rails pg ruby-on-rails-3 rails-postgresql
那里有很多文章和资源,涉及通过Rails 5 API验证和访问用户信息的不同选项,例如Knock,Doorkeeper,JWT等,但是我很难找到有关如何处理实际信息的可靠建议。注册新用户和相关功能(即密码请求)。
我可以使用Devise,但我想知道它是否过大。实际上,许多有关JWT的文章以及诸如Knock之类的宝石都建议不要这样做。
在构建仅使用Rails 5 API的应用程序时,是否存在用于处理新用户注册的其他推荐解决方案,或者即使有其他所有开销,Devise仍然是到达此处的最佳方法吗?Rails 5是否内置了某些内容?
我有一个编译好的 Ruby protobuf 消息,如下所示:
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "PingPacket" do
optional :message_counter, :int32, 1
optional :message_type, :enum, 2, "PingPacket.MessageType"
end
add_enum "PingPacket.MessageType" do
value :REPORT, 0
value :LOW_BATTERY, 1
value :LOCATE_REQUEST, 2
value :CHECK_IN, 3
value :SOS, 4
value :RESTING, 5
value :MOVING, 6
value :EVENT, 7
value :SYSTEM_TEST, 8
end
end
PingPacket = Google::Protobuf::DescriptorPool.generated_pool.lookup("PingPacket").msgclass
PingPacket::MessageType = Google::Protobuf::DescriptorPool.generated_pool.lookup("PingPacket.MessageType").enummodule
Run Code Online (Sandbox Code Playgroud)
我正在尝试获取包含所有 MessageType 值的数组。我已经尝试过显而易见的方法:
PingPacket::MessageType.enums
PingPacket::MessageType.values
PingPacket::MessageType.to_s
Run Code Online (Sandbox Code Playgroud)
但没有任何效果。我怎样才能获得这些值?
我正在处理图片库应用程序,因此我们需要有条件地在具有白色或透明背景的图像周围添加填充,以使它们在我们页面的网格内看起来正常。
基本上,我们需要:
有没有办法在一两行中使用ImageMagick做到这一点,还是我们需要使用其他库?
我们一直在尝试使用Heroku的CF并遇到一些问题.其中一个涉及在CF AI中访问rails控制台.我们正在使用Pivotal的PWS并尝试了很多方面,包括:
cd app; export HOME=$(pwd); source .profile.d/0_ruby.sh; rails c
Run Code Online (Sandbox Code Playgroud)
和
cd app; export HOME=$(pwd); source .profile.d/*.sh; rails c
Run Code Online (Sandbox Code Playgroud)
两者都是命中或错过,通常不起作用.
看起来有点荒谬,通过CF访问rails控制台是非常有用的.我觉得必须有更好,更快的方式.
有人有任何提示吗?
对于任何人说我们应该cf ssh进去,这是发生的事情:
vcap@2f4663e4-f876-490c-65e2-a498:~$ cd app
vcap@2f4663e4-f876-490c-65e2-a498:~/app$ ls .profile.d/000_multi-supply.sh 0_ruby.sh
vcap@2f4663e4-f876-490c-65e2-a498:~/app$ source .profile.d/0_ruby.sh
vcap@2f4663e4-f876-490c-65e2-a498:~/app$ cd ..
vcap@2f4663e4-f876-490c-65e2-a498:~$ rails c
bash: rails: command not found
vcap@2f4663e4-f876-490c-65e2-a498:~$ source app/.profile.d/000_multisupply.sh
vcap@2f4663e4-f876-490c-65e2-a498:~$ rails c
bash: rails: command not found
Run Code Online (Sandbox Code Playgroud) 这非常奇怪.我正在升级Rails 2.3.12应用程序并一遍又一遍地遇到同样的问题.我很难过,没有别的东西似乎触及它.
我有两个型号:
class User < ActiveRecord::Base
has_many :logs, :class_name => 'UserLog'
end
Run Code Online (Sandbox Code Playgroud)
和
class UserLog < ActiveRecord::Base
attr_accessor :site_id, :controller, :action, :url, :session
belongs_to :user
validates_presence_of :user
end
Run Code Online (Sandbox Code Playgroud)
然后在另一个控制器中我这样做:
def log_user_activity
@current_user.logs.create(:site_id => @site.id, :controller => params[:controller],
:action => params[:action], :url => request.path,
:session => request.session_options[:id]) if @current_user
end
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,它非常简单,但当我调用log_user_activity时,我得到了这个:
Can't mass-assign protected attributes: site_id, controller, action, url, session
Run Code Online (Sandbox Code Playgroud)
但是,如果我将所有创建或构建更改为:
def log_user_activity
log = @current_user.logs.new
log.site_id = @site.id
log.controller = params[:controller]
log.action = params[:action]
log.url = request.path
log.session = …Run Code Online (Sandbox Code Playgroud) api ×2
activerecord ×1
amazon-s3 ×1
chromium ×1
console ×1
devise ×1
hosting ×1
image ×1
imagemagick ×1
javascript ×1
jwt ×1
linux ×1
logging ×1
ls ×1
pg ×1
rspec-rails ×1
ruby ×1
rubygems ×1
saas ×1
safari ×1
unit-testing ×1