require

Rails 3 library not loading until require

元气小坏坏 提交于 2019-11-27 03:41:13
I'm trying to load the Tokbox SDK in rails 3. I've placed the library in my /lib directory, so currently my directory structure looks like so: /lib opentok.rb /OpenTok Exceptions.rb OpenTokSDK.rb Session.rb I'm loading all files in the /lib directory using the following in application.rb: config.autoload_paths += %W(#{config.root}/lib) config.autoload_paths += Dir["#{config.root}/lib/**/"] Other files I have in the /lib directory are auto-loading just fine, but this library does not load until I add a require 'OpenTok' : ruby-1.9.2-p0 > OpenTok NameError: uninitialized constant OpenTok ruby-1

How to remove module after “require” in node.js?

天大地大妈咪最大 提交于 2019-11-27 03:23:14
Let say, after I require a module and do something as below: var b = require('./b.js'); --- do something with b --- Then I want to take away module b (i.e. clean up the cache). how I can do it? The reason is that I want to dynamically load/ remove or update the module without restarting node server. any idea? ------- more -------- based on the suggestion to delete require.cache, it still doesn't work... what I did are few things: 1) delete require.cache[require.resolve('./b.js')]; 2) loop for every require.cache's children and remove any child who is b.js 3) delete b However, when i call b, it

How do I use a Perl package known only in runtime?

家住魔仙堡 提交于 2019-11-27 03:13:47
问题 I have a Perl program, that needs to use packages (that I also write). Some of those packages are only chosen in Runtime (based on some environment variable). I don't want to put in my code a "use" line for all of those packages, of course, but only one "use" line, based on this variable, something like: use $ENV{a}; Unfortunately, this doesn't work, of course. Any ideas on how to do this? Thanks in advance, Oren 回答1: eval "require $ENV{a}"; " use " doesn't work well here because it only

TypeError: __init__() missing 1 required positional argument: 'on_delete'错误

跟風遠走 提交于 2019-11-27 03:04:05
在低版本的Django中,可以直接写模型外键,不用写后面的冲突代码 转换成Django的时候就会报错 $ python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "C:\python3.6\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\python3.6\lib\site-packages\django\core\management\__init__.py", line 357, in execute django.setup() File "C:\python3.6\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\python3.6\lib\site-packages\django\apps

webpack 多环境打包

时光怂恿深爱的人放手 提交于 2019-11-27 02:52:11
目前来说有两种方案: 方案一: 1.修改build文件夹下build.js文件   添加声明变量    2.修改config文件夹下dev.env.js文件   这个是开发环境所用版本    3.修改config文件夹下prod.env.js文件    添加不同环境的名称,暂时以正式环境和测试环境两个环境为例    4.不同配置参数引用       这样打包的时候就可以分环境进行打包,测试环境直接运行npm run build即可,正式环境运行npm run build prod。 方案二: 第1步:安装cross-env 在项目目录下运行如下命令安装cross-env,我的ide是webstorm,要以直接在ide里的Terminal窗口中运行,也可能通过windows的CMD、Linux的Terminal定位到项目根目录运行下面的命令。 npm i --save-dev cross-env 第2步:修改各环境下的参数 在config/目录下添加test.env.js、prod.env.js。修改prod.env.js里的内容,修改后的内容如下: 'use strict' module.exports = { NODE_ENV: '"production"', ENV_CONFIG:'"prod"', BASE_API: '"https://api-prod"' }

how to require_once in codeigniter

人走茶凉 提交于 2019-11-27 02:09:56
问题 I am trying to extend a library in codeigniter. The only way to do so seems to include the original library using require_once then load the extended library using $this->load->library() right now I have tried require_once('ion_auth.php'); require_once('home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php') require_once('/home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php') but unfortunately not luck..... I keep getting this error Message: require

RequireJS入门(二)

▼魔方 西西 提交于 2019-11-27 01:52:58
上一篇是把整个jQuery库作为一个模块。这篇来写一个自己的模块:选择器。 为演示方便这里仅实现常用的三种选择器id,className,attribute。RequireJS使用define来定义模块。 新建目录结构如下 这次新建了一个子目录js,把main.js和selctor.js放入其中,require.js仍然和index.html在同一级目录。 HTML 如下 <!doctype html> <html> <head> <title>requirejs入门(二)</title> <meta charset="utf-8"> <style type="text/css"> .wrapper { width: 200px; height: 200px; background: gray; } </style> </head> <body> <div class="wrapper"></div> <script data-main="js/main" src="require.js"></script> </body> </html>    这次把script标签放到了div的后面,因为要用选择器去获取页面dom元素,而这要等到dom ready后。 因为把main.js放到js目录中,这里data-main的值须改为“js/main”。 selector.js 如下

Is 'require(…)' a common javascript pattern or a library function?

▼魔方 西西 提交于 2019-11-27 01:52:48
I usually find this as the first line in node.js scripts/modules as well as phantomJS, casperJS etc. I'm curious, if this is a common pattern for server-side javascript (SSJS) (similar to #include in C/C++ or import in Java) or is it a a library like RequireJS or LabJS that is being called for this inclusion (neither of which I have gotten a chance to use in practice, as yet)? e.g. var http = require('http') or var casper = require('casper').create() I'm curious if this is a pattern that has become standardized for SSJS or does every library/tool call an existing function? Please pardon the

What's better of require(dirname(__FILE__).'/'.'myParent.php') than just require('myParent.php')?

血红的双手。 提交于 2019-11-27 00:38:05
问题 Lots of famous PHP scripts including WordPress use dirname(__FILE__).'/myParent.php' instead of just 'myParent.php' when including files in the same directory of the currently running script. Aren't they the same thing? Why do you prefer typing more? Thanks. 回答1: PHP needs to know the absolute path to the file. dirname(__FILE__).'/myParent.php' already is the absolute path but 'myParent.php' requires a lookup using the given paths in include_path to get an absolute path and find the file. A

How do I change the order in which Meteor loads Javascript files?

本秂侑毒 提交于 2019-11-27 00:35:50
When you make a project with the Meteor framework, it packages all the files together, but there doesn't seem to be a way to explicitly say "I want this file to be loaded before that one". Let's say, for example, I have 2 javascript files: foo.js and bar.js . The file bar.js is actually containing code depending one the one inside foo.js but Meteor is loading bar.js before foo.js , breaking the project. In node.js I would simply use require('./bar') inside foo.js In the browser , I would put a <script> tag pointing to foo.js and another, after, pointing to bar.js , in order to load the files