text:
Q: Unity hit Android DEX limit but ref count increases after removing .jars I have a Unity project that's just chock full of 3rd-party libs and has hit the DEX limit. One of the plugins is an ad mediator and there are several ad network integrations under it. So that was my first target for the removal of libraries, I just took out some of the networks. Easy.
Except that after removing .jars, the method count actually goes up instead of down. Now, my knowledge of how these counts are generated is still fairly limited but it seems like this shouldn't be possible?
Here's an example of what I'm seeing.
Before removing libs:
trouble writing output: Too many method references: 68955; max is 65536.

     6 android.accessibilityservice
    15 android.accounts
    23 android.animation
   423 android.app
   222 android.content
    93 android.content.pm
   104 android.content.res
    59 android.database
    24 android.database.sqlite
   228 android.graphics
   111 android.graphics.drawable
     2 android.graphics.drawable.shapes
     3 android.graphics.pdf
    34 android.hardware
     5 android.hardware.display
    11 android.hardware.fingerprint
    26 android.location
   156 android.media
    17 android.media.browse
    87 android.media.session
    66 android.net
     6 android.net.http
     7 android.net.nsd
     2 android.net.wifi
    44 android.opengl
   279 android.os
     7 android.preference
    18 android.print
     5 android.print.pdf
    15 android.provider
     8 android.renderscript
     9 android.security
     6 android.security.keystore
    12 android.speech.tts
    20 android.support.annotation
   124 android.support.customtabs
   320 android.support.graphics.drawable
    19 android.support.graphics.drawable.animated
    19 android.support.v4
    41 android.support.v4.accessibilityservice
    62 android.support.v4.animation
  1632 android.support.v4.app
   272 android.support.v4.content
     1 android.support.v4.content.pm
    20 android.support.v4.content.res
     3 android.support.v4.database
    55 android.support.v4.graphics
   261 android.support.v4.graphics.drawable
    19 android.support.v4.hardware.display
    66 android.support.v4.hardware.fingerprint
    74 android.support.v4.internal.view
   645 android.support.v4.media
   818 android.support.v4.media.session
    64 android.support.v4.net
    68 android.support.v4.os
    84 android.support.v4.print
    96 android.support.v4.provider
    14 android.support.v4.speech.tts
   103 android.support.v4.text
   284 android.support.v4.util
  1790 android.support.v4.view
  1116 android.support.v4.view.accessibility
    29 android.support.v4.view.animation
  1402 android.support.v4.widget
   972 android.support.v7.app
    19 android.support.v7.appcompat
    19 android.support.v7.cardview
    69 android.support.v7.graphics.drawable
     1 android.support.v7.recyclerview
     3 android.support.v7.text
     2 android.support.v7.transition
   140 android.support.v7.util
   156 android.support.v7.view
   587 android.support.v7.view.menu
  3899 android.support.v7.widget
   148 android.support.v7.widget.helper
     5 android.support.v7.widget.util
    13 android.telephony
    37 android.text
     3 android.text.method
     2 android.text.style
    17 android.transition
    75 android.util
   706 android.view
   215 android.view.accessibility
    45 android.view.animation
     2 android.view.inputmethod
   171 android.webkit
   694 android.widget
     9 bitter.jnibridge
   257 bolts
     1 com.adcolony.adcolonysdk
  3132 com.adcolony.sdk
   263 com.applovin.adview
   358 com.applovin.impl.adview
   957 com.applovin.impl.sdk
    24 com.applovin.nativeAds
   120 com.applovin.sdk
    73 appnexuscustom.com.playandwin.appnexuscustom
  1148 com.appnexus.opensdk
    32 com.appnexus.opensdk.mediatedviews
    62 com.appnexus.opensdk.transitionanimation
   192 com.appnexus.opensdk.utils
   350 com.appsflyer
    19 com.appsflyer.cache
   441 com.chartboost.sdk
    35 com.chartboost.sdk.InPlay
   183 com.chartboost.sdk.Libraries
    88 com.chartboost.sdk.Model
    68 com.chartboost.sdk.Tracking
  1006 com.chartboost.sdk.impl
   719 com.facebook
    12 com.facebook.ads
    19 com.facebook.android
   214 com.facebook.appevents
    78 com.facebook.appevents.internal
    34 com.facebook.applinks
    13 com.facebook.devicerequests.internal
   763 com.facebook.internal
    27 com.facebook.messenger
   158 com.facebook.unity
    97 com.facebook.share
   624 com.facebook.share.internal
   466 com.facebook.share.model
   392 com.facebook.share.widget
   450 com.facebook.login
   192 com.facebook.login.widget
    31 com.google.ads
   323 com.google.ads.conversiontracking
   109 com.google.ads.mediation
     2 com.google.ads.mediation.admob
    41 com.google.ads.mediation.customevent
   213 com.google.android.gms.ads
    90 com.google.android.gms.ads.doubleclick
   114 com.google.android.gms.ads.formats
    23 com.google.android.gms.ads.identifier
    18 com.google.android.gms.ads.impl
   543 com.google.android.gms.ads.internal
    67 com.google.android.gms.ads.internal.cache
   721 com.google.android.gms.ads.internal.client
   163 com.google.android.gms.ads.internal.formats
   313 com.google.android.gms.ads.internal.overlay
    97 com.google.android.gms.ads.internal.purchase
   198 com.google.android.gms.ads.internal.request
   131 com.google.android.gms.ads.internal.reward.client
    65 com.google.android.gms.ads.internal.reward.mediation.client
    17 com.google.android.gms.ads.internal.safebrowsing
    52 com.google.android.gms.ads.internal.util.client
    98 com.google.android.gms.ads.mediation
     2 com.google.android.gms.ads.mediation.admob
    63 com.google.android.gms.ads.mediation.customevent
    16 com.google.android.gms.ads.purchase
    22 com.google.android.gms.ads.reward
    14 com.google.android.gms.ads.reward.mediation
   137 com.google.android.gms.ads.search
    18 com.google.android.gms
     4 com.google.android.gms.actions
   381 com.google.android.gms.analytics
    37 com.google.android.gms.analytics.ecommerce
   756 com.google.android.gms.analytics.internal
    79 com.google.android.gms.auth.api.signin
    20 com.google.android.gms.auth.api.signin.internal
    18 com.google.android.gms.base
     5 com.google.android.gms.clearcut
   202 com.google.android.gms.common
   258 com.google.android.gms.common.api
   148 com.google.android.gms.common.data
   106 com.google.android.gms.common.images
   632 com.google.android.gms.common.internal
    86 com.google.android.gms.common.internal.safeparcel
     9 com.google.android.gms.common.server
    42 com.google.android.gms.common.server.converter
   117 com.google.android.gms.common.server.response
    90 com.google.android.gms.common.stats
   122 com.google.android.gms.common.util
   213 com.google.android.gms.dynamic
     1 com.google.android.gms.dynamite.descriptors.com.google.android.gms.ads.dynamite
     1 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
    27 com.google.android.gms.flags.impl
     1 com.google.android.gms.gass.internal
   251 com.google.android.gms.gcm
   134 com.google.android.gms.iid
  6406 com.google.android.gms.internal
   364 com.google.android.gms.location
   402 com.google.android.gms.location.internal
    18 com.google.android.gms.location.places
    34 com.google.android.gms.phenotype
    13 com.google.android.gms.playlog.internal
    13 com.google.android.gms.security
   139 com.google.android.gms.signin.internal
   951 com.google.android.gms.tagmanager
     6 com.google.android.gms.tasks
     4 com.google.firebase
     4 com.google.firebase.iid
     2 com.google.firebase.messaging
   289 com.google.gson
     6 com.google.gson.annotations
   269 com.google.gson.internal
   292 com.google.gson.internal.bind
    18 com.google.gson.reflect
    90 com.google.gson.stream
    24 com.jirbo.adcolony
    46 com.karman.utils
   541 com.leanplum
   536 com.leanplum.a
   209 com.leanplum.a.a
     5 com.leanplum.a.a.a
    91 com.leanplum.activities
    13 com.leanplum.annotations
    29 com.leanplum.callbacks
     7 com.leanplum.json
   121 com.leanplum.messagetemplates
    21 com.leanplum.utils
    26 com.leanplum.views
   366 com.moat.analytics.mobile.tjy
     1 com.moat.analytics.mobile.tjy.base.asserts
     1 com.moat.analytics.mobile.tjy.base.exception
    12 com.moat.analytics.mobile.tjy.base.functional
    18 com.mopub
   578 com.mopub.common
   225 com.mopub.common.event
     5 com.mopub.common.factories
    24 com.mopub.common.logging
   165 com.mopub.common.util
     6 com.mopub.exceptions
  1409 com.mopub.mobileads
     1 com.mopub.mobileads.adcolony
     1 com.mopub.mobileads.admob
     1 com.mopub.mobileads.base
     1 com.mopub.mobileads.chartboost
     1 com.mopub.mobileads.facebook
    36 com.mopub.mobileads.factories
     1 com.mopub.mobileads.interstitial
    50 com.mopub.mobileads.resource
    35 com.mopub.mobileads.util
     1 com.mopub.mobileads.vungle
   344 com.mopub.mraid
   246 com.mopub.network
    78 com.mopub.unity
   170 com.mopub.volley
   219 com.mopub.volley.toolbox
   273 com.onevcat.uniwebview
    14 com.pch.common
    40 com.pch.leanplumcustommessaging
    30 com.pch.lotto
    18 com.pch.lottoblast
   348 com.prime31
    18 com.prime31.Etcetera
    18 com.prime31.NAME
   891 com.tapjoy
  2572 com.tapjoy.internal
    22 com.tapjoy.mediation
     1 com.tapjoy.mraid
   118 com.tapjoy.mraid.controller
    34 com.tapjoy.mraid.listener
    47 com.tapjoy.mraid.util
   227 com.tapjoy.mraid.view
   245 com.truste.mobile.sdk
    36 com.truste.mobile.sdk.exception
     8 com.truste.unity
   503 com.unity3d.player
    18 com.vungle.log
  6176 com.vungle.publisher
    34 com.vungle.publisher.env
    11 com.vungle.publisher.inject
    41 com.vungle.sdk
    14 dagger
    70 dagger.internal
     4 dagger.multibindings
     2 dalvik.system
     6 default
   222 java.io
   460 java.lang
    10 java.lang.ref
    57 java.lang.reflect
    21 java.math
   104 java.net
    45 java.nio
     7 java.nio.channels
     5 java.nio.charset
    40 java.security
     3 java.security.cert
     2 java.security.spec
     3 java.sql
    22 java.text
   441 java.util
   148 java.util.concurrent
    35 java.util.concurrent.atomic
    21 java.util.concurrent.locks
     4 java.util.jar
    12 java.util.logging
    15 java.util.regex
    18 java.util.zip
    16 javax.crypto
     3 javax.crypto.spec
     2 javax.inject
    12 javax.microedition.khronos.egl
     2 javax.net
    33 javax.net.ssl
     1 javax.security.auth.x500
     5 javax.xml.parsers
    16 org.apache.http
     2 org.apache.http.client
    15 org.apache.http.client.methods
     1 org.apache.http.client.utils
     1 org.apache.http.conn
     7 org.apache.http.entity
     5 org.apache.http.impl.client
     1 org.apache.http.impl.conn.tsccm
     2 org.apache.http.impl.cookie
     9 org.apache.http.message
     2 org.apache.http.params
    19 org.fmod
    72 org.json
    10 org.w3c.dom
     1 org.xml.sax
    19 org.xmlpull.v1
    10 sun.misc

After removing the vungle package:
trouble writing output: Too many field references: 71569; max is 65536.

     3 android.accounts
    29 android.app
     1 android.content
    50 android.content.pm
    14 android.content.res
     3 android.database
    59 android.graphics
     2 android.graphics.drawable
     6 android.hardware
     1 android.location
     2 android.media
     1 android.media.browse
     4 android.net
    42 android.os
     3 android.print
     6 android.provider
  1879 android.support.customtabs
  1968 android.support.graphics.drawable
  1815 android.support.graphics.drawable.animated
  1815 android.support.v4
    13 android.support.v4.accessibilityservice
    17 android.support.v4.animation
   770 android.support.v4.app
   110 android.support.v4.content
     1 android.support.v4.content.pm
     9 android.support.v4.graphics
    42 android.support.v4.graphics.drawable
     4 android.support.v4.hardware.display
    12 android.support.v4.hardware.fingerprint
     9 android.support.v4.internal.view
   337 android.support.v4.media
   272 android.support.v4.media.session
     5 android.support.v4.net
    19 android.support.v4.os
    49 android.support.v4.print
     9 android.support.v4.provider
     5 android.support.v4.speech.tts
    55 android.support.v4.text
    74 android.support.v4.util
   385 android.support.v4.view
   112 android.support.v4.view.accessibility
     8 android.support.v4.view.animation
   495 android.support.v4.widget
   378 android.support.v7.app
  1815 android.support.v7.appcompat
  1815 android.support.v7.cardview
    18 android.support.v7.graphics.drawable
    14 android.support.v7.recyclerview
     1 android.support.v7.text
     2 android.support.v7.transition
    93 android.support.v7.util
    77 android.support.v7.view
   191 android.support.v7.view.menu
  1335 android.support.v7.widget
    86 android.support.v7.widget.helper
     1 android.support.v7.widget.util
     5 android.text
    15 android.util
    30 android.view
     7 android.webkit
    28 android.widget
  1838 appnexuscustom.com.playandwin.appnexuscustom
     2 bitter.jnibridge
   158 bolts
     6 com.adcolony.adcolonysdk
  2166 com.adcolony.sdk
    88 com.applovin.adview
   168 com.applovin.impl.adview
   612 com.applovin.impl.sdk
    81 com.applovin.sdk
  2344 com.appnexus.opensdk
    13 com.appnexus.opensdk.mediatedviews
    44 com.appnexus.opensdk.transitionanimation
   111 com.appnexus.opensdk.utils
   332 com.appsflyer
     7 com.appsflyer.cache
   256 com.chartboost.sdk
    25 com.chartboost.sdk.InPlay
    93 com.chartboost.sdk.Libraries
   146 com.chartboost.sdk.Model
    33 com.chartboost.sdk.Tracking
   591 com.chartboost.sdk.impl
  2216 com.facebook
     5 com.facebook.ads
  1815 com.facebook.android
   169 com.facebook.appevents
    39 com.facebook.appevents.internal
    46 com.facebook.applinks
     9 com.facebook.devicerequests.internal
   563 com.facebook.internal
   183 com.facebook.login
    81 com.facebook.login.widget
    32 com.facebook.messenger
    51 com.facebook.share
   360 com.facebook.share.internal
   113 com.facebook.share.model
   124 com.facebook.share.widget
    53 com.facebook.unity
    25 com.google.ads
   309 com.google.ads.conversiontracking
    22 com.google.ads.mediation
    11 com.google.ads.mediation.customevent
  1809 com.google.android.gms
    20 com.google.android.gms.actions
  1852 com.google.android.gms.ads
    12 com.google.android.gms.ads.doubleclick
    19 com.google.android.gms.ads.formats
    13 com.google.android.gms.ads.identifier
  1809 com.google.android.gms.ads.impl
   256 com.google.android.gms.ads.internal
    22 com.google.android.gms.ads.internal.cache
   222 com.google.android.gms.ads.internal.client
   100 com.google.android.gms.ads.internal.formats
   158 com.google.android.gms.ads.internal.overlay
    51 com.google.android.gms.ads.internal.purchase
   197 com.google.android.gms.ads.internal.request
    14 com.google.android.gms.ads.internal.reward.client
     6 com.google.android.gms.ads.internal.reward.mediation.client
     6 com.google.android.gms.ads.internal.safebrowsing
    17 com.google.android.gms.ads.internal.util.client
    22 com.google.android.gms.ads.mediation
     1 com.google.android.gms.ads.mediation.admob
    12 com.google.android.gms.ads.mediation.customevent
     7 com.google.android.gms.ads.purchase
     1 com.google.android.gms.ads.reward.mediation
    46 com.google.android.gms.ads.search
  1908 com.google.android.gms.analytics
    14 com.google.android.gms.analytics.ecommerce
   237 com.google.android.gms.analytics.internal
    36 com.google.android.gms.auth.api.signin
     6 com.google.android.gms.auth.api.signin.internal
  1809 com.google.android.gms.base
     1 com.google.android.gms.clearcut
    98 com.google.android.gms.common
    95 com.google.android.gms.common.api
    41 com.google.android.gms.common.data
    46 com.google.android.gms.common.images
   188 com.google.android.gms.common.internal
     1 com.google.android.gms.common.internal.safeparcel
     4 com.google.android.gms.common.server
    12 com.google.android.gms.common.server.converter
    33 com.google.android.gms.common.server.response
    63 com.google.android.gms.common.stats
    22 com.google.android.gms.common.util
    27 com.google.android.gms.dynamic
     2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.ads.dynamite
     2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
    16 com.google.android.gms.flags.impl
  1910 com.google.android.gms.gcm
  1856 com.google.android.gms.iid
  3552 com.google.android.gms.internal
  1956 com.google.android.gms.location
   100 com.google.android.gms.location.internal
     5 com.google.android.gms.location.places
    18 com.google.android.gms.phenotype
    11 com.google.android.gms.playlog.internal
     6 com.google.android.gms.security
    26 com.google.android.gms.signin.internal
   401 com.google.android.gms.tagmanager
    68 com.google.gson
   115 com.google.gson.internal
   117 com.google.gson.internal.bind
     3 com.google.gson.reflect
    74 com.google.gson.stream
  1821 com.karman.utils
   188 com.leanplum
   242 com.leanplum.a
    87 com.leanplum.a.a
     4 com.leanplum.a.a.a
    13 com.leanplum.activities
     8 com.leanplum.annotations
     5 com.leanplum.callbacks
    40 com.leanplum.messagetemplates
    21 com.leanplum.utils
    13 com.leanplum.views
   175 com.moat.analytics.mobile.tjy
     2 com.moat.analytics.mobile.tjy.base.functional
  1809 com.mopub
   322 com.mopub.common
   142 com.mopub.common.event
     1 com.mopub.common.factories
     5 com.mopub.common.logging
   112 com.mopub.common.util
   632 com.mopub.mobileads
     6 com.mopub.mobileads.adcolony
     6 com.mopub.mobileads.admob
     6 com.mopub.mobileads.base
     6 com.mopub.mobileads.chartboost
     6 com.mopub.mobileads.facebook
     7 com.mopub.mobileads.factories
     6 com.mopub.mobileads.interstitial
    84 com.mopub.mobileads.resource
   132 com.mopub.mraid
   120 com.mopub.network
    40 com.mopub.unity
   106 com.mopub.volley
    93 com.mopub.volley.toolbox
   118 com.onevcat.uniwebview
     1 com.pch.common
  1820 com.pch.leanplumcustommessaging
  1816 com.pch.lotto
  1809 com.pch.lottoblast
   232 com.prime31
  1809 com.prime31.Etcetera
  1809 com.prime31.NAME
   721 com.tapjoy
  1141 com.tapjoy.internal
    11 com.tapjoy.mediation
     6 com.tapjoy.mraid
    79 com.tapjoy.mraid.controller
    19 com.tapjoy.mraid.listener
    29 com.tapjoy.mraid.util
    84 com.tapjoy.mraid.view
   145 com.truste.mobile.sdk
    17 com.truste.mobile.sdk.exception
     2 com.truste.unity
   235 com.unity3d.player
     2 java.io
    28 java.lang
    11 java.lang.annotation
     1 java.math
     2 java.nio
     6 java.util
     6 java.util.concurrent
     8 java.util.logging
     4 javax.microedition.khronos.egl
    20 org.fmod
     1 org.json

Does anyone know why this is the case? Thanks for any insight.


text:
Q: Where should the Page Objects be instantiated? I would like to know where should I instantiate my Page objects?
Here is my project hierarchy:
Pages : Contains all page objects with constructor such as
public LoginPage extends BasePage
 {
   super(driver);
   PageFactory.initElements(driver, this);
}

My BasePage contains all common methods such as table handling, data gathering from webtable etc..
I have a baseTest which contains all of the Page Objects instantiation and my tests are extend this class.
LoginPage loginPage = new LoginPage(driver);

I have helper (non-static) classes as well for navigation, database connection, custom waits etc.
Any best practice? Basetest is the proper place to instantiate them?
Thanks!

A: I instantiate page objects in the test code, but not the base class, as the scenario requires. E.g.,
@Test(dataProvider = PROVIDER)
public void testLogin(WebDriver driver, Info info) {
  Login login = new Login(driver);
  assertTrue(login.isDisplayed());
  login.enterCredentials(info.getUser(), info.getPw());
  Welcome welcome = new Welcome(driver);
  assertTrue(welcome.isDisplayed());
}

This is just one way to use page objects.
Be careful not to write too many "helper" classes, or too deep an inheritance hierarchy.

A: I do it in the way given below. I'm not sure how good it is. Comments and Feedback welcome.
a. I use an AbstractPage class which contains instantiates page objects, and also has all the object level wrapper methods such as clickButton(), sendKeys() etc. Page Object instantiation happens via constructor
public AbstractPage(WebDriver driverWeb) {
  this.driverWeb = driverWeb;
  PageFactory.initElements(driverWeb, this);
}

b. Then I have all my Page Classes which extend this AbstractPage -
public LoginCanvas(WebDriver driverWeb) {
  super(driverWeb);
}

c. Then a class which runs all my test cases. But I use cucumber so this base class just runs the cucumber scenarios.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Is it better way to learn math by doing a lot of normal problems or is it better to be stuck at hard problems? I'm studying Precalculus Algebra(around factoring quadratics at this point).
I want to know if it's worth banging your head for 2-3 days stuck on a hard problem or skipping them and doing all other thing that you seem that you're able to solve.
justification to your answer would be much appreciated

A: Both have their own merits. But for the former please pay attention to this quote by Terence Tao which I always find comforting.

It's like if you want to be a good pianist, you have to do a lot of
scales and a lot of practice, and a lot of that is kind of boring,
it's work. But you need to do that before you can really be very
expressive and really play beautiful music. You have to go through
that phase of practice and drill.

Hope this helps. :$)$

A: What's your definition of normal problems?questions you feel comfortable with?  I feel the other way it's better the essence of solving in the first place is that we learn new ways,knowledge and acquire new skills I don't see how you can accomplish this by doing questions you are familiar with. The only thing you end up doing is exercising your already acquired skills.so it's better if you work up new challenging problems,you could also devise means to go about this

A: I have profited the most from challenging problems that also required me to apply one or two core ideas of a field.
When things get too obscure, it is a nice feeling solving the problem, but it may not help me understand the mathematics behind it any better.
Personally, I always try to prove statements from my lecture that are a consequence of some main theorem, without looking at the notes from class.
This helps me figure out the general ideas behind the theorems and definitions while often still requiring some nice idea I have to come up with.


text:
Q: How to read multiple line of text from console and then save the content to a file with line break? It is because the users do not know how to use vi, I need to create a solution to let the user create a file in the AIX server using a copy and paste.
I refer to the solution from the below link:
How to read multi-line input in a Bash script?
I create a script as below:
#!/bin/bash
echo "Paste the Bulletin:"
IFS= read -d '' -n 1 keyvariable
while IFS= read -d '' -n 1 -t 2 c
do
    keyvariable+="$c"$'\n'
done
echo $keyvariable >abc.txt
echo "Thanks!"

The input:
sdsdfsdfsd
4354353453
/*-/*/-/--/`

Expected the abc.txt content:
sdsdfsdfsd
4354353453
/*-/*/-/--/

Actual the abc.txt content:
sd s d f s d f s d 4 3 5 4 3 5 3 4 5 3  /*- /* /-/- - /

Unfortunately, the line breaks in the original text do not preserve, so how can I preserve the line breaks and then write the text to the output file?

A: If you have bash on your AIX, then you can try this:
#!/bin/bash
echo "Paste the Bulletin:"
while IFS= read -r -t 2 c
do
    keyvariable+="$c"$'\n'
done
echo "$keyvariable" >abc.txt
echo "Thanks!"

A: As a simplification / alternative, consider a slight change in workflow and just do this:
#!/bin/sh
echo "Paste the Bulletin; hit Control-D on its own line when you're done"
cat > abc.txt


text:
Q: Best way to access API from React App? What's the best way for me to access an API using a React app? The API is currently developed in Golang using kami & mgo for the POST/GET/DELETE requests.
I want to be able to make a GET request to the following URL:
http://user:password@localhost:8000/api/v1/systems
on my React app and store the result in a state attribute:
this.state = {
    data: //store the data here
}

I also want to load this data whenever the page is loaded so maybe I should use the componentDidMount() function to handle this?
I've never used API calls on React, so I was wondering if anyone here could tell me a good way to this?
EDIT
I'm using React 15.3.2.
EDIT #2
I've taken a look at fetch to handle the requests, but I'm still unsure how to use it in my situation. I've got the react app running on localhost:3000 and the api running on localhost:8000, /api/v1/systems will return a JSON with the following format:
{ systems : [ //list of objects ] }

I've tried the following inside my componentDidMount():
fetch(myRequest)
  .then(result => {
    console.log(result);
    //this.setState({ data: result.json() });
    });

Not too sure what myRequest should be (been trying with a simple string of the URL: 'http://localhost:8000/api/v1/systems') and I'm also not sure if the ports where the apps are running could make a conflict or something.

A: You will have to decide on a library to do API calls. A simple way is to use fetch, which is built-in in modern browsers. There's a polyfill to cover older ones. jQuery's AJAX or SuperAgent are two alternatives. Here's a simple example using fetch. You'll only have to change the URL of the request.

class Example extends React.Component {
  constructor() {
    super();
    this.state = { data: {} };
  }
  componentDidMount() {
    var self = this;
    fetch('http://reqres.in/api/users')
      .then(function(response) {
        return response.json()
      }).then(function(data) {
        self.setState({ data }, () => console.log(self.state));
      });
  }
  render() {
    return (

    );
  }
}

ReactDOM.render(<Example/>, document.getElementById('View'));


text:
Q: Grok filter not working even though it works in grok debugger I'm using logstash-1.4.0 with elasticsearch 1.3.4 and kibana 3.1.1 (I know I'm outdated, that's the best I can do right now).
Log Example:

2016-05-31 16:05:33 RequestManager [INFO] The manual flag LOLROFLin TRALALA 123456Was changed to true

My grok filter:
filter {
    grok {
        match => { "message" => "%{DATESTAMP:timestamp} %{WORD:clazz} %{NOTSPACE:level} %{GREEDYDATA:content}"}
    }

    if (!([stack_trace])) and (!([clazz] == "RequestAsset")) {
        drop {}
    }
}

My questions are:

*

*Why do I not see the grok fields in kibana? I only see the default fields but not mine. Grok Debugger shows success, but kibana does not work.

*My goal is to drop any log message that does not have a stack trace OR is not from class (called clazz in my grok filter) "RequestAsset". Should this work? can I use the fields created by the grok filter in a seperate if filter?
EDIT: I realised what went wrong, I was using the log4j plugin which already seperates the log to its contents, and the field message was already just the message itself.

A: I tested your grok filter in this grok debugger and it failed. So i have rewritten it.
Here is the correct grok filter.
filter {
grok {
    match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} %{WORD:clazz} %{NOTSPACE:level} %{GREEDYDATA:content}"}
}

if (!([stack_trace])) and (!([clazz] == "RequestAsset")) {
    drop {}
}

TIMESTAMP_ISO8601 => %{YEAR}-%{MONTHNUM}-%{MONTHDAY}[T ]%{HOUR}:?%{MINUTE}(?::?%{SECOND})?%{ISO8601_TIMEZONE}?
If you see "_grokparsefailure" in Kibana, you know that your grok filter failed.
On your second question shouldn't you use the OR operator?

A: I realised what went wrong, I was using the log4j plugin which already seperates the log to its contents, and the field message was already just the message itself.


text:
Q: How to open a new activity when an item is clicked in Firebase RecyclerView I have used FirebaseRecyclerView from Firebase UI to show a list of data. Now when I click on one of the items, depending on the ID of the item in database, I want to open DetailActivity. How can I get Firebase generated ID(eg: -KRAVjAhr6A_spgJZEET) in populateViewHolder.
Query queryRef = mDatabase.child("user-tickets").child(userId);
FirebaseRecyclerAdapter<Ticket, TicketViewHolder> adapter = new FirebaseRecyclerAdapter<Ticket, TicketViewHolder>(
            Ticket.class,
            R.layout.item_ticket,
            TicketViewHolder.class,
            queryRef
    ) {
        @Override
        protected void populateViewHolder(TicketViewHolder viewHolder, Ticket model, int position) {
            //want to get Id here for this record
        }
    };

A: you must put your data in a ArrayList then on your populateView attche onClickListener on your view and pass the id that is clicked using a Bundle, remember you have set your view to clickable="true" on your xml if its not a button.
viewHolder.container.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Bundle bundle = new Bundle();
            bundle.putString("ID_KEY", items.get(position).getId());

            Intent intent = new Intent(context.getApplicationContext(), DetailActivity.class);
            intent.putExtra("EXTRAS_KEY", bundle);
            context.startActivity(intent);
        }
    });

A: I have implemented one TouchListener for each Item click, in the onClick callback, depending on the position, you can get the key as shown:
mRecyclerView.addOnItemTouchListener(new RecyclerTouchListener(this, mRecyclerView, new RecyclerClickListener() {
        @Override
        public void onClick(View view, int position) {
            String key = adapter.getRef(position).getKey();
        }

        @Override
        public void onLongClick(View view, int position) {

        }
    }));

Credit: How to get obj key from FirebaseListAdapter on Item Click. FirebaseUI


text:
Q: Is it a good manner to have a nice question/answer without any edit history? I know it's recommended to edit a post if there's improvement. But as a personal preference, I'm often proud of having an upvoted question or answer without a revision history, and I'll admire if someone has one. So at last is it a commended practice to be so?

A: TL;DR: It doesn't matter.

If a question or answer is good, it can be posted and never be edited. On the other hand, it can also be edited to make it even better, or updated as things change over time.
Editing is not a bad mark, by any means. If someone, for their own personal reasons, see this as something bad, it's purely their own personal matter/opinion and it should not affect anyone else.
Good manner is putting the quality of contents above anything else, so even if you consider post without edits as some ultra achievement, and see something needing edit in your post, best thing to do is edit and enjoy the fact you helped some other people by doing so.

A: Not really. It can also be interpreted as lazyness, or more extremely, arrogance. I have seen many answers which produced a subsequent discussion between the author and the asker (and maybe other users). The comments provide clarifications to the answer, and could well be summarised by improving the answer and then deleting the comments. That is very efficient as it might save time to other readers, who are not really interested in the nuances of a conversation but on a precise answer. A good user would edit the answer to incorporate clarifications or further information from comments. A lazy one would not be bothered. An arrogant would actively avoid editing posts.


text:
Q: Getting SharePoint data from list that uses alternate list from a SPServices query I have a list that that looks up another table to get the value for that data.  I can query the table directly, and it returns the data I want.  I have another table that uses the previous table as a selection for a field in it.  I have queried all the fields in the table that uses the lookup table, and the fields that correspond to that lookup are two of the data fields of the lookup table separated by a semicolon and hash symbol.  I've been trying to format a CAML query to filter the data from the table that uses the lookup table based upon the field that is in that table, and get another field from it.  Sorry, this really hard to explain, but perhaps after you see my code, you will see what I'm trying to get.
If I do a query on the lookup table like this:

var ViewFields = "<ViewFields>" +
                 "<FieldRef Name='Title' />" +
                 "<FieldRef Name='Column_x0020_Number' Type='Number' />" +
                 "</ViewFields>";

$(document).ready(function() {
    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "Categories",
        CAMLViewFields: ViewFields,
        completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function() {
                var categoryHtml = "" + $(this).attr("ows_Title") + "	";
                var columnNumHtml = "" + Math.round($(this).attr("ows_Column_x0020_Number")) + "	";
                var addRow = "
" + categoryHtml + columnHtml + "
";
                $("#Categories").append(addRow);
            });
        }
    });
});

</script>

I get returns like:
Cat1    1
  Cat2    2
....
So, It's working.  That's the table that gets the lookup from.
Next we have the code to try and get data form the question table:
var ViewFields = "<ViewFields>" +
                 "<FieldRef Name='Title' />" +
                 "<FieldRef Name='Category_x0020_Name' />" +
                 "<FieldRef Name='Amount' Type='Number' />" +
                 "<FieldRef Name='Question' />" +
                 "<FieldRef Name='Answer' />" +
                 "</ViewFields>";

    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "Categories",
        CAMLViewFields: ViewFields,
        completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function() {
                var titleHtml = "" + $(this).attr("ows_Title") + "	";
                var categoryNameHtml = "" + $(this).attr("ows_Category_x0020_Name")) + "	";
                var nameHtmlSplitString = categoryNameHtml.split(";#");
                var categoryNumString = "" + nameHtmlSplitString[0] + "	";
                var categoryNameString = "" + nameHtmlSplitString[1] + "	";
                var amount = "" + Math.round($(this).attr("ows_Amount)) + "	";
                var question = "" + $(this).attr("ows_Question) + "	";
                var categoryNumString = "" + $(this).attr("ows_Answer) + "	";
                var addRow = "
" + titleHtml + categoryNameHtml + categoryNameString + categoryNumString + amountHtml + questionHtml + answerHtml + "
";
                $("#Questions").append(addRow);
            });
        }
    });
});
</script>

That comes back fairly fine with:
Cat1 Question 1|1;#Cat1|1|Cat1|100|(question 1.1)|(answer 1.1)
Cat1 Question 2|1;#Cat1|1|Cat1|200|(question 1.2)|(answer 1.2)
Cat1 Question 3|1;#Cat1|1|Cat1|300|(question 1.3)|(answer 1.3)
Cat1 Question 4|1;#Cat1|1|Cat1|400|(question 1.4)|(answer 1.4)
Cat1 Question 5|1;#Cat1|1|Cat1|500|(question 1.5)|(answer 1.5)
Cat2 Question 1|2;#Cat2|2|Cat2|100|(question 2.1)|(answer 2.1)
Cat2 Question 2|2;#Cat2|2|Cat2|200|(question 2.2)|(answer 2.2)
Cat2 Question 3|2;#Cat2|2|Cat2|300|(question 2.3)|(answer 2.3)
Cat2 Question 4|2;#Cat2|2|Cat2|400|(question 2.4)|(answer 2.4)
Cat2 Question 5|2;#Cat2|2|Cat2|500|(question 2.5)|(answer 2.5)
Cat3 Question 1|3;#Cat3|3|Cat3|100|(question 3.1)|(answer 3.1)
Cat3 Question 2|3;#Cat3|3|Cat3|200|(question 3.2)|(answer 3.2)
......
So that goes fine almost, except for the "1;#Cat1" returns.  I can obviously parse them fine, but now, when I try to write a query:
var Query = "<Query>" +
            "    <Where>" +
            "        <Eq>" +
            "            <FieldRef Name='Category_x0020_Name' />" +
            "                <Value Type='Text'>" +
            "                    2;#Cat2" +
            "                </Value>" +
            "        </Eq>" +
            "    </Where>" +
            "</Query>";

and I apply it in the SPServices
        ...
        listName: "Categories",
        CAMLViewFields: ViewFields,
        CAMLQuery: Query,
        completefunc: function (xData, Status) {
        ....

I get nothing.
Any suggestions how to handle the dropdown data?

A: I did find a way to do it, and I think this may have been a question for http://spservices.codeplex.com/ , or, at least, that's where I finally got an answer.  I'm just posting it here, in case anyone else needs help.
It has to do with a item in the query of the "lookup" flag.  The query needed to be formatted like this:
var Query = "<Query>" +
                "<Where>" +
                    "<Eq>" +
                        "<FieldRef Name='Category_x0020_Name' LookupId='True' />" +
                            "<Value Type='Lookup'>" +
                                categoryNum +
                            "</Value>" +
                    "</Eq>" +
                "</Where>" +
            "</Query>";

Note: the categoryNum is just a variable that was passed into the function.  To get more information on the LookupId, I can't exactly find anything.  It has to do with CAML.  My understanding is that the LookupId='true' tells the query to use the id of the dropdown menu, where as, if you wanted to just use the value you are looking for, then you can leave the LookupId out.  Thus, with LookupId='True', you use the ID, otherwise, just query the data your looking for.  Oh, be sure to use the Value Type='Lookup'.
I hope this helps someone.
Thanks


text:
Q: Temperature dependence of emission spectra? Since an emission spectra represents electrons moving back down to different energy levels and releasing a photon with the energy difference, wouldn't the emission spectra of a star be temperature dependant? Wouldn't the hotter stars have more electrons in higher energy states and so have larger energy releases when they fall back? So my question is do we see that hotter stars have a more pronounced emission spectra in the high frequency range of light, if not, why?

A: This is not how stars emit light. Stellar emission is thermal radiation for the most part. So while it is true that stars with higher temperatures emit spectra that are shifted to the shorter wavelengths of light, it has nothing to do with excitation and recombination processes in atoms.
There are often certain lines missing in stellar spectra, which is due to the inverse effect you are describing. Atoms on the outermost layers and surrounding a star can absorb some of the thermal radiation to excite electrons in their shells. These lines can be used to determine which elements are present in the vicinity of a star.


text:
Q: RDLC Expression shows #Error My writing an Expression RDLC SSRS
((Sum(Fields!MockObtMarks.Value))/(Sum(Fields!MockTotalMarks.Value))) * 100

Now this expression shows #Error when the sum (0/0) *100
i have used if and switch case still not working

A: You should really show the expressions you tried in your question, but this should do:
=IIF( (Sum(Fields!MockTotalMarks.Value)) = 0, 0,  ((Sum(Fields!MockObtMarks.Value))/(Sum(Fields!MockTotalMarks.Value))) * 100 )


text:
Q: Create URL with a inherited block variable as argument in Django I'm trying to create an URL in a Django (1.9) template which parses an inherited block variable as argument. So
href="{% url 'overview:detail' '{% block test_id %}{% endblock %}' %}"

With the test_id inherited from a child template like:
{% extends 'overview/base.html' %}
{% block test_id %}{{test.id}}{% endblock %}

When I try to execute this it gives the following error:

TemplateSyntaxError at /testviewer/
Could not parse the remainder: ''{%' from ''{%'

How to prevent this?

A: I don't think you'll be able to, but I assume you just want a detail page for the test object so what you can do is define the get_absolute_url method for the test instance
def get_absolute_url(self):
    return reverse('overview:detail', args=[self.pk])

Then in your template you just need {{ test.get_absolute_url }}


text:
Q: iBatus returns null when using #value# as a parameter I have a problem with select statement using iBatis, it returns null when I sumit the query as select soc from soc where soc.soc = #value#, but it returns correct result when I hard code the #value# as 'test'.
I have searched for solutions, and seems like the way that i am using is correct.
Is there anyone having a similar issue?
I am using iBatis 2.3 and oracle db.
Thanks in advance

A: Its because you are sending a null value in your class attribute (value). Debug the attribute value in your logs. You can debug by setting:
log4j.logger.com.ibatis=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG

both of the above can be used to get the sql parameter value.


text:
Q: conditionality render headerRight - React Native I have to render headerRight conditionally  in navigation options.
Right now
static navigationOptions = ({ navigation }) => ({
    title: i18N.t('atmbranchpickHeader'),

    headerRight: (

        <TouchableHighlight
            underlayColor="#E22F39"
            onPress={() => {
                navigation.navigate("home");
            }}
        >
            <Image
                style={{ marginRight: 20 }}
                source={require('../../resources/toolbar/home_white.png')}
            />
        </TouchableHighlight>
    ),
    headerTintColor: "white",
    headerStyle: {
        backgroundColor: "#E22F39"
        //  top: 30
    }
});

My Component
  import React, { Component } from "react";
import {
    View,
    TextInput,
    Text,
    TouchableOpacity,
    TouchableHighlight,
    StyleSheet,
    AsyncStorage,
    BackHandler,
    Image,
    FlatList,
    Dimensions,
    TouchableWithoutFeedback
} from "react-native";
import i18n from "../../i18n/i18n.js";
import { colors } from "../../constants/colors.js";
import Storage from "../../utils/AsyncStorage.js";

class AtmBranchTypeSelect extends Component {

    // Render callBack
    constructor(props) {
        super(props);
        this.state = {
            data: [
            ],
            stBool: false,
        }

    }
    async componentWillMount() {

        BackHandler.addEventListener('hardwareBackPress', () => this.props.navigation.goBack());
    }
    componentWillUnmount() {
        BackHandler.removeEventListener('hardwareBackPress', () => this.props.navigation.goBack());
    }

    static navigationOptions = ({ navigation }) => ({
        title: i18n.t('atmbranchpickHeader'),
        headerRight: (
            <TouchableHighlight onPress={() => {
                navigation.navigate('home');
            }}>
                <Image style={{ marginRight: 20 }} source={require('../../resources/toolbar/home_white.png')} />
            </TouchableHighlight>),

        headerTintColor: 'white',
        headerStyle: {
            backgroundColor: colors.themeColor,
            //  top: 30
        }
    });

    _renderList = ({ item }) => {
        return (
            <TouchableWithoutFeedback onPress={(event) => this._selectedItem(item.key)}>
                <View style={styles.listRowContainer}>
                    <View style={styles.listinside1Container}>
                        <Image style={styles.listImage} source={item.icon} />
                        <View style={styles.listContainer} onPress={(event) => this._selectedItem(item.text)}  >
                            <Text style={styles.listHeader} >{item.header}</Text>
                            <Text style={styles.listValue} >{item.value}</Text>
                        </View>
                    </View>
                    <Image style={styles.listimgArrow} source={require('../../resources/toolbar/chevron_right_grey.png')} />
                </View>
            </TouchableWithoutFeedback>
        );

    }
    // Render callBack

    render() {
        return (
            <View style={styles.mainWrapper} >

                <FlatList data={this.state.data} renderItem={this._renderList} />
            </View>
        );
    }
}

const styles = StyleSheet.create({

    mainWrapper: {
        flex: 1,
        height: Dimensions.get('window').height,
        width: Dimensions.get('window').width,

        flexDirection: 'column',
        justifyContent: 'flex-start'
    },
    listRowContainer: {
        flexDirection: 'row',
        marginTop: 10,
        height: 80,
        backgroundColor: '#FFFFFF',
        justifyContent: 'space-between',
        borderBottomWidth: 1,
        borderColor: 'lightgray'
    },
    listinside1Container: {
        flexDirection: 'row',
        justifyContent: 'flex-start',
        alignItems: 'center'

    },
    listContainer: {
        alignItems: 'flex-start',
        justifyContent: 'center',
        flexDirection: 'column',
        backgroundColor: '#FFFFFF',
        // borderBottomWidth: 1,
        // borderColor: 'lightgray'

    },
    listHeader: {
        color: 'black',
        fontFamily: 'Roboto-Medium',
        marginLeft: 10,
        fontSize: 18,
    },
    listValue: {
        fontFamily: 'Roboto-Regular',
        marginTop: 4,
        color: 'black',
        marginLeft: 10,
        fontSize: 14,
    },
    listImage: {
        alignSelf: 'center',
        height: 25,
        width: 25,
        margin: 10
    },
    listimgArrow: {
        // flex: 1,
        // flexDirection:'row',
        alignSelf: 'center',
        height: 25,
        width: 25,
        margin: 10
    },
    listVal: {
        borderWidth: 1,
        borderRadius: 10,
        color: 'darkgreen',
        borderColor: 'white',
        backgroundColor: 'white',
        fontWeight: 'bold'

    },

});

export default AtmBranchTypeSelect;

From the code I have, headerRight will be displayed in all scenarios. consider I have a scenario like based on state value I have to enable/disable headerRight Button .

for example this.state.stBool? headerRight:(.....) : null

I have to render in this way.Please guide me to achieve this.

A: You could nest the navigation options inside the render and toggle it based on the state value. Haven't tested and not positively on performace. Hope it helps.
import React, { Component } from "react";
import {
  View,
  TextInput,
  Text,
  TouchableOpacity,
  TouchableHighlight,
  StyleSheet,
  AsyncStorage,
  BackHandler,
  Image,
  FlatList,
  Dimensions,
  TouchableWithoutFeedback
} from "react-native";
import i18n from "../../i18n/i18n.js";
import { colors } from "../../constants/colors.js";
import Storage from "../../utils/AsyncStorage.js";

class AtmBranchTypeSelect extends Component {
  // Render callBack
  constructor(props) {
    super(props);
    this.state = {
      data: [],
      stBool: false
    };
  }
  async componentWillMount() {
    BackHandler.addEventListener("hardwareBackPress", () =>
      this.props.navigation.goBack()
    );
  }
  componentWillUnmount() {
    BackHandler.removeEventListener("hardwareBackPress", () =>
      this.props.navigation.goBack()
    );
  }

  _renderList = ({ item }) => {
    return (
      <TouchableWithoutFeedback onPress={event => this._selectedItem(item.key)}>
        <View style={styles.listRowContainer}>
          <View style={styles.listinside1Container}>
            <Image style={styles.listImage} source={item.icon} />
            <View
              style={styles.listContainer}
              onPress={event => this._selectedItem(item.text)}
            >
              <Text style={styles.listHeader}>{item.header}</Text>
              <Text style={styles.listValue}>{item.value}</Text>
            </View>
          </View>
          <Image
            style={styles.listimgArrow}
            source={require("../../resources/toolbar/chevron_right_grey.png")}
          />
        </View>
      </TouchableWithoutFeedback>
    );
  };
  // Render callBack

  render() {
    const { stBool } = this.state;
    const navigationOptions = ({ navigation }) => ({
      title: i18n.t("atmbranchpickHeader"),
      headerRight: stBool ? (
        <TouchableHighlight
          onPress={() => {
            navigation.navigate("home");
          }}
        >
          <Image
            style={{ marginRight: 20 }}
            source={require("../../resources/toolbar/home_white.png")}
          />
        </TouchableHighlight>
      ) : null,
      headerTintColor: "white",
      headerStyle: {
        backgroundColor: colors.themeColor
        //  top: 30
      }
    });
    return (
      <View style={styles.mainWrapper}>
        <FlatList data={this.state.data} renderItem={this._renderList} />
      </View>
    );
  }
}


text:
Q: How to transfer the date string from my DatePickerFragment? I get this source from another question in stackoverflow..
this is my fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#e1e1e1">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="55dp"
        android:scrollbars="vertical">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:padding="10dp">

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:background="#fff"
                android:padding="10dp"
                android:layout_marginBottom="10dp">

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:background="#fff">

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Set Reminder"
                        style="@style/Base.TextAppearance.AppCompat.Medium"
                        android:layout_marginBottom="5dp"
                        android:layout_marginTop="10dp"
                        android:textColor="#009cee"/>

                    <View
                        android:layout_width="fill_parent"
                        android:layout_height="1dp"
                        android:background="#e1e1e1"
                        android:layout_marginBottom="25dp"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Range Hari"
                        android:textStyle="bold"
                        android:textSize="16sp"/>

                    <EditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingTop="5dp"
                        android:inputType="number"
                        android:gravity="top"
                        android:textSize="16sp"
                        android:id="@+id/range"
                        android:ems="10" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Tanggal Awal"
                        android:textStyle="bold"
                        android:textSize="16sp"/>

                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:gravity="right"
                        android:orientation="horizontal"
                        android:background="#fff">

                    <EditText
                        android:layout_width="200dp"
                        android:layout_height="wrap_content"
                        android:paddingTop="5dp"
                        android:gravity="top"
                        android:textSize="16sp"
                        android:id="@+id/tanggalawaltxt"
                        android:ems="10" />

                    <Button
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:background="#EC407A"
                        android:textColor="#ffffff"
                        android:text="Set Tanggal"
                        android:textSize="14sp"
                        android:id="@+id/tanggal"
                        android:layout_marginBottom="15dp"/>

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:gravity="right"
                        android:orientation="horizontal"
                        android:layout_marginTop="20dp"
                        android:background="#fff">

                        <Button
                            android:layout_width="match_parent"
                            android:layout_marginLeft="10dp"
                            android:layout_height="wrap_content"
                            android:background="#009cee"
                            android:textColor="#ffffff"
                            android:text="Simpan"
                            android:textSize="14sp"
                            android:id="@+id/simpan"
                            android:layout_marginBottom="15dp"/>

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

        </LinearLayout>

    </ScrollView>

</LinearLayout>

and this is my DatePickerFragment.java
package com.example.gandi.symanlub;

/**
 * Created by mgd on 10/07/16.
 */

public class DatePickerFragment extends DialogFragment
        implements DatePickerDialog.OnDateSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);

// Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
    }

    @Override
    public void onDateSet(DatePicker view, int year, int month, int day) {
        Calendar c = Calendar.getInstance();
        c.set(year, month, day);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String formattedDate = sdf.format(c.getTime());
    }
}

and this is my setreminder.java
package com.example.gandi.symanlub;

public class Setreminder extends Fragment {

    Button btnshowtanggal;
    TextView tanggalawal;
    View rootview;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        rootview = inflater.inflate(R.layout.fragment_setreminder, container, false);

        btnshowtanggal = (Button)rootview.findViewById(R.id.tanggal);
        btnshowtanggal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment picker = new DatePickerFragment();
                picker.show(getActivity().getFragmentManager(), "datePicker");

                tanggalawal = (TextView) rootview.findViewById(R.id.tanggalawaltxt);

            }
        });

        return rootview;

    }

}

How to get the string of Datetimepicker selected date into tanggalawal (TextView) ?

A: 1) Make an interface in your SetReminder called DateListener with a method onDateSelected(Date date);
2) Make any Activity using the SetReminder Fragment to implement an interface SetReminder.DateListener.
3) In onAttach(Activity activity) in your SetReminder Fragment, check if the attaching Activity implements that SetReminder.DateListener, and if so intitalize your Fragment's DateListener.
4) Normally you'd want to extend your flow a bit, and maybe add a confirmation button by adding an AlertDialog before you actually call onDateSet on your listener.  In your case though, you could just call onDateSelected(Date date), add a delegate callback to your activity by calling
if (mDateListener != null){
   mDateListener.onDateSelected(calendar.getTime());
}

EDIT: for Dialog code example...you should be able to figure out how to implement the provided interface in your Activity and set it on the view that's listening for date updates.
public class DatePickerFragment extends DialogFragment
        implements DatePickerDialog.OnDateSetListener {

public interface DateTimePickedListener {
        void onDateTimePicked(String formattedDate);
    }

    DateTimePickedListener listener;

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if(activity instanceof DateTimePickedListener){
            listener = (DateTimePickedListener) activity;
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);

// Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
    }

    @Override
    public void onDateSet(DatePicker view, int year, int month, int day) {
        Calendar c = Calendar.getInstance();
        c.set(year, month, day);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String formattedDate = sdf.format(c.getTime());
        if(listener != null){
            listener.onDateSelected(formattedDate);
        }
    }
}


text:
Q: error installing npm@1.1.1 on Mac OS X Lion I am trying to get going with express framework on Mac OS X Lion.  Having these issues:
SilverFir-2:Node mike$ sudo curl http://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7881  100  7881    0     0  29556      0 --:--:-- --:--:-- --:--:-- 43541
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@1.1
fetching: http://registry.npmjs.org/npm/-/npm-1.1.1.tgz
0.6.1
1.1.1
cleanup prefix=/usr/local

All clean!
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm@1.1.1

npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Darwin 11.3.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/6x/frvx23td327frc2z_hgl12sc0000gn/T/npm.3230/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/6x/frvx23td327frc2z_hgl12sc0000gn/T/npm.3230/package
npm ERR! node -v v0.6.1
npm ERR! npm -v 1.1.1
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/usr/local/lib/node_modules'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/6x/frvx23td327frc2z_hgl12sc0000gn/T/npm.3230/package/npm-debug.log
npm not ok
It failed

Node version v0.6.1.
I looked around on the web and most of the answers are from node 0.4 days and they all just say upgrade.  It looks like I am more up to date than those previous questions...

A: When you do this:
sudo curl http://npmjs.org/install.sh | sh

You will run curl as root, but sh as your current user. You should do this instead:
curl http://npmjs.org/install.sh | sudo sh

And all will be well.


text:
Q: Angular monorepo error TS6059: File 'ng-youtube-api.service.ngtypecheck.ts' is not under 'rootDir'. 'rootDir' is expected to contain all source files I've created 3 angular libraries/packages:

*

*@example/ng-youtube-player containing a YoutubePlayerComponent and YoutubeApiService

*@example/ng-dailymotion-player containing a DailymotionPlayerComponent and DailymotionApiService

*@example/ng-vimeo-player containing a VimeoPlayerComponent and VimeoApiService
Now I wanted to create a library containing a VideoPlayerComponent, using only the packages providing the YoutubeApiService, DailymotionApiService and VimeoApiService. In order to not include the other components unnecessarily, I want to split the 3 libraries each, so that I can install only the Service classes.

You could argue that angular uses tree-shaking, so the components
will not be bundled with the application anyway, but anyhow I'd rather
have those dependencies seperated for brevity.

I've tried setting up a monorepo containing 2 libraries and a test application, but from the moment I reference a service from another library, the build fails. I've created a very basic example workspace to reproduce the issue:
git clone https://github.com/PieterjanDeClippel/angular-monorepo-test
cd angular-monorepo-test
npm install
ng build @mintplayer/ng-youtube-api
ng build @mintplayer/ng-youtube-player
ng build ng-youtube-player-demo

# All projects compile successfully
# Now go to the NgYoutubePlayerComponent and uncomment the injection parameter in the constructor (line 16)

ng build @mintplayer/ng-youtube-player

The build fails with tons of the following errors:
✖ Compiling with Angular sources in Ivy partial compilation mode.
projects/mintplayer/ng-youtube-api/src/lib/ng-youtube-api.service.ts:1:1 - error TS6059: File 'C:/Users/user/source/repos/Tmp/mintplayer-ng-youtube-player/projects/mintplayer/ng-youtube-api/src/lib/ng-youtube-api.service.ngtypecheck.ts' is not under 'rootDir' 'C:\Users\user\source\repos\Tmp\mintplayer-ng-youtube-player\projects\mintplayer\ng-youtube-player\src'. 'rootDir' is expected to contain all source files.
1 import { Injectable } from '@angular/core';

projects/mintplayer/ng-youtube-api/src/public-api.ts:1:1 - error TS6059: File 'C:/Users/user/source/repos/Tmp/mintplayer-ng-youtube-player/projects/mintplayer/ng-youtube-api/src/public-api.ngtypecheck.ts' is not under 'rootDir' 'C:\Users\user\source\repos\Tmp\mintplayer-ng-youtube-player\projects\mintplayer\ng-youtube-player\src'. 'rootDir' is expected to contain all source files.

There are 2 main problems here:

*

*You have to build each project seperately, in the correct order

*You cannot use services from libraries in other libraries

I've already read the following similar question, but it didn't help me out:

*

*'rootDir' is expected to contain all source files
Code
My test code is hosted here. All instructions to reproduce the issue are noted in the code block above. The main changes I made are in the root tsconfig.json:
{
  ...
  "compilerOptions": {
    ...,
    "paths": {
      "@mintplayer/ng-youtube-api": [
        "projects/mintplayer/ng-youtube-api/src/public-api.ts"
      ],
      "@mintplayer/ng-youtube-player": [
        "projects/mintplayer/ng-youtube-player/src/public-api.ts"
      ]
    }
  }
}

I've already setup a workspace containing a library and application, where the application consumes classes from the library without any problems (see the 3 repositories on top of the question), but from the moment a library consumes classes from another library, the build is broken.
How can I fix this, and have a single workspace with 2 libraries and a test application?

A: if you're using nx and have the errors reported by the op...
i also encountered this problem...
it was killing me... i couldn't figure out why nx didn't build right... it was giving me tons of errors about one of my referenced project @scope1/lib2 and all of its .ts files being outside the project that referenced it... i also noticed that the dep-graph had @scope1/lib2 but there was no dependency arrow from the referencing library...
i found this fix:
rm -rf node_modules/.cache

i'm guessing nx had something in the cache that was wrong... after deleting, the dep-graph finally showed the link properly and the build started working

A: Maybe I'm a little late here, but I was experiencing this problem here and I use just regular Angular CLI to manage my workspace...after searching A LOT and going through Typescript documentation on Module Resolution, I believe I understood what was going on:
Path mapping is a regular thing for Angular Libraries (especially when using a secondary entry-points strategy), but its behavior is a little tricky. Things get even more complicated when we have multiple libraries in the same workspace: sometimes the IDE goes crazy with errors; sometimes things look fine, but break during build; sometimes things are okay during the library's build, but it all explodes when building the consumer app/lib.
The problem is: consumers need the built version of the libraries to properly work, so they should be looking at the dist folder. The way I solved this was:

*

*Keep dev-time mappings (resolving to projects/...) in the root tsconfig.json

*Add mappings to built artifacts in the tsconfig used to build the consumer library (listed in angular.json configurations)

The IDE is happy, ng-packagr is happy hahahahh
Cheers!

A: After days of finding the reason for this bug, my error was due to webstorm importing the model file using incorrect import part.
import { Invoice } from "libs/invoicing/src/lib/invoice/invoice.model";
should have simply been
import { Invoice } from "../../../../invoice/invoice.model";

A: you are probably importing a module from outside your library's rootDir which mostly is src
example:
// src/file.ts
import something from '../../another-module' //<-- ouutside rootDir

A: This was basically a cache issue for me in an angular/nx monorepo. Solved it using
rm -rf node_modules/.cache

A: NX it is apparently: https://nx.dev. If you ever need to create an angular library, it's best to generate an NX project rightaway.
npm install -g @angular/cli@latest
npm install -g nx
npx create-nx-workspace
cd mycompany-ng-youtube-player

Generate a library for the youtube player:
nx g @nrwl/angular:lib mycompany-ng-youtube-player --buildable --publishable --import-path @mycompany/ng-youtube-player

Specify your package name and version in the package.json:
{
  "name": "@mycompany/ng-youtube-player",
  "version": "1.0.0",
  ...
}

Generate a library for the IFrame API:
nx g @nrwl/angular:lib mycompany-ng-youtube-api --buildable --publishable --import-path @mycompany/ng-youtube-api

Specify your package name and version in the package.json:
{
  "name": "@mycompany/ng-youtube-api",
  "version": "1.0.0",
  ...
}

Generate a component in the @mycompany/ng-youtube-player package:
cd .\libs\mycompany-ng-youtube-player\src\lib
nx g component ng-youtube-player --project=mycompany-ng-youtube-player --module=mycompany-ng-youtube-player --export

Generate a service in the @mycompany/ng-youtube-api package:
cd ..\..\..\mycompany-ng-youtube-api\src\lib
nx g service ng-youtube-api --project=mycompany-ng-youtube-api

Now you can add the package dependency to the package.json of the player:
{
  ...,
  "peerDependencies": {
    "@mycompany/ng-youtube-api": "~3.0.0",
    ...
  }
}

Now it's just a matter of modifying the code.
To build and run the application:
npm run nx run-many -- --target=build --projects=ng-youtube-player-demo --with-deps
npm run nx serve -- --open

Important note
If you're considering using NX, then you apparently need to bear the following in mind:

*

*Angular releases a new version (v14)

*Whoever uses your library, is waiting for you to release a @angular/core@v14 compatible version of your library

*You will be waiting for NX to support Angular 14

*NX is waiting for jest-preset-angular to release a v14 compatible version

*...


text:
Q: Setting TextInputLayout hint using html string As a follow up on this, I was trying to pass a html string to setHint() method of TextInputLayout. But it's not working.
Using that html string input to setText() method of a TextView is obviously working.
Going into the implementation of this method, in the parent method which is called at the end of setText() call (you can view the function here), I was trying to figure out what extra is being done here to handle that html string that can't be done in case of setting TextInputLayout hint. Maybe it's related to the BufferType argument that's passed here. Maybe not. I couldn't figure it out actually.
As we know, same parent method is called when you call setText() on an EditText.
Going into the detail of setHint() method of TextInputLayout, I was thinking that maybe it also uses an internal textview and using that, maybe we can somehow achieve it.
I saw that it uses an instance of the class CollapsingTextHelper. After looking into it for a while, I didn't go beyond it.
So, my question is, can we achieve it?  Can we set an html string to behave properly when it is set as a hint to the TextInputLayout.
Example html string : CharSequence text = "write any thing here write any thing here 2";.
So for this, hint should be displayed in appropriate colors as mentioned.


text:
Q: Cannot resolve method ´getDownloadUrl' I am new to Android Studio. I am having a problem with the code, and I don't know what it is since I am following a YouTube tutorial
of creating a user in Android plus Firebase. The problem is about the storage on Firebase.
My code:
public class Profile extends AppCompatActivity {
    private static final int CHOOSE_IMAGE = 101;
    EditText editText;
    ImageView imageView;
    String profileimageurl;
    Uri uriProfileImage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile2);

        editText = (EditText) findViewById(R.id.nome);
        imageView = (ImageView) findViewById(R.id.foto);

        imageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                showImageChooser();
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == CHOOSE_IMAGE && data != null && data.getData() != null) {
            uriProfileImage = data.getData();
            try {
                Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uriProfileImage);
                imageView.setImageBitmap(bitmap);

                uploadImageToFirebaseStorage();

            } catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

    private void uploadImageToFirebaseStorage() {
        StorageReference profileImageRef = FirebaseStorage.getInstance().getReference("profilepics/" + System.currentTimeMillis() + ".jpg");
        if (uriProfileImage != null) {
            profileImageRef.putFile(uriProfileImage)

            .addOnSuccessListener(new OnSuccessListener < UploadTask.TaskSnapshot > () {@Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    profileimageurl = taskSnapshot.getDownloadUrl().toString();

                }
            }).addOnFailureListener(new OnFailureListener() {@Override
                public void onFailure(@NonNull Exception e) {

}
            });
        }
    }

    private void showImageChooser() {
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Escohe a imagem de perfil"), CHOOSE_IMAGE);
    }

}

A: That method has been deprecated.
Use the storageReference to get the download url.
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
  @Override
  public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
      profileImageRef.addOnSuccessListener(new OnSuccessListener<Uri>() {
                                @Override
                                public void onSuccess(final Uri uri) {
                                    String downloadUri = uri;
  }  })

You can now use the downloadUri  String to load the image.


text:
Q: Merge 2 external hive tables into single new table I am new to hive. I have created 2 external hive tables and also imported data from oracle using sqoop. Also I have created a new external table which will have data of both External table 1 and External table 2 as follows
create external table transaction_usa_canada
(
tran_id int,
acct_id int,
tran_date string,
amount double,
description string,
branch_code string,
tran_state string,
tran_city string,
speendby string,
tran_zip int,
source_table string
)
row format delimited
stored as textfile
location '/user/gds/bank_ds/tran_usa_canada';

Now , I dont know how to merge the data of 2 external tables into above external table.
Please help.

A: If you have have same column structure for your 2 external table, then you can copy the text files to a common location or folder and create a new table that is pointing to new location.
If the metadata is different for 2 external table, you can consider the option of "create table  as select  " to load to new table.

A: You can use a union statement to read them into a new table.
    INSERT OVERWRITE TABLE [database].[table]
SELECT
*
FROM (
SELECT
Col_1 STRING,
Col_2 STRING,
Col_3 STRING
FROM
[table]
UNION ALL
SELECT
Col_1 STRING,
Col_2 STRING,
Col_3 STRING
FROM
[table]) [table];


text:
Q: Combine two Just values if present, else return first Just I want  a shorter way to write this block of code as this is going to be used in multiple places in a project I am working on. Is there a library I can use which would have a function for my specific need?
case mbData1, mbData2 of
       (Just data1, Just data2) -> Just $ mergeData data1 data2
       (Nothing, Just data2) -> Just data2
       (Just data1, Nothing) -> Just data1
       (Nothing, Nothing) -> Nothing

A: First, note that your expression only makes sense if mergeData x y has the same type as x and y each have, i.e. if its type is
mergeData :: X -> X -> X

for some concrete type X.
Given that, we can rely on Maybe's Applicative and Alternative instances:
mergeTwoMaybeDatas :: Maybe X -> Maybe X -> Maybe X
mergeTwoMaybeDatas a b = liftA2 mergeData a b <|> a <|> b

If you want to reuse this pattern many times but for different functions, and you think this is not clear, you could define a function parameterizing over mergeData.
But wait, maybe we can do something even simpler! If your mergeData function is associative (i.e., mergeData x (mergeData y z) = mergeData (mergeData x y) z), then your X type is a Semigroup, with mergeData as its combine operation. In that case, consider defining the Semigroup instance. Then you could use the tools designed for Semigroups to handle this even more simply.
data X = ...
instance Semigroup X where
  (<>) = mergeData

mergeTwoMaybeDatas :: Maybe X -> Maybe X -> Maybe X
mergeTwoMaybeDatas = (<>)

Amazing: if you give X its Semigroup instance, you don't even have to implement mergeTwoMaybeDatas at all - it's just how (<>) already behaves for a Semigroup lifted into Maybe.
I encourage giving your types instances of all the typeclasses they can reasonably support: you will find many generic tools like this then work on them "for free". Having a Semigroup instance will likely help out for some of your other uses of this X type as well.

A: You're looking for the salign function from the semialign package. Create a Semigroup instance for your type, with (<>) = mergeData (or inline its definition and just always call it this way), and then
just call salign mbData1 mbData2.


text:
Q: Excel data gets formated with only one DataFormat using poi I want to write some cells in excel using poi with a cuurency formatter and some with a number formatter. It seems that the whole document uses the formatting I pass to it in the constructData method, to the last cell. Why is that and how can I fix it? I believe the code is self explanatory but if you need help be free to ask :)
private static final int TITLE_COLUMN_WIDTH = 8500;
private static final int VALUES_COLUMN_WIDTH = 6000;
private static final float VALUES_ROW_HEIGHT_IN_POINTS = 26.25f;
private static final float HEADER_ROW_HEIGHT_IN_POINTS = 21.5f;
private static final String CURRENCY_DATA_FORMAT = "#,##0.00 \u20AC";
private static final String NUMBER_DATA_FORMAT = "#,##0";

private final String NO_STYLE_CURRENCY = "NO_STYLE";
private final String NO_STYLE_NUMBER = "NO_STYLE_NUMBER";
private final String LIGHT_GREY= "LIGHT_GREY";
private final String HEADER_BLUE = "HEADER_BLUE";

Map <String, HSSFCellStyle> styles = new HashMap<String, HSSFCellStyle>();

// there are other styles in this method that I call from buildHeader that don't seem to cause problems
private void populateStyles(Map <String, HSSFCellStyle> styles, HSSFWorkbook workbook){

    HSSFCellStyle noStyleWithCurrency = workbook.createCellStyle();
    noStyleWithCurrency.setDataFormat(workbook.createDataFormat().getFormat(CURRENCY_DATA_FORMAT));
    styles.put(NO_STYLE_CURRENCY,noStyleWithCurrency);

    HSSFCellStyle noStyleNumber = workbook.createCellStyle();
    noStyleNumber.setDataFormat(workbook.createDataFormat().getFormat(NUMBER_DATA_FORMAT));
    styles.put(NO_STYLE_NUMBER,noStyleNumber); }

private void ConstructData(HSSFWorkbook workbook,HSSFSheet sheet, List<Long> sortedProductNames, SalesGridModelBean model){

    Map<Long, String> productTypeNames = model.getProductTypeNames();
    Map<Long, SalesGridRowBean> gridRows = model.getGridRows();
    Long totalProductId = model.getTotalProductTypeId();
    List<SalesGridRowBean> sortedGridRows = sortAndMoveToList(gridRows, model.getTotalProductTypeId());

    int rowCount = 2;

    for(SalesGridRowBean row : sortedGridRows){
        HSSFRow dataRow = sheet.createRow(rowCount);
        dataRow.setHeightInPoints(VALUES_ROW_HEIGHT_IN_POINTS);
        int cellCount = 0;

        HSSFCell nameCell = dataRow.createCell(cellCount);
        nameCell.setCellValue(row.getName());

        if(productTypeNames.size() == 1){
            SalesBean salesBean = row.getSalesBeanForProductType(totalProductId);

            HSSFCell revenueCell = dataRow.createCell(++cellCount);
            revenueCell.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_CURRENCY)));

            revenueCell.setCellValue(salesBean.getRevenue());

            HSSFCell quantityCell = dataRow.createCell(++cellCount);
            quantityCell.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_NUMBER)));

            quantityCell.setCellValue(salesBean.getSales());

            HSSFCell averageCell = dataRow.createCell(++cellCount);
            averageCell.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_CURRENCY)));

            averageCell.setCellValue(salesBean.getAveragePrice());
        } else {
            SalesBean salesBean = row.getSalesBeanForProductType(totalProductId);

            HSSFCell revenueCell = dataRow.createCell(++cellCount);
            revenueCell.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_CURRENCY)));

            revenueCell.setCellValue(salesBean.getRevenue());

            HSSFCell quantityCell = dataRow.createCell(++cellCount);
            quantityCell.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_NUMBER)));

            quantityCell.setCellValue(salesBean.getSales());

            for(int j = 0; j < sortedProductNames.size(); j++){
                 salesBean = row.getSalesBeanForProductType(sortedProductNames.get(j));

                HSSFCell revenueCell2 = dataRow.createCell(++cellCount);
                revenueCell2.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_CURRENCY)));

                revenueCell2.setCellValue(salesBean.getRevenue());

                HSSFCell quantityCell2 = dataRow.createCell(++cellCount);
                quantityCell2.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_NUMBER)));

                quantityCell2.setCellValue(salesBean.getSales());

                HSSFCell averageCell = dataRow.createCell(++cellCount);
        // This seems to cause the problem. The last assignment !!!
       //If replaced with NO_STYLE_NUMBER uses that one
           averageCell.getCellStyle().cloneStyleFrom((styles.get(NO_STYLE_CURRENCY)));

                averageCell.setCellValue(salesBean.getAveragePrice());
            }
        }
        rowCount++;
        cellCount = 0;
    }
}

PS: I construct the headers of the file (first 2 rows) using the HEADER_BLUE style and it gives no error. I do that in a separate method.


text:
Q: How to fetch all DNS entries from JAVA application? As of now, I'm using the below code to get DNS name of the given IPAddress. Instead of  fetching it for each IPAddress in the network, I want to fetch all the DNS entries (IPAddress - HostName mapping) from the DNS Server in one go. Is it possible? If so, how to do it?
InetAddress addr = InetAddress.getByName(address);
dnsname = addr.getCanonicalHostName().trim();

A: From a public DNS server, there is no way to pull out all the data it holds. Enumerating all the IP addresses one by one is the only solution.
If you have a special relationship with the DNS server (for instance, it is managed by your employer), you may request from the DNS administrator a right to transfer the whole zone (the DNS request known as AXFR). They may authorize your IP address or gives you a TSIG key to authentify yourself.
Then, you will have to find a way to do a zone transfer (possibly with TSIG authentication) in Java. Using these keywords, I find some code and documentation. Use a code search engine like Google Code Search or Krugle to find examples of use.
[DNS experts will probably scream "Use zone walking on NSEC" but most DNS zones are not signed with NSEC.]


text:
Q: Range of values of $t$ for which $ 2\sin t = \frac{1-2x+5x^2}{3x^2-2x-1}\;,$ Calculation of Range of values of $t$ for which $\displaystyle 2\sin t = \frac{1-2x+5x^2}{3x^2-2x-1}\;,$ where $\displaystyle t \in \left[-\frac{-\pi}{2}\;,\frac{\pi}{2}\right]$
$\bf{My\; Try::}$ Given $\displaystyle 2\sin t = \frac{1-2x+5x^2}{3x^2-2x-1}\Rightarrow 6\sin t\cdot x^2-4\sin t \cdot x-2\sin t = 1-2x+5x^2$
$\displaystyle \Rightarrow (6\sin t-5)x^2+2(1-2\sin t)x-(2\sin t+1) = 0$ , Now for calculation of value of $2\sin t\;,$
equation must have real roots. So $\bf{D\geq 0}$.
So $4(1-2\sin t)^2+4(2\sin t+1)\cdot (6\sin t-5)\geq 0$
$\displaystyle (1-2\sin t)^2+(2\sin t+1)\cdot(6\sin t-5)\geq 0$
So we get $16\sin^2 t-8\sin t-4\geq 0\Rightarrow 4\sin^2 t-2\sin t-1\geq 0$
Now HGow can I solve after that, Help me
Thanks

A: i think the answer is $ t \in [\frac{3\pi}{10}, \frac{6\pi}{10}] \cup [\frac{11\pi}{10}, \frac{19\pi}{10}]$ if i have not made any silly arithmetic errors.
here are steps:
(a) establish that the range of the rational function on the right hand side of your equation is $(-\infty, \frac{1-\sqrt 5}{2}] \cup [\frac{1+\sqrt 5}{2}, \infty).$
(b) now your equation reads as $\sin t$ is in $[-1, \frac{1-\sqrt 5}{4}] \cup [\frac{1+\sqrt 5}{4}, 1].$ the solution to this equation is what i claimed at the beginning of this answer.
you can establish (a) by turning $k = {{1-2x + 5x^2} \over {3x2 -2x -1}}$ into a quadratic equation $(3k-5)x^2 -2(k-1)x -(k+1) = 0$ whose discriminant is $4(k^2 - k -1)$ which is positive for $k$  in the range $(-\infty, \frac{1-\sqrt 5}{2}] \cup [\frac{1+\sqrt 5}{2}, \infty).$

A: Hint: If we assume that $x$ can be any real number, then we know that $2\sin t$ can take values between -2 and 2. So the problem is then to find what possible values of the right hand side are, assuming it can't take all possible values. Given those, work out the arcsin of the values and the possible range of $t$ from that. You can factorize $3x^2-2x-1=(3x+1)(x-1)$ but $1-2x+5x^2$ doesn't have any real roots.

A: The final quadratic is an upward drawn parabola. You can solve for $4sin^2 t -2 sin t -1 =0 $ and take the values for t such that sint  >0 in [-$\frac{\pi}{2}$,$\frac{\pi}{2}$].
The roots are $\frac{1-\sqrt{5}}{4}$ and $\frac{1+\sqrt{5}}{4}$. So $\frac{1+\sqrt{5}}{4}$ =< sint  and sin t <= $\frac{1-\sqrt{5}}{4}$ in  [-$\frac{\pi}{2}$,$\frac{\pi}{2}$].Does this help?


text:
Q: Front-End disappears while creating a drop-down list in php populated by oracle database I am working on a CRUD web application. Using php and oracle database. I want to make a dropdown populated by the data in the database.
Here's the code.
queries.php
public static function getAllNames(string $mmid){
        $dbUser = "...";
        $dbPass = "...";
        $dbConn = "(DESCRIPTION = (ADDRESS = (PROTOCOL=TCP)(HOST=...)(PORT=...))(CONNECT_DATA=(SID=...)))";
        $conn = oci_connect($dbUser, $dbPass, $dbConn);
        $sql = oci_parse($conn,"SELECT * FROM mmPERSON where mmid = :mmid");
        oci_bind_by_name($sql, ':mmId', $mmId);
        oci_execute($sql, OCI_DEFAULT);
        oci_fetch_all($sql);
       $results = oci_result($sql, 'FNAME');
        return $results;
    }

roles.php
<?php
$mmid = filter_input(INPUT_GET, "fname");
require_once './pages/header.php';
require_once './functions/queries.php';
$nameArr = Queries::getAllNames($mmid);
?>

        <button type="button" class="close" data-dismiss="alert" aria-label="Close">×</button>

    <form class="cmxform" id="addroles">
        <legend>Add Roles</legend>
        Select Name
        <select class="form-control" name="names" id="names">
           <option selected disabled></option>
           <?php
            for ($i = 0; $i < count($nameArr); $i++) {
                echo '<option value="' . $nameArr[$i][''] . '">' . $nameArr[$i][''] . '</option>';
            }
           ?>
        </select>

    </form>

When I delete that line of code($nameArr = Queries::getAllNames($mmid);) from roles.php the frontend is visible else the page is blank. There is something wrong with that line of code. I've been trying to find out since past two days.
I am new to php. Please review the code. Any help would be appreciated.


text:
Q: Browserify/Watchify Cannot find module 'waypoints' I'm just starting with browserify.
When it's working it's brilliant.
But require()...ing some modules isn't working (by default).
I have this code:
var $ = require("jquery");
var gsap = require('gsap');
var waypoints = require('waypoints');

In the above. jQuery and gsap work and are imported. But waypoints doesn't. When waypoints is included I get the error:
Browserify Error { [Error: Cannot find module 'waypoints' from '/Users/mk/Sites/PROJECTNAME/app/scripts']

This happens with some random other modules too.
All modules installed with npm.
Using the browserify/watchify recipe from this page:
https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md
I have tried some fixes inspired by similar stack overflow questions but no luck so far.
Some answers suggest that there's is/was a bug with npm that might be responsible. If that's the case is there anything reliable I can do?
Happy to provide further info.

A: It's issue
Link to thread https://github.com/imakewebthings/waypoints/issues/458
use
require('waypoints/lib/noframework.waypoints.js')


text:
Q: How to load powershell profile from cygwin bash? So in cygwin bash I am able to type "powershell" to bring me into a powershell prompt but it won't load my powershell profile.ps1 due to not being able to execute scripts, but I can't set the execution policy in this prompt...
So I tried running the default powershell prompt (as administrator) and was able to set the execution policy to remote signed, but it doesn't affect the powershell within bash
what am I missing?

A: You could run this from your bash shell:
 powershell -ExecutionPolicy RemoteSigned
EDIT
For me this works without the dash before cmdlet so:

powershell ExecutionPolicy RemoteSigned

A: You can bypass this:
powershell -ExecutionPolicy bypass


text:
Q: Finding if a circle is fully contained within multiple triangles? In a game, an area is defined by triangles that never overlap, and characters are defined by circles.
How can I know whether the full character's collision circle is contained within these triangles?
Example image:

Here, the red parts are outside triangles, so the circle isn't contained within them. Is there an algorithm that can detect this?
I've only came up with "non-perfect" solutions, like sampling points at the border of the circle, then testing if each is inside a triangle.

A: So basically, the triangles form a domain with polygonal boundary and you want to check if a disk, defined by a center point and a radius is contained inside the domain. So if you start with the triangles, you have to find a way to extract the polygonal boundary of your domain and represent it as a 2D array (matrix) of shape n rows and two columns so that every row is the two coordinates of a vertex point of the polygonal boundary line and the points are ordered so that they are consecutive order along the boundary in a counterclockwise position, i.e. when you walk in a direction from point of index i to the next point i+1 the domain stays on your left. For example, here is the representation of a polygonal boundary of a domain like yours:
a = 4/math.sqrt(3)
Pgon = np.array([[0,0],
                 [a,0],
                 [2*a,-1],
                 [2*a+4,0],
                 [2*a+4,4],
                 [2*a,4],
                 [2*a,2],
                 [a,1],
                 [a,4],
                 [0,0]])

Observe that the first and the last points are the same.
In such a scenario, maybe you can try the following algorithm:
import numpy as np
import math

def angle_and_dist(p1, p2, o):
  p12 = p2 - p1
  op1 = p1 - o
  op2 = p2 - o
  norm_p12 = math.sqrt(p12[0]**2 + p12[1]**2)
  norm_op1 = math.sqrt(op1[0]**2 + op1[1]**2)
  norm_op2 = math.sqrt(op2[0]**2 + op2[1]**2)
  p12_perp = np.array([ - p12[1], p12[0] ])
  h = - op1.dot(p12_perp)
  theta12 = op1.dot(op2) / (norm_op1*norm_op2)
  theta12 = math.acos( theta12 )
  if h < 0:
    theta12 = - theta12
  if op1.dot(p12) > 0:
    return theta12, norm_op1
  elif op2.dot(p12) < 0:
    return theta12, norm_op2
  else:
    return theta12, h/norm_p12

def is_in_polygon(p, disk):
  o, r = disk
  n_p = len(p)-1
  index_o = 0
  h_min = 400
  for i in range(n_p):
    theta, h = angle_and_dist(p[i,:], p[i+1,:], o)
    index_o = index_o + theta
    if 0 <= h and h < h_min:
      h_min = h
  if theta <= math.pi/100:
    return 'center of disc is not inside polygon'
  elif theta > math.pi/100:
    if h_min > r:
      return 'disc is inside polygon'
    else:
      return 'center of disc is inside polygon but disc is not'

a = 4/math.sqrt(3)

Pgon = np.array([[0,0],
                 [a,0],
                 [2*a,-1],
                 [2*a+4,0],
                 [2*a+4,4],
                 [2*a,4],
                 [2*a,2],
                 [a,1],
                 [a,4],
                 [0,0]])

# A test example:
#disc = (np.array([3*a/4, 2]), a/4-0.001)
disc = (np.array([3*a/4, 2]), math.sqrt(3)*a/8 - 0.0001)

print(is_in_polygon(Pgon, disc))


text:
Q: Symbol in anonymous namespace when inspecting memory dump in Visual Studio Background
I have a bug report of some server written in C++. Bug report contains description of unexpected behavior and memory dump. Now I try fetch information from memory dump. I'm trying inspect memory content of that memory dump.
Problem
I was able to find pointer to object wish I wish to inspect to analyze issue. It is pointer to some interface. Now I know that this pointer points to object of some specific type which is defined in anonymous namespace. Sadly VS didn't deduce that tape (based on runtime information). The only thing VS shows me for this pointer to interface is contents of virtual table. So to inspect content of this object I have to instruct Visual Studio to cast down this pointer to that type. Problem is what should I type to satisfy Visual Studio.
Note since this is memory dump breakpoints or continuing an execution are not an option. I'm unable to reproduce issue ion my development environment, so this dump is my best chance to find the issue.
Adding to watches this:
(InterfaceImplementation*)(some_pointer->pointer_to_interafece)

Doesn't works since VS says:

identifier "InterfaceImplementation" is undefined

Possible solution
AFAIK anonymous namespaces actually generate a namespace with random name. So to solve my problem I should find a way to provide this generated random name so I can use full symbol name.
Question
Is there way to inspect symbols in anonymous namespace?
Can I find my symbol in anonymous namespace somehow to identify that namespace?

A: Ok I've got sudden epiphany.
Clue found
VS for this pointer shown me contents of virtual table. Happily function listed there were described in human readable form. for example:
        [0] 0x00007ff75595b0a0 {MyApp.exe!InterfaceImplementation<`anonymous namespace'::SystemApi>::`scalar deleting destructor'(unsigned int)}    void *

Solution
So yes I've forget to mention that InterfaceImplementation is actually a template, which instance represents either production or testable version (that it is way it depends in SystemApi).
So I just copy paste this part InterfaceImplementation<'anonymous namespace'::SystemApi> to the casting and now I see everything I need to see.


text:
Q: React map is not rendering names from array, only flickers because aync/await bug React is not rendering my mapped array after using asyn functions to call on API
I use the following useEffect to get characters into an array and set it as state  in setRelatedCharacters
 // Find related characters
  useEffect(() => {
    // for promise to work in useEffect. need to put async function inside then call it
    const relatedCharacters = async () => {
      // if data exist. set related characters array by calling utility function and wait for it
      if (data) setRelatedCharacters(await relatedSwapi(data.characters));
    };
    relatedCharacters();
  }, [data]);

Then, when logging relatedCharacters, I get an array of 17 objects(characters).
Next, I send a condition to wait until the array is full of characters and when full I try to map through the array and render a name for each object in array. However, it quickly flickers and then disappears. I have no idea why.
{!data && !relatedCharacters ? (
        <Loading />
      ) : (

hello
 // renders
 {console.log(relatedCharacters, "<= relatedCharacters")} // shows correct array

 {relatedCharacters?.map((character) => (

{character.name}
 //DOESN'T SHOW, SLIGHTLY FLICKERS ONLY
              ))}

)

-- EDIT FOR COMMENT --
Here is the entire code once taking away everything else
const Film = () => {
  const location = useLocation();
  const url = location.state.url;
  const index = location.state.index;
  const [data, setData] = useState(null);
  const [relatedCharacters, setRelatedCharacters] = useState(null);

  // Find related characters
// PROBLEM HAS TO BE HERE I THINK AS PROMISES AND SUCH ARE ACTING UP
const relatedSwapi = (data) => {
  let relatedArray = [];
  data.map(async (url) => {
    const related = await callSingleSwapi(url);
    relatedArray.push(related);
  });
  return relatedArray;
};

  useEffect(() => {
    const fetchCharacters = async () => {
      // if data exist. set related characters array by calling utility function and wait for it
      if (data) {
        const x = await relatedSwapi(data.characters);
        setRelatedCharacters(x);
      }
    };

    fetchCharacters();
  }, [data]);

  return (

                {console.log(relatedCharacters, "<= related Characters")} // RENDERS AND THEN GOES BACK TO NULL
                {relatedCharacters?.map((character) => (

{character.name}

                ))}

      )}

  );
};

export default Film;

Here is console.log(relatedCharacters)


text:
Q: Why doesn't Python logger display info or debug message at level logging.INFO? Can someone please explain to me why the .info() and .debug() calls do not print anything, even when it seems like they should? I feel like there is something very basic I'm not understanding, even after going through the logging module documentation...
$  python
Python 3.6.5 (default, Apr 25 2018, 14:23:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logger = logging.getLogger()
>>> logger.setLevel(logging.INFO)
>>> logger.warning('This is a warning. We should see it.')
This is a warning. We should see it.
>>> logger.debug('This is a debug message. We should not see it.')
>>> logger.info('This is an info message. We should... see it, right?')
>>> logger.setLevel(logging.DEBUG)
>>> logger.info('This is an info message. We should... see it, right?')
>>> logger.debug('Weird. So I guess we are not going to see this as well?')
>>>

A: It's logging, just not to terminal. If you want to see the logs output to your terminal (much like print), you need to add a handler:
logger.addHandler(logging.StreamHandler())

After doing so, logging should display to your terminal as expected.


text:
Q: Postgres - merge two tables with sum I have two tables with identical columns, a different number of lines. I need to merge these tables into one using client_id AND segment_name as the unique identifiers of a distinct entry, summing the user_count if there is a match between the two tables. Any help much appreciated.
table A

client_id | segment_name    | user_count
-------------------------------------
45845     | segment45877-58 | 2358
55255     | weather558      | 20
88890     | jobs-listing    | 558

table B

client_id | segment_name | user_count
--------------------------------------
45845     | segment45877-58   | 100
55255     | weather558        | 350
2454      | leonardo-da-vinci | 5465

table C (new)

client_id | segment_name      | user_count
-------------------------------------
45845     | segment45877-58   | 2458
55255     | weather558        | 370
88890     | jobs-listing      | 558
2454      | leonardo-da-vinci | 5465

A: You could try
CREATE TABLE C AS
       (SELECT client_id,
               segment_name,
               SUM(user_count) AS user_count
        FROM   (SELECT * FROM A UNION ALL
                SELECT * FROM B) Data
        GROUP  BY client_id, segment_name);