require

Extending Array.prototype in Node.js, from a require'd file

情到浓时终转凉″ 提交于 2019-12-04 08:26:08
I have the following saved in test.js. It successfully extends Array in the browser, but it doesn't seem to work with node and require. Can someone explain what's wrong here? (function() { Array.prototype.max = function() { return console.log("Array.prototype.max"); }; return Array.max = function() { return console.log("Array.max"); }; }).call(this); Then, from a terminal: > My-MacBook-Pro: me$ node > var test = require("./test") > [1,2,3].max() TypeError: Object 1,2,3 has no method 'max' at [object Context]:1:9 at Interface.<anonymous> (repl.js:171:22) at Interface.emit (events.js:64:17) at

php上传视频文件怎么实现

依然范特西╮ 提交于 2019-12-04 07:24:36
我们平时经常做的是上传文件,上传文件夹与上传文件类似,但也有一些不同之处,这次做了上传文件夹就记录下以备后用。 首先我们需要了解的是上传文件三要素: 1.表单提交方式:post (get方式提交有大小限制,post没有) 2.表单的enctype属性:必须设置为multipart/form-data. 3.表单必须有文件上传项:file,且文件项需要给定name值 上传文件夹需要增加一个属性webkitdirectory,像这样: <input id="fileFolder" name="fileFolder" type="file" webkitdirectory> 功能介绍: 树形目录导航。您可以通过树型目录导航和路径导航栏快速跳转到指定目录。在跳转后树型目录将会自动选中当前的目录。 ​ 路径导航,点击根目录按钮便可返根目录 ​ 文件和目录重命名 ​ 点击删除按钮 ​ 点击确定后,页面中的文件消失 批量上传文件 ​ 粘贴上传 复制文件夹、文件或图片 ​ 在页面中选择好相应的上传目录,点击粘贴上传按钮,数据即可快速开始上传 ​ 批量上传文件和文件夹 ​ 数据库记录 ​ 文件和目录下载 ​ 工程截图 ​ 以下是实例的部分脚本文件与文件块处理代码: //文件上传对象 function FileUploader(fileLoc, mgr) { var _this = this;

HTML&&CSS基础知识点整理

岁酱吖の 提交于 2019-12-04 05:55:39
HTML&&CSS基础知识点整理 一、WEB标准:一系列标准的集合 1. 结构(Structure):html 语言:XHTML[可扩展超文本标识语言]和XML[可扩展标记语言] 2. 表现(Preasentation):css 3. 行为(Behavior):JS[DOM+ES] 其中一些小的具体要求: 结构:标签小写、闭合、不能随意嵌套 CSS+JS:精良使用外链,不用行内 优点: 1. 易于维护 2. 页面响应快 3. 可访问性高 4. 提高设备兼容性 5. 易被解析(搜索引擎) Ps: 可维护性:出现问题时,修复Bug成本低且维护性好,还有一点是代码能够被其他开发人员理解。 可访问性:所有人都能理解,解析 二、浏览器内核 > - IE:Trident内核(多称:IE内核) > - Chrome:Webkit内核 ==> Blink内核 > - Firefox:Gecko内核(多称:IE内核) > - Safari:Webkit内核 > - Opear:Preato====>Webkit内核 ====> Blink内核 三、渲染原理 1、涉及到的概念 Dom Tree:浏览器将Html解析成属性的数据结构 Parse(构建Dom树):生成Dom树的行为 Css Rule Tree:浏览器将Css解析成属性的数据结构 Render Tree

php include file that has includes

给你一囗甜甜゛ 提交于 2019-12-04 05:21:33
问题 I am working on a site and have been asked to include files that are sitting in a folder above my php scripts. Problem is those php files I have been asked to include, have includes in them. And thus the files they refer to cannot be found when calling my php pages. What is the best way to handle this situation? 回答1: When including a file from folder B to folder A, the B script acts like it was stored in A. Either change your pointer paths or chdir(). http://se2.php.net/manual/en/function

PHP Phar - file_exists() issue

耗尽温柔 提交于 2019-12-04 05:13:55
My Phar script creates a new file with fwrite, which works fine, it creates the new file outside the phar, in the same directory as the phar file. But then when i use if(file_exists('file.php')) it doesn't pick it up. But then include and require do pick it up. Anyone know about this problem? Been testing and researching for a while a can't seem to find a solution. At the PHAR's stub, you can use the __DIR__ magic constant to get the PHAR file's folder. With that in mind, you can simply use is_file(__DIR__ . DIRECTORY_SEPARATOR . $path); To check for a file's existence outside the PHAR. You

performance / templating issues when using requirejs with JQuery, jQuery Mobile, Knockout and Sammy to build a structured app with External Templates

烈酒焚心 提交于 2019-12-04 05:06:52
问题 I have a setup for a test app which includes require.js, jQuery, jQueryMobile (jqm), knockout and sammy require.js loads in jqm, knockout and sammy on the app main page i use sammy to load in knockout viewModels. these viewModels the load in the templates.. so to show the code... require page: require.config({ jquery: 'vendor/jqm/jquery_1.7_min', jqm: 'vendor/jqm/jquery.mobile-1.1.0', knockout: 'vendor/knockout/knockout-2.2.0', sammy : 'vendor/sammy/sammy', text: 'vendor/require/text', views:

How to require ActiveRecord In IRB

六月ゝ 毕业季﹏ 提交于 2019-12-04 04:59:35
问题 I would like to load the ActiveRecord gem in my IRB session, but the following is not working: require 'activerecord' 2.4.1 :004 > require 'activerecord' LoadError: cannot load such file -- activerecord from /Users/robskrob/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/robskrob/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' from (irb):4 from /Users/robskrob/.rvm/rubies/ruby-2

深入浅出Node.js

梦想的初衷 提交于 2019-12-04 04:36:24
深入浅出Node.js 一直想致力于写一篇关于广义讲解Node.js系统的文章,苦于时间有限,资源有限。这篇文章是在结合自己的学习心得以及与行业大佬共同探讨下争对于熟练掌握JS语言后的广义Node.js.至于为什么叫作广义在后文会提到。希望看到这篇文章后可以激发大家对Node.js的学习兴趣,这篇文章的初衷就是致力于帮助大家可以走进Node.js世界。 简介: Node.js 就是运行在服务端的 JavaScript。 Node.js 是一个基于Chrome JavaScript 运行时建立的一个平台。 Node.js是一个事件驱动I/O服务端JavaScript环境,基于Google的V8引擎,V8引擎执行Javascript的速度非常快,性能非 常好。 底层选择用c++和v8来实现的 注意:广义的Node.js是指不掌握以底层C++技术以及V8知识,利用Node.js运行在服务端的JS特性完成操作,很多小伙伴会产生疑惑Node.js是什么,简单的来说:Node.js是解析器. 优势: RESTful API 这是NodeJS最理想的应用场景,可以处理数万条连接,本身没有太多的逻辑,只需要请求API,组织数据进行返回即可。它本质上只是从某个数据库中查找一些值并将它们组成一个响应。由于响应是少量文本,入站请求也是少量的文本,因此流量不高

composer Deprecation Notice

大兔子大兔子 提交于 2019-12-04 04:27:18
今天在执行 composer global require "laravel/installer" 出现错误提示: Deprecation Notice: The Composer\Package\LinkConstraint\MultiConstraint class is deprecated, use Composer\Semver\Constraint\MultiConstraintinstead.in phar:///usr/local/bin/composer/src/Composer/Package/LinkConstraint/MultiConstraint.php:17. Deprecation Notice: The Composer\Package\LinkConstraint\LinkConstraintInterface interface is deprecated,use Composer\Semver\Constraint\ConstraintInterface instead. in phar:///usr/local/bin/composer/src/Composer/Package/LinkConstraint/LinkConstraintInterface.php:17 解决办法: composer global require "fxp

Failed to open stream: No such file or directory, yes there is!

十年热恋 提交于 2019-12-04 03:38:31
I've got a problem with requiring some files, PHP is telling me these files do not exist, but when I scan the directory it tells me it does exist. I've simplified the files to the require functionality, and it's still not working. Here is my setup: root/ test.php test/ test2.php sub/ test3.php test.php echo 'test'; require 'test/sub/test3.php'; test/test2.php (the file that for some reason doesn't get included) echo 'test2'; test/sub/test3.php echo 'test3'; /* because we are still on test.php, the include path is the root that means the following would work: require 'test/test2.php'; however I