text:
Q: How can I remove regular months' obervations in an unstructured series in R? I have the following dataframe:
df = dput(sent_results_mp)
structure(list(Date = structure(c(11690, 11725, 11753, 11781,
11809, 11844, 11872, 11942, 11970, 11998, 12026, 12061, 12089,
12117, 12145, 12180, 12208, 12243, 12299, 12327, 12362, 12390,
12425, 12453, 12481, 12509, 12544, 12572, 12600, 12663, 12698,
12726, 12754, 12796, 12817, 12845, 12880, 12907, 12936, 12971,
13027, 13062, 13090, 13118, 13160, 13181, 13209, 13244, 13272,
13307, 13335, 13363, 13391, 13426, 13454, 13489, 13524, 13552,
13580, 13615, 13643, 13670, 13699, 13762, 13790, 13825, 13853,
13888, 13916, 13944, 13979, 14007, 14035, 14063, 14098, 14126,
14154, 14189, 14217, 14259, 14280, 14308, 14336, 14371, 14399,
14427, 14462, 14490, 14525, 14553, 14581, 14623, 14644, 14672,
14707, 14735, 14770, 14798, 14826, 14854, 14889, 14917, 14945,
14987, 15008, 15036, 15071, 15099, 15134, 15162, 15190, 15225,
15253, 15281, 15316, 15351, 15379, 15407, 15434, 15463, 15497,
15526, 15554, 15589, 15617, 15652, 15680, 15715, 15743, 15771,
15799, 15827, 15862, 15890, 15918, 15953, 15980, 16016, 16044,
16079, 16107, 16135, 16163, 16198, 16226, 16254, 16289, 16317,
16345, 16380, 16408, 16457, 16499, 16540, 16589, 16632, 16681,
16730, 16772, 16821, 16870, 16912, 16954, 17003, 17052, 17094,
17143, 17185, 17234, 17283, 17325, 17367, 17416, 17465, 17514,
17556, 17598, 17647, 17696, 17738, 17787, 17829, 17878, 17920,
17962, 17996, 18053, 18102, 18151, 18193, 18242, 18284, 18333,
18382, 18417, 18459, 18515, 18564, 18606), class = "Date"), Sentiment = c(0,
0, 0, 0, -0.0957529552593197, -0.239862173958995, 0, 0, 0, -0.188924269202003,
-0.091167278669553, 0, -0.135208666258976, -0.234113624774356,
-0.212585339838951, -0.105651305696646, -0.222774417797656, -0.159894235955241,
-0.138472470255942, -0.0585150174036769, 0.103711250566817, 0.22031952297964,
0.145250201234944, -0.0323994910462342, 0.111593250830965, 0.0295247989691986,
0, 0.212482042926666, 0.158605081733718, 0.191920529302748, 0.173414462996843,
0.216876858126887, 0.20756261971968, 0.154883876782037, 0.149137898593547,
0.142165761354657, 0.121643683652311, 0.143972172018566, 0.0657414955655748,
-0.0324914378153873, 0.22264327839293, 0.185010294208908, 0.200374287833188,
0.0673440137703783, 0.0929770244712388, 0.113554686221999, 0.182856427591615,
0.0934514885524806, 0.183617393098071, 0.0937019320979792, 0.159373306262786,
0.189215896294599, 0.112404940944111, 0.148174048572046, 0.141732287695358,
0.110064057625983, 0.0551168195596121, 0.123436755747825, 0.133480320068247,
0.101616646400401, 0.109118646472558, 0.13840615378245, 0.063620964728031,
-0.0929040604032753, 0.0213563501297979, 0.0477819585658106,
0.0521622996105026, 0.116380748001251, 0.0145928432680972, 0.130906487222809,
0.242361449110559, 0.122366901526266, 0.189549946862169, 0.121341708778681,
0.0275950455528882, 0.115830049217305, -0.00268196934335387,
-0.268667095406521, -0.270654675922787, -0.345097118931143, -0.201666970593853,
-0.197870820068962, -0.183318344286775, -0.256780314062594, -0.164952289086926,
-0.203040493784049, -0.0953052320370853, -0.0564353925542141,
-0.0595365444481821, -0.0391431509940865, -0.158559094494205,
-0.103666510741687, -0.0341276356813399, -0.145250783683547,
-0.0348102368055625, -0.11164828986622, -0.153872166218408, -0.172037964130696,
-0.143868340198388, -0.253504128423768, -0.161731136069997, -0.0757134096682664,
-0.24850284019793, -0.0241736860282622, -0.0497985627029049,
0.0267362983301218, -0.0288807405823324, -0.0216738497959909,
-0.0547198276698082, -0.0713004669575829, -0.179452611448087,
-0.0882044859593271, -0.262589845197242, -0.277194378086572,
-0.264553715711326, -0.259524252590977, -0.196382049608858, -0.0759425223156328,
-0.0361527200578723, -0.106850259008264, -0.286292773362804,
-0.25954572063577, -0.28324826826043, -0.290781100752149, -0.221078940043079,
-0.203717181838236, -0.156778915779193, -0.0518897691822025,
-0.192229960033653, -0.170680784237861, -0.270654390695637, -0.305547637220867,
-0.077830807264447, -0.142463997328291, -0.111816767186701, -0.0969791693314262,
-0.0977361569524874, -0.273767496166023, -0.25730447171265, -0.271029007126539,
-0.252917481283751, -0.242632588726111, -0.0811418391092237,
-0.215566014069223, -0.362387647325206, -0.270342963775206, -0.314850509295431,
-0.337486756477923, -0.285711580880554, -0.340974038135234, -0.331945731128118,
-0.304930629110979, -0.150278570470029, -0.283028615895731, -0.277429801826168,
-0.185458849789886, -0.277688809057794, -0.22402331728913, -0.375964402684551,
-0.255242751090043, -0.344736427759783, -0.309107710644531, -0.293704494677478,
-0.243479266198671, -0.245051446889861, -0.231687103050292, -0.350613730820339,
-0.169486098633503, -0.311849636896508, -0.223447284729041, -0.119431392144917,
-0.275098935303954, -0.22189613629342, -0.299753093156644, -0.213188459452649,
-0.194131767679836, -0.293604768058008, -0.235407074042252, -0.304132799905395,
-0.34748336796163, -0.362535972556536, -0.321477097322425, -0.364037876416921,
-0.313450665525883, -0.294676350612345, -0.254149309015538, -0.232363154687674,
-0.313000245989788, -0.326964317594564, -0.26214055036952, -0.268116079703687,
-0.267480139301619, -0.319864093982952, -0.360481609256352, -0.314464988256011,
-0.298918676729976, -0.278082463263552, -0.270358321007133, -0.328174016516938
)), class = "data.frame", row.names = c(NA, -199L))

This dataframe is not regular in its frequency. With the following code, you can see the missing months in the series that would have made it monthly:
missingMonths <- lapply(split(df,format(as.Date(df$Date),"%Y")),
                        function(x) month.name[setdiff(seq(12),as.numeric(format(as.Date(x$Date),"%m")))])

missingMonths

# this is from 2015 to 2020

$`2015`
[1] "February" "May"      "August"   "November"

$`2016`
[1] "February" "May"      "August"   "November"

$`2017`
[1] "February" "May"      "August"   "November"

$`2018`
[1] "February" "May"      "August"   "November"

$`2019`
[1] "February" "May"      "August"   "November"

$`2020`
[1] "February" "May"      "August"   "November"

I only printed the missing months from 2015 to 2020 because they show a pattern, i.e. always the same four months come up. What I would like to do is to make the observation missing for the same months in previous years as well. Let me take an example. This is the series in 2014, with no missing months:
          Date   Sentiment
140 2014-01-09 -0.27102901
141 2014-02-06 -0.25291748
142 2014-03-06 -0.24263259
143 2014-04-03 -0.08114184
144 2014-05-08 -0.21556601
145 2014-06-05 -0.36238765
146 2014-07-03 -0.27034296
147 2014-08-07 -0.31485051
148 2014-09-04 -0.33748676
149 2014-10-02 -0.28571158
150 2014-11-06 -0.34097404
151 2014-12-04 -0.33194573

# Yet, I want to remove the observations for February, May, August and November by taking the mean with the previous month. I would get:

          Date   Sentiment
140 2014-01-09  # this should be the mean between jan and feb
142 2014-03-06 -0.24263259
143 2014-04-03  # this should be the mean of april and may
145 2014-06-05 -0.36238765
146 2014-07-03  # this should be the mean of july and august
148 2014-09-04 -0.33748676
149 2014-10-02  # this should be the mean of october and november
151 2014-12-04 -0.33194573

This should be applied to all the years.
Can anyone help me?
Thanks!

A: If you want to remove the months manually from the complete data you could do :
library(dplyr)
missingMonths <- c(2, 5, 8, 11)

df %>%
  group_by(group = cumsum(!as.numeric(format(Date, '%m')) %in% missingMonths)) %>%
  summarise(Date = first(Date),
            Sentiment = mean(Sentiment)) %>%
  select(-group)

#    Date       Sentiment
#   <date>         <dbl>
# 1 2002-01-03    0
# 2 2002-03-07    0
# 3 2002-04-04   -0.0479
# 4 2002-06-06   -0.240
# 5 2002-07-04    0
# 6 2002-09-12    0
# 7 2002-10-10   -0.0945
# 8 2002-12-05   -0.0912
# 9 2003-01-09   -0.0676
#10 2003-03-06   -0.234
# … with 141 more rows

A: You may exploit the months function. Analogously, we may use substr to get the years. This enables us to use table to count zero values z which we use for subsetting.
z <- rowSums(with(df, table(months(Date), substr(Date, 1, 4))) == 0)
res <- df[months(df$Date) %in% names(z[z == 0]), ]
head(res)
#         Date  Sentiment
# 1 2002-01-03  0.0000000
# 3 2002-03-07  0.0000000
# 4 2002-04-04  0.0000000
# 6 2002-06-06 -0.2398622
# 7 2002-07-04  0.0000000
# 9 2002-10-10  0.0000000

Check:
with(res, table(months(res$Date), substr(res$Date, 1, 4)))
#          2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
# April       1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
# December    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
# January     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
# July        1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
# June        1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
# March       1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
# October     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1

Edit
To impute as described in comment below you could use a "flag" to calculate the mean, then delete flagged rows afterwards.
res2 <- within(df, {
  flag <- ifelse(months(Date) %in% names(z[z == 0]), 0, 1)
  Sentiment <- ave(Sentiment, cumsum(flag == 0), FUN=mean)
})

res2 <- res2[res2$flag == 0, 1:2]
head(res2)
#         Date   Sentiment
# 1 2002-01-03  0.00000000
# 3 2002-03-07  0.00000000
# 4 2002-04-04 -0.04787648
# 6 2002-06-06 -0.23986217
# 7 2002-07-04  0.00000000
# 9 2002-10-10 -0.09446213


text:
Q: How to do localization? im really neww to the term localization, can any one of you expound, i've been searching for good references. can anyone of you provide me some good references or can anyone of you explain about this matter to give me more insights

A: Basically you just need to create a seperate strings.xml file for every language you want to support.
Your fallback language is in the directory res/values. Your german translation would be in res/values-de, the spanish one in res/values-es and so on.
Read also the official documentation about that.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Transform connection string depending on data centre for Azure SQL database I am converting a single data centre .NET app to be geo-distributed. Currently there is one web app running in IIS on a single VM. It connects to a single database server using a connection string in the config.
I already use config transform for dev, UAT and production, which get applied from my build server at deploy time.
In the geo-distributed setup, the web app will be deployed to 2 or more (possibly up to 10) different data centres.
Each data centre will hold geo-replicated Azure SQL databases.
I need each VM in each data centre to hit the Azure SQL database located in that same data centre.
I don't want to have to create a configuration in my project for each data centre, specifying a different connection string in each config transform. This is not maintainable or scaleable.
Example
| Data centre      | VM  | DB server                |
| -------------    |-----| -------------------------|
| UK South         | VM1 | db1.database.windows.net |
| South Central US | VM2 | db2.database.windows.net |
| West US          | VM3 | db3.database.windows.net |
| West Europe      | VM4 | db4.database.windows.net |
| ...              | ... | ...                      |

As you can see the server name for each db server is different and that is a requirement on Azure SQL. You can't use the same name in different data centres because the name is global.
I haven't been able to find a way to map 1 connection string to each of the above db server names.
Azure Traffic Manager is able to do the geo DNS for you, but Azure SQL demands that you include the server name (db1, db2...) in the connection string (as part of the "server name" or with the "login" e.g. "user@db1").
What's the best way to approach this? Is my only option to create a config transform for each data centre, or is there another way?

A: I'm not aware of any baked in feature that matches up SQL Azure geographically distributed database with a corresponding region to output the correct connection string (I could be wrong). The only geographically aware database I'm aware of (in azure) is CosmosDB.  Instead of writing this type of feature yourself, one that I suspect would be fragile and add overhead, I would suggest approaching it from a different direction.
You mention your build environment. It's very common for the same code to have different settings based on the region it's deployed to and I generally manage these as part of the CI\CD pipeline. When an app gets deployed (via the pipeline) it updates the setting for that region as part of the deployment to that specific region.  If you deploy to new regions you simply update your CI\CD with the correct connection string. Same rules apply to dev\stage etc.  Manage the complexity in your build and keep it simple everywhere else.

A: I know you've looked into ATM a bit, but this technically can be done with custom urls and Azure Traffic Manager. This should get you around the connection string issues.
Obtain a custom domain and map it an Azure ATM.  Add the four database urls to the ATM as external endpoints and you should have enough info for the Azure SQL connection string; if you do an nslookup on the custom ATM url, you'll see one of your 4 database urls in the Alias list complete with the DB server name.
Caveat Emptor on Geo routing with Azure TM.  It's been wildly inaccurate for me for cases where we don't own the IP.  You could also use Performance routing, but that will not 100% guarantee your going to be routed to the closest DB Server.


text:
Q: The Importance Of Good Teachers and Guidance In the Academics I'm a first year student for a math degree. I'm very curious on how good students overcome their bad teachers in the journey of learning and grasping the courses material fully, all in the pressure of the semester.
Assuming many of you went through this roud - how did you overcome this obstacle, while still getting good grades and good understanding of the course material?
What do you think is the importance of good guidance?
I personally feel very discouraged by this fact; Maybe bad teachers are a good thing in the sense that it will filter only the best students who are truly gifted? Maybe only the brightest students should succeed in their journey at understanding the mystery of math at the academic level?

A: As a student, I found there to be a remarkably similarity in the effect of good and bad teachers on my own learning.
In a lecture by a good teacher I thought, "Yes, yes, I understand."
Then I went home and found that I didn't understand as well as I thought and needed to do some work.
In a lecture by a bad teacher I thought, "I don't understand. In fact, this seems to be all wrong."
Then I went home and had to do some work to find out what, if anything, was wrong.
In either case, I found the most important factor was my own struggle, alone, with many good books at hand.${}^\dagger$
A good teacher is like a good guide on a trek.
He/she is sure-footed, knows the landscape, takes you to the scenic views, points out the dangers, and gets you to your destination.
However, your guide will not carry you.
You are the one that must take in the views and put one foot in front of the other.
And very soon you will be traveling this region without your guide, so you'd better remember the lay of the land!
One last remark on "good" and "bad" teachers.
I found it useful as a student to give my professors the benefit of the doubt---I recommend trying to remain agnostic about how "bad" a teacher is.
Ultimately, you must own the material and no matter how "good" your teacher is, he/she can't do it for you.
(In fact, a "good" teacher may lull you into thinking that you understand something you don't.)
Your teacher knows much more than you and is trying to instill that knowledge as best he/she can.
If your teacher is covering the material and not making too many wrong statements he/she isn't half bad.
To succeed at university, you should know your goals (degrees, research projects, what happens after graduation, etc.) as well as the obstacles that you must navigate (university rules, etc.) to achieve those goals.
A good advisor helps you to come up with a realistic set of appropriate goals and to navigate the obstacles, and may even give you a well-timed kick in the seat.
An advisor can be moderately to very important depending on the person.
I wish you luck in your studies.

${}^\dagger$ This struggle is often more successful and enjoyable with fellow students.
And, of course, make good use of your teacher's office hours and whatever other educational services are available at your school.
Lastly, consider becoming a tutor yourself.
You will be exposed to different ways of thinking about a subject and will uncover holes in your understanding that you will be strongly motivated to patch up.

A: What I am doing (I'm a third year) is reading books - If you don't know what fits the course ask the lecture or take recommendations from freinds or even this forum here.

A: I am graduating in December and have had my rough patches throughout my undergraduate years. When you have a bad teacher, it is more important than ever that you take it upon yourself to go get outside help, go to office hours, organize a study group, anything else you can think of.
Something I've discovered is that most professors who are terrible in the classroom are really good in their office hours, just make sure you go in with specific questions, going in blank won't help you and will annoy your professor. Do most of your homework, have an idea of what you don't understand and ask your professor to clarify.
Many schools offer some sort of free tutoring somewhere on campus, see if you can find it and go there for help.
Finally, get into a study group with your classmates, meet to work together on your homework and study for tests.


text:
Q: Right Triangle Trig I need to find the measure of each angle indicated and round to the nearest tenth.
I am given two sides 12 and 13 and one angle C which is 90 degrees. How do I figure this out?

A: Since you have a triangle with an angle of $90^\circ$, you have a right triangle.
That means you'll want to use the Pythagorean Theorem. (HINT!)
The side opposite the right angle is the longest side: the hypotenuse with length $c$. In your case, we have $c = 13$. The other two sides of the right triangle that meet at the right angle are its legs: say they are of length $a, b$: In your triangle, $a$ is the side opposite angle $A$, and $a$ is unknown; $b$ is the side opposite angle $B$ and $b = 12$. Then we know that $$a^2 + b^2 = c^2\tag{Pythagorean Theorem}$$
Solving for $a$ will give you the length of the side opposite side $A$. To find the measures of the unknown angles, you can use the trigonometric relations given by "TOA SOH CAH" (ask me if you need to, what this means) to determine the two unknown angles.
TOA: $\text{tangent} = \dfrac{\text{opposite}}{\text{adjacent}}$ $\quad \tan A = \dfrac{a}{12}$
SOH: $\text{sine} = \dfrac{\text{opposite}}{\text{hypotenuse}}$ $\quad \sin B = \dfrac{12}{13}$
CAH: $\text{cosine} = \dfrac{\text{adjacent}}{\text{hypotenuse}}\;\;$ E.g.,$\quad \cos B = \dfrac{a}{13}$
You will need only to know one angle, using, say, $B =\sin^{-1}\left(\dfrac{12}{13}\right)$ to find its measure. Then you can solve for $A$ since the sum of the angles of any triangle is standard Euclidean Geometry is $180^\circ$: $$A + B + C = A + B + 90 = 180$$

A: First use Pythagoreas' theorem to find the side of the last side. By the SOH CAH TOA rule, $\sin \theta=\frac{opposite}{hypotenuse}\implies \sin^{-1}(\theta)=\square $degrees. And then since there are 180 degrees in a triangle, $180-90-\text{(the angle you found)}$= the other angle measure for the last angle. Also if you didn't want to find the last angle that way, you could have just used SOH CAH TOA again, just like you are going to do for the second step of this problem.

A: You can use laws of sine (http://www.transtutors.com/math-homework-help/laws-of-triangle/)
12/ Sin B = 13 / Sin 90
Sin B = 12 / 13
From here you can calculate Angle B and then using A + B + C = 180
Calculate Angle A


text:
Q: How to use Select query in encode decode function postgresql I have checked on web I got one example like
select convert_from(decode(encode('abc', 'base64'), 'base64'), 'UTF8');

now I want to decode my string so I am trying the same with below mentioned
select convert_from(decode(encode((select resumestring from submitapplications where id=1030), 'base64'), 'base64'), 'UTF8');

ERROR:  function encode(text, unknown) does not exist

LINE 1: select convert_from(decode(encode((select resumestring from ...

A: SELECT
    convert_from(
        decode(
            encode(
                convert_to(
                    (
                        select resumestring from submitapplications where id=1030
                    ),
                    'UTF-8'
                ),
                'base64'
            ),
            'base64'
        ),
        'UTF8'
    )


text:
Q: TypeError: Cannot read property 'update' of undefined The following line of code from my Cloud Function was working fine last year.
event.data.adminRef.update({fromDB:1})
After a year of inactivity, I redeployed my function today (after updating everything) and I get the following error:
TypeError: Cannot read property 'update' of undefined
So, I changed it to this:
change.adminRef.update({fromDB:1})
But, I still get the same error.
What has changed since last year? How can I fix this?

A: The adminRef property was present in the beta version of the firebase-functions library, but it was removed in the 1.0 version. You can now just use the ref property to get the same behavior.
See the section adminRef replaced by ref in the documentation on upgrading from beta to version 1.0 or higher. That also shows other things that have changed, and which you may have to update in your code.


text:
Q: Get duration of using app for user from log table I have a table in which I'm recording logins/logouts. Schema and sample data: http://sqlfiddle.com/#!2/e1b35/1
I need to create stored procedure which will print sum of (logout-login) times for an user and date (duration of using application for user on date). In column type I represents login and O logout.
Input parameters: @username, @date. Output: time.

A: You need to identify all groups of logins that are related to each other.  The way I would do this is by finding the logout associated with logins.  You are dealing with log data, so don't be surprised if there are multiple logins with no logout.
select l.*,
       (select min(l2.time) from logs l2 where l2.username = l.username and l2.type = 'O' and l2.time > l.time
       ) as logoutTime
from logs l
where l.type = 'I'

Now, you can use the username and LogoutTime as a pair for aggregation to get what you want:
select username, logoutTime, min(time) as StartTime, logouttime as EndTime,
       datediff(s, min(time), logoutTime) as TimeInSeconds
from (select l.*,
             (select min(l2.time) from logs l2 where l2.username = l.username and l2.type = 'O' and l2.time > l.time
             ) as logoutTime
      from logs l
      where l.type = 'I'
     ) l
group by username, logoutTime

Note that you specify SQL Server as a tag, but the SQL Fiddle is for MySQL; date functions tend to differ among databases.
And, if you are using SQL Server 2012, there is an easier way.  You should specify that if it is the case.

A: This is Gordon Linoff's solution, modified so it doesn't include the outermost level of aggregation, and uses clearer aliases, IMO
select username,time_in,time_out_min,
       datediff(s, time_in, time_out_min) as TimeInSeconds
from (
select i.username, i.time as time_in,
       (select min(o.time) as min_time_out
        from logs o
        where o.username = i.username and
        o.type = 'O' and
        o.time > i.time
       ) as time_out_min
from logs i
where i.type = 'I'
  ) d;


text:
Q: Getting the locations from a MySQL database and displaying them on a map How can I get locations from a Mysql database and display them on a android app showing a marker on the map?
I have a custom Google map that currently gets the locations from an array or javascript variable named locations. I want the data to no longer be enter manually, but to be inserted dynamically from a database. How can I go about achieving this? I am using the Google map Api.
Thanks in advance

A:     inside your MapActivity instanciate LocationListener.
    under onLocationChange(Location location) insert your method to insert data in mySQL.
    everytime you request for new location it will automatically save the location to your database

        public void Connected(){
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection(CONN, USER, PASSWORD);
            System.out.println("CONNECTION ZERO::::"+connection);
        } catch (SQLException e) {
            e.printStackTrace();
//            Toast.makeText(this, "asdasd", Toast.LENGTH_SHORT).show();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

public void getLocation() {
        locationManager = (LocationManager) this.getSystemService(LOCATION_SERVICE);
        isGpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            return;
        }

        if (isGpsEnabled) {
            if (location == null) {
                locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 25000, 0, MainActivity.this);
                if(locationManager != null){
                    location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                }

            }
        }
        if(location == null){
            if(isNetworkEnabled){
                locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,25000 , 0, ll);
                location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            }
        }
        if(location == null){
            location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }
        if(location != null){
            locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,25000 , 0, ll);
        }
    }

LocationListener ll = new LocationListener();
    @Override
    public void onLocationChanged(Location location) {
        System.out.println(location.getLatitude()+",:::::::::"+location.getLongitude());
        Constants.LONGITUDE = location.getLongitude();
        Constants.LATITUDE = location.getLatitude();
        Toast.makeText(this, ":::::::::::::::::::::::::onchangelocation::::"+Constants.LATITUDE+","+Constants.LONGITUDE+",\n"+location.getProvider(), Toast.LENGTH_LONG).show();

                                    try {
//                                    Connected();
                                        String query = " insert into myusers_tbl (latitude, longitude)"
                                                + " values (?, ?)";
                                        preparedStatement.setDouble(5, Constants.LATITUDE);
                                        preparedStatement.setDouble(6, Constants.LONGITUDE);
                                        System.out.println("prepared statement"+preparedStatement);
                                        System.out.println("::::"+preparedStatement .executeUpdate());
                                        connection.close();
                                    } catch (SQLException e) {
                                        e.printStackTrace();
                                        System.out.println("::::::::"+e);
                                    }
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {

    }

    @Override
    public void onProviderEnabled(String provider) {

    }

    @Override
    public void onProviderDisabled(String provider) {

    }

private static final String USER = "username";
private static final String PASSWORD = "password";
private static final String CONN = "jdbc:mysql://localhost:3306/database";


text:
Q: Yii2: model not loading array I am using the following (simple) code for a model to be used with a form in yii2:
class ChooseAgeCategoriesForm extends Model
{

    public $ageCategories;

    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            ['ageCategories', 'safe'],
            [['ageCategories'], 'each', 'rule' => ['integer']],
        ];
    }
}

However, then trying to load the model like this:
$model = new ChooseAgeCategoriesForm();

if ($model->load(Yii::$app->request->post())) {
        $acIDs = $model->ageCategories;
}

The code is never executed. In fact, $model->load returns Bool(false) but $model->errors is empty. Dumping the content of post yields this result:
array(2) { ["_csrf"]=> string(56) "SzhjdWIuc0oIQSA0BEs4BDp8KzYEXwM5CG80RhNBRDkPUzIXO1gBew==" ["ageCategories"]=> array(9) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" [3]=> string(1) "4" [4]=> string(1) "5" [5]=> string(1) "6" [6]=> string(1) "7" [7]=> string(1) "9" [8]=> string(2) "10" } }

So yes, the field is actually sent and filled with an array of numbers. What don't I see here, what is the problem? Thanks in advance. I also tried to add ['ageCategories', 'exist', 'allowArray' => true], as another rule, but this does not work either. Any ideas?
Form code
As requested, the code of the form itself:
<?php $form = ActiveForm::begin([
    'action' => Url::to(['/result/team-result']),
    'method' => 'post',
    'options' => ['id' => 'chooseAgeCategory', 'style' => "margin-bottom: 15px;"]
]); ?>

<?= Select2::widget([
    'name' => 'ageCategories',
    'id' => 'ac-id',
    'value' => $acIDs,
    'data' => ArrayHelper::map(AgeCategory::find()->all(), 'id', 'name'),
    'options' => ['multiple' => true, 'placeholder' => Yii::t('view', 'Select Age Category')],
    'pluginEvents' => [
        "change" => "function() { this.form.submit(); }",
    ]
]) ?>

<?php $form->end(); ?>

A: I would suggest you use the Select2 using the model attribute, so that would be automatically linked to the field easing the loading process and also using your model's validation functions:
<?= Select2::widget([
    'name' => 'ageCategories',
    'id' => 'ac-id',
    'value' => $acIDs,
    'data' => ArrayHelper::map(AgeCategory::find()->all(), 'id', 'name'),
    'options' => ['multiple' => true, 'placeholder' => Yii::t('view', 'Select Age Category')],
    'pluginEvents' => [
        "change" => "function() { this.form.submit(); }",
    ]
]) ?>

A: Please change your select2 widget code like below. Yii2 wrapping model name with field name like

ChooseAgeCategoriesForm[ageCategories]

If you inspect your form you will come to know. SO you have to give model value in the select2 widget.
<?= Select2::widget([
    'model' => $model,
    'attribute' => 'ageCategories',
    'id' => 'ac-id',
    'value' => $acIDs,
    'data' => ArrayHelper::map(AgeCategory::find()->all(), 'id', 'name'),
    'options' => ['multiple' => true, 'placeholder' => Yii::t('view', 'Select Age Category')],
    'pluginEvents' => [
        "change" => "function() { this.form.submit(); }",
    ]
]) ?>

Ref: http://demos.krajee.com/widget-details/select2


text:
Q: How do I get a list of all font features supported by current font With LuaTeX, how do I get a list of OTF features supported by the current font in use printed?
For example, with otfinfo, I can get a list of OTF features by otfinfo -f font_file_name. Can I do anything similar with LuaTeX?
The goal is to produce such a list for each font I tested. For example, I would like to have such a macro,
\def\listfontfeatures{
 \directlua{... some lua code to list font features to a string, say ff ...}
 \directlua{tex.print(ff)}
}

And use it like the following,
Times Ten LT Std: \fontspec{Times Ten LT Std} \listfontfeatures \par
Palatino LT Std:  \fontspec{Palatino LT Std}  \listfontfeatures \par
Minion Pro:       \fontspec{Minion Pro}       \listfontfeatures \par

Update 12/01/2017
Here's just a small improvement to michal.h21's answer, just in case anyone will be interested.
fontspec_if_feature actually tests font features for the currently selected font family instead of the currently selected font. Normally this makes little difference and I only noticed this recently. For some fonts, different shapes have different features. For example, the italics may have swashes while the roman fonts lack it.
Below is a few macros that I now use for font feature test. It only work for LuaTeX. some modifications to the FontName macro is needed to make it to work with XeTeX.
\ExplSyntaxOff % remove the necessity to use ~ for space
\NewDocumentCommand\FontName{}{%
  \directlua{
    local i = font.current()
    local f = font.getfont(i)
    local n = f.fullname
    tex.sprint(n)
  }%
}
\ExplSyntaxOn

% Setup a new font family whose "n/m" shape is the current font.
% Limitations: The contents of the true/false clauses will be
% set in current fonts without any features selected by default,
% and it will be set in a group. For myself, this was intentionally.
\NewDocumentCommand\FontFeatureTF{m +m +m}{
  \group_begin:
  \fontspec_set_family:Nnn\thisfont:{}{\FontName}
  \fontfamily\thisfont:\selectfont
  \fontspec_if_feature:nTF{#1}{#2}{#3}
  \group_end:
}

\NewDocumentCommand\FontFeatureT{m +m}{
  \FontFeatureTF{#1}{#2}{\prg_do_nothing:}
}

\NewDocumentCommand\FontFeatureF{m +m}{
  \FontFeatureTF{#1}{\prg_do_nothing:}{#2}
}

A: On Linux it is simple and I suppose that Windows has a similiar command
voss@shania:~/.fonts/Junicode> otfinfo -f Junicode.ttf
c2sc    Small Capitals From Capitals
calt    Contextual Alternates
case    Case-Sensitive Forms
ccmp    Glyph Composition/Decomposition
dlig    Discretionary Ligatures
fina    Terminal Forms
frac    Fractions
hist    Historical Forms
hlig    Historical Ligatures
kern    Kerning
liga    Standard Ligatures
mark    Mark Positioning
mgrk    Mathematical Greek
mkmk    Mark to Mark Positioning
onum    Oldstyle Figures
rtlm    <unknown feature>
salt    Stylistic Alternates
smcp    Small Capitals
ss01    Stylistic Set 1
ss02    Stylistic Set 2
ss04    Stylistic Set 4
ss05    Stylistic Set 5
ss06    Stylistic Set 6
ss07    Stylistic Set 7
ss08    Stylistic Set 8
ss09    Stylistic Set 9
ss14    Stylistic Set 14
ss15    Stylistic Set 15
ss18    Stylistic Set 18
ss19    Stylistic Set 19
ss20    Stylistic Set 20
subs    Subscript
sups    Superscript
swsh    Swash

A: You can use the ConTeXt script mtxrun to get this information:

$mtxrun --script fonts --info --list --name --pattern="*Cambria*"

mtx-fonts       |
mtx-fonts       | mapping : cambriaitalic
mtx-fonts       | fontname: cambriaitalic
mtx-fonts       | fullname: cambriaitalic
mtx-fonts       | filename: cambriai.ttf
mtx-fonts       | family  : cambria
mtx-fonts       | weight  : normal
mtx-fonts       | style   : italic
mtx-fonts       | width   : normal
mtx-fonts       | variant : normal
mtx-fonts       | subfont :
mtx-fonts       | fweight : conflict: book
mtx-fonts       |
mtx-fonts       | gpos features:
mtx-fonts       |
mtx-fonts       | feature  script   languages
mtx-fonts       |
mtx-fonts       | kern     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       |
mtx-fonts       | gsub features:
mtx-fonts       |
mtx-fonts       | feature  script   languages
mtx-fonts       |
mtx-fonts       | c2sc     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | calt     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | case     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | ccmp     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | dnom     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | frac     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | liga     latn     dflt rom trk
mtx-fonts       | lnum     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | locl     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     rom
mtx-fonts       | numr     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | onum     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | ordn     latn     dflt rom trk
mtx-fonts       | pnum     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | salt     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | sinf     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | smcp     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | sups     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk
mtx-fonts       | tnum     cyrl     dflt srb
mtx-fonts       |          grek     dflt
mtx-fonts       |          latn     dflt rom trk

See $TEXMF/scripts/context/lua/mtx-fonts.lua for the lua code that implements this.

A: You can use fontspec function \fontspec_if_feature:nTF. It will work in both xelatex and lualatex
\documentclass{article}
\usepackage{fontspec,etoolbox,expl3}
\setmainfont{Cambria}
\def\fontfeatures{abvf, abvm, abvs, aalt, akhn, nalt, halt, afrc, valt, vhal, blwf, blwm, blws, cpsp, c2pc, c2sc, case, cpct, cv01, cv02, cv03, cv04, cv05, cv06, cv07, cv08, cv09, cv10, cv11, cv12, cv13, cv14, cv15, cv16, cv17, cv18, cv19, cv20, cv21, cv22, cv23, cv24, cv25, cv26, cv27, cv28, cv29, cv30, cv31, cv32, cv33, cv34, cv35, cv36, cv37, cv38, cv39, cv40, cv41, cv42, cv43, cv44, cv45, cv46, cv47, cv48, cv49, cv50, cv51, cv52, cv53, cv54, cv55, cv56, cv57, cv58, cv59, cv60, cv61, cv62, cv63, cv64, cv65, cv66, cv67, cv68, cv69, cv70, cv71, cv72, cv73, cv74, cv75, cv76, cv77, cv78, cv79, cv80, cv81, cv82, cv83, cv84, cv85, cv86, cv87, cv88, cv89, cv90, cv91, cv92, cv93, cv94, cv95, cv96, cv97, cv98, cv99, cjct, cfar, calt, clig, cswh, curs, dnom, dlig, dist, expt, falt, frac, fwid, ccmp, haln, half, hwid, hngl, hist, hlig, hkna, hojo, init, isol, ital, jp04, jp78, jp83, jp90, jalt, kern, lnum, ljmo, lfbd, ltra, ltrm, locl, mark, mset, mkmk, mgrk, medi, med2, nlck, nukt, numr, onum, opbd, size, ordn, ornm, pcap, pref, pres, psts, pstf, palt, vpal, pnum, pkna, pwid, qwid, rand, rkrf, rphf, rlig, rtbd, rtla, rtlm, ruby, sinf, smpl, zero, smcp, liga, salt, ss01, ss02, ss03, ss04, ss05, ss06, ss07, ss08, ss09, ss10, ss11, ss12, ss13, ss14, ss15, ss16, ss17, ss18, ss19, ss20, subs, sups, swsh, tnum, fina, fin2, fin3, twid, titl, trad, tnam, tjmo, unic, vatu, vert, vrt2, vkna, vkrn, vjmo}
% see http://en.wikipedia.org/wiki/OpenType_feature_tag_list#OpenType_Typographic_Features for their list
\ExplSyntaxOn
\newcommand\listfontfeatures{%
\renewcommand*{\do}[1]{
\fontspec_if_feature:nTF {##1}{##1,\ }{}
}
\expandafter\docsvlist\expandafter{\fontfeatures}
}
\ExplSyntaxOff
\begin{document}
\listfontfeatures
\end{document}

A: This should list all features in the current font, it can even be extended to list supported scripts and languages for every feature:
\documentclass{article}
\usepackage{fontspec}

\begin{document}
\newcommand\listfontfeatures{%
\directlua{
local id   = font.current()
local font = fonts.identifiers[id]
local data = font.shared.otfdata
if data then
  local features = data.luatex.features
  for i,_ in next, features do
    for f,_ in next, features[i] do
      %print(f, table.serialize(features[i][f]))
      tex.sprint(-1, f.." ")
    end
  end
end
}}

\fontspec{TeX Gyre Pagella} \listfontfeatures
\end{document}


text:
Q: Travis add pull_request_branch into slack template on pull requests i've seen on the variables page(https://docs.travis-ci.com/user/environment-variables/) that you're able to get 'pul_request_branch' which is the original branch you're pulling from. I want to use this in a template like so:
- "Build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) of %{repository_slug}@%{pull_request_branch} in PR <%{pull_request_url}|#%{pull_request_number}> by %{author} %{result} in %{duration}"

But i get the following message in slack:
Build #1234 (abcdef12) of repo-slug@

If i just use branch then i get repo-slug@master where i'm expecting something more like repo-slug@working-branch
Can someone help please


text:
Q: Get result to python variable after executing R script i am executing a r script from python and i want the output to be available in  the python variable. how can i do that?
python script:
import subprocess

def runR(id, lat, long):
    value = subprocess.popen("C:/R/R-3.2.0/bin/Rscript      E:/Personal/python/script.R --args "+id+" "+lat+" "+long , shell=True)
    print value

R script :
a = "Hello";

I want Hello to be availabe on the python variable value.

A: You could use rpy2:
import rpy2.robjects as robjects

robjects.r('''
a = "Hello";
''')
a = robjects.r['a']

As an alternative, you could rewrite your R script so that it would dump its result to stdout in some well-known format such as json, then run it using subprocess module, and parse the result:
#!/usr/bin/env python
import json
import subprocess

id, lat, long = 1, 40, 74
out = subprocess.check_output(r"C:\R\R-3.2.0\bin\Rscript.exe "
                              r"E:\path\to\script.R --args "
                               "{id} {lat} {long}".format(**vars()))
data = json.loads(out.decode('utf-8'))

Note: no need to use shell=True on Windows if you use the full path to the executable here.

A: You can modify the following example by your need.
a.py:
print 'hello'

b.py:
import subprocess
result = subprocess.check_output(["python", "a.py"])
print result.strip() + 'world'

Output of b.py:
helloworld


text:
Q: TRIGGER CON CONDICION tengo un código donde intento hacer un insert a una tabla dependiendo del caso, para esto utilizo un triggers, todo estoy en MYSQL... necesito ayuda en la manera de elaborar el triggers ya que al ejecutar me sale error de sintaxis
acá el código:
CREATE TRIGGER insert_role after insert on users
        for EACH ROW
        BEGIN
        if new.tipo_usuario = 'ADMINISTRADOR' then
            insert into model_has_roles(role_id,model_type,model_id) values (1,concat_ws(CHAR(92),'App','User'),new.id);
        end IF
        if NEW.tipo_usuario = 'EMPLEADO' then
            insert into model_has_roles(role_id,model_type,model_id) values (2,concat_ws(CHAR(92),'App','User'),new.id);
        end IF
        if NEW.tipo_usuario ='CLIENTE' then
            insert into model_has_roles(role_id,model_type,model_id) values (3,concat_ws(CHAR(92),'App','User'),new.id);
        end IF
        END;


text:
Q: How to convert Date to timestamp using MomentJS? I used MomentJS to convert local date to UTC date using the following way:

$("#div1").text(moment("2016-10-11 18:06:03").tz("Europe/Paris").format());

Now I need timestamp from the output value using MomentJS.

A: To get the time from the date use the format method of momentjs

var date = moment('2016-10-11 18:06:03').tz('Europe/Paris').format();

console.log(date);
console.log(moment(date).format("X"));
console.log(moment(date).format("x")); // for milliseconds
console.log(moment(date).format("HH:mm"));
console.log(moment(date).format("hh:mm A"));

A: Just to expand on something mentioned earlier. These generate the results.
// less precision
moment().unix() === moment().format('X')  // uppercase X

// more precision
moment().valueOf() === moment().format('x')  // lowercase x

Hope that sheds some light

A: I think moment().unix() do the trick !
See https://momentjs.com/docs/#/displaying/unix-timestamp-milliseconds/

A: moment().format("X"); // lowercase 'x' for milliseconds

var date = moment('2016-10-11 18:06:03').tz('Europe/Paris').format(),
    timestamp = moment(date).format("X");

$('#div1').text(date);
$('#timestamp').text(timestamp);

A: You said:

I used MomentJS to convert local date to UTC date using the following way:
  moment("2016-10-11 18:06:03").tz("Europe/Paris").format()

That doesn't do that.  That converts a local value to Paris time, and emits it as a string in ISO8601 format.

Now I need timestamp from the output value using MomentJS.

That's a different question, and wouldn't involve the output of the above because:

*

*You can't get a timestamp from the output string, you'd get it from a moment object.  You could parse that string, but that would be silly since you already had a moment object earlier.

*Timestamps are UTC based, so time zone conversion is irrelevant.  You'd get the same timestamp if you didn't convert at all.
You can get a string with a timestamp using .format('X') or .format('x') depending on which precision you want.  But it's much cleaner to just get the numerical timestamp using .valueOf() or .unix(), again depending on precision.


text:
Q: What makes the popular categories so popular? If you know about finite categories, you know that there are a lot categories out there.  There are many, many categories.  Oddly, though, mathematics as a whole seems to be interested in just a few of these.  Sets, groups, manifolds, vector spaces etc.  Now, obviously there aren't infinitely many mathematicians working for infinitely long to probe out every category.  Still, is there a way of specifying why the few categories that show up in literature have been chosen in the first place?
The guess I have worked on for a long time had to do with locally finitely presentable categories.  My first guess was that the compact categories in CAT were the familiar ones, then I was thinking that it was the colimits over compact categories, then both.  It didn't get me anywhere.

A: I would guess it is more about the popularity of the objects of the categories you cite than about the categories themselves. Sets, groups, manifolds, vector spaces, etc. are here for a very long time in mathematics (even if not formalized as such in the early years), hence the understanding of those objects is something mathematicians can get a grasp on. Hence it is very natural for them to turn to those objects when trying to develop new ideas in new formalism. At the risk of sounding caricatural, remember when you first learned about rings: would you then have preferred to have $\mathbb Z,\mathbb Q,\mathbb R$,etc. as examples or the Haar-integrable functions on a locally compact Hausdorff topological group?
Also keep in mind that your view of what is popular is de facto subjective. For example, in my lab, I would have more chances selling some categorical property based on $\mathsf{Rel}$ rather than on $\mathsf{Vect}_k$, or on some abstract elementary topos rather than on $G$-sets for a group $G$. I don't even want to think of the uncanny face expressions I would get trying to explain something by interpreting it in the category of Lie groups. Everyday mathematics is very very different from one mathematician to another.


text:
Q: NFS mount within container(alpine) to host(M1) nfs server fails with error : permission denied Content of my docker-compose file is

version: '2'
services:
  myserver:
    image : alpine:latest
    volumes:
      - mount-folders:/mnt/mount1
volumes:
  mount-folders:
    driver_opts:
       type: nfs
       o: nfsvers=3,addr=host.docker.internal,nolock,rw
       device: ":/Users/mnt"

I created a folder

/Users/mnt

on my M1 Monterey and enabled nfs and tested mount from another laptop successfully
but fails when running the container

Attaching to myserver-myserver-1
Error response from daemon: error while mounting volume '/var/lib/docker/volumes/myserver_mount-folders/_data': failed to mount local volume: mount :/Users/mnt:/var/lib/docker/volumes/myserver_mount-folders/_data, data: nfsvers=3,addr=192.168.65.2,nolock: permission denied

I tried also with the hostname of the host and the real ip but nothing has changed. I checked the tcp dumps of the nfs server and I guess the mount request is even can not get out of the container.
What may be the reason ?


text:
Q: How can I insert data to a table in database using codeigniter I am looking for some examples I haven't found it yet on the internet. I can insert data to database with array but I am not sure about how to add data to database with objects.
Could you show me an example inserting data basically with object?

A: lets say you have an customer object and you want to insert the details into a billing database. in your billing model:
    function insertFor( $customer ) {

       // Create the data structure
       $billing = array(
        'first' => $customer->first,
        'last' => $customer->last,
        'address' => $customer->address,
        'address2' => $customer->address2,
        'city' => $customer->city,
        'state' => $customer->state,
        'zip' => $customer->zip,

        // you can also use other things like helper functions you have created
        'inserttime' => returnMicroDate(),

       // php magic constants
        'whatsmyname' => __FUNCTION__
     );

    // insert the array into billing table
    $this->db->insert( 'billingtable', $billing );

    // confirm that it inserted correctly
    if ( $this->db->affected_rows() == '1' ) {
        return true ; }

    //return false if there was an error
    else {return FALSE;}

    }

in your controller check if the insert came back as false
 if( $this->billing->insertFor( $customer ) == false ){

     $this->showerror($customer) ; }

 else{ $this->nextMethodFor($customer) ;  }

A: You should always start with the CodeIgniter User guide.
class Myclass {
    var $title = 'My Title';
    var $content = 'My Content';
    var $date = 'My Date';
}

$object = new Myclass;

$this->db->insert('mytable', $object);

// Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date')

https://www.codeigniter.com/userguide2/database/active_record.html#insert


text:
Q: Remote acces to Sharepoint 2010 I'm very new to sharepoint 2010.
Since I have Win 7 32 bits in my machine, I can't install SP2010.so, I want to install it on another machine that is using windows server 2008 as system operator.then I want to acces sharepoint from my machine(Win7 x86) using internet or shared domain.
Is it possible and how ?

A: Yes this is possible.
Access to SharePoint sites and even Central Administration is all web-browser based so you just need to ensure you can connect to your server from your Windows 7 machine over HTTP.


text:
Q: Notepad ++ not responding This all started because I tried to open a very large file by right clicking on a text file and then selecting "edit with notepad++". Since then I have removed and reinstalled. I have followed the steps in (https://community.notepad-plus-plus.org/topic/21755/notepad-not-responding/2) but when I put the items listed in steps 2 and 3.. it tells me that they are not valid commands. At the moment, If I open it it says, "not responding" and stays that way indefinitely. Any ideas as to get this operational?

A: Uninstalling probably is not clearing out the program's entry in AppData. Go to C:\Users[YourUser]\AppData\Roaming\Notepad++ and you might be okay with just removing the session.txt file (this appears to be the file that tells NotePad++ which files you had open). If that doesn't work delete everything here then try on a fresh install.
Edit: Also your commands are probably not recognized as valid because notepad++ is not in your PATH variable. Try opening a command prompt in the same folder as notepad++'s exe THEN running them from there


text:
Q: Cannot get bootstrap dropdown to work with local files offline so I have been looking for how to solve this and it's been over a day now.
I have bootstrap version 4.5.2 downloaded locally. I have linked it to my html page and it seems to already be working, but one thing I cannot seem to get to work is the dropdown menu. I tried it with the exact same code in bootstrap website but it doesn't seem to want to work. If anyone could help I would appreciate it very much, thank you all! Also note that when I use the cdn everything works but I want it to work offline if possible.
I will link the code below.
<!DOCTYPE html>

  <meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="./css/bootstrap/css/bootstrap.min.css">

  <title>Test</title>

    Navbar
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">

    </button>

          Home (current)

          Link

          Disabled

      <form class="form-inline my-2 my-lg-0">
        <input class="form-control mr-sm-2" type="search" placeholder="Search">
        <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
      </form>

A: To make bootstrap work offline. you have to link the boostrap javascript to your project. It comes with the downloaded file. Also you have to link the dependencies.

<!DOCTYPE html>

      <meta charset="UTF-8">


text:
Q: Is building an application in Java different than making one in C#? I mean using and IDE of course.
Does Java come with a toolbox like control that has drag and drop controls, that you can move around, etc?
Also, if I make an application in Java, will it run on any machine that has the Java Runtime Environment? I wouldn't mind learning some Java because of this single trait. :)
Say I build a simple calculator, will it run on Linux/Mac/Windows?

A: I think you are confusing programming languages and software development tools.
Both C# and Java have available development toolkits and libraries which can be used to create applications. However, their source code and function calls will not be interchangeable.
If you build a simplistic application in Java, you will most likely be able to run it on any machine with a Java Virtual Machine. Writing more specialized, platform-specific code that will not run everywhere is still possible. You can probably ignore this for now.

A: *

*There are visual Java GUI designers which can be found on Google

*If you build a Java app it will run on any machine with the correct version of the JRE -- just like in .NET, you can target a certain version

*If you build a simple calculator, you should be able to get it to work on Linux/Mac/Windows

A:
Does Java come with a toolbox like control that has drag and drop controls, that you can move around, etc?

Java itself not. However, there are several IDEs such as Eclipse and Netbeans with a drag&drop-enabled designer.

will it run on any machine that has the Java Runtime Environment?

If you do not anything platform specific (normally not neccessary): Yes.

A: One big difference between Java and MS IDEs is that with Java IDEs you will not get the support for data binding via drag and drop as with MS IDEs. This is actually discouraged in the Java camps because it results in tough to maintain code.
So while the Java IDEs do tend to have very complete toolboxes, don't expect anything that favors RAD over OOP.

A: I for the most part agree with the answers that have been given but I want to put a slightly different spin on this.
You sound like a .NET developer who is looking at Java.  I am a Java developer who has started getting into .NET.  One thing that is very different from the .NET world and the Java world is the IDEs.  If you go into a .NET shop you may see VB coders, C# coders and such all developing .NET using Visual Studio.  If you go into a Java shop you'll see coders all coding Java but they may be using different IDEs (Eclipse, RAD, NetBeans, etc) and even within those you may see different functionality within the IDEs (in Eclipse for example you add functionality via plug-ins).
That being said there are plug-ins in IDEs such as Eclipse that are similar to what you see in Visual Studio.  The main difference I see is that these are more fundamental to Visual Studio than any IDE I've seen that Java developers use (many Java developers I know don't drag-and-drop anything past the initial screen creation).
Hope this helps.


text:
Q: getstream.io getting CORS request rejected: https://api.stream-io-api.com/api/v1.0/feed/user Trying to get realtime feed from getstream.io, but getting error saying "CORS request rejected: https://api.stream-io-api.com/api/v1.0/feed/user/..."
Following is my javascript code and Key,APP_ID and ReadOnlyToken is provided correctly.
        var stream = require('getstream');
        var client = stream.connect({{Key}}, null, {{APP_ID}});
        var user = client.feed('user', 511,{{ReadOnlyToken}});
        user.get({ limit:20, offset:0 })
        .then(function(response){
                console.log(response);
         })
        .catch(function(error){
                console.log(error);
         });

What do I need to do to make it work. I want to show users post in realtime at newsfeed. I'm using laravel as backened, and that was working fine and I'm able to get feeds from Feed Manager.
FeedManager::getUserFeed($user_id)->getActivities(0,25)['results'];

This is providing the user's feed but I need to implement realtime via javascript in VueJS.

A: Problem was I was using older browser working good with new browsers. Also if you used wrong read only token then also CORS error will appear.


text:
Q: Jquery date picker (select multipe hours on a particular day) I have looked up at several jquery date picker.I need a date picker that allows the user to select multiple time on a day (after every half an hour). The user is picking room reservations, multiple hours on a particular day (similar to google calendar). Therefore, I want the date picker to show such explicitly.
Thank you for any help!

A: For your requirement fullcalendar - http://arshaw.com/fullcalendar/ would provide the ideal solution.


text:
Q: Is there a sequence of swaps that would generate all possible permutations? You are given a list of numbers 1, 2, ... ,n - is there a sequence of n!-1 swap operations that would generate all n! permutations of the list where swap (i, j) swaps elements at cell i and j? What about the general case when the input list is not sorted to start with and/or there are repetitions in the list?
Context: I am solving a problem where the "score" of an array is easy to calculate if you already know the score if 2 elements are swapped and I want to brute force (using C++ next_permutation()) all possible permutations.

A: Sure, and it was known to 17th century bell-ringers. So how's that for a bit of combinatorial history?
See the Steinhaus Johnson Trotter algorithm or consult your local change-ringing group.

I did a bit of research on the second part of your question, which is whether it is possible to do this with repeated elements. The answer, I believe, is "yes, but not so easily". Furthermore, it is not possible to permute a list with repeated elements with just adjacent swaps, as can be easily seen for the set {0, 0, 1, 1}. However, it is possible with just single swaps.
The basic approach is to use the basic change-ringing algorithm, but on groups of identical elements instead of on single elements. For a group of k identical elements, you need to be able an algorithm for combinations of the list 0n-k1k (where n is the total size of the base set). A number of such algorithms exist, but I can't find any which are really simple; the simplest one is (roughly speaking) to assign a direction to the overall group, and also a direction to each 1 (in a similar fashion to the Shimon Even algorithm). When moving the group left, the leftmost element sweeps back and forth; every time it changes direction, the next mobile element to the right steps one; etc. This eventually moves the entire group from the right-hand side of the list to the left-hand side, after which its overall direction is flipped and it proceeds back to the original configuration, now with the rightmost element leading the sweeps.
Since the number of direction reversals might be even in this case, the above algorithm might not trace out a permutation cycle, but I believe that it is possible to produce a cycle using a more sophisticate algorithm. In effect, you're looking for a hamiltonian cycle in the graph induced by possible single swaps from each permutation -- a variant of the permutehedron -- but, while hamiltonian cycles do exist, they are not so easy to find since the graphs are quite large.


text:
Q: GooglePlusUtil cannot be resolved (Android) I have an Android 2.2 targeted library project, whose MyLibraryGooglePlusSocialPlugin.java has a import com.google.android.gms.plus.GooglePlusUtil; being failed to compile (GooglePlusUtil cannot be resolved), while others are okay:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.plus.PlusClient;
import com.google.android.gms.plus.PlusClient.OnPeopleLoadedListener;
import com.google.android.gms.plus.PlusClient.OnPersonLoadedListener;
import com.google.android.gms.plus.PlusShare;
import com.google.android.gms.plus.model.people.Person;
import com.google.android.gms.plus.model.people.PersonBuffer;

I've updated the related Google services through Android SDK manager today, and set the build path and dependencies.

A: The GooglePlusUtils class has been removed because you no longer need it. All of the existing error handling functionality has been integrated in a way that doesn't require developer intervention.
As an example of how you can migrate from using this (now deprecated) class, see the following change from the Google+ Photohunt Android client sample that resolves the issue:
https://github.com/gguuss/gplus-photohunt-client-android/commit/090c22b4721fde6859361aca210823822c218da8

A: Their documentation has not changed online, but it is indeed missing form the jar. I would look for a copy of the last version and use it for the time being.
** UPDATE **
You can do the same things with the GooglePlayServicesUtil and checking to see if they user has the correct package name for Google Plus.

A: I work it around by downgrading to a previous version where the AndroidManifest.xml in the google-play-services_lib goes like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.gms"
    android:versionCode="3159130"
    android:versionName="3.1.59 (744626-30)" >

    <uses-sdk android:minSdkVersion="8"/>

</manifest>

UPDATE
I downgrade the library by reloading a lower version that was saved in my local disk. No idea how to downgrade through Android SDK manager.

A: The old GooglePlusUtil + error codes are not needed now, because even if the device has not installed GooglePlus application, GooglePlay services provides connection to user account. You can only check if GooglePlay services is present and updated using GooglePlayServicesUtil.isGooglePlayServicesAvailable and hide UI field with GooglePlus. In other case connection to user (GooglePlus) account will be made.


text:
Q: Prove existence of expectation Let $g: \mathbb{R} \rightarrow \mathbb{R}$ be a nonmonotone convex function. Prove that existence of $\mathbb{E}g(X)$ implies existence of $\mathbb{E}X$.
I know that exists distributions with undefined expectation, but I can't really understand how I suppose to prove existence of it

A: Pictorially, if you have a convex function and you choose any point on it and draw a tangent line (or subgradient), then the convex function is always above or on the tangent line. So $aX + b \le g(X)$ everywhere. This gives you either an upper or lower bound on $X$ relative to $a^{-1}(g(X) - b)$ which depends on the sign of $a$.
Next, $g$ is not monotone so we get subgradient lines with positive and negative slopes. That gives you both an upper and a lower bound on $X$. So the expectation exists.


text:
Q: OAuth2.0 to vk.com using curl in bash I want to write a bash script which will work with vk.com API.
My first step is to make OAuth2.0 authorization. But i can't use web browser because my script will work on machine without xserver.
As described on developers page i need firstly to make GET request:
https://oauth.vk.com/authorize?client_id=<myapp_id>&redirect_uri=https://oauth.vk.com/blank.html&display=mobile&scope=video,audio&response_type=token&v=5.44&revoke=1

With this request is everything OK. Then i opened source code of this page and found there next code:
<form method="post" action="https://login.vk.com/?act=login&soft=1&utf8=1">
<input type="hidden" name="_origin" value="https://oauth.vk.com">
<input type="hidden" name="ip_h" value="<some_value>" />
<input type="hidden" name="lg_h" value="<some_value>" />
<input type="hidden" name="to" value="<some_value>">

Phone or email:

<input type="text" class="textfield" name="email" value="" />

Password:

<input type="password" class="textfield" name="pass" />

<input class="button" type="submit" value="Log in" />
Cancel

Not registered yet?

Sign up for VK

</form>

It means that to make authorization i need to send POST request to
https://login.vk.com/?act=login&soft=1&utf8=1

and pass as parameters next inputs:
_origin, ip_h, lg_h, to, email, pass

but it's not working. I'm getting nothing using curl and getting error page with message about incorrect pass or login using different rest clients using gui. I thought that problem may be in cookies but adding cookies give nothing.
script code i am trying to make work:
#!/bin/bash
username=$1
password=$2

response=$(curl --cookie-jar vk.txt "https://oauth.vk.com/authorize" --data "client_id=<app_id>&redirect_uri=https://oauth.vk.com/blank.html&display=mobile&scope=video,audio&response_type=token&v=5.44&revoke=1")
echo "response is $response"
echo "================================================================="
response=$(curl --request POST --cookie vk.txt "https://login.vk.com/?act=login&soft=1&utf8=1" --data-urlencode "_origin=https://oauth.vk.com&ip_h=<some_value>&lg_h=<some_value>&to=<some_value>&email=<my_email>&pass=<my_pass>")
echo "response is $response"
echo "================================================================="

exit 0

I'he tried different params in curl, different cookie formats. But result the same.
Maybe the problem that i need to do special security encodes because of SSL? But shouldn't curl do it?
I found out one script on python where author didn't do any more actions when i, but his code works fine. Of course it's may be because of his third party libs for rest requests but maybe not. Link to this paper (in Russian):
https://habrahabr.ru/post/143972/


text:
Q: JSF 2 validation alongwith tabbedPanel in rich faces causing issue I am developing a web app with JSF 2.0 and rich faces 4.2.3.
I have a page with tabbed panels nested inside each other like below (code is given at the end).
I am facing following issue :
When a tab is clicked, validation gets fired and second tab doesn't get displayed (since text fields don't have any value set, validation fails).
It is because, when a tab is clicked, POST request is fired causing validation to invoke.
How can I get around this?
One of the option could be to change the switchType to "client". But then updated data will not be displayed when a tab is clicked.
<h:form>
    <rich:tabPanel switchType="client">

        <rich:tab header="UserManagement">
             <rich:tabPanel switchType="client">
                    <rich:tab header="AddUser">

                     <h:form>
                         <h:panelGrid id="addUserForm" columns="3">

                                Enter Name :
                                <h:inputText id="name" value="#{userBean.name}"
                                    required="true" requiredMessage="User Id Required.">
                                </h:inputText>
                                <h:message for="name"></h:message>

                                Enter passWord :
                                <h:inputText id="passWord" value="#{userBean.passWord}" required="true" requiredMessage="PassWord Required.">
                                </h:inputText>
                                <h:message for="passWord"></h:message>

                                Roles :
                                 <h:selectOneMenu id="roles" value="#{userBean.roleId}">
                                                <f:selectItems  value="#{userBean.roles}"/>
                                </h:selectOneMenu>
                                <h:message for="roles"></h:message>

                                <h:commandButton action="#{userBean.addUser}"
                                                    value="Add User">
                                      <f:ajax render="addUserForm" execute="@form"></f:ajax>
                                </h:commandButton>
                        </h:panelGrid>
                    </h:form>

                    </rich:tab>
                    <rich:tab header="EditUser">

                        <h:form>

                            <h:panelGrid id="editUserForm" columns="3">

                                    Enter passWord :
                                    <h:inputText id="passWord" value="#{userBean.passWord}" required="true" requiredMessage="PassWord Required.">
                                    </h:inputText>
                                    <h:message for="passWord"></h:message>

                                    Roles :
                                    <h:selectOneMenu id="roles" value="#{userBean.roleId}">
                                                    <f:selectItems  value="#{userBean.roles}"/>
                                    </h:selectOneMenu>
                                    <h:message for="roles"></h:message>

                                    <h:commandButton action="#{userBean.editUser}"
                                                        value="Edit User">
                                          <f:ajax render="editUserForm" execute="@form"></f:ajax>
                                    </h:commandButton>
                            </h:panelGrid>
                        </h:form>

                    </rich:tab>
             </rich:tabPanel>

        </rich:tab>

        <rich:tab header="DeviceManagement">
        </rich:tab>

    </rich:tabPanel>
</h:form>

A: You're already doing one thing very wrong up there, which is nesting <h:form/>s. Form nesting is illegal in both HTML and by extension JSF. even if nothing else were wrong with your view, that construct alone will give you serious headaches later on. See this and this answer
Validation is being triggered on tab click because, at the end of the day, all your components are lumped within the same <h:form/>. As a result, any action within that form will submit the entirety of all the components in there. You have to get rid of the topmost <h:form/> and restructure your components accordingly. Additionally, you may selectively process view components with <a4j:commandButton process="someId" ajaxSingle="true"/>, specifying the clientId of the components you want to submit for processing


text:
Q: MySQL boolean type to return boolean query? I'm trying to see if its possible to test for a certain result specific to a boolean value in an SQL database.
if($result = $mysqli->query("SELECT * FROM `work_orders` WHERE `is_open` = '1' "))
{
    show_workorder($result);
}

I would then want to execute:
#TRUE allows this to show
if($result = True){
    echo "<p> No current work orders are open. Good Work !</p>\n";
    return;
}

If i change database in work_orders.is_open , the boolean is 0, meaning its "not open" .. the if statement for TRUE above, still shows...
I am sure that I'm missing something.

A: Seems I have solved my own question:
the if statement should just test for rows that were returned or not.
if($result->num_rows == 0)

this would allow it to show if there is nothing returned. If results are returned then it will continue moving forward.


text:
Q: Continuous linear function agrees with inner product Consider a continuous linear function $\lambda: H \to \mathbb{C}$, where $H$ is a Hilbert space. I want to show that there is $v \in H$ such that
$$\lambda(h) = \langle h, v \rangle$$
for all $h \in H$, where $\langle, \rangle$ is the inner product on $H$. I tried choosing $v \in (\ker \lambda)^{\perp}$, but only got as far as showing $\lambda$ agrees with $\langle \cdot, v \rangle$ on $\ker \lambda$. Thanks for any advice.

A: If $\ker \lambda = \mathbb{H}$, then choose $v = 0$ and you are finished.
So, suppose $\ker \lambda \neq \mathbb{H}$. Choose $v \in (\ker \lambda)^\bot \setminus \{0\}$. Note that $\operatorname{sp} \{ v \} = (\ker \lambda)^\bot$.
Let $\phi(x) = \frac{\lambda(v)}{\|v\|^2} \langle v, x \rangle$. By construction, we have $\phi(v) = \lambda(v)$, hence $\phi,\lambda$ agree on $\operatorname{sp} \{ v \}= (\ker \lambda)^\bot$. Now suppose $n \in \ker \lambda$. Then $\lambda(n) = 0$, and $\phi(n) = 0$, and hence $\lambda, \phi$ agree on $\ker \lambda$.
Since every $x \in \mathbb{H}$ can be written as $x=n+\alpha v$, with $n \in \ker \lambda$, we see that $\lambda(x) = \lambda(n+\alpha v)=  \alpha \lambda (v) = \alpha \phi(v) = \phi(n+\alpha v) = \phi(x)$.
Note: Continuity of $\lambda$ appears implicitly in that it implies $\ker \lambda$ is closed, which allows the decomposition $\mathbb{H} = \ker \lambda \oplus (\ker \lambda)^\bot$.


text:
Q: c++ : comparison function for next_permutation I want to use std::next_permutation() on a vector of Object.
To do so I have to define a comparison function that defines the < operator between two Objects (otherwise it will take a default comparison operator that has an unpredictable behavior)
But sometimes I got two Objects that are equal (according to my criteria) and so Object1 < Object2 and Object2 < Object1 both return false so next_permutation() turns indefinitely...
EDIT : here is a simple example of what I have (the loop never ends)
MyObject.h :
class MyObject {
    int param;
    MyObject(int i);

};

Main.cpp :
bool comparison (MyObject * o1, MyObject * o2) { return (o1->param < o2->param); }

int main(){

    std::vector<MyObject*> myVector;
    myVector.push_back(new MyObject(0));
    myVector.push_back(new MyObject(1));
    myVector.push_back(new MyObject(1));

    std::sort(myVector.begin(), myVector.end(), comparison);

    do{
        printf("%i, %i, %i \n", myVector[0]->param, myVector[1]->param, myVector[2]->param);
    } while(std::next_permutation(myVector.begin(), myVector.end()), comparison);

    return 0;
}

So how could I handle that case ? How does the default < operator handles this case ?

A: In your code:
while(std::next_permutation(myVector.begin(), myVector.end()), comparison)

your parent is misplaced
it should be
while(std::next_permutation(myVector.begin(), myVector.end(), comparison))

else you do std::next_permutation with default comparison, discard result with comma operator and then return comparison which is always true (function pointer not null)

A:
But sometimes I got two Objects that are equal

std::next_permutation does not require a range of unique elements.
Therefore, this should work. You did something wrong.

So how could I handle that case ?

Fix your bug.
Of course, we have no way of knowing what that is, as you failed to present your testcase.


text:
Q: Powershell & XML: Save data to a certain node of xml-file I have a powershell script which loads data from an xml. The XML looks like:
<meta>
<log>
    <path>D:\logs\l1.log</path>
    <lastwrite>01/30/2015 13:01:00</lastwrite>
    <num>23</num>
</log>
<log>
    <path>D:\log\l2.log</path>
    <lastwrite>02/30/2015 14:02:00</lastwrite>
    <num>67</num>
</log>
</meta>

What I would like to do is to change a certain value in the xml. First I load the Data:
[xml]$xml = Get-Content "D:\config.xml"

My problem is, how can I address a certain log-Node in my xml? What I'm searching for is something like this:
$xml.meta.log.path | where path = "D:\log\l2.log"

And also something to set the new value and save it back to the xml-file.
Maybe sb can help me, I have now idea how to search, but I'm sure there's a way. To use IDs within the log-tags is not a good solution, because I have to address the nodes by the paths.

A: You are almost there. Instead of a = use the -eq condition. You also have to use curly brackets and access the current value using $_:
$xml.meta.log.Path | where { $_ -eq 'D:\log\l2.log' }

Alternative, you can use the where path query on $xml.meta.log and select the path in an additional statement:
$xml.meta.log | where path -eq 'D:\log\l2.log' | select -expand path

And here a complete example which modifies the path and save the xml back:
$configPath = 'D:\config.xml'

[xml]$xml = Get-Content $configPath

# Select the log log node where path equals 'D:\log\l2.log'
$node = $xml.meta.log | where path -eq 'D:\log\l2.log'

# Set the new path
$node.path = 'D:\newLogPath\newLog.log'

# Save the xml back
$xml.Save($configPath)

A: Ok, I made a little change:
XML is now:
<meta>
<log path="D:\logs\l1.log">
    <lastwrite>01/30/2015 13:01:00</lastwrite>
    <num>23</num>
</log>
<log path="D:\log\l2.log">
    <lastwrite>02/30/2015 14:02:00</lastwrite>
    <num>67</num>
</log>
</meta>

And now this code works:
$configPath = 'D:\config.xml'

[xml]$xml = Get-Content $configPath

# Select the log log node where path equals 'D:\log\l2.log'
$node = $xml.meta.log | where {$_.path -eq 'D:\log\l2.log'}

# Set the new path
$node.line_num = "5"

# Save the xml back
$xml.Save($configPath)

Path is not needed to be modified.
Thanks for your help. Wouldn't have been able to solve this without your code snippet;)


text:
Q: Retrieve images from Google Places API I am using the Google Places api to get places data:
https://maps.googleapis.com/maps/api/place/search/json? + "location=" + strlatitude + "," + strlongitude + "&" +"radius=" + searchRadius + "&" +"types="+ types + "&" + "sensor=true" + "&" + "key=" + googleAPIKey;

I am just getting only "icon" from this response.But I want to get image of that place.
Is there any parameter to get the image of the places?
Additionally, how can I get reviews of the places (like 9reviews, 6reviews, etc.)

A: You can get the image_link by using JSONObject, and you can easily convert the particular link to an image using Bitmap.
For example, getting image_link from Json:
JSONObject jsonObj = new JSONObject(Global.JSON.toString());

// Creating JSON Parser instance
JSONArray jr=jsonObj.getJSONArray("results");

for(int h=0;h<jr.length();h++)
{
    JSONObject js=jr.getJSONObject(h);
    icon_array=js.getString("icon");
}

Converting Link to Image
url = new URL("http://www.paho.org/Images/DD/PIN/whd08_banner2_eng.jpg");
//In URL pass your link

bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
image_view.setImageBitmap(bm);

A: I found the link to get the location image from places Api..
try this link
http://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,%20-73.988354&fov=90&heading=235&pitch=10&sensor=false
you'll get image like this for the above link

Refernce Link
https://developers.google.com/maps/documentation/streetview/


text:
Q: Why is internet explorer the only browser that can open .url links by default? Why is Internet Explorer the only browser that can open .url links by default?
I have tried setting Chrome, Firefox and Edge to be the default browser but none of them have this open .urls by default option.
Side note- I was able to set firefox to the default for opening .url files by  going to the file associations link in the control panel rather than the default program link. (Default Programs\Set Associations)  So if firefox can do it, why isn't this option available as a default association?

A: You can, you may just have to hunt down the .exe of the browser you wish.
Example:
Chrome's .exe is usually stored at C:\Program Files (x86)\Google\Chrome\Application
So when you go to choose a default application, go ahead and hit browse and direct it to Chrome's executable inside that directory.

You can do the same with other browsers as well, just gotta hunt down the .exe that runs the browser.

Extra note
As of now, you have the default set as "Internet Browser" which means whatever browser your computer considers your "default" is the one that will open .url shortcuts.  Which is probably Internet Explorer at the moment from what it seems.


text:
Q: c# HttpRequestException: Error while copying content to a stream in HttpMessageHandler Using a custom RetryHandler in .NET for HttpClient.
//Create client
var client = new HttpClient(new RetryHandler(new HttpClientHandler()));

//PutAsync
var result = await client.PutAsync(new Uri($"{fileSystem}?resource=filesystem"), null).ConfigureAwait(true);

//Retry Handler
public class RetryHandler : DelegatingHandler
    {
        private const int MaxRetry = 3;
        private const int DelayMilliSeconds = 10000;

        public RetryHandler(HttpMessageHandler innerHandler)
            : base(innerHandler)
        {
        }

        protected override async Task<HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            HttpResponseMessage response = null;

            for (int i = 0; i < MaxRetry; i++)
            {
                try
                {

                    CancellationTokenSource source = new CancellationTokenSource(TimeSpan.FromMinutes(5));

                    response = await base.SendAsync(request, source.Token).ConfigureAwait(true);

                    if (response.IsSuccessStatusCode)
                    {
                        return response;
                    }
                }
                catch (Exception e)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(Math.Pow(2, i) * DelayMilliSeconds));
                    continue;
                }
                Thread.Sleep(TimeSpan.FromMilliseconds(Math.Pow(2, i) * DelayMilliSeconds));
            }
            return response;
        }

Looks like that it never enters the RetryHandler, getting the following error before entering the RetryHandler.

System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.ObjectDisposedException: Cannot access a closed Stream.
at System.IO.Stream.CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
at System.Net.Http.DelegatingStream.CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
at System.Net.Http.StreamToStreamCopy.CopyAsync(Stream source, Stream destination, Int32 bufferSize, Boolean disposeSource, CancellationToken cancellationToken)


text:
Q: Conditional cumulative distribution function of multivariate normal distribution I am able to calculate the cumulative distribution function for a multivariate normal distribution, as I have both the means and covariances. Wikipedia gives the formula for calculating the conditional distribution. However, that is the conditional probability distribution function. Is it possible to calculate the conditional cumulative distribution function?
Right now I can directly calculate (with scipy.stats.multivariate_normal.cdf):
$P(X_1 \le a_1)$
I am trying to calculate:
$P(X_1 \le a_1 | X_2 \le a_2 )$
Thanks!


text:
Q: Ubuntu won't boot after updating time I have a laptop that is a dual boot Windows 8/Ubuntu 12.04 machine. I recently noticed that while in Windows, my system time was off. I tried to change it from within Windows but it reset every time I rebooted. My first thought was that the CMOS battery was bad but the clock was working just fine in Ubuntu.
I double checked the BIOS and since the clock was off there, I adjust the time and rebooted.
Now, Ubuntu no longer boots.
I'm very new to Ubuntu (just got it installed and working for the first time Tuesday) so I have no idea where to go from here. Any help would be great.
Thanks!

A: Okay, I think I figured it out. Well, enough to get past it anyway...
Apparently Ubuntu stores the UTC time to the system time in the BIOS and Windows stores the local time. If the system time reads 12:00PM, Ubuntu adjusts to display the correct time for your time zone. For example, Central Time is UTC-6 so it would read the 12:00PM system time and subtract the 6 hours for me and show 6:00AM.
Windows on the other hand saves the local time. So if I save the clock to show 6:00AM in Windows, Ubuntu will no longer display the correct time. I have no idea why this causes Ubuntu not to boot AT ALL but it is what it is...
I got Ubuntu back up and running by using boot-repair. I booted to an Ubuntu install disc and typed this from the terminal:
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair && (boot-repair &)

Then I selected Recommended Repair and restarted once it was finished.
There's a way to either force Ubuntu to treat the system time as the local time or force Windows to treat it as UTC time. This link showed me how to do that:
Clock time is off on dual boot


text:
Q: How to structure and markup dialogue in XML for a book? I have some structure for a book that looks basically like this:
<chapter>
  <verse>Eva said, <quote speaker="Eva">I'm not the one who's underestimating her cleverness.</verse>
  <verse>Or maybe it's you I'm underestimating. Have you finally joined her side, sister?</quote></verse>
</chapter>

The problem, as you can see, is that I have quotes that need to span across multiple verses. How should I handle this? There might also be other tags (not just quote tags) that need to span verses and possibly—though unlikely—even chapters.
The XML will be parsed by some application that I am writing in a high-level language such as Go, Java, JavaScript, etc. I have full control over this.
Am I using an inappropriate markup language for the data I have? Or am I structuring the verses and other tags incorrectly?

A: Well it isn't going to parse that!
Two options I can see, that would make more sense than what you have
<chapter>
  <verse>Eva said, <quote speaker="Eva">I'm not the one who's underestimating her cleverness.</quote></verse>
  <verse><quote speaker="Eva">Or maybe it's you I'm underestimating. Have you finally joined her side, sister?</quote></verse>
</chapter>

Oh and I'd say that the comma after Eva said, is redundant
or
<voice speaker = default/>
<chapter>
  <verse>Eva said, <voice speaker="Eva"/>I'm not the one who's underestimating her cleverness.</verse>
  <verse>Or maybe it's you I'm underestimating. Have you finally joined her side, sister?<voice speaker = default /></verse>
</chapter>

A: I think you'd be best advised to adopt the docbook standard. An enormous amount of work has already gone into its schema, enabling it to support all forms of printed document.
In your case you could use one of the following docbook xml elements:

*

*quote

*citation
Docbook is used for documenting high profile projects, such as the Linux Kernel and Ubuntu. It can however be intimidating to use.
I prefer to use simpler text based markup languages (markdown, asciidoc). These have tools available to generate docbook. This gives me the best of both worlds, simplicity of use and support for professional publishing standards.

A: The problem is the structure.  Your XML is not valid.
Instead of trying to put the quote elements inline with the verses, I'd suggest using an index that spans the entire document.  That way, you could decouple the quote elements from the verse elements.  So, for example, you might have a quote that looks like this:
<quote speaker="Eva" start=11 end=89/>

OR
<quote speaker="Eva" start=11 length=78/>

This way, you don't need to worry about your quotes spanning multiple verses.


text:
Q: Turn On/Off Wifi in android programmatically using gluon-mobile API's I have been working around with Android app using JavaFx (using JavaFxPorts and Gluon-Mobile ).
I have used ConnectivityService.class to check Whether the device to connected to Network.
But,the next Thing I have to do is Turn On/Off the Device's Wifi Programmatically.
How do I Implement this using Gluon-mobile API's.

A: So. To get access to the FXActivity (via FXActivity.getActivity()) you will need to update your Gradle file just slightly.
Here is how my file looks like
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.5'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

compileJava.options.encoding = 'UTF-8'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'ch.cnlab.disentis.Main'
// preloaderClassName = 'ch.cnlab.disentis.Preloader'

dependencies {

    compile 'com.gluonhq:charm:4.3.1'
    compile 'org.controlsfx:controlsfx:8.40.12'

    compileNoRetrolambda 'com.airhacks:afterburner.mfx:1.6.2'

    compile 'de.jensd:fontawesomefx-commons:8.15'
    compile 'de.jensd:fontawesomefx-fontawesome:4.7.0-5'
    compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'
    compile 'de.jensd:fontawesomefx-materialicons:2.2.0-5'
    compile 'de.jensd:fontawesomefx-controls:8.15'

    compile 'com.fasterxml.jackson.core:jackson-databind:2.8.4'

    compile 'commons-codec:commons-codec:1.10'

    androidCompile files("$System.env.ANDROID_HOME/platforms/android-22/android.jar")
    androidCompile files("$System.env.ANDROID_HOME/extras/android/support/v4/android-support-v4.jar")

    compile 'org.javafxports:jfxdvk:8.60.9'
    androidRuntime 'org.javafxports:jfxdvk:8.60.9'
}

jfxmobile {
    downConfig {
        plugins 'display', 'lifecycle', 'storage', 'orientation', 'settings', 'browser', 'ble'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
        compileSdkVersion = 22
        minSdkVersion = 19
        targetSdkVersion = 22
        dexOptions {
            javaMaxHeapSize '2g'
        }
        packagingOptions {
            pickFirst 'META-INF/LICENSE'
            pickFirst 'META-INF/NOTICE'
            pickFirst 'license/LICENSE.txt'
        }
        signingConfig {
            storeFile file('signing/android/my-release-key.keystore')
            File propsFile = file('signing/android/keystore.properties');
            if (propsFile.exists()) {
                Properties props = new Properties();
                props.load(new FileInputStream(propsFile))
                storePassword props.getProperty('RELEASE_STORE_PASSWORD')
                keyAlias props.getProperty('RELEASE_KEY_ALIAS')
                keyPassword props.getProperty('RELEASE_KEY_PASSWORD')
            }
        }
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'de.jensd.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'javax.xml.**.*',
                'org.glassfish.json.**.*',
                'com.airhacks.**.*',
                'okio.**.*',
                'okhttp3.**.*',
                'com.fasterxml.**.*',
                'ch.cnlab.disentis.**.*'
        ]
    }
}

The takeaway is, that I needed to include the dependencies androidCompile files("$System.env.ANDROID_HOME/**"), otherwise my Eclipse installation wasn't able to access the Android stuff. :-/
And the dependencies, you need to access the FXActivity, are:
compile 'org.javafxports:jfxdvk:8.60.9'
androidRuntime 'org.javafxports:jfxdvk:8.60.9'

To learn about the lastest versions for jfxdvk (JavaFX Dalvik), I check the following pages, from time to time
https://bitbucket.org/javafxports/javafxmobile-plugin - here you can see, the stuff, the javafxmobile-plugin depends on.
http://nexus.gluonhq.com/nexus/content/repositories/releases and http://nexus.gluonhq.com/nexus/content/repositories/releases - to find out, what the lastest version of the Charm Down library is (mine in the Gradle file is a bit dated already).
I hope, that helps.
Regards, Daniel

A: Hi am not familiar with gluon but if your using java You can use this method:
In the Manifest file add the following permissions:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>

you can then check if WiFi is enabled through a Boolean Like this:
boolean wifiEnabled = wifiManager.isWifiEnabled()

and finaly can change state through:
WifiManager wifiManager = (WifiManager)
`this.getSystemService(Context.WIFI_SERVICE);`
wifiManager.setWifiEnabled(true);
wifiManager.setWifiEnabled(false);

hope this helps


text:
Q: C# trigger a Jenkins job with parameters I'm trying to use C# to trigger a remote Jenkins job which has parameters.  The job triggers, but I have two problems.  First, the parameter is not being received by Jenkins, and two, I'm receiving no response from Jenkins.  Here is my code snippet:
`string url = "http://172.30.25.33:8080/job/CloudTeam/job/Tests/job/TestJob/buildWithParameters";
        using (var wb = new WebClient())
        {
            string json = @"{""parameter"": [{""testvar"" : ""user""" + @"""}]`";

                           //return json;

            string password = "mypassword";
            string username = "myuser";

            string basicAuthToken = Convert.ToBase64String(Encoding.Default.GetBytes(username + ":" + password));
            wb.Headers["Authorization"] = "Basic " + basicAuthToken;

            wb.Headers[HttpRequestHeader.ContentType] = "application/json";

            return wb.UploadString(url, json);
        }`

A: Microsoft does not recommend using WebClient API for new development. Instead, they recommend using HttpClient.
I would recommend using NewtonSoft's Json.NET (or similar library) to build the JSON data instead of crafting it by hand.
Have you tried using a tool like Postman to validate the request?


text:
Q: Android service keeps blocked indefinetly in a thread.join I'm trying to build a function that determines if there's telephony network connectivity, but if it fails on detecting I want it to keep on trying to detect it for a certain amount of time, once this time is passed and it hasn't been detected it would be returned that it hasn't been detected, on the other hand if its detected, the checking of its detection will be stopped and what would be returned is that connectivity exists.
I think I could achieve that with the following code:
public static String operatornetwork = null;
static boolean finish = false;
static boolean telephonynetworkfound = false;

[...]

       final CountDownTimer cdt=new CountDownTimer(60 * 1000, 5 * 1000)
       {
            public void onTick(long millisUntilFinished)
            {
                operatornetwork = tel.getNetworkOperator();
                if ((operatornetwork != null) && (!operatornetwork.equals("")))
                {
                    telephonynetworkfound = true;
                    finish=true;

                }
            }

            public void onFinish()
            {
                operatornetwork = tel.getNetworkOperator();
                if ((operatornetwork != null) && (!operatornetwork.equals(""))) {
                    telephonynetworkfound = true;

                }
                finish=true;
            }
        };

        cdt.start();

        final Thread welcomeThread = new Thread()
        {

            @Override
            public void run()
            {
                try
                {
                    super.run();

                    while (true)
                    {

                        if (finish)
                        {
                            break;
                        }
                        sleep(3000);
                    }

                }
                catch (Exception e)
                {

                } finally
                {

                }
            }
        };
        welcomeThread.start();
        try
        {
            welcomeThread.join();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return telephonynetworkfound;

I thought that as the infinite loop is running on a separate thread it wouldn't block the app, and finish iss supposed to be true at least onFinish in the CountDownTimer, but it looks that the block comes in welcomeThread.join(), but I cannot be sure because whenever I reach the welcomeThread.join in debugging I get the error frames not available for unsuspended thread, even if it that's only a debugging error the app doesn't go further than that point.
Any idea on what might be happening?