小编Ter*_*nja的帖子

使用无符号原始类型

大多数时候,我们代表的概念永远不会小于0.例如,为了声明长度,我们写道:

int length;
Run Code Online (Sandbox Code Playgroud)

该名称很好地表达了它的目的,但您可以为其指定负值.在某些情况下,您可以通过这种方式更清楚地表达您的意图:

uint length; 
Run Code Online (Sandbox Code Playgroud)

我能想到的一些缺点:

  • unsigned types(uint,ulong,ushort)不符合CLS,因此您不能将其与其他不支持此语言的语言一起使用
  • .Net类大多数时候都使用签名类型,因此你必须进行强制转换

思考?

c# primitive-types

7
推荐指数
3
解决办法
754
查看次数

如何在wiki api中获取图片网址?

当我调用wiki API来访问图像URL时,我得到这样的图像URL,

File:Ad-tech London 2010 (2).JPG
Run Code Online (Sandbox Code Playgroud)

如何从wiki API获取此文件的正确URL?

api wiki mediawiki

7
推荐指数
2
解决办法
5654
查看次数

从导出的维基百科文章中检索Interlanguage链接?

我曾经通过使用一些正则表达式解析导出来从导出的维基百科文章中检索中介语链接.

WikiData项目的第1阶段,这些链接已移至维基数据上的单独页面.

例如,文章Ore Mountains在导出中不再有语言链接.语言链接现在是Q4198.

如何导出语言链接?

wikipedia wikipedia-api wikidata wikidata-api

6
推荐指数
2
解决办法
1132
查看次数

如何检查 TURN 服务器日志?

我已经安装了开源的 TURN 服务器(rfc5766-turn-server),我使用以下命令运行它 sudo turnserver -L my.domain.in -a -b /usr/local/etc/turnuserdb.conf -f -r domain.in

这是我在终端中得到的输出,

RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Citrix-3.1.5.0 'Arch Lector'
0:

==== Show them the instruments, Practical Frost: ====

0: TLS supported
0: DTLS supported
0: Redis is not supported
0: PostgreSQL is not supported
0: MySQL is not supported
0: OpenSSL version: fresh enough
0: TURN Network Engine version: 2.5

=====================================================

0: Config file found: /usr/local/etc/turnserver.conf
0: ERROR: Cannot add a listener address: qeee.rtbi.in
0: Config file …
Run Code Online (Sandbox Code Playgroud)

google-chrome stun webrtc

6
推荐指数
2
解决办法
1万
查看次数

如何找到字符串中值的倒数第二个索引?

string referrer = "?404;http://stage.hello.com:80/Applications/";

referrer = referrer.Substring(referrer.LastIndexOf("/") + 1);
Run Code Online (Sandbox Code Playgroud)

通过这样做,我得到引用者值""作为答案.

我希望我的引荐来源值为"Applications /"

我怎样才能做到这一点?

任何帮助将不胜感激.

c# asp.net

6
推荐指数
2
解决办法
5838
查看次数

如何在 Doctrine 中附加分离的实体?

我有一个脚本将循环中的一些“A”类型的新实体保存到数据库中。但是循环会抛出一些关闭 entityManager 的异常。所以必须重开。它导致应该与每个“A”实体连接的另一个“B”类型的实体与 unitOfWork 分离。如何将“B”附加到 unitOfWork?这是一个例子:

public function insert( Array $items )
{
    $B = $this->bRepository->findOneBy( ['name' => 'blog'] );
    $result = [ 'errors' => [], 'saved_items' => [] ];

    foreach( $items as $item )
    {
        try
        {
            $A = new Entity\A();
            $A->create([
                'name' => $item->name,
                'B' => $B // Here is the problem after exception. $B is detached.
            ]);
            $this->em->persist( $A );
            $this->em->flush( $A );
            $result['saved_items'][] = $item->name;
        } catch( \Eception $e )
        {
            $result['errors'][] = 'Item ' . …
Run Code Online (Sandbox Code Playgroud)

entity unit-of-work entitymanager detach doctrine-orm

6
推荐指数
1
解决办法
4287
查看次数

如何从VectorDrawable获取位图

馅饼

我还在努力解决几天前我遇到的问题,但我还没有找到解决方案.但是,我一步一步到达那里.现在我遇到了另一个障碍.

我试图Bitmap.getpixel(int x, int y)返回Color用户使用的内容OnTouchListener.馅饼是一种VectorDrawable资源,vectordrawable.xml我不需要对像素数据做任何事情,我只需要测试它.所以我做了一个TextView会吐了出来的Color.

public class MainActivity extends AppCompatActivity {
    ImageView imageView;
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageView = (ImageView) findViewById(R.id.imageView);
        textView = (TextView) findViewById(R.id.textView);

        imageView.setOnTouchListener(imageViewOnTouchListener);
    }

    View.OnTouchListener imageViewOnTouchListener = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {

            Drawable drawable = ((ImageView)view).getDrawable();
            //Bitmap bitmap = BitmapFactory.decodeResource(imageView.getResources(),R.drawable.vectordrawable);
            Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();

            int x = (int)event.getX();
            int y = …
Run Code Online (Sandbox Code Playgroud)

android bitmap getpixel ontouchlistener android-vectordrawable

6
推荐指数
2
解决办法
1万
查看次数

如何通过API在Wikimedia Commons中搜索图像?

我正试图从维基共享资源查询猫的所有图像(例如).

我想到的方法是首先搜索这里的Cat页面(我不知道如何以编程方式找到它,可能重定向?):

https://commons.wikimedia.org/wiki/Felis_silvestris_catus

因此,要获得图像,我只需要这样做:

https://commons.wikimedia.org/w/api.php?action=query&prop=images&imlimit=500&titles=Felis_silvestris_catus

这将返回我想要的.但是,即使Cat重定向到Felis_silvestris_catus,对Cat的搜索也不会返回任何内容.

有没有人知道是否有任何简单的方法在维基媒体共享上进行图像搜索,只需从"Cat"开始,它将返回Cat图像,如果没有最好的可以做到的话?

我已经看了几个小时的API,但我似乎无法弄明白.

mediawiki-api wikimedia-commons

6
推荐指数
1
解决办法
1928
查看次数

如何从 Wikipedia API 获得超过默认的 10 个结果?

我正在使用 Wikipedia API,在其中获取我输入的某些字符串的图像。它总是返回 10 个结果,但我想要超过大约 50 个。

https://en.wikipedia.org/w/api.php?action=query&prop=pageimages&format=json&piprop=thumbnail&pithumbsize=500&pilimit=50&generator=prefixsearch&gpssearch=game of thrones
Run Code Online (Sandbox Code Playgroud)

我如何获得 50 个结果?

wikipedia-api

6
推荐指数
1
解决办法
800
查看次数

缺少 XCode 仪器自动化

我想使用 Xcodes Instruments 进行 UI 自动化测试。但似乎缺少“自动化”。我怎样才能添加这个?

图片

xcode instruments

6
推荐指数
1
解决办法
2382
查看次数