draw multiple polygons from a dataframe

I want to create a simple map for my stores showing the size of all the different checkouts. I have 3 different till types. One is sized 4 and the other 2 are sized 1.

e.g.

Till1 – 4

Till2 – 1

Till3 – 1

I have created a table as per the following:



Till Size Polygon
Till1 4 [[0,1],[0,5],[1,5],[1,1]]
Till2 1 [[1,1],[1,2],[2,2],[2,1]]

ETC

Running this code:

df1.iloc[0]['polygon']

I get ‘[[0,1],[0,5],[1,5],[1,1]]’

However when I try to make this into a vector it struggles:

Polygon(df1.iloc[0]['polygon'], True)

TypeError: len() of unsized object

I think it’s reading it as a string and I need to pass the individual parts somehow.

Any ideas?

The final code would look similar to this:

fig, ax = plt.subplots()
patches = []
num_polygons = len(df1)
for i in range(num_polygons):
    #polygon = Polygon([[1,1],[1,5],[2,5],[2,1]], True)
    polygon = Polygon(df1.iloc[0]['polygon'], True)
    patches.append(polygon)
p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4)
colors = 100*np.random.rand(len(patches))
p.set_array(np.array(colors))
ax.add_collection(p)
plt.ylim([0,10])
plt.xlim([0,10])
plt.show()

All topic

Certificates, and multiple CNAME records

If I host a service that has endsystem.example.org as it’s URL, and it is hosting a certificate for www.example.org, and I have a CNAME intermediate.example.org that points to endsystem.example.org, and a CNAME www.example.org that points to intermediate.example.org, will the certificate work for a user in the browser, or will it be considered a man-in-the-middle attack ? Or perhaps fail because intermediate.example.org is not part of the certificate ?

So the scenario is: www.example.org -> intermediate.example.org -> endsystem.example.org, and endsystem.example.org is hosting a certificate for www.example.org, will a browser accept it ?

All topic

How to add multiple products to cart at the same time with attributes

I have different view blocks that display multiple products on the same page, each product has their own attributes such as product bundle and custom line item, these serves as an option set / criteria of the main product. The results of the options slider will be the value of the customs line item that is hidden.

What I plan to accomplish is to add all these selected products with the selected attributes on the cart at the same time with just one button.

Example:

Product 1:

enter image description here

Product 2:

enter image description here

These are the methods/modules I have tried:

  • VBO + Rules : https://www.drupal.org/node/1468392#comment-10270105
  • Commerce Add to Cart Extras
  • Commerce Ajax Add to Cart + Jquery : Looping through all selected products then clicking the add to cart button by jquery. It works but not that great because sometimes some of the products are not being added. Maybe because of all the ajax request running at the same time?

The first two methods work for the main product only, no attributes of the customs line item and bundle products. I tried including the add to cart form in the view with the VBO or commerce product: quantity field of commerce add to cart extras but it doesn’t work maybe because it’s a form within a form.

Does anyone have any suggestion on how to make this work?

Thank you in advance!

All topic

Convert multiple bézier segments to a nurbs curve

I have multiple cubic Bézier curve segments which are contiguous and G1 (they are the result of the fitting of many curve samples).

Now I would like to transform these Bézier segments into a single NURBS curve. When there is a single Bézier segment, the operation is rather easy:

  • Same 4 control points as the Bézier segment
  • Knots vector is 0 0 0 0 1 1 1 1
  • degree is 3

Now when there are multiple Bézier segments I don’t know what to do to convert them into a single NURBS. Any idea?

All topic

python rsync to copy the logs from multiple remote Servers

I have the below code which i’m working to copy(using rsync) the contents From remote host labserver01 and dumps those into the directory /var/log/infoSec/ on the base system from where scripts runs and this works correctly and sends e-mail to the recipients, However i’m also figuring out to include a way to send e-mail even if it fails.

I’m Just wondering if there is better way do this, i’m sure there will be more elegant ways.

Appreciate any idea and review in advance.

#!/usr/bin/python3
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
import subprocess
import argparse
import sys
import os

#Dir Structure
dest_dir = "/infralogs/external_dns_logs"
rsync_user = "root"

email_sender = "dnslogger@udalt.com"
email_receiver = "gusain@udalt.com"
msg = ""

parser = argparse.ArgumentParser()
parser.add_argument("-n","--hosts",dest="hosts",help="enter remote host/hosts name, comma seperated",metavar="HOSTS")
parser.add_argument("-s","--src",dest="source",help="source file/directory",metavar="SOURCE")
parser.add_argument("-e","--exclude",dest="exclude",help="Exclude files/Directories, comma seperated list",metavar="EXCLUDE")

if len(sys.argv) < 7:
    print(len(sys.argv))
    parser.print_help()
    parser.exit()

args = parser.parse_args()

def sync(host,dest_dir):
    exclude = ""
    if not os.path.exists(dest_dir):
        os.mkdir(dest_dir)
    if ',' in args.exclude:
        for excl in args.exclude.split(','):
            exclude = exclude + " --exclude " + excl
        cmd = "rsync -e 'ssh -o StrictHostKeyChecking=no' -auPz %s %s@%s:%s %s/"%(exclude,rsync_user,host,args.source,dest_dir)
    else:
        cmd = "rsync -e 'ssh -o StrictHostKeyChecking=no' -auPz --exclude %s %s@%s:%s %s/"%(args.exclude,rsync_user,host,args.source,dest_dir)
    cmd_content = cmd
    p = subprocess.Popen(cmd,shell=True)
    p.wait()
    print("DONE")
    return cmd_content + " Rsync process completed."  # returns the msg to the caller

msglist = []             # a list to store the cmd_contents for the mail body

if ',' in args.hosts:
    for host in args.hosts.split(','):
        dest = dest_dir + "/" + host
        msglist.append(sync(host,dest))
else:
    dest = dest_dir + "/" + args.hosts
    msglist.append(sync(args.hosts,dest))

msg = "n".join(msglist)                 # combine all cmd_contents, one per line


try:
    Mail = smtplib.SMTP('mailserver.global.udalt.com', 25, 'localhost.udalt.com')
    mail_obj = MIMEMultipart('alternative')
    mail_obj["From"] = email_sender
    mail_obj["To"] = email_receiver
    mail_obj["Cc"] = "gusain@udalt.com"
    mail_obj["Subject"] = "Rsync process completed Successfully."
    mail_obj.attach(MIMEText(msg, 'plain'))
    Mail.sendmail(from_addr=[email_sender], to_addrs=[email_receiver],msg=mail_obj.as_string())
    print("Mail Sent to %s" % (email_sender))
except Exception as error:
    print("Mail Failed - {}".format(error))

Command Execution method:

$ /usr/bin/dns_rsync.py -n labserver01 -s /var/log/infoSec/ -e "null"

All topic

How can I use OR constraint with multiple semi-joins?

How can I implement the below SQL using semijoin in either SparkSQL or Dataframe API?

select * 
from foo
left join a on foo.id = a.id
left join b on foo.id = b.id
where exists (select 1 from a x where foo.id = x.id)
or exists (select 1 from b x where foo.id = x.id)
;

I have tried this but it functions as AND

.join(loincDF, foo("id") <=> a("id"), "leftsemi")
.join(loincDF, foo("id") <=> b("id"), "leftsemi")

All topic

Permutation of multiple sets of elements where adjacent elements are different.

There are 5 red balls, 6 white balls and 7 black balls. How many ways can we arrange these ball in a line where the adjacent balls are in different color? And generalize the 5, 6, 7 into R, W, B.

All topic

The sum of three consecutive cubes numbers produces 9 multiple

I want to prove that $n^3 + (n+1)^3 + (n+2)^3$ is always a $9$ multiple

I used induction by the way.

I reach this expression: $(n+1)^3 + (n+2)^3 + (n+3)^3$

But is a lot of time to calculate each three terms, so could you help me to achieve the induction formula

Thanks in advance

All topic

Time manager with multiple vector layers QGIS

I am trying to create an animation using Time Manager for multiple vector layers.

Each layer is a graduated map of rent prices for a quarter of a year.

I have 8 quarters, each in a separate layer. 4 for 2016, 4 for 2017. I would like to run an animation that shows rent prices in Q1 2016 and runs until Q4 2017.

My layers have no date column. So I imported a csv with dates for each quarter, e.g. for Q1 2017 there is a column Q1_2017 with the value 2017-01-01 and I computed a join to this csv for each of the 8 vector layers to give them a unique date column.

When I run time manager I am adding a layer with the following settings:

time manager settings

When I add all my layers in a similar way and try to run the animation I get an error like the below:

error

Can anyone help? Is it my settings? Or is it the join? Does the date field need to be in the vector layer itself?

Thanks!

All topic

Do bears with multiple letter bonuses give you a bonus power letter or only in combination

Bears, such as the Viking bear, can give you bonuses when you play letters.

Is this bonus applied only when all letters appear together or separately?

All topic