在成为textmate的长期用户之后,我正在尝试使用vim,虽然我可以看到应用程序的吸引力,甚至像在命令行上调用vim一样简单地粘贴到另一个应用程序中的东西似乎是不必要的复杂.
你怎么把你抓到其他应用程序可用的缓冲区?
目前,我正在键入ggvG以选择整个文件,然后键入y以将其拉入缓冲区,但此缓冲区不可用于其他应用程序.
我正在使用Ubuntu Jaunty(股票上网本混音安装),我正在使用vim 7.2.79.
另外,有没有办法获得一个简单的gui包装vim,就像你使用macvim一样?
我正在寻找有关如何在Web应用程序中清理提交的html的建议,以便将来可以重新显示样式或未封闭的标签破坏应用程序的布局.
在我的应用程序上,用户使用YUI Rich文本编辑器提交了丰富的HTML,默认情况下会运行一些正则表达式来清理输入,而且我还调用[ filter_MSWord][1]捕获从办公室发送的任何废话
在后端,我正在运行ruby-tidy以在显示为评论之前清理html,但有时粘贴不好的html仍会影响我正在使用的应用程序的布局 - 我该如何防范这个?
FWIW这里是我正在使用的消毒剂设置 -
module HTMLSanitizer
def tidy_html(input)
cleaned_html = Tidy.open(:show_warnings=>false) do |tidy|
# don’t output body and html tags
tidy.options.show_body_only = true
# output xhtml
tidy.options.output_html = true
# don’t write newlines all over the place
tidy.options.wrap = 0
# use utf8 to play nice with rails
tidy.options.char_encoding = 'utf8'
xml = tidy.clean(input)
xml
end
end
end
Run Code Online (Sandbox Code Playgroud)
我还有什么选择呢?
我想要做的就是规定视图的一行帮助方法应该如何表现,但我不确定如果我在Rails中工作,我应该创建什么样的模拟对象(如果有的话).
这是events_helper.rb的代码:
module EventsHelper
def filter_check_button_path
params[:filter].blank? ? '/images/buttons/bt_search_for_events.gif' : '/images/buttons/bt_refine_this_search.gif'
end
end
Run Code Online (Sandbox Code Playgroud)
这是我的规范代码,在events_helper_spec.rb中:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe EventsHelper do
#Delete this example and add some real ones or delete this file
it "should be included in the object returned by #helper" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(EventsHelper)
end
it "should return the 'refine image search' button if a search has been run" do
# mock up params hash
params = {}
params[:filter] = …Run Code Online (Sandbox Code Playgroud) 我正在开发一个开源 django 网络应用程序,我希望使用 Factory Boy 来帮助我为一些测试设置模型,但是在阅读文档和查看示例几个小时后,我认为我需要接受失败并在这里问。
我有一个客户模型,它看起来有点像这样:
class Customer(models.Model):
def save(self, *args, **kwargs):
if not self.full_name:
raise ValidationError('The full_name field is required')
super(Customer, self).save(*args, **kwargs)
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
related_name='customer',
null=True
)
created = models.DateTimeField()
created_in_billing_week = models.CharField(max_length=9)
full_name = models.CharField(max_length=255)
nickname = models.CharField(max_length=30)
mobile = models.CharField(max_length=30, default='', blank=True)
gocardless_current_mandate = models.OneToOneField(
BillingGoCardlessMandate,
on_delete=models.SET_NULL,
related_name='in_use_for_customer',
null=True,
)
Run Code Online (Sandbox Code Playgroud)
我也在使用来自 django.contrib.auth 的标准 Django 用户模型。
这是我的工厂代码:
class UserFactory(DjangoModelFactory):
class Meta:
model = get_user_model()
class CustomerFactory(DjangoModelFactory):
class Meta:
model = models.Customer
full_name = …Run Code Online (Sandbox Code Playgroud) 最近我被这种情况所困扰,确切地知道发生了什么事情是有用的,所以其他人避免这种错误.
我有一个模型用户,其架构如下:
create_table "users", :force => true do |t|
t.string "user_name"
t.string "first_name"
t.string "last_name"
t.string "email"
t.string "location"
t.string "town"
t.string "country"
t.string "postcode"
t.boolean "newsletter"
Run Code Online (Sandbox Code Playgroud)
在类user.rb中,我有三个方法的attr_accessor:
class User < ActiveRecord::Base
# lots of code
attr_protected :admin, :active
# relevant accessor methods
attr_accessor :town, :postcode, :country
end
Run Code Online (Sandbox Code Playgroud)
现在在我的用户控制器中,如果我有以下方法:
def create
@user = User.new params[:user]
end
Run Code Online (Sandbox Code Playgroud)
当我尝试使用此params哈希中的内容创建新用户时:
--- !map:HashWithIndifferentAccess
# other values
country: United Kingdom
dob(1i): "1985"
dob(2i): "9"
dob(3i): "19"
town: london
Run Code Online (Sandbox Code Playgroud)
返回的对象为空字符串country,town以及邮政编码postcode值,就像这样. …
什么因素决定了svn copy从一个发布版本中包装标签时调用的速度?
我一直在使用git一两年,在最近的一个项目中我不得不回到使用subversion,在我提交之前调用svn copy需要2到25分钟才能在我的机器上完成,没有与每次更改的代码量有很大关系.
您通常采取哪些步骤来加快包装过程,或至少使其更具可预测性?
我知道聪明的事情就是使用git-svn,但是当我尝试时我无法推送到正确的分支,团队中的其他人都在使用svn,所以我对于在中途使用一个不熟悉的工具很谨慎一个专案.