Random color generator

Random color generator

Given this function, I want to replace the color with a random color generator.document.overlay = GPolyline.fromEncoded({color: "#0000FF", weight: 10, points:

Create a dictionary with list comprehension in Python

Create a dictionary with list comprehension in Python

I like the Python list comprehension syntax.Can it be used to create dictionaries too? For example, by iterating over pairs of keys and values:mydict = {(k,v) for (k,v) in blah blah blah} # doesn't work 1:In Python 2.6 and earlier, the

What's the purpose of the LEA instruction?

What's the purpose of the LEA instruction?

For me, it just seems like a funky MOV. What's its purpose and when should I use it? 1:As others have pointed out, LEA (load effective address) is often used as a "trick" to do certain computations, but that's not its primary purpose. Th

What is the difference between char s[] and char *s?

What is the difference between char s[] and char *s?

In C, one can use a string literal in a declaration like this:char s[] = "hello";or like this:char *s = "hello";So what is the difference? I want to know what actually happens in terms of storage duration, both at compile and run time.

How do I convert an existing callback API to promises?

How do I convert an existing callback API to promises?

I want to work with promises but I have a callback API in a format like:1. DOM load or other one time event:window.onload; // set to callback...window.onload = function(){};2. Plain callback:function request(onChangeHandler){...request(func

What is `type_info::before` useful for?

What is `type_info::before` useful for?

According to cplusplus.com, the std::type_info::before() function... Returns true if the type precedes the type of rhs in the collation order. The collation order is just an internal order kept by a particular implementation and is not ne

Get rid of leading zeros for date strings in Python? [duplicate]

Get rid of leading zeros for date strings in Python? [duplicate]

This question already has an answer here: Python strftime - date without leading 0? 16 answers Is there a nimble way to get rid of leading zeros for da

Split stacks unneccesary on amd64

Split stacks unneccesary on amd64

There seems to be an opinion out there that using a "split stack" runtime model is unnecessary on 64-bit architectures. I say seems to be, because I haven't seen anyone actually say that, only dance around it: The memory usage of a typica

RAILS: How to get has_many associations of a model

RAILS: How to get has_many associations of a model

how I can get the has_many associations of a model?For example if I have this class:class A I would a method like this:A.get_has_manythat return[B,C]Is it possible? Thanks! 1:You should be using ActiveRecord reflections.Then you can type

Convert array-of-hashes to a hash-of-hashes, indexed by an attribute of the hashes

Convert array-of-hashes to a hash-of-hashes, indexed by an attribute of the hashes

I've got an array of hashes representing objects as a response to an API call. I need to pull data from some of the hashes, and one particular key serves as an id for the hash object. I would like to convert the array into a hash with the k

nhibernate mapping: A collection with cascade=“all-delete-orphan” was no longer referenced

nhibernate mapping: A collection with cascade=“all-delete-orphan” was no longer referenced

I am having some probs with my fluent mappings. I have an entity with a child collection of entities i.e Event and EventItems for example.If I set my cascade mapping of the collection to AllDeleteOrphan I get the following error when saving

What should the return type be when the function might not have a value to return?

What should the return type be when the function might not have a value to return?

In the old days, you might have a function like this:const char* find_response(const char* const id) const;If the item could not be found, then a null could be returned to indicate the fact, otherwise obviously return the relevant string.Bu

How to combine filter and map in scala?

How to combine filter and map in scala?

I have List[Int] in Scala. The List is List(1,2,3,4,5,6,7,8,9,10). I want to filter the list so that it only has even numbers. And I want to muliply the numbers with 2. Is it possible?I hope I have explained the question clearly. If u have

com.google.gson.internal.LinkedHashTreeMap cannot be cast to my object

com.google.gson.internal.LinkedHashTreeMap cannot be cast to my object

I have JSON file looks like { "SUBS_UID" : { "featureSetName" : "SIEMENSGSMTELEPHONY MULTISIM", "featureName" : "MULTISIMIMSI", "featureKey" : [{ "key" : "SCKEY", "valueType" : 0,

Python: finding lowest integer

Python: finding lowest integer

I have the following code:l = ['-1.2', '0.0', '1']x = 100.0for i in l: if i The code should find the lowest value in my list (-1.2) but instead when i print 'x' it finds the value is still 100.0Where is my code going wrong? 1:To find

Changing cell color using apache poi

Changing cell color using apache poi

I'm using Apache POI to read data in a spreadsheet of part numbers. I look up the part number in our database, if we have a CAD drawing of the part I color the part number cell green, if we don't I color it red. After the processing is do

Get attribute of child element

Get attribute of child element

If I have the following markup: Hours How can I target the tag within the anchor tag? There are five other similar tag entries, each with a different value for sortcat= 1:$(".sort").click(function(){ var cat = $(this).

How to remove all the polylines from a map

How to remove all the polylines from a map

FollowingHow to draw a path between two markersI had to add lot of polylines between two markers, to make a path.One of the markers is draggable, lets say source is draggable.So, when user starts dragging the marker, the path previously dra

Getting index of item while processing a list using map in python

Getting index of item while processing a list using map in python

While processing a list using map(), I want to access index of the item while inside lambda. How can I do that?For exampleranked_users = ['jon','bob','jane','alice','chris']user_details = map(lambda x: {'name':x, 'rank':?}, ranked_users)How

How to Map AD Groups to User Role Spring Security LDAP

How to Map AD Groups to User Role Spring Security LDAP

I have a web application built using Java Spring MVC.I'm just setting up spring security connecting to an LDAP server for authentication.I've successfully set it up so that I am able to login to my application but I can't find anything to h

Organizing memcache keys

Organizing memcache keys

Im trying to find a good way to handle memcache keys for storing, retrieving and updating data to/from the cache layer in a more civilized way.Found this pattern, which looks great, but how do I turn it into a functional part of a PHP appli

Do not serialize Entity Framework class references in JSON (ServiceStack.Text library)

Do not serialize Entity Framework class references in JSON (ServiceStack.Text library)

As most of the people I've also ran into a problem of circular reference error when serializing (terrible) EF objects to JSON. Doing db.Detach(efObject) helps - but I still get garbage like "EntityKey" outputted.So I was wondering if there

Recursive JSON view of an entity with one-to-many relationship in REST controller

Recursive JSON view of an entity with one-to-many relationship in REST controller

I'm using SpringBoot and JPA to build a REST interface. Now, I have a strange JSON returned for the list of products fetched from the database. Let's say that I have:@Entitypublic class Product { @Id @GeneratedValue(strategy = Generat

Android - How to open google maps with Intent and KML?

Android - How to open google maps with Intent and KML?

I need to open google maps using kml file wich already exists on sdcard. (/sdcard/example.kml)I tried:Open local KML File in Google Maps on Androidthis answer is wrong, when click on link, maps open, but search for location "file:///sdcard/

Do commercial (paid) iPhone apps have to pay a license to Google for Maps? [closed]

Do commercial (paid) iPhone apps have to pay a license to Google for Maps? [closed]

I know that happens with commercial websites so I was wondering if commercial iPhone apps that use the MapKit (especially those that generate a lot of traffic) need to get any sort of license from Google Maps as well.My best guess would be