小编Ric*_*nop的帖子

如何从浮点数中得到一个分数?

我有一个浮点数:

var f = 0.1457;
Run Code Online (Sandbox Code Playgroud)

要么:

var f = 4.7005
Run Code Online (Sandbox Code Playgroud)

如何将分数余数作为整数?

即在第一个例子中我想得到:

var remainder = 1457;
Run Code Online (Sandbox Code Playgroud)

在第二个例子中:

var remainder = 7005;
Run Code Online (Sandbox Code Playgroud)

javascript jquery

21
推荐指数
3
解决办法
3万
查看次数

表垂直标题?

如何使表格标题在表格的左侧显示为列而不是在顶部显示为行?我有这个标记:

<table>
  <thead>
    <tr>
      <th>a</th>
      <th>b</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>2</td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

html css xhtml html-table

21
推荐指数
2
解决办法
4万
查看次数

Python HMAC:TypeError:字符映射必须返回整数,None或unicode

我对HMAC有轻微的问题.运行这段代码时:

signature = hmac.new(
    key=secret_key,
    msg=string_to_sign,
    digestmod=sha1,
)
Run Code Online (Sandbox Code Playgroud)

我收到一个奇怪的错误:

  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 133, in new
    return HMAC(key, msg, digestmod)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 72, in __init__
    self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode
Run Code Online (Sandbox Code Playgroud)

当我打印string_to_sign时,它是一个正确的字符串,如下所示:

GET
\n
\n
application/json
\n
\n
\n
Run Code Online (Sandbox Code Playgroud)

错误是什么意思?是因为新线?

python

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

为什么DOM会改变编码?

$string = file_get_contents('http://example.com');

if ('UTF-8' === mb_detect_encoding($string)) {
    $dom = new DOMDocument();
    // hack to preserve UTF-8 characters
    $dom->loadHTML('<?xml encoding="UTF-8">' . $string);
    $dom->preserveWhiteSpace = false;
    $dom->encoding = 'UTF-8';
    $body = $dom->getElementsByTagName('body');
    echo htmlspecialchars($body->item(0)->nodeValue);
}
Run Code Online (Sandbox Code Playgroud)

这会将所有UTF-8字符更改为Å,¾,¤和其他垃圾.有没有其他方法如何保存UTF-8字符?

不要发布答案告诉我确保我输出它作为UTF-8,我确定我是.

提前致谢 :)

php dom utf-8

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

向Eclipse添加Java支持

我从这里下载并安装了Eclipse for PHP Developers:

http://www.eclipse.org/downloads/

我还需要编写一些Java应用程序.如何在PHP Eclipse版本中添加Java支持?我是否必须为Java安装第二个Eclipse?

php java eclipse

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

[__NSCFNumber length]:无法识别的选择器发送到实例0x6d21350

这个错误意味着什么?

[__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

    NSString *urlString = @"http://api.twitter.com/1/statuses/update.json";
    NSURL *url = [NSURL URLWithString:urlString];

    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:status forKey:@"status"];
    [params setObject:replyToID forKey:@"in_reply_to_status_id"];
    [params setObject:@"1" forKey:@"include_entities"];

    // Build the request with our parameter
    TWRequest *request = [[TWRequest alloc] initWithURL:url parameters:params requestMethod:TWRequestMethodPOST];

    // Attach the account object to this request
    [request setAccount:twitterAccount];

    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        if (!responseData) {
            // inspect the contents of error 
            NSLog(@"%@", [error localizedDescription]);

            self.alert …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios

20
推荐指数
2
解决办法
4万
查看次数

在foreach循环中取消设置数组元素

所以这是我的代码:

<?php

$arr = array(array(2 => 5),
             array(3 => 4),
             array(7 => 10));

foreach ($arr as $v) {
    $k = key($v);
    if ($k > 5) {
        // unset this element from $arr array
    }
}

print_r($arr);

// now I would like to get the array without array(7 => 10) member
Run Code Online (Sandbox Code Playgroud)

如您所见,我从一个单键=>值数组的数组开始,我循环遍历此数组并获取当前元素的键(这是一个单项数组).

我需要用高于5的键取消数组的元素,我怎么能这样做?我可能还需要删除值小于50的元素或任何其他条件.基本上我需要能够获得当前数组项的键,它本身就是一个带有单个项的数组.

php

19
推荐指数
2
解决办法
3万
查看次数

如何更改Exception对象的异常消息?

所以我捕获一个异常(Exception类的实例),我想要做的是更改它的异常消息.

我可以得到这样的异常消息:

$e->getMessage();
Run Code Online (Sandbox Code Playgroud)

但是如何设置异常消息?这不起作用:

$e->setMessage('hello');
Run Code Online (Sandbox Code Playgroud)

php

19
推荐指数
5
解决办法
2万
查看次数

必须加载memcache扩展才能使用此后端

我安装了memcached.这是来自phpinfo():

在此输入图像描述

但是当它像这样使用时:

private static function getZendCacheMemcachedObject()
{
    $frontendOpts = array(
        'caching' => true,
        'lifetime' => 3600,
        'automatic_serialization' => true
    );

    $backendOpts = array(
        'servers' =>array(
            array(
            'host'   => 'localhost',
            'port'   => 11211,
            'weight' => 1
            )
        ),
        'compression' => false
    );

    return Zend_Cache::factory('Core', 'Memcached', $frontendOpts, $backendOpts);
}

public function foo($id)
{
    $cache = self::getZendCacheMemcachedObject();
    $cacheKey = 'foo_'.$id;
    $xml = $cache->load($cacheKey);

    if (false === $xml) {
        $xml = $this->httpClient->foo();
        $cache->save($xml, $cacheKey);
    }

    return $xml;
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

The memcache extension must be …
Run Code Online (Sandbox Code Playgroud)

php memcached zend-framework

19
推荐指数
1
解决办法
3万
查看次数

Oracle - 为所有用户授予权限

我需要向所有用户授予权限,我可以这样做:

GRANT select on table TO user1;
GRANT select on table TO user2;
...
Run Code Online (Sandbox Code Playgroud)

但是有很多用户.如何立即将此权限授予所有用户?

我试过了:

GRANT select on table TO ALL;
Run Code Online (Sandbox Code Playgroud)

但这不起作用.

oracle

18
推荐指数
2
解决办法
4万
查看次数

标签 统计

php ×5

css ×1

dom ×1

eclipse ×1

html ×1

html-table ×1

ios ×1

iphone ×1

java ×1

javascript ×1

jquery ×1

memcached ×1

oracle ×1

python ×1

utf-8 ×1

xcode ×1

xhtml ×1

zend-framework ×1