Is there a way to automatically zip certain files at the build time with Node.js and npm? For example, I have a project, that file structure looks like this: I want to be able to zip lib folder, certain modules from node_modules and index.js into some zip archive to upload it on the AWS Lambda, for example. I…
Tag: javascript
Disable Jasmine’s fdescribe() and fit() based on environment
fdescribe() and fit() are great for reducing noise when you’re working on a subset of tests. I sometimes forget to change them back to describe()/it() before merging my branch into master. (It’s okay to have them in separate branch while working on code – i.e. a pre-commit check wouldn’…
How to unset a Javascript Constant in ES6?
I read this post, using delete keyword, we can delete JavaScript variable. But when I tried the same operations with constant but it is returning false when I try to delete constant. Is there any way to delete constants from memory? I tried this answer but its also not working. Answer You can’t directly…
Understanding Matrix in SVG
I need help in deep understanding of matrix in SVG. I already know about matrix, I want to rotate and scale without using scale or rotate word. I want to use transform=’matrix(a,b,c,d,e,f)’. I know ‘a/d’ value determine the scale, ‘e/f’ determines the position. tan(b),tan(c…
How to add custom html attributes in JSX
There are different reasons behind it, but I wonder how to simply add custom attributes to an element in JSX? Answer EDIT: Updated to reflect React 16 Custom attributes are supported natively in React 16. This means that adding a custom attribute to an element is now as simple as adding it to a render functio…
Assign value from successful promise resolve to external variable
I have a pretty silly problem. Consider the following: getFeed() returns a $q deferred promise (I am on angular) that resolves successfully. My goal is to set vm.feed equal to the data value returned by the successful callback. As it is right now, the code simply assigns vm.feed equal to the $promise object r…
Refused to load the script because it violates the following Content Security Policy directive
When I tried to deploy my app onto devices with Android system above 5.0.0 (Lollipop), I kept getting these kind of error messages: 07-03 18:39:21.621: D/SystemWebChromeClient(9132): file:///android_asset/www/index.html: Line 0 : Refused to load the script ‘http://xxxxx’ because it violates the fo…
Can not read the slug from url on Flow Router (Meteor)
I’m trying to implement a basic route using Flow Router. But no matter what _id of a collection document I request; I always only get the info about the first document in my collection – ‘Requests’. So here’s my route definition in the file /lib/routes.js: Here’s my helper:…
JSON stringify a Set
How would one JSON.stringify() a Set? Things that did not work in Chromium 43: I would expect to get something similar to that of a serialized array. Answer JSON.stringify doesn’t directly work with sets because the data stored in the set is not stored as properties. But you can convert the set to an ar…
Regex bold characters using *
If I have text like: I need to bold *this* text and *that* text. I need to bold this text and that text. I need to convert both to <b>this</b> and <b>that</b>. This is not doing what I want for 2 or more matches. It’s doing this instead: I need to bold this text and that text and…