我是Linux的粉丝,但由于Linux中的英特尔无线驱动程序不好,我不得不切换到Windows 7.我在Windows中安装了Cygwin,并希望配置SSH以远程连接到我的笔记本电脑.
我在Google上搜索并找到了在Win 7上安装openssh服务器的信息,但运行时出现以下错误ssh-host-config:
bala@bala-PC ~ $ ssh-host-config yes *** Info: Creating default /etc/ssh_config file *** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes *** Info: Creating default /etc/sshd_config file *** Info: Privilege separation is set to yes by default since OpenSSH 3.3. *** Info: However, this requires a non-privileged account called 'sshd'. *** Info: For more info on privilege separation read /usr/share/doc/openssh/READ ME.privsep. *** Query: Should privilege separation be used? (yes/no) no *** Info: Updating /etc/sshd_config …
我正在关注Flask快速入门指南.http://flask.pocoo.org/docs/quickstart/#static-files 我按照指南得到了这个错误.
/application
/__init__.py
/templates
/hello.html
@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
return render_template('hello.html', name=name)
>python _init_.py
Traceback (most recent call last):
File "_init_.py", line 4, in <module>
@app.route('/hello/')
NameError: name 'app' is not defined
Run Code Online (Sandbox Code Playgroud) 很久以前,我在Windows XP(32位)计算机上安装了32位Oracle SQL Developer 2.1.我已经转移到Windows 7(64位)并将SQL Developer 2.1从旧机器复制到新机器上.
当我尝试运行时sqldeveloper.exe,我收到以下消息:
程序无法启动,因为您的计算机缺少MSVCR71.dll.尝试重新安装该程序以修复此程序.
我知道这是因为安装在Windows XP中的32位软件与64位机器不兼容.是否有在64位计算机上打开32位软件的替代方法,还是需要安装64位版本的Oracle SQL Developer?
我已经完成了一个Go程序,人类可以在任何时候打断软件来命令它播放.基本上,我有一个算法在另一个线程中运行,每个时刻都有一个"最佳移动",它不断改进.
我的问题是:如何在无限循环中正确中断线程?
我尝试了一些事情,并决定这样做:
class MyWorker : public QObject
{
Q_OBJECT
public:
MyWorker();
~MyWorker();
public:
ThreadControl * getThreadControl();
public slots:
void work();
private:
void endOfComputation();
private:
ThreadControl * threadControl;
}
Run Code Online (Sandbox Code Playgroud)
请注意,我不是QThread的子类:
class ThreadControl : public QObject
{
Q_OBJECT
public:
ThreadControl();
public:
bool getAbort();
Parameter getParameter();
void setParameter(Parameter & param);
public slots:
void setAbort(bool b);
private:
QMutex mutex;
bool abort;
Parameter param;
};
Run Code Online (Sandbox Code Playgroud)
最后,无限循环被编码为:
void Myworker::work()
{
// ...
forever
{
abort = threadControl->getAbort();
if(abort)
{
break;
}
// …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来做i18n和l10n.
我之前使用gettext过它很好:我只是用不同的语言创建.mo文件,所有需要翻译的文件都是这样的符号:
echo __('string to be translated');
Run Code Online (Sandbox Code Playgroud)
我知道现在有一个内置于PHP的Intl库,我被告知我应该使用它代替gettext().
阅读完所有关于php.net上的Intl的内容后,我发现它有一些很好的功能,如语言环境处理,字符串比较,数字格式化等.
我无法弄清楚我是如何使用Intl库处理常规字符串到字符串的转换.有任何想法吗?
我有以下代码
@asset = Asset.first(
:include => [
:asset_statuses => [
:asset_status_name,
{:asset_location => [
{:asset_floor => :asset_building}
]}
],
:asset_type => [
:asset_category => :asset_department
]
],
Run Code Online (Sandbox Code Playgroud)
(可能不是最好的数据库表设计,但这是我必须使用的)
该Asset.first工作正常并正确带回的数据,但是当我尝试使用相同:include的to_json失败与以下错误方法:
@asset.to_json(
:include => [
:asset_statuses => [
:asset_status_name,
{:asset_location => [
{:asset_floor => :asset_building}
]}
],
:asset_type => [
:asset_category => :asset_department]
]
)
NoMethodError (undefined method `macro' for nil:NilClass):
Run Code Online (Sandbox Code Playgroud)
该to_json方法:include与find 具有相同的语法; 我不明白为什么它不起作用.
在看过Ryan优秀的Railcast Simple OmniAuth后,我已经设法在我的应用程序中实现身份验证.
一切都很好,但在我看来,我的链接看起来像这样:
<%= link_to 'Sign in with Twitter', '/signin/twitter' %>
<%= link_to 'Sign in with Facebook', '/signin/facebook' %>
Run Code Online (Sandbox Code Playgroud)
我想知道是否有一种优雅的方法来创建一个命名路由来替换它:
<%= link_to 'Sign in with Twitter', signin_twitter_path %>
<%= link_to 'Sign in with Facebook', signin_facebook_path %>
Run Code Online (Sandbox Code Playgroud)
要么:
<%= link_to 'Sign in with Twitter', signin_path(:twitter) %>
<%= link_to 'Sign in with Facebook', signin_path(:facebook) %>
Run Code Online (Sandbox Code Playgroud)
OmniAuth已经处理了这些路线......在我的routes.rb文件中,我只有回调和退出的东西:
match '/signin/:provider/callback' => 'sessions#create'
match '/signout' => 'sessions#destroy', :as => :signout
Run Code Online (Sandbox Code Playgroud)
所以我不知道在哪里可以创建那些命名的路由.
任何帮助将不胜感激.谢谢.
我正在尝试使用RubyMine(7.0.4)与PostgreSQL(9.3)建立一个简单的rails应用程序(4.2.0,ruby 2.2.0); 我正计划部署到Heroku.
我遇到两件事有问题:
首先(也是更重要的),我的ENV变量在我的database.yml文件中不起作用.
其次,RubyMine根本不识别该文件中的erb.
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
development:
<<: *default
database: my_app_development
test:
<<: *default
database: my_app_test
production:
<<: *default
# database: my_app_production
# username: <%= ENV['DB_USERNAME'] %>
# password: <%= ENV['DB_PASSWORD'] %>
url: <%= ENV['DATABASE_URL'] %>
Run Code Online (Sandbox Code Playgroud)
(我正在使用dotenv-rails gem):
DB_USERNAME=my_app
DB_PASSWORD=password
Run Code Online (Sandbox Code Playgroud)
编辑:我也试过了
export DB_USERNAME=myapp, DB_USERNAME="my_app",和 export DB_USERNAME="myapp"...
group :development, :test do
...
# Shim to load environment variables …Run Code Online (Sandbox Code Playgroud) 许多博客使用"标签"和"类别"的概念来向帖子添加元数据.这种信息的语义标记的最佳实践是什么,这样阅读博客文章的机器可以轻松识别标签?
目前我添加"tag"到rel属性的链接,例如在
<a rel="tag" class="tag" href="/tags.html#site-configuration">#site-configuration</a>
Run Code Online (Sandbox Code Playgroud)
我想可以使用Dublin Core的html格式作为关键字:
<meta name = "DC.Subject"
content = "site-configuration">
Run Code Online (Sandbox Code Playgroud)
并将其添加到页眉,还是元标签可以进入正文?是一个或另一个更好,或一些完全不同的选择?
在为内容提供精确和标准化的定义方面是否有更好的策略?
如果我想对元数据如此挑剔,或者我应该使用XML文档类型,HTML5是一个合理的选择吗?
不同方法的优缺点是什么?
我试图从我的应用程序支持的所有URL的代码自动创建文档.我们使用完全客户端MVC,因此支持的每个URL本质上是UI的REST API.有没有一种从这些URL生成文档的简单方法?
我现在写了这个小模块,但我正在寻找更好的方法.如果类似的东西已经存在,我不想重新发明轮子.
更新:请注意,目的是为网站的消费者提供公共文档,而不是内部消费.在这方面,我们需要记录每个URL: - 响应是什么, - 接受哪些参数, - 如果URL响应GET/POST或两者,等等.
某些只是重定向到主页的URL(^ $)不应该被记录,所以我还需要一些排除机制.
from django.core.management.base import BaseCommand
from django.conf import settings
class Command(BaseCommand):
''' Generates documentation for the URLs. For each URL includes the documentation from
the callback implementing the URL and prints the default arguments along with the URL pattern and name'''
def handle(self, *args, **options):
url_module = None
exec 'import '+settings.ROOT_URLCONF+'; url_module='+settings.ROOT_URLCONF
doc = file('doc.html','w')
doc.write("<table border=1 cellspacing=0 cellpadding=5>")
doc.write("<tr><th>URL Pattern<th>Name<th>Documentation<th>Parameters")
for x in url_module.urlpatterns:
doc.write("<tr>")
doc.write("<td>")
doc.write(x._regex) …Run Code Online (Sandbox Code Playgroud)