require

Reading from file (require)

我的梦境 提交于 2019-12-20 05:40:53
问题 I have something like this: http://i.imgur.com/KPulyBg.png and im currently working on "admin" folder and inside of that i have "admin.php", but the problem is that i want to read "core/init.php" from there. Now i have this in admin.php <?php require '../includes/header.php'; ?> <?php $user = new User(); if(!$user->isLoggedIn()){ Redirect::to(404); } else if(!$user->hasPermission('admin')){ Redirect::to(404); } ?> <div id="content"> </div> <?php require '../includes/footer.php'; ?> And inside

On-demand require()

青春壹個敷衍的年華 提交于 2019-12-20 03:46:41
问题 Say I create a library in ./libname which contains one main file: main.js and multiple optional library files which are occasionally used with the main object: a.js and b.js . I create index.js file with the following: exports.MainClass = require('main.js').MainClass; // shortcut exports.a = require('a'); exports.b = require('b'); And now I can use the library as follows: var lib = require('./libname'); lib.MainClass; lib.a.Something; // Here I need the optional utility object lib.b

TypeScript require with type checking

二次信任 提交于 2019-12-20 02:44:44
问题 I am using TypeScript v1.4.1 and would like to require an external module (in this case "chai") and have it be type checked. However, I am running into some sort of naming conflict with this code: /// <reference path="../typings/node/node.d.ts" /> /// <reference path="../typings/chai/chai.d.ts" /> /// <reference path="../typings/mocha/mocha.d.ts" /> var chai = require("chai"); var expect = chai.expect; var assert = chai.assert; describe("TEST", () => { it("true should be true", (done)=> {

Cannot load `Cwd` (and other, non-core, modules) at runtime

浪尽此生 提交于 2019-12-19 17:40:53
问题 Imagine I want to load a module at runtime. I expected this to work use warnings; use strict; eval { require Cwd; Cwd->import; }; if ($@) { die "Can't load Cwd: $@" } say "Dir: ", getcwd; but it doesn't, per Bareword "getcwd" not allowed ... . The Cwd exports getcwd by default. I tried giving the function name(s) to import and I tried with its other functions. It works with the full name, say Cwd::getcwd , so I'd think that it isn't importing. This works as attempted for a few other core

Javascript error : Uncaught ReferenceError: require is not defined

北城以北 提交于 2019-12-19 10:22:18
问题 I making a regster form in HTML, with javascript. I Have file Login.js. My browser says the following error: Uncaught ReferenceError: require is not defined. 回答1: require is a way for different compilers to put in stuff that is needed, later on, while keeping the file small. Did you copy the js file from somewhere else? You may need to include http://requirejs.org/ Also, this looks incredibly insecure. Are you planning to release this site to the word? or is it just for class/experiment? As

Require nodejs “child_process” with TypeScript, SystemJS and Electron

不想你离开。 提交于 2019-12-19 05:57:38
问题 I'm working on a simple nodejs electron (formerly known as atom shell) project. I'm writing it using angular 2, using the project the same project setup as they recommend in the documentation for typescript: tsc: { "compilerOptions": { "target": "es5", "module": "system", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts

Lua Require function on a full path name

左心房为你撑大大i 提交于 2019-12-19 05:17:21
问题 I need to call the require on a lua file that will not always be in the same place. I was trying to call require on the full path name but that doesn't seem to be working either. I even tried replacing one of my working normal requires with a correct full path name to the same file example changing require "foo" to require "C:\Users\Me\MyLuaProject\foo" but when i switched it to the full path name it could no longer find it. So I am wondering if you can even call require on a full path and if

PHP file_get_contents after php has evaluated

强颜欢笑 提交于 2019-12-19 03:35:13
问题 I know how to use file_get_contents and fopen etc, but when I do it to one of my own file, I get the literal string, meaning, the code is not preprocessed! How can i import text from a file without using require etc. because I want to store the value into a string 回答1: See examples #5 and #6 on the manual. Taken straight from there: $string = get_include_contents('somefile.php'); function get_include_contents($filename) { if (is_file($filename)) { ob_start(); include $filename; $contents = ob

使用node写爬虫

不想你离开。 提交于 2019-12-19 02:59:01
node爬虫 爬虫介绍 爬取接口 使用 axios 使用与接口类型的爬取 爬取页面 使用 request + cheerio 适用于后端渲染,直接返回 HTML 页面的情况 cheerio 使用方法类似于 jQuery 文档 关于 request 转码问题 const cheerio = require ( 'cheerio' ) const requuest = require ( 'request-promise' ) // 转码问题 let iconv = require ( 'iconv-lite' ) let url = 'http://top.baidu.com/category?c=10&fr=topindex' let options = { url , encoding : null // 告诉 request 不要帮我把 buffer 转成字符串 } request ( options , async ( err , response , body ) => { // console.log(body.toString()) // 默认转 utf8 编码 // 获取返回的编码格式 let ContentType = response . headers [ 'content-type' ] let encoding ; if ( ContentType .

报错(SQLite 3.8.3 or later is required (found 3.7.17).)的解决办法

泄露秘密 提交于 2019-12-18 23:38:54
在服务器上刚部署完Django项目, python manage.py runserver 0.0.0.0:8000 启动启动的时候报错:django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).,以下为报错展示及解决办法。 目录 一、报错演示 二、问题解决 一、报错演示 ( venv ) [ root@localhost celery ] # python manage.py runserver 0.0.0.0:8000 Watching for file changes with StatReloader Exception in thread django - main - thread : Traceback ( most recent call last ) : File "/usr/local/python3/lib/python3.6/threading.py" , line 916 , in _bootstrap_inner self . run ( ) File "/usr/local/python3/lib/python3.6/threading.py" , line 864 , in run self . _target ( *