reusability

How can I reuse the audio a browser already downloaded so it doesn't download it again in other pages that use the same audio file?

倖福魔咒の 提交于 2019-12-07 20:36:27
I'm making an audio heavy page. I'm using the JavaScript audio element. The code looks like this: JavaScript: var x = new Audio("x.mp3"); var y = new Audio("y.mp3"); var z = new Audio("z.mp3"); function playMe(n){ n.play(); } HTML: <button class="button" onclick="playMe(x)")>Play</button> <button class="button" onclick="playMe(y)")>Play</button> <button class="button" onclick="playMe(z)")>Play</button> Some pages use up to 30 different audio files so this will consume a lot of bandwith. This can potentially kill the project, as it's a one-man effort with almost no budget. The audios are being

How to reuse code across multiple domains?

杀马特。学长 韩版系。学妹 提交于 2019-12-07 13:23:13
问题 I just build a CMS framework using Yii framework. I want to deploy the CMS to multiple domains. /home/root/www/domain1.com /home/root/www/domain2.com /home/root/www/domain3.com /home/root/www/domain4.com I want to reuse the css files and all the files under protected folder, so that once I update css and the files in the protected folder, all the domains should reflect the change. 回答1: Yes, Yii supports this. In fact, this is how I have some websites configured. (Of course, this is predicated

How to write reusable business logic in MVC models?

时间秒杀一切 提交于 2019-12-07 04:48:25
问题 my problem is that we try to use a MVC (PHP) framework. After discussing a lot think that MVC is very good, but I'm missing the possibility to write reusable model-(application)logic. So, I'm not sure if we have the right approach to implement our software in a MVC framework. First I´ll describe the non-MVC, oo-approach which we use at the moment. For example - we are working on some browser games (yes that's our profession). Imagine we have an player object. We use this player object very

How to deal with code duplication in puppet modules?

一个人想着一个人 提交于 2019-12-06 22:26:57
I have implemented two puppet modules to setup and configure two components - A & B. The directory structure of the modules folder looks like below: modules modulea manifests init.pp install.pp config.pp service.pp templates 1.properties.erb (This one is also needed by moduleb) 2.properties.erb (This one is also needed by moduleb) moduleb manifests init.pp install.pp config.pp service.pp templates 1.properties.erb (same as in modulea) 2.properties.erb (same as in modulea) 3.properties.erb 4.properties.erb 5.properties.erb The code in install.pp and service.pp is identical in both the modules.

Symfony2 reusable functions in controllers

喜欢而已 提交于 2019-12-06 15:50:37
After some time without knowing how to do this properly, and avoid duplicating code in several controllers, I searched and again to seek, but can not find a clear answer. One case in particular, need to calculate several statistics data completed of an entity. This calculation will use in 3 different controllers. In two of them, I'll show broken down into different layouts, and on the third, I will use this data to make a global calculation. business logic for each calculation, involves more than 100 lines of code, I would have to triple in the different controllers. A scheme could be:

Reuse cell… :(

拈花ヽ惹草 提交于 2019-12-06 15:17:51
问题 I have a table with 9 sections and 56 rows. I want to add a text label for each cell. I created a NSArray menuList with 56 NSDictionaries and an array containing the number of rows in each section ( sectionsArray ). Here is my code, but it doesn't work properly at all: // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //Use existing cell (reusable) UITableViewCell *cell = [tableView

How to implement reusable callback functions

点点圈 提交于 2019-12-05 23:47:47
问题 I am fairly new to JavaScript and I am working in node which requires a good understanding of async programming and callback design. I have found that using embedded functions is very easy to do even when your callbacks are multiple levels deep. Your embedded callbacks just end up being closures. However, when you have several layers of callbacks where many of the callbacks are similar across execute routes, you end up rewriting a lot of callback code over and over in separate callback chains

How to reuse code across multiple domains?

好久不见. 提交于 2019-12-05 21:01:56
I just build a CMS framework using Yii framework. I want to deploy the CMS to multiple domains. /home/root/www/domain1.com /home/root/www/domain2.com /home/root/www/domain3.com /home/root/www/domain4.com I want to reuse the css files and all the files under protected folder, so that once I update css and the files in the protected folder, all the domains should reflect the change. Yes, Yii supports this. In fact, this is how I have some websites configured. (Of course, this is predicated on having all your sites on the same server. But I see that Evan has this. This would not work accross

How to write reusable business logic in MVC models?

只谈情不闲聊 提交于 2019-12-05 10:24:42
my problem is that we try to use a MVC (PHP) framework. After discussing a lot think that MVC is very good, but I'm missing the possibility to write reusable model-(application)logic. So, I'm not sure if we have the right approach to implement our software in a MVC framework. First I´ll describe the non-MVC, oo-approach which we use at the moment. For example - we are working on some browser games (yes that's our profession). Imagine we have an player object. We use this player object very often. We have some different pages where you can buy thinks, so you need to make "money" transactions on

How to include a reusable widget in Symfony (Twig)?

六月ゝ 毕业季﹏ 提交于 2019-12-05 05:01:37
So, I'm still fairly new to Symfony and Twig. I was wondering how to best include/create a snippet of reusable code in the templates. Say, for example, that you have a sidebar that you want to show on every page. {% extends 'AppBundle::base.html.twig' %} {% block body %} <div id="wrapper"> <div id="content-container"> {# Main content... #} </div> <div id="sidebar"> {% include 'sidebar.html.twig' %} </div> </div> {% endblock %} And that in that sidebar are a couple of widgets that all do their own logic. How you do go about creating/including those widgets? So far, I've come across several