在git中进行高级操作时,我更像是一个新手.我使用博客框架Octopress维护我的博客.虽然Octopress自2011年以来没有任何发展,但它很好地实现了我的目的,所以到目前为止我还没想过要改变任何东西.
仅供参考,我的博客是在Github Pages上托管的.
今天,在处理新帖子时,git status显示以下消息:
On branch source
Your branch is based on 'origin/master', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
Run Code Online (Sandbox Code Playgroud)
对所有后续命令重复相同的消息,例如git add .,git commit -m 'message'和git push origin source.
如果可能的话,请指向我的pdf/web文章,在那里我可以阅读并了解它以备将来使用.
更多细节:
bash-3.2$ git branch -a
* source
remotes/octopress/2.1
remotes/octopress/HEAD -> octopress/master
remotes/octopress/gh-pages
remotes/octopress/linklog
remotes/octopress/master
remotes/octopress/refactor_with_tests
remotes/octopress/rubygemcli
remotes/octopress/site
remotes/origin/source
Run Code Online (Sandbox Code Playgroud)
如果需要更多信息,请告诉我.谢谢.
CVS中有一个中央存储库,我想在本地使用Git,然后将我的更改发送回CVS.
我每天能做到什么?
我想完成的任务是:
顺便说一下,我也看过了使用git和CVS的最佳实践.但它没有用,我无法弄清楚我错过了什么或做错了什么.
我最近接受了采访,并被问到这个问题.让我正确解释一下这个问题:
给定M(N位整数)和K个交换操作(交换操作可以交换2位),设计算法以获得最大可能的整数?
示例:
M = 132 K = 1输出= 312
M = 132 K = 2输出= 321
M = 7899 k = 2输出= 9987
我的解决方案(伪代码算法).我使用max-heap来获取每个K操作中N位数的最大数字,然后适当地交换它.
for(int i = 0; i<K; i++)
{
int max_digit_currently = GetMaxFromHeap();
// The above function GetMaxFromHeap() pops out the maximum currently and deletes it from heap
int index_to_swap_with = GetRightMostOccurenceOfTheDigitObtainedAbove();
// This returns me the index of the digit obtained in the previous function
// .e.g If I have 436659 and K=2 given,
// then …Run Code Online (Sandbox Code Playgroud) 我正在使用Devise:确认和:可恢复模块来确认用户并让他在忘记密码时恢复密码.一切都很好,邮件生成,我可以在服务器日志中看到它,但然后我遇到错误,邮件没有传递到邮箱.我的environment.rb文件的SMTP设置是:
require 'tlsmail'
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true, #this is the important shit!
:address => 'smtp.gmail.com', #'localhost',
:port => 587,
:tls => true,
:domain => 'mail.google.com', # mail.customdomain.com if you use google apps
:authentication => :login,
:user_name => 'jatinkumar.nitk@gmail.com',
:password => '_secret_password'
}
Run Code Online (Sandbox Code Playgroud)
如果:地址是'smtp.gmail.com',那么我得到以下错误:
SocketError (getaddrinfo: Name or service not known):
Run Code Online (Sandbox Code Playgroud)
如果我将:address设置为'localhost',那么我会收到以下错误:
Errno::ECONNREFUSED Connection refused - connect(2)
Run Code Online (Sandbox Code Playgroud)
我不知道这是什么:地址意味着,所有这些东西的新手.在运行uname -a时,我得到了
Linux jatin-ubuntu 2.6.32-24-generic #38-Ubuntu SMP Mon Jul 5 …Run Code Online (Sandbox Code Playgroud) 在我的申请中,我想在评论或帖子中提及他/她时通知用户.
用户句柄@user_name类似于Facebook.
提及的数据库表如下所示:
Mention
mentioned_by: user_id (foreign key)
user_mentioned: user_id (foreign key)
comment_id: (foreign key)
post_id: (foreign key)
Run Code Online (Sandbox Code Playgroud)
我无法想出实现它的方法.Facebook/Twitter如何做到这一点?
我决定使用的是使用ActiveRecord callbacks/ Observer design pattern,每当新的评论/帖子保存到数据库时,我都可以浏览帖子/评论的内容,并留意任何提及,然后根据需要执行通知.
我觉得有一些缺失的东西,我没有把它弄好.
这是最好的方式吗?
twitter notifications facebook ruby-on-rails observer-pattern
最近,在一次讨论中,一位程序员要求我做一些代码更改.我有类似的东西:
if( mystring.size() == 0)
// do something
else
// do something else
Run Code Online (Sandbox Code Playgroud)
讨论是关于使用mystring.empty()验证字符串是否为空.现在,我同意可以认为string.empty()更详细和可读的代码,但它有任何性能优势吗?
我做了一些挖掘,发现这2个答案与我的问题有关:
这两个答案都支持了我的说法,即string.empty()相比之下,它更具可读性,并没有提供任何性能优势string.size() == 0.
我仍然想确定,如果有任何实现string,保持内部布尔标志来验证字符串是否为空?
或者某些实现使用其他方式,这将使我的声明无效?
当我brew doctor在Mac上运行时,我收到以下警告:
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libntfs-3g.80.dylib
/usr/local/lib/libntfs.9.0.0.dylib
/usr/local/lib/libublio.1.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
/usr/local/lib/libntfs-3g.la
/usr/local/lib/libntfs.la
/usr/local/lib/libublio.la
Warning: Unbrewed .pc files were found …Run Code Online (Sandbox Code Playgroud) 在我的rails应用程序中,用户可以拥有一个目录结构,其中包含子文件夹中的文件夹和文件.哪种是存储此类数据的最佳方式?
此外,哪个数据库提供了最佳方法?
我正在使用ActionMailer我的申请表中的"联系我们"表单发送邮件.
我正在使用Mandrill应用程序发送我的电子邮件.这些是我的设置:
配置/环境/ development.rb
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:enable_starttls_auto => true,
:user_name => 'SMTP username i.e Mandrill a/c username',
:password => 'API key for development',
:domain => 'example.com',
:authentication => 'plain'
}
Run Code Online (Sandbox Code Playgroud)
配置/环境/ production.rb
我已删除该行
config.action_mailer.raise_delivery_errors = true
并更改了生产密码 - 这是用于生产的Mandrill app API密钥.
应用程序/邮寄者/ contactus_mailer.rb
class ContactusMailer < ActionMailer::Base
default :from => "noreply@example.com"
default :to => "help@example.com"
def new_message(message)
@message = message …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有一个文本字段,用户输入这样的内容
"1,2,3,4"
Run Code Online (Sandbox Code Playgroud)
它被存储到数据库中.现在,当我想使用内部数字时,我有两个选择:
"1,2,3,4".split(',')
Run Code Online (Sandbox Code Playgroud)
要么
string.scan(/\d+/) do |x|
a << x
end
Run Code Online (Sandbox Code Playgroud)
两种方式我得到一个像这样的数组
["1","2","3","4"]
Run Code Online (Sandbox Code Playgroud)
然后我可以通过在每个数字上调用to_i来使用这些数字.
有没有更好的方法来做到这一点,转换
"1,2,3" to [1,2,3] and not ["1","2","3"]
Run Code Online (Sandbox Code Playgroud) actionmailer ×2
git ×2
smtp ×2
algorithm ×1
brew-doctor ×1
c++ ×1
c++11 ×1
cvs ×1
database ×1
devise ×1
facebook ×1
git-branch ×1
git-cvs ×1
git-svn ×1
github-pages ×1
homebrew ×1
localhost ×1
macos ×1
mandrill ×1
outlook.com ×1
performance ×1
ruby ×1
string ×1
twitter ×1