require

Rails 4 + simple_form and jQuery UI. Datepicker is not working via turbolinks

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this form which calls datepicker: ... ... Simple_form wrapper: app/inputs/datepicker_input.rb class DatepickerInput attribute_name.to_s + "-alt"}) end end When the page is loaded from scratch ( $(document).ready event ), the following html is generated: However, when the page is loaded with turbolinks (from side nav bar, "page:load" event), the rendered HTML is the following: Of course, I can simply add hasDatepicker class in .html.erb or in application.js file, but I wonder if it's possible to achieve it with Rails functionality. 回答1

How to expose 'require' to the browser when using browserify from within gulp?

匿名 (未验证) 提交于 2019-12-03 02:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I have a file x.js that looks like this: x.js module.exports = function (n) { return n * 111 } and I run browserify from the command line like so: browserify -r ./x.js > bundle.js I get an output file that looks like this (roughly): require=(function e(t,n,r){function ...... ./App.jsx":[function(require,module,exports){ module.exports=require('0+DPR/'); },{}]},{},[]) Then in my browser code I can do this: React server rendering example Welcome to the React server rendering example. Here is a server-rendered React component: I actually

Gulp less not handling includes properly, included variables not defined

匿名 (未验证) 提交于 2019-12-03 02:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using less and Grunt, and am moving to gulp. My less works. When I run: lessc public/less/myapp.less I get working output with no errors. All my less, including includes, is in public/less , BTW. Here is my gulpfile: var gulp = require('gulp'); var prefixer = require('gulp-autoprefixer'); var less = require('gulp-less'); gulp.task('compileLess', function () { gulp .src('./public/less/*') .pipe(less({ paths: ['./public/less'], // Search paths for imports filename: 'myapp.less' })) .pipe(gulp.dest('./public/css')); }); // The default task

require 'rubygems'

北城以北 提交于 2019-12-03 02:03:52
I have seen many samples of Ruby code with this line (for example, http://www.sinatrarb.com/ ). What is purpose of this require? # require 'rubygems' require 'sinatra' get '/hi' do "Hello world!" end In all cases the code works without this line. Jakob Kruse It is often superfluous. It will allow you to require specific versions of particular gems though, with the gem command. https://guides.rubygems.org/patterns/#requiring-rubygems require 'rubygems' will adjust the Ruby loadpath allowing you to successfully require the gems you installed through rubygems, without getting a LoadError: no such

Does rollapply() allow an array of results from call to function?

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: # Loading packages require(forecast) require(quantmod) # Loading OHLC xts object getSymbols('SPY', from = '1950-01-01') # Selecting weekly Close prices x This code returns me an error because of return(c(supp, rest)) at the end of a.ari.fun() function I wrote; I'm sure about that because if a.ari.fun() returns just return(rest) it works fine. How do I have to arrange the a.ari.fun() in order to obtain an object suitable to rollapplyr() ? 回答1: It looks like using by.column=FALSE will give what you request. tail(rollapplyr(data = as.zoo(x),

How to serve an image using nodejs

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a logo that is residing at the public/images/logo.gif . Here is my nodejs code. http.createServer(function(req, res){ res.writeHead(200, {'Content-Type': 'text/plain' }); res.end('Hello World \n'); }).listen(8080, '127.0.0.1'); It works but when I request for localhost:8080/logo.gif then I obviously I don't get the logo. What changes I need to do to serve an image. 回答1: I agree with the other posters that eventually, you should use a framework, such as Express.. but first you should also understand how to do something fundamental like

Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: When I want to create a Ruby on Rails project, I get the message below. /usr/ lib / ruby / gems / 1.8 / gems / activesupport - 2.3 . 8 / lib / active_support / dependencies . rb : 55 : uninitialized constant ActiveSupport :: Dependencies :: Mutex ( NameError ) from / usr / local / lib / site_ruby / 1.8 / rubygems / custom_require . rb : 36 : in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in ` require ' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support.rb:57 from /usr

Shiny rcharts multiple chart output

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I overwrite the output display options with running multiple charts with shiny and rchart so the output result is a 2x2 matrix type grid layout. require(rCharts) require(shiny) require(data.table) runApp(list( ui = mainPanel( span="span6", showOutput("chart2", "Highcharts"), showOutput("chart3", "Highcharts"), showOutput("chart4", "Highcharts") ), server = function(input, output){ output$chart3 回答1: Change ui to: ui = bootstrapPage(mainPanel( div(class = "row", div(showOutput("chart2", "Highcharts"), class = "span4"), div(showOutput(

NodeJS, promises, streams - processing large CSV files

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I need to build a function for processing large CSV files for use in a bluebird.map() call. Given the potential sizes of the file, I'd like to use streaming. This function should accept a stream (a CSV file) and a function (that processes the chunks from the stream) and return a promise when the file is read to end (resolved) or errors (rejected). So, I start with: 'use strict' ; var _ = require ( 'lodash' ); var promise = require ( 'bluebird' ); var csv = require ( 'csv' ); var stream = require ( 'stream' ); var pgp = require (