尽管打开了隐藏文件夹,但是崇高文本无法在侧边栏中看到不可见的文件夹,例如git存储库.我怎样才能解决这个问题?
Mac OSX 10.7.5
Sublime Text 2.0.1
我有一个数组:
array = ['mario','luigi','kong']
Run Code Online (Sandbox Code Playgroud)
我调用它的splice函数来删除索引之前的所有项:
array.splice(1) //-> ['luigi','kong']
Run Code Online (Sandbox Code Playgroud)
我只是想知道是否有一个类似于splice的函数来删除索引后的所有项:
伪代码
array.mirrorsplice(1) //-> ['mario','luigi']
Run Code Online (Sandbox Code Playgroud) 基本上,我在终端打字很好,使用IRB运行ruby命令:
2.0.0-p0 :014 > bank_account.withdraw(2222)
=> -1222
Run Code Online (Sandbox Code Playgroud)
但有时我不小心错过了一个引号.
2.0.0-p0 :020 > BankAccount.create_for("Jim","Johnson)
2.0.0-p0 :021"> bank_account.withdraw(333)
Run Code Online (Sandbox Code Playgroud)
如果你仔细观察,你会发现我遗漏的语音标记出现在左边的行号旁边,旁边是补丁版本.
从现在开始,每次运行命令时都会出现该语音标记!它会阻止命令工作:
2.0.0-p0 :021"> BankAccount.create_for("Julian","Hurley")
2.0.0-p0 :022"> BankAccount.create_for("Katt","Smith")
2.0.0-p0 :023"> exec($0)
Run Code Online (Sandbox Code Playgroud)
我想知道的是,我该如何摆脱这个引号?或者从命令行退出IRB以重置它?
我按照本指南记录了puma.rb
存储在app的config目录中的文件.
该指南有点夸张,但这是我假设puma.rb
文件的作用.而不是像这样运行疯狂的命令来让puma在指定的套接字上运行:
bundle exec puma -e production -b unix:///var/run/my_app.sock
Run Code Online (Sandbox Code Playgroud)
您可以在文件中指定端口,pid,会话和其他参数,puma.rb
如下所示:
rails_env = ENV['RAILS_ENV'] || 'production'
threads 4,4
bind "/home/starkers/Documents/alpha/tmp/socket"
pidfile "/home/starkers/Documents/alpha/tmp/pid"
state_path "/home/starkers/Documents/alpha/tmp/state"
activate_control_app
Run Code Online (Sandbox Code Playgroud)
然后你可以进入应用程序的root并运行一个简单的命令
"彪马"
并puma.rb
遵循设定的参数.不幸的是,这似乎对我不起作用.
至少,我在puma
一个小测试应用程序的根目录内运行,没有.sock
文件出现,
/home/starkers/Documents/alpha/tmp/sockets
所以这意味着它不起作用?
我该如何工作?我在本地开发机器上,所以可能会以某种方式导致此错误?运行时是否需要传入参数
puma
?
让我解释.我正在开发一个javascript应用程序来帮助人们开发网站.我不会明确地了解它的作用,只知道它的工作原理是将它的html/inline css接口叠加在正在开发的网站上,并提供各种工具,如跟踪图像和代码缩小器.
我把它作为.js文件存储在服务器上.所有人要访问我的应用程序都是复制并粘贴一小部分html到他们的页面上使用它,如下所示:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="www.example.com/application.js">
<div class="application"></div>
Run Code Online (Sandbox Code Playgroud)
然后使用jquery的.html()函数将接口的html和内联css插入到'application'div中.
一切都很完美.
除了一件事.加载时间.当用户开发他们的网站时,他们将不断刷新他们的页面,这导致他们不得不等待大约3秒钟(随着时间的推移非常烦人)加载应用程序的界面.
当然,如果打开浏览器的缓存,则问题会消失,但如果您正在开发网站,则需要禁用缓存!这是一个难题.
然后我想使用本地存储对象来保存接口的svg图形的字符串,然后将.html()这些字符串转换为内联css.这是一个精心设计的解决方法,但只有开发人员才会使用此工具.它不是最终用户的事情.它也很漂亮,但事实是,浏览器仍然需要下载脚本才能知道访问本地存储的图像!处理器速度不是瓶颈,而是带宽.
所以我在考虑将脚本本身存储在本地存储对象中,并使用一个很小的初始化脚本来运行它.
初始化脚本将简单地从本地stroage对象中检索脚本作为字符串,相应地解析它然后运行它.
重申我的问题,运行它是我不能做的部分!我可以通过.html(脚本)将脚本插入到页面中,但是我该如何运行呢?
我很确定Guard是罪魁祸首,因为跑步rspec
运行所有规格一次.运行guard
并enter
导致所有规格运行两次.不知道为什么.谷歌搜索到破坏,常见的陷阱,如在spec_helper.rb中要求'rspec/autorun'根本不是它的原因.
当规格开始变慢时,它会变得非常烦人!
.rspec
--color
--order default
Run Code Online (Sandbox Code Playgroud)
Guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and …
Run Code Online (Sandbox Code Playgroud) 我正在为Rails编写一个自定义rake任务,有一点是程序总结了它将要做什么,然后询问用户它将要执行的操作是否正确.
puts "\n Is this what you want to happen? [Y/N]"
answer = gets.chomp
if answer == "Y"
# commits
else if answer == "N"
return false #(Aborts the rake task)
end
Run Code Online (Sandbox Code Playgroud)
但是,此代码会导致rake过早中止;
rake aborted!
No such file or directory - populate
Run Code Online (Sandbox Code Playgroud)
" populate "是rake任务的名称.
我认为在.gets方法中导致此错误的原因是什么.
我不知道.gets方法是如何显式工作的,但我猜它必须自动将用户输入发送回写入脚本的文件,并且由于某种原因它变得混乱并且它认为是rake的名称task是文件的名称.由于populate.rake不存在,我认为这就是抛出错误的原因.
但是,我不知道如何解决这个错误.rake是否为.gets提供了另一种方法?
不知道为什么会这样:
git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: file (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
starkers@ubuntu:~/Documents/currentWork/protection_demo$ git add --all
starkers@ubuntu:~/Documents/currentWork/protection_demo$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what …
Run Code Online (Sandbox Code Playgroud) 对.这简直就是拒绝工作.在这几个小时.
专辑模型
class Album < ActiveRecord::Base
has_many :features, through: :join_table1
end
Run Code Online (Sandbox Code Playgroud)
功能模型
class Feature < ActiveRecord::Base
has_many :albums, through: :join_table1
end
Run Code Online (Sandbox Code Playgroud)
join_table1模型
class JoinTable1 < ActiveRecord::Base
belongs_to :features
belongs_to :albums
end
Run Code Online (Sandbox Code Playgroud)
join_table1架构
album_id | feature_id
Run Code Online (Sandbox Code Playgroud)
专辑架构
id | title | release_date | genre | artist_id | created_at | updated_at | price | image_path
Run Code Online (Sandbox Code Playgroud)
功能架构
id | feature | created_at | updated_at
Run Code Online (Sandbox Code Playgroud)
在调试测试数据库并运行此集成测试时:
require 'test_helper'
class DataFlowTest < ActionDispatch::IntegrationTest
test "create new user" do
album = albums(:one)
feature = features(:one)
album.features …
Run Code Online (Sandbox Code Playgroud) 或者是生成随机和唯一用户名所必需的外部gem?
这是我目前的工厂:
factory :user_4 do
sequence(:id) { |n| n }
sequence(:first_name) { |n| "Gemini" + n.to_s }
sequence(:last_name) { |n| "Pollux" + n.to_s }
sequence(:profile_name) { |n| "GeminiPollux" + n.to_s }
sequence(:email) { |n| "geminipollus" + n.to_s + "@hotmail.co.uk" }
end
Run Code Online (Sandbox Code Playgroud)
使用序列方法适用于id,profile_name和email,但我的REGEX验证意味着名字和姓氏自动无效,因为它们中有一个数字.与独特性无关.
那么我该如何创建这些独特的名字呢?
javascript ×2
jquery ×2
ruby ×2
capybara ×1
factory-bot ×1
git ×1
git-add ×1
irb ×1
macos ×1
puma ×1
rake ×1
rspec ×1
sublimetext ×1
terminal ×1