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:

How do you read from stdin in Python?

How do you read from stdin in Python?

I'm trying to do some of the code golf challenges, but they all require the input to be taken from stdin. How do I get that in Python? 1:You could use the fileinput module:import fileinputfor line in fileinput.input(): passfileinput w

How to make a query with group_concat in sql server [duplicate]

How to make a query with group_concat in sql server [duplicate]

This question already has an answer here: Simulating group_concat MySQL function in Microsoft SQL Server 2005? 9 answers I know that in sql server we c

Return row only if value doesn't exist

Return row only if value doesn't exist

I have 2 tables - reservation: id | some_other_column ----+------------------ 1 | value 2 | value 3 | valueAnd second table - reservation_log: id | reservation_id | change_type ----+----------------+------------- 1

Efficiently convert rows to columns in sql server

Efficiently convert rows to columns in sql server

I'm looking for an efficient way to convert rows to columns in SQL server, I heard that PIVOT is not very fast, and I need to deal with lot of records.This is my example: ---------------------------- | Id | Value |ColumnName | -----

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

hex string to character in python

hex string to character in python

I have a hex string like: data = "437c2123"I want to convert this string to a sequence of characters according to the ASCII table.The result should be like: data_con = "C|!#"Can anyone tell me how to do this? 1:In [17]: data = "437c2123

What is a LEFT JOIN in PostgreSQL

What is a LEFT JOIN in PostgreSQL

I've seen a query using a LEFT JOIN as opposed to an INNER or LEFT OUTER.What is a LEFT JOIN exactly? 1:Where an inner join returns only entries that match in both tables, a left join takes all the entries from first table and any that m

__file__ does not exisit in Jupyter Notebook

__file__ does not exisit in Jupyter Notebook

I'm on a Jupyter Notebook server (v4.2.2) with Python 3.4.2 andI want to use the global name __file__, because the notebook will be cloned from other users and in one section I have to run:def __init__(self, trainingSamplesFolder='samples',

How do I read/write binary files?

How do I read/write binary files?

I've written a simple Huffman encoding in Ruby. As output I've got an array, for example:["010", "1111", "10", "10", "110", "1110", "001", "110", "000", "10", "011"]I need to write, and then read, it to and from a file. I tried sev

MAX function in where clause mysql

MAX function in where clause mysql

How can I use max() function in where clause of a mysql query, I am trying: select firstName,Lastname,MAX(id) as max where id=max;this is giving me an error:Unknown column 'max' in 'where clause'Any Help? Thanks in advance. 1:You can't r

SQL Return only duplicate rows

SQL Return only duplicate rows

I have a query that returns the following rows:StateId, OrderId, OrderTime, PermitIdI need to return only the rows that are exact duplicates all across the board so each record must be exctly the same as the other record for it to be a dupl

Faster 16bit multiplication algorithm for 8-bit MCU

Faster 16bit multiplication algorithm for 8-bit MCU

I'm searching for an algorithm to multiply two integer numbers that is better than the one below. Do you have a good idea about that? (The MCU - AT Tiny 84/85 or similar - where this code runs has no mul/div operator)uint16_t umul16_(uint16

what is the query to get “related tags” like in stack overflow

what is the query to get “related tags” like in stack overflow

i have 3 tables:links (id, linkName) tags (id, tagName) tagsBridge (tagID, linkID) i am trying to support showing related tags like in SOF. so if you click on tags "XYZ", right now i am showing all the links with tag "XYZ" but i also wa

Starting out with an application for Facebook Connect on the iPhone

Starting out with an application for Facebook Connect on the iPhone

I would like to make a button in order for the user to be able to connect and join a group I have created in Facebook. Is this possible with Facebook Connect? Is there a tutorial or something? 1:You can try checking out the newly-updated

How to do a moving average on a range of dates in SQL?

How to do a moving average on a range of dates in SQL?

Let's just say I have two columns, DATE and VALUE. The dates are not necessarily regularly spaced intervals. How can I create a moving average on VALUE over the past N days? I'm using postgres but mysql solutions would also be helpful.Data:

Calling function of Action class in Jsp Struts2

Calling function of Action class in Jsp Struts2

I have a little scenario. I have two POJO classes and two tables User and Domain(same name for tables). Every user will belong to one and only one domain. I have two Action classes one is UsersManagemntAction and other is DomainsManagementA

Return values from one script to another script

Return values from one script to another script

I have the following script that will run each script (sequentially) in a directory:import osdirectory = []for dirpath, dirnames, filenames in os.walk("path\to\scripts"): for filename in [f for f in filenames if f.endswith(".py")]:

python - networkx - graph different colored nodes using two lists

python - networkx - graph different colored nodes using two lists

I'm new to networkx and need some help. I've searched previously and couldn't resolve my issue. I have a networkx graphviz image I made, using a list as input for the nodes, and a two column file for the edges. A second file contains the it

pass list item from c# to javascript array

pass list item from c# to javascript array

I have following code to show multiple marker on gmap I want to make this dynamic so i have to pass this var locations = [ ['Bondi Beach', -33.890542, 151.274856, 4], ['Coogee Beach', -33.923036, 151.259052, 5],

d3 pattern to add an element if missing

d3 pattern to add an element if missing

With D3, I'm finding myself doing this a lot:selectAll('foo').data(['foo']).enter().append('foo')I'd like to simply add a node if it doesn't already exist, because I need to do updates at different places in the DOM tree, and the data I hav

How do you add the star ratings for products in woocommerce?

How do you add the star ratings for products in woocommerce?

I have a woocommerce store and I want to add star ratings to each of the products when you see their thumbnails. I already have the stars in the big product view but I want them to display below each thumbnail like in most ecommerce stores

has_many :through questions

has_many :through questions

I was previously using has_and_belongs_to_many, and have converted to has_many :through. Here's how it looks for a list of games that can have many users playing. With this, I can do game.users and user.games....:class Game :destroy has_

Tkinter: Treeview widget

Tkinter: Treeview widget

At the moment I am working on a program that has its own project files and inside that are like sub-files and I want to know how to use the treeview widget to display all the sub-files inside the project file, Any Ideas?Thanks in advance!

How create a P2P web-chat without any server?

How create a P2P web-chat without any server?

is there a way to create a P2P web-chat without any server ? 1:If you're willing to use Flash, check out Adobe Stratus, which allows for peer to peer data and video streaming. http://labs.adobe.com/technologies/stratus/ 2:Yes, but you