小编Era*_*ozi的帖子

转换为CPS(续传样式)

如何将Scheme中的这些程序转换为CPS表格?

  1. (lambda (x y)
      ((x x) y))
    
    Run Code Online (Sandbox Code Playgroud)
  2. (lambda (x)
      (lambda (f)
        (f (lambda (y)
             (((x x) f) y))))
    
    Run Code Online (Sandbox Code Playgroud)
  3. ((lambda (x) (x x)
     (lambda (x) (x x))
    
    Run Code Online (Sandbox Code Playgroud)

*这不是任何功课!

scheme continuation-passing

8
推荐指数
1
解决办法
5322
查看次数

为什么 java RandomAccessFile 比 FileOutputStream 慢这么多?

只要我能理解java api,使用“rw”打开RandomAccessFile就不会在底层存储设备上同步写入每个单字节。与“rws”或“rwd”不同。
为什么它与“rw”的无缓冲 FileOutputStream 的“速度”几乎相同,而“rws”/“rwd”的速度慢 10 倍以上?

下面的简单代码显示了这一点,我无法对此得到任何合理的解释。有什么线索吗?

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;

public class StreamTest {

  public static void main(String[] args) throws Exception {

    OutputStream os;
    RandomAccessFile raf;
    int size = 10000;
    File file = new File("test.log");

    long a=System.currentTimeMillis();
    os = new FileOutputStream(file);
    for(int i=0;i<size;i++){
      os.write(("1").getBytes());
    }
    os.close();     
    long b=System.currentTimeMillis();
    System.out.println("writing direct "+(b-a));

    raf = new RandomAccessFile(file,"rws");
    for(int i=0;i<size;i++){            
      raf.write(("1").getBytes());
    }
    raf.close();

    long c=System.currentTimeMillis();
    System.out.println("random access write "+(c-b));

    raf = new RandomAccessFile(file,"rw");
    for(int i=0;i<size;i++){            
      raf.write(("1").getBytes());
    } …
Run Code Online (Sandbox Code Playgroud)

java

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

如何有效地处理3D体素?

我有一个拥有数百万点的3D点云.我想将这些点存储在3D体素空间中.沿坐标轴的体素数大于3000(x),4000(y),1500(z),总共3000*4000*1500体素.我需要存放在体素中; 最大点数,最小高度,最大高度和centorid.但是,90%的体素都是空的.因此存储它需要大量内存.实际上,我想在以后搜索每个体素的26个相邻体素.那么在体素空间中存储这些数据并有效访问这些数据的最佳方法是什么?

在性能方面,创建一个多维数组并不是最好的解决方案......请提出任何提示?

c++ 3d computational-geometry

5
推荐指数
1
解决办法
5000
查看次数

有人可以解释下面的Scheme代码吗?

我一直在听斯坦福大学的编程范例讲座系列,但我对下面的代码感到困惑(来自第20讲).有人会逐行解释这是做什么的吗?

谢谢.

(define (flatten sequence)
  (cond ((null? sequence) '())
        ((list? (car sequence)) (append (flatten (car sequence))
                                        (flatten (cdr sequence))))
        (else (cons (car sequence)
                    (flatten (cdr sequence))))))
Run Code Online (Sandbox Code Playgroud)

scheme

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

C++ OpenCV mat.at在使用数据时提供访问冲突

我在visual studio 2010 C++ dll中使用openCV 2.1进行矩阵运算.该DLL从VB.NET程序接收数组并将它们加载到矩阵中以进行某些操作.但是,我不能在任何cv :: mat对象上使用.at成员而不会抛出访问冲突异常.我以为是因为我传入了数组,但我甚至无法运行:

Mat Rhat(2,1,CV_32FC1);
Rhat.at<double>(0,0) = 10;
Rhat.release();
Run Code Online (Sandbox Code Playgroud)

如果我删除该.at行,那么它运行正常.我使用CvMat类型完成了C的全部工作,但它不喜欢cvCreateMat并开始使用cv命名空间.我在dll中的所有非opencv函数工作正常,所以问题出在我的cv设置或其他东西.
有人可以帮忙吗?

c++ dll opencv access-violation

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

使用CSS3动画扩展圆圈

我试图这样做,当页面加载圆圈出现,这很好,但我需要它们向外生长,从中心到小到大,而不是从左上角:

你可以看到我目前在这里:http://thomasbritton.co.uk/projects/ebrd/

理想情况下,希望这可以在CSS中完成,但如果它更容易/更稳定,可以使用JS.

有任何想法吗?

这是我的动画部分的css:

.circle a {
  border-radius: 150px;
  color: #fff;
  height: 0;
  position: absolute;
  text-decoration: none;
  width: 0;
}

.circle a.grow {
  -webkit-animation-name: grow;
  -webkit-animation-duration: 2.2s;
  -webkit-animation-timing-function: ease;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-direction: normal;
  -webkit-animation-delay: 0;
  -webkit-animation-play-state: running;
  -webkit-animation-fill-mode: forwards;

  -moz-animation-name: grow;
  -moz-animation-duration: 2.2s;
  -moz-animation-timing-function: ease;
  -moz-animation-iteration-count: 1;    
  -moz-animation-direction: normal;
  -moz-animation-delay: 0;
  -moz-animation-play-state: running;
  -moz-animation-fill-mode: forwards;

  animation-name: grow;
  animation-duration: 2.2s;
  animation-timing-function: ease;
  animation-iteration-count: 1; 
  animation-direction: normal;
  animation-delay: 0;
  animation-play-state: running;
  animation-fill-mode: forwards;
}

@-webkit-keyframes grow {
  0% …
Run Code Online (Sandbox Code Playgroud)

css jquery animation css3 css-animations

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

将MD5 +盐密码导入MD5

我正在将我的网站从oscommerce商店转移到商业应用程序.

新应用程序使用直接MD5加密存储其密码.Oscommerce使用MD5存储密码,但也会向哈希添加一个随机的2位数字(以明文形式提供).

以下是某人在论坛上发布的内容:

添加的两个字符用于以
hash = md5(twocharactersPlainPassword)的方式创建哈希,
即:2let:74
普通密码:PaSs
哈希= md5('74PaSs')= acaa6e689ae0008285320e6617ca8e95:74


以下是Oscommerce如何加密密码的代码:

// This function makes a new password from a plaintext password.
function tep_encrypt_password($plain) {
  $password = '';

  for ($i=0; $i<10; $i++) {
    $password .= tep_rand();
  }

  $salt = substr(md5($password), 0, 2);
  $password = md5($salt . $plain) . ':' . $salt;

  return $password;
}

// This funstion validates a plain text password with an encrypted password
function tep_validate_password($plain, $encrypted) {
  if (tep_not_null($plain) && tep_not_null($encrypted)) {
    // split apart …
Run Code Online (Sandbox Code Playgroud)

php passwords import md5 oscommerce

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