marlonfan / experiences-for-coding Goto Github PK
View Code? Open in Web Editor NEW记录码代码路上遇到的问题
记录码代码路上遇到的问题
直接扔代码
interface TaskFunction {
(done: (result?: any) => void): void;
}
function all(taskFns: TaskFunction[], callback: (results: any[]) => void): void {
var results: string[] = [];
var pending = taskFns.length;
taskFns.forEach((taskFn, index) => {
taskFn(result => {
if (index in results) {
return;
}
results[index] = result;
if (--pending == 0) {
callback(results);
}
});
});
}
all([
done => {
done('hello');
},
done => {
setTimeout(() => {
done(', ');
}, 100);
},
done => {
setInterval(() => {
done('world');
}, 1000);
},
done => {
done('!');
}
], results => {
console.log(results.join('')); // 输出 hello, world!
})
在循环中的in_array()
问题
昨天做一个时间匹配的时候需要大范围内的进行循环对比 我的思路是循环用in_array()对比是否包含某个字,立神说循环次数太多了... 原来要将要查找的值直接转换成键,然后去对比等不等于,这样是黑红二分叉查询。要比我的思路快很多~~
之前认为laravel取多条数据的时候因为拿到的单条数据是一个对象,所以认为每个记录拿出来都要执行一次toArray()
方法.
但是... 没有好好读文档的错啊. 在review的时候被立神看出来了
$bmlist = Appointment::all();
$baoming = [];
foreach ($bmlist as $bm) {
$baoming[] = $bm->toArray();
}
return $baoming;
改进后的代码:
$baoming = Appointment::all()->toArray();
return $baoming;
看自己绕这么大个弯儿好像说句fuck!
具有像线一样性质的表,由零个或者多个数据元素构成的有限序列.
之前开发由于用到一个短信平台的SDK,就为Laravel
专门开发了这个平台的SDK包.基于composer
的.
但是把逻辑代码全部实现以后测试的时候发现通过Laravel
的Config
类的get()
方法拿不到自定义的配置项. 百思不得其解找了很久.
最后发现,是在用Config::get()
方法获取配置的时候包名和配置名大小写的问题而导致的...
写着写着突然发现在代码的实现上有很大的改进空间.
之前写的代码很乱,发现在把代码模块化,低耦合重构后会好很多,也可以让别人看上去思路更清晰.
还有利于编写单元测试.. (捂脸...能说写的次数真心不多么..)
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "create"]
Stderr: 0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Code E_FAIL (0x80004005) - Unspecified error (extended info not available)
VBoxManage.exe: error: Context: "int __cdecl handleCreate(struct HandlerArg *,int,int *)" at line 66 of file VBoxManageHostonly.cpp
出现这个问题的时候帮朋友解决掉了,但是发现其实网络还是没有通的,后来发现它是用一个类似来宾用户登录的. 然后给到一些权限连接的virtualbox里面的机子.
但是发现只适用于部分用户!
然后win7同样出现了这样的问题. 百思不得其解. 然后猜测是无权限创建与虚拟机外的主机的共享文件夹. 在这样的猜测下,试着,试着将homestead.yaml里的共享文件夹下面的nfs.png关掉以后,顺利开启.
那么这个nfs是个什么东西呢?下面的百度给出的解释:
NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源。在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样。
这样看来确实是vagrant的配置在virtualbox与外部主机进行通信的时候发生问题了呢...
然而对这块不大明白,还没找到个所以然.. 如有疏忽的地方,欢迎大牛指正~
Unable to load R3 module D:\app\virtualbox/VBoxDD.DLL (VBoxDD): GetLastError=1790 (VERR_UNRESOLVED_ERROR).
这是我的错误日志,是使用vagrant的过程中虚拟机打不开找到的.百思不得其解,google之~ 发现这里出现的问题主要是因为windows7的三个主题破解文件引起的,在网上有专门针对恢复的一种工具UniversalThemePatcher! 前车之鉴....
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.