在我的工作环境中,Internet访问由NTLM身份验证管理,并与Windows用户帐户关联,easy_install或pip不起作用:
C:\>easy_install django
install_dir D:\Python26\Lib\site-packages\
Searching for django
Reading http://pypi.python.org/simple/django/
Download error: timed out -- Some packages may not be found!
....
C:\>pip install django
Downloading/unpacking django
Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement django
No distributions at all found for django
Run Code Online (Sandbox Code Playgroud)
是否有可能让他们在这样的环境中工作?
我正在使用Term::ANSIColor我的Perl脚本对终端输出进行着色,并且我正在使用该colorstrip函数,该函数仅在Term::ANSIColor版本2.01中添加,根据更改日志.那么,有没有办法让我的脚本自动die使用适当的错误消息,如果它至少找不到该版本的Term::ANSIcolor?
我有一个FrameLayout包含一个子类SurfaceView和一个ImageView.我想在ImageView上做一个TranslateAnimation.我能使其工作的唯一方法是向FrameLayout添加一个空的View.否则,在动画期间,ImageView会被剪裁(到动画开始时ImageView位置的边界).
我很好奇为什么空兄弟View允许ImageView正确动画.使其工作的行在下面的代码中标有注释.
public class Test5 extends Activity {
private static final String TAG = "Test5";
private MySurfaceView mMSV;
private ImageView mRectView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mMSV = new MySurfaceView(this);
mRectView = new ImageView(this);
ShapeDrawable sd = new ShapeDrawable(new RectShape());
sd.getPaint().setColor(Color.RED);
sd.setIntrinsicWidth(300);
sd.setIntrinsicHeight(100);
mRectView.setImageDrawable(sd);
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.addView(mMSV);
frameLayout.addView(mRectView, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT));
// I don't know why the following line prevents clipping during
// animation. It simply adds a vacuous View.
frameLayout.addView(new View(this));
setContentView(frameLayout);
} …Run Code Online (Sandbox Code Playgroud) 如何检查用户输入的文本是否为网址?
假设我想检查文本是否是网址,然后检查字符串中是否包含"youtube.com".之后,我想在子串"watch?v ="和任何"&"参数(如果它们确实存在)之间得到链接的部分.
我UISearchBar在我的应用程序中使用它既可以作为编辑字段,也可以作为搜索.因此,当我想要消失键盘时,我必须在UISearchBar中使用取消按钮,但我不能在屏幕上有取消按钮,那么如果不使用取消按钮不使用T键盘会如何消失.请帮助我,因为我是iPhone应用程序开发的新手.
提前致谢!
我是Emacs的新手并且喜欢它.在我的.emacs中,我有一句话:
(setq frame-title-format "%b - GNU Emacs")
如何让它显示前两个目录?我倾向于使用相同的名称打开多个文件,并且知道它所在的目录会非常有用.
当我们初始化这样的数组时int a[5] = {0},编译器会使所有5个元素为0.这是非常好的,紧凑的初始化和有用的功能.
但我想知道为什么编译器没有int a[5]={1}类似的初始化?为什么它不能使所有5个元素1?为什么标准不强制要求?它不是一个很棒的功能吗?不是不见了?
此外,如果初始化程序中的元素数小于数组的大小,则编译可以使用初始化程序中的最后一个元素初始化剩余的元素.手段,int a[5]={1,2,3}相当于int a[5]={1,2,3,3,3}.同样,int a[10]={1,2,3,0}相当于int a[10]={1,2,3,0,0,0,0,0,0,0};.
如果标准要求,这一切都不是一个很棒的功能吗?或者这个缺失的功能有什么好的理由吗?
并且在C99中有一个称为指定初始化程序的东西,其用途如下:
指定的初始值设定项可以与常规初始值设定项结合使用,如下例所示:
int a[10] = {2, 4, [8]=9, 10}在该示例中,a [0]被初始化为2,a 1被初始化为4,a [2]至a [7]被初始化为0,并且a [9]被初始化为10.
很有趣.但即便是这个功能也不在C++中.
c++ arrays language-features language-design array-initialization
我想我最后应该为我的rails应用程序编写一些测试.
我的控制器是"UsersController".它没有任何HTML,因为我只有一个iphone应用程序发送一个帖子到rails控制器.
这是我的测试:
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
def test_create
# to http post
# /users
#user[email]=%@&user[password]=%@&user[password_confirmation]=%@
#post
post(:create, :user => {:password => "testpassword", :password_confirmation => "testpassword"})
end
Run Code Online (Sandbox Code Playgroud)
问题是我收到此错误:
1)错误:test_create(的UsersControllerTest):::的ActionView MissingTemplate:缺少模板用户/新含{:处理器=> [:ERB,:RJS,:助洗剂,:RHTML,:RXML]:格式=> [:HTML] ,:locale => [:en,:en]}在视图路径中
所以我猜它正在尝试填充HTML页面?如果是这样,我发现这很奇怪.我认为它会直接向控制器发帖.有人可以确认这个"post"方法尝试并填充HTML表单吗?
如果是这种情况,我应该如何编写测试以直接向控制器发送HTTP帖子?
谢谢你的帮助
我正在调用该方法并期望多次更新位置:
locationManager.requestLocationUpdates("gps",0 ,0, loc_listener);
Run Code Online (Sandbox Code Playgroud)
我loc_listener的定义是:
LocationListener loc_listener = new LocationListener() {
private final String TAG = "xoxoxo.LocationListener";
public void onLocationChanged(Location l) {
Intent locationAlert = new Intent("xoxoxo.LOCATION_CHANGED")
.putExtra("target_location", l);
sendBroadcast(locationAlert);
// locationManager.requestLocationUpdates("gps", 0 ,0, this);
}
public void onProviderEnabled(String p) {
Log.i(TAG, "Provider enabled");
}
public void onProviderDisabled(String p) {
Log.i(TAG, "Provider disabled");
}
public void onStatusChanged(String p, int status, Bundle extras) {
Log.i(TAG, "Status changed");
}
};
Run Code Online (Sandbox Code Playgroud)
按原样定义,我只会在HTC Evo 2.2和2.2 + Google API模拟器上获得一次更新.获取多个更新的黑客是取消注释每个更新上注册更新的行:
locationManager.requestLocationUpdates("gps", 0 ,0, this); …Run Code Online (Sandbox Code Playgroud) 我正在研究一些JavaScript代码,以在等距3Dish视图中渲染标准的2D SVG/Canvas元素(用Raphael-JS绘制).
假设我们有两个相邻的矩形.然后我将它们以正确的角度重新绘制(基本上是30度扭曲),用于等轴测视图.

(在上图中,我展示了两个相应元素的来源.)
我的问题是我不知道如何正确翻译所有单个元素,以便它们正确"平铺"而不是仅仅重叠.
虽然实际使用瓷砖会使事情变得更容易,因为我可以将任何给定的瓷砖放置在它之前的瓷砖上,但瓷砖在这种情况下不起作用.一切都是动态的,比简单的x/y平面更复杂.
这是一些等距瓷砖的图像,如果有任何关于我希望如何放置这些对象的混淆.