frontend

Gulp change working directory for entire task

时光毁灭记忆、已成空白 提交于 2019-11-29 09:22:41
I'm working on a gulp file that contains tasks for both the frontend and the backend of my site. The task below for example will concat my scripts into app.js: gulp.task 'frontend:scripts', -> gulp.src frontendPath(scriptsFolder, scriptsPattern) .pipe sourcemaps.init() .pipe coffee() .pipe concat 'app.js' .pipe sourcemaps.write('.') .pipe gulp.dest frontendPath(tempFolder, scriptsFolder) As you can see I've created a helper to provide the correct frontend path: frontendPath = (dirs...) -> path.join.apply null, ['frontend'].concat(dirs) But I have to be really careful that all the steps of my

Angular 2 stand alone components

纵然是瞬间 提交于 2019-11-29 08:14:08
Just moved over to Angular 2 recently and i am just trying to get my head around pretty much all of it. I need to build and that just uses stand-alone components, I want to be able to utilise my components as follows. <body> <component-one></component-one> <component-two></component-two> </body> I have got as far as getting these components to render out on the page the problem is when one of these component selectors are not present on the current page i get the following console error... core.umd.js:2838 EXCEPTION: Error in :0:0 caused by: The selector "component-one" did not match any

What is the use of `self.Clients.claim()`

非 Y 不嫁゛ 提交于 2019-11-29 06:43:16
问题 To register a service worker, I can call navigator.serviceWorker.register('/worker.js') Every time the page loads it checks for an updated version of worker.js . If an update is found, the new worker won't be used until all the page's tabs are closed and then re-opened. The solution I read was: self.addEventListener('install', function(event) { event.waitUntil(self.skipWaiting()); }); self.addEventListener('activate', function(event) { event.waitUntil(self.clients.claim()); }); I can

iOS: Positioning navigation bar buttons within custom navigation bar

房东的猫 提交于 2019-11-29 06:29:24
I'm building an app with a custom navigation bar. After some research I decided to do this using a category on UINavigationBar. The navigation bar needs to be a bit larger than usual to accomodate a drop shadow. Here is the code: #import "UINavigationBar+CustomWithShadow.h" @implementation UINavigationBar (CustomWithShadow) - (void)drawRect:(CGRect)rect { // Change the tint color in order to change color of buttons UIColor *color = [UIColor colorWithHue:0.0 saturation:0.0 brightness:0.0 alpha:0.0]; self.tintColor = color; // Add a custom background image to the navigation bar UIImage *image =

what is `optimistic updates` in front-end development

萝らか妹 提交于 2019-11-28 22:24:39
I'm reading the intro to redux pattern , and there is the following paragraph there: ... consider the new requirements becoming common in front-end product development, such as handling optimistic updates, rendering on the server, fetching data before performing route transitions, and so on. My question is what is optimistic updates here? In an optimistic update the UI behaves as though a change was successfully completed before receiving confirmation from the server that it actually was - it is being optimistic that it will eventually get the confirmation rather than an error. This allows for

How to add/include js file into Magento theme

穿精又带淫゛_ 提交于 2019-11-28 21:38:01
I am modifying a Magento theme. And want to add a js file into the theme /js folder. I have added the following code: <action method="addItem"><type>skin_js</type><name>js/custom-script.js</name></action> into the /app/design/frontend/theme-name/default/layout/page.xml and published the js file into /skin/frontend/theme-name/default/js/ . But no luck. It is not showing on the page. Someone please help me to rectify this. Thanks. Sunil Kumar Try adding the following to your layout .xml file within <reference name="head"> <action method="addJs"> <script>js/custom-script.js</script> </action>

React Input Element : Value vs Default Value

点点圈 提交于 2019-11-28 20:26:35
i am new in React and REDUX, i just develop a simple react app, and now i face a problem, when i render an input element within my component if i set the element "value" it become read-only but if i set the value on "defaultValue" it will never update again when i re-update my state. Here is my code : import React from "react"; export default class EditForm extends React.Component { editTransaction(event) { var transaction = this.props.transaction; event.preventDefault(); var NewTransaction = { transactions_data: { amount: this.refs.amount.value } } this.props.editTransaction(NewTransaction,

Phantomjs - take screenshot of a web page

拟墨画扇 提交于 2019-11-28 19:17:09
I have a URL (for e.g. http://www.example.com/OtterBox-77-24444-Commuter-Series-Optimus/dp/B00A21KPEI/ref=pd_sim_cps_4 ) and want to take a screenshot of it and preview it on my web page. Meaning, the user clicks on the preview button and PhantomJS needs to preview the web page as PNG/JPEG I'm ok with using any other open source too. I am going to assume you have installed Phantomjs and have created an alias in your .bashrc or have updated your system path to call the Phantomjs binaries. If not, you need to peruse a few beginner tutorials: http://net.tutsplus.com/tutorials/javascript-ajax

Is there a way around using [[ and ]] for Part in Mathematica?

怎甘沉沦 提交于 2019-11-28 17:14:41
问题 Is there a way to avoid having to do ⋮[[⋮ to obtain those great looking brackets for Part ? Is there a way for this to be done automatically after you ran a function or a definition ? 回答1: I have the following addition in /Applications/Mathematica.app/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr which lets me enter double brackets with key combinations. You can do the same by modifying the file (where ever it is on your OS). I first learnt of this from Szabolcs's

How to set build .env variables when running create-react-app build script?

拟墨画扇 提交于 2019-11-28 16:49:35
I'm using the following environment variable in my create-react-app: console.log(process.env.REACT_APP_API_URL) // http://localhost:5555 It works when I run npm start by reading a .env file: REACT_APP_API_URL=http://localhost:5555 How do I set a different value like http://localhost:1234 when executing a npm run build ? This is my package.json file: { "name": "webapp", "version": "0.1.0", "private": true, "devDependencies": { "react-scripts": "0.9.0" }, "dependencies": { "react": "^15.4.2", "react-dom": "^15.4.2" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build",