Affichage des articles dont le libellé est Recent Questions - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Recent Questions - Stack Overflow. Afficher tous les articles

lundi 31 août 2015

Losing material when prefab is created

I have a game object with these properties:

So when I create the prefab, right after the creation, on the prefab the material is lost. The mesh renderer doesn't contain any material.

What is the problem? The other properties are set as default.



via Chebli Mohamed

Order by long Distance from Google Distance Matrix

Google Distance Matrix API for long distance between the origin and destination respond with a blank space when it's > 1000km: "1 865"

When I try to order the result using LINQ:

.OrderBy(g => Double.Parse(g.Distance, CultureInfo.GetCultureInfo("pt-PT")))

I get the error:

System.FormatException: Input string was not in a correct format.
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)

I tried to remove the blank space using g.Distance.replace(" ","") but it's not working.



via Chebli Mohamed

Find distinct values based upon multiple columns

I have a spreadsheet of sales with (to keep the example simple) 3 columns

NAME -- STATE -- COUNTRY 

It's easy to find how many sales. (sum all the lines) I can find out how many customers I have but how about finding out how many customers from a particular state (and country)

NAME -- STATE -- COUNTRY
p1----- CA------ USA
p2----- CA------ USA
p1----- CA------ USA
p1----- CA------ USA
p3----- NY------ USA
p3----- NY------ USA

The above example would give 2 unique customers from CA and 1 unique customer from NY and 3 from the USA

EDIT:

The desired result from the above table would be

STATE - UNIQUE CUSTOMERS 
CA ----  2
NY ----  1

COUNTRY - UNIQUE CUSTOMERS
USA ---- 3



via Chebli Mohamed

how to trim incoming values in a stored procedure in mysql?

I have my stored procedure defined as following:

CREATE PROCEDURE `customers`(
IN `in_customer_name` VARCHAR(255),
IN `in_primary_contact` VARCHAR(255), 
IN `in_phone` VARCHAR(255),
IN `in_email` VARCHAR(255), 
IN `in_address` VARCHAR(255),
IN `in_city` VARCHAR(255), 
IN `in_state` VARCHAR(255),
IN `in_zip` VARCHAR(255),
IN `in_tenant_id` INT(11),
IN `cus_id` INT(11),
IN `con_id` INT(11),
IN `loc_id` INT(11),
IN `usr_id` INT(11))


BEGIN

    DECLARE cont_name, cont_phone, cont_email, loc_address, loc_city, loc_state, loc_zip, cont_id VARCHAR(255);

the problem is that sometimes the incoming values have trailing spaces in left or right. I've heard of LTRIM and RTRIM, but I'm not sure if I can use them in incoming values and not just values selected from the database, and if so I can use them I don't know exactly how I can use them. Any ideas?



via Chebli Mohamed

Node.js - Log in to LinkedIn as an application vs client?

I'm trying to build an application that will read job postings from a LinkedIn site and load them into a database for future use - all back end.

Does anyone know where I can find a current working node.js example of signing in to LinkedIn as an "application", rather than as a "client/user"? Is there a difference?

I followed the tutorial here (http://ift.tt/1wF0QPo). I had to use passport-linkedin-oauth2 in order to retrieve an authorization token. After doing this, my passport.authentication fails - without any useful messages.

Here's all I get on the console before the app is routed back to the login screen:

c:\_Todd\_Projects\node-passport\aaa>node server
The magic happens on port 3000
GET / 304 26ms
GET /auth/linkedin 302 13ms - 264b
GET /auth/linkedin/callback?code=AQQe8cSBUaP8A_YRoB5FEncATOOvyMdsAoEsF_v_yYAvG0j2v3Q8ypE28ls5Yqqow6dkDtS16KQBrmhAYxvn9i4s36D6I4iQKSU
SBkaenuGhR7kIZSc&state=true 302 4ms - 35b
GET / 200 6ms - 1.13kb
GET /favicon.ico 404 1ms

My team lead said it looks like I'm trying to log in as a client (because I'm using the sign-in screen), and that I should log in as an application. Is there a difference??? I found some old tutorials that show "Consumer Key / API Key", but the current developer apps only have "Client ID".

Can someone please help?



via Chebli Mohamed

Async database creation with php

I am building a system where every account has its own databases. Creating these databases when the user is actually creating the account results in a long wait before the page is refreshed. Logically, since php is still busy, so the page cannot finish.

Therefore my idea is to 'buffer' up a few, like 5 of these packages, all named $DBNAME$number, where number is 1 to 5. So I just rename the databases at account creation time, thereby minimizing the wait. I think this will work pretty well, but off course, I need to replenish my buffer.

That's where I figured I'd need a method to just replenish the database buffer in the background, which could even run while the accounts database is prepared, and the user is already logging in. The thing is, I haven't found a solution to this, while looking aroung a lot. I tried pthread, which runs exactly as if I would run the code inline. I even gave ajax a shot, hoping the .php file will run async, but it will not.

Does anyone have a recommendation on how to achieve this goal I have? PS: if xy problem, you may notify me :)



via Chebli Mohamed

Determine Spring Version at runtime

Is there a way to determine my Spring Version at runtime? eg

log.info("I'm running spring version '{}'", SpringWhatever.getVersion());

Debug-level logging is not showing me anything.

Full background is that I can compile but am getting java.lang.NoSuchMethodError: org.springframework.context.support.PropertySourcesPlaceholderConfigurer.getAppliedPropertySources() at runtime.



via Chebli Mohamed

Is it possible to incorporate Ruby code into a lpsolve file?

I would like to know if it is possible for a file that is read by gem lpsolve in a rails app to read ruby code. If lpsolve can read ruby code then how can it do it?

Can gem lpsolve understand ruby code?

Just like how an html file can read ruby code when the file's name extension is "html.erb".



via Chebli Mohamed

tinymce setcontent getcontent, what is difference of default usage and format raw?

What is the difference

tinymce.activeEditor.setContent(foo);
tinymce.activeEditor.setContent(foo, {format:'raw'});

I know the documentation of tinymce.setContent/getContent but it does not explain too much. And i could not any detailed explanations or examples in stackoverflow or google. When should we use one and the other? Which drawbacks has each one? Can anyone give some more details? What I found so far is, i am using TinyMCE embedded in a java application and use it as mail reader and mail editor. When we receive an email written by outlook which contains numbered lists, the HTML of the mail contains mso tags. If we set the content which contains mso tags with default usage, setContent(foo), we can not see the numbered lists elements properly, they are left aligned. And other font problems occur. But if we use setContent(foo, {format:raw}) we can see the document properly. Why this difference occurs?



via Chebli Mohamed

Empty list bigger in size than corpus object in nltk

If some works with nltk and does a

from nltk.book import *

she will discover that text1 has object size of 64 bytes doing an

import sys
sys.getsizeof(text1)

If now she does a

text1 = []

the size of text1 increases to 72 ! Why is that? Why an empty list occupies more memory than its previous object form in my machine?

Does anyone know something about this? Thank you



via Chebli Mohamed

Do we still need to use `[...]` in Bash?

If don't care about compatibility, do we still need to use [...] in Bash? Many tutorial/book tell that [[...]] is more better/flexible than [...] e.g. [[...]] is support glob/regex, But today I still see many people prefer to use [...] as standard form, what is a reason behind this? What [[...]] can not do but [...] can do?



via Chebli Mohamed

dynamic task execution in java

I'd like to hear some advice on which technologies to use to solve this problem.

I would like a task executor based on events. These tasks are created by the user (in this moment I am thinking that a task would be a java class that implements the interface task, but I'm open to suggestions). Then the user could load a "jar" or "ear" in the application and using java reflection could execute new tasks.

Another approach I can think of would be that the user creates these tasks in a ejb, deploy the ear and make the ejb loockup to run tasks.

I appreciate any advice. sorry for my english



via Chebli Mohamed

Getting Specific Values from string

If i have a string that is

string Text="@Time:08:30PM,@Date:08/30/2015,@Duration:4,"

How would one go about extracting each of those starting with "@" and ending with the ",". I've searched and I've seen people get one pair with substring, but not how I need it. I want to say:

string Time = "08:30PM" //However i can extract it from that string
string Date = "08/30/2015" //etc...

Could it be done with Regex?

Thanks!



via Chebli Mohamed

Why am I not getting any data using these HQL queries?

I use this query to pull the highest encounter from the highest chapter a user has reached:

SELECT COUNT(hc.s) as users, highest_chapter, highest_encounter
FROM
(SELECT s, MAX(l) as highest_chapter
FROM appl9_evt
WHERE month = "201508" AND st1 = "player" AND st2 = "level_progression" AND n = "level_start"
GROUP BY s
ORDER BY highest_chapter) hc
INNER JOIN
(
SELECT s, l, MAX(get_json_object(json_data, '$.CurrentEncounter')) as highest_encounter 
FROM appl9_evt
WHERE month = "201508" AND st1 = "player" AND st2 = "level_progression" AND n = "level_start"
GROUP BY s, l
ORDER BY highest_encounter
) he
ON hc.s = he.s AND hc.highest_chapter = he.l 
GROUP BY highest_chapter, highest_encounter

Then I save it as a table and try to get only version 2.2.1 (or whatever version, a self-join I think it's called) with this:

SELECT COUNT(DISTINCT highest.s) as users, highest_chapter, highest_encounter FROM
(SELECT users as s, highest_chapter, highest_encounter 
FROM augusers221 ) highest
JOIN
(SELECT s 
FROM appl9_cpu
WHERE v_maj = '2.2.1') ver
ON highest.s = ver.s
GROUP BY highest_chapter, highest_encounter
ORDER BY highest_chapter, highest_encounter

But there's something wrong with this second stage, because I can't pull any data... Thank you in advance for looking at this wall of text.



via Chebli Mohamed

Sending to Multiple Emails in PHP

There is something off in this php, after the Reply-To email address in an email - I am getting a Cc afterward and it's not getting send to both the CC & BCC. This tells me I am making an error somewhere in this code and it's probably really obvious.

// Create email 
$email_subject = "Subject";
$email_body = "You have received interest. \n\n".
              "Name: $name \nEmail: $email \n";
$headers = "From: 1-email@email.com\n";
$headers .= "Reply-To: $email";
$headers .= "Cc: 2-email@email.com\r\n";
$headers .= "Bcc: 3-email@email.com\r\n";

mail($to,$email_subject,$email_body,$headers); // Post message



via Chebli Mohamed

bootstrap datepicker won't load from javascript

When I load the datepicker through the data-provide="datepicker", it will show up but not in safari. I also need to block out dates, such as the weekend. I was thinking both problems could be solved loading it through javascript and throwing in some config variables but I'm getting an error:

ReferenceError: $ is not defined

I'm thinking it's because maybe the jquery is being loaded in the wrong order, but other functionality is working.

Test site is here: http://ift.tt/1IAc7WZ

Field for datepicker is under "Select your prefered day & time"

Any help would be greatly appreciated!



via Chebli Mohamed

Select mismatch column values from database

I want to select and fetch all mismatch value of two table having same Column Name But Id, Name and City are different. I am Using Sql Server Management Studio

Table A:

id   Name   City

1    John   karachi

2    smith  Capetown

3     liza   Washington        

Table B:

id   Name   City

7    Grey   Dubai

8    Clarke  Texas

9     liza   Washington

OUTPUT:

7    Grey   Dubai

8    Clarke  Texas



via Chebli Mohamed

Can't Match Dates in VBA

My code is:

Application.Match(DateValue(x),dat,0)

and it's returning Error 2042

In the Watches I can see that:

The value of x is 02/01/2015 and it is a Variant/Date

The values ox DateValue(x) is 02/01/2015 and it is a Variant/Date

The value of dat(0) is #02/01/2015# and it is of the type Date

Any insights on why I'm getting th #N/A error ?

Thanks !

enter image description here



via Chebli Mohamed

Firebase Angularfire and Angular-nvD3

please visit this link. I used firebase as a backend data store. the front end is Angular. I try to draw chart by Angular-nvD3.js. when I try to read the data from firebase it is take time. So, the array come empty Array[]. then the data come but no update to the chart.

can someone help PlZ



via Chebli Mohamed

How to update a table with values coming from another table?

I found similar ones at here, but not exactly the same.

Here is what I need:

I have two tables a and b, with the following structures:

Table a:

id  b_id    b_col2 b_col3 col5
1   NULL    NULL   NULL   NULL
2   XXX     XXX    XXX    XXX

Table b:

id    col2 col3
101   ABC  DEF
102   XXX  XXX

UPDATE: The goal is that with three given inputs (id, b_id, col5), one row of table a should be updated accordingly. Specifically, b_col2 and b_col3 are extracted from table b with that b.id = b_id. For example, I want to update the first item of a with b_id=101 and col5 = ZZZ. Notice that b_col2 = ABC and b_col3 = DEF in this case, the updated row should be:

id  b_id    b_col2 b_col3 col5
1   101     ABC    DEF    ZZZ

I know there is at least a not-so-effective way which I don't like:

update a set 
    a.b_id = some-id, 
    a.b_col2 = (SELECT col2 FROM b WHERE b.id = some-id),
    a.b_col3 = (SELECT col3 FROM b WHERE b.id = some-id),
    ...
    where a.`id` = xxx

As I said, this is not a very good method, and I am just wondering if there is any better method?



via Chebli Mohamed