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