Categories
discuss

How to highlight all instances of variables that are clicked on?

Netbeans
Android Studio

First image is my Netbeans IDE. As you can see whenever I place the text cursor on a variable, that variable is highlighted everywhere else where it appears.
I find this feature very helpful and want to enable it on Android Studio (second image).

Answer

Have you tried Identifier under caret setting?

Probably some mismatch with the colors you have set for Foreground and Background

Check my screenshot and let me know how it goes

enter image description here

Categories
discuss

Text Field box creation as per Material Design docs

I have been trying to create a text field box as mentioned in the Material Design guidelines. I couldn’t figure out how to achieve this. This is what I want to achieve.

TextField Box Material Design Screenshot

I am also attaching the link which has the material design guidelines if the image is not clear enough. I just need to create a text field box, but I couldn’t figure it out. Here is the link to Material design guidelines page

https://material.io/guidelines/components/text-fields.html#text-fields-text-field-boxes

Also attaching my xml code for the text field which I want to create.

<android.support.design.widget.TextInputLayout
                    android:id="@+id/firstNameTextInputLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp">

                        <android.support.design.widget.TextInputEditText
                            android:id="@+id/firstNameTextInputEditText"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="@string/firstName"
                            android:inputType="textPersonName"
                            tools:ignore="MissingPrefix" />

                </android.support.design.widget.TextInputLayout>

Thanks in advance. Kindly help.

Answer

You’re welcome to use my library here on Github:

https://github.com/HITGIF/TextFieldBoxes

text field boxes

Note that it requires Android 4.0.3 IceCreamSandwich (API lv 15) or greater.

First add the dependency in your project:

For Gradle:

allprojects {
    repositories {
      ...
      maven { url 'https://jitpack.io' }
    }
}

dependencies {
    compile 'com.github.HITGIF:TextFieldBoxes:1.3.9'
}

For other build tools & instructions, see the Github repo: README.md

Then add these to your layout:

...
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    android:id="@+id/text_field_boxes"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:labelText="Label">

    <studio.carbonylgroup.textfieldboxes.ExtendedEditText
        android:id="@+id/extended_edit_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
...

For more information and usage, see the Github repo above.

Categories
discuss

How to use Node 8 inspector with Chrome?

I am familiar with using the --inspect option since node 7 or something. Now on node 8, it’s just not working. Today I asked node to use the inspector, as usual:

$ node --inspect --debug-brk node_modules/mocha/bin/_mocha o/**/*.test.js

It responds with this:

Debugger listening on ws://127.0.0.1:9229/97a6264d-a751-4467-ac36-172ff3ebaac1
For help see https://nodejs.org/en/docs/inspector

If I try to open that link, Chrome says:

This site can’t be reached

The webpage at ws://127.0.0.1:9229/97a6264d-a751-4467-ac36-172ff3ebaac1 might be temporarily down or it may have moved permanently to a new web address.
ERR_DISALLOWED_URL_SCHEME

Before it used to be a “chrome-devtools://” link, which worked splendidly.

What gives?

Searching around, I can’t find anything I’m supposed to do with this ws:// link.

Answer

There is information from nodejs docs

Option 1: Open chrome://inspect in a Chromium-based browser. Click the Configure button and ensure your target host and port are listed. Then select your Node.js app from the list.

Option 2: Install the Chrome Extension NIM (Node Inspector Manager)

I prefer option 2.

Also --debug-brk is deprecated. Node.js 8.x uses --inspect-brk

Categories
discuss

vuejs configuration: using a global variable?

This seems dumb, but I have it setup like this:

in config/index.js:

module.exports = {
    API_LOCATION: 'http://localhost:8080/api/'
}

then in src/app.js I have:

import Vue from 'vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource';

Vue.use(VueRouter);
Vue.use(VueResource);

const App = require("./app.vue");
const home = require("./components/home.vue");
const config = require('../config');
window.config = config;

Then in src/components/home.vue, I have a script block that uses it like so:

<script>
    module.exports = {
        data: function() {
            return {
                obj: null
            }
        },
        created: function() {
            this.$http.get(config.API_LOCAITON + '/call').then(res => {
                // Do some business
            }, res => {
                // Handle some error
            });
        }
    }
</script>

This works but it strikes me as a bad idea to use window to handle an application configuration. What’s the more canonical approach here?

Answer

Import it.

<script>
    import config from "../config"

    module.exports = {
        data: function() {
            return {
                obj: null
            }
        },
        created: function() {
            this.$http.get(config.API_LOCATION + '/call').then(res => {
                // Do some business
            }, res => {
                // Handle some error
            });
        }
    }
</script>

Or just the location.

<script>
    import { API_LOCATION } from "../config"

    module.exports = {
        data: function() {
            return {
                obj: null
            }
        },
        created: function() {
            this.$http.get(API_LOCATION + '/call').then(res => {
                // Do some business
            }, res => {
                // Handle some error
            });
        }
    }
</script>
Categories
discuss

How to remove undefined and create a new array Javascript?

I have the following array:

var imagesList = [undefined x 1, cars.jpg, undefined x 1, boats.jpg];

How do I filter out the undefined? so I can get it as follows:

var imagesShow = [cars.jpg, boats.jpg];

I have not found much documentation on getting rid of undefined in an array using javascript.

Answer

You could use Array#filter with Boolean as callback for truthy values.

var imagesList = [undefined, 'cars.jpg', undefined, 'boats.jpg'],
    imagesShow = imagesList.filter(Boolean);
    
console.log(imagesShow);
Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..