Posts

python - How to highlight a specific word in tkinter? -

i need highlight specific word in text within tkinter frame. in order find word, put balise in html. in text "hello i'm in |house|" want highlight word "house". my frame defined that: class framecodage(frame): self.t2codage = text(self, height=20, width=50) and insert text code: fenetre.fcodage.t2codage.insert(end, res) , res being variable containing text. i saw code on other post: class customtext(tk.text): '''a text widget new method, highlight_pattern() example: text = customtext() text.tag_configure("red", foreground="#ff0000") text.highlight_pattern("this should red", "red") highlight_pattern method simplified python version of tcl code @ http://wiki.tcl.tk/3246 ''' def __init__(self, *args, **kwargs): tk.text.__init__(self, *args, **kwargs) def highlight_pattern(self, pattern, tag, start="1.0", end="end", regexp=false): ...

servicebus - Trying to communicate with azure service bus from android device using proton-j -

i trying make android app talk azure service bus using proton-j library when try add proton-j-0.11.1 jar file library on android project. try send azure service bus end exception broken epipe broken: 01-15 19:37:02.165: e/proton.messenger(822): error processing connection 01-15 19:37:02.165: e/proton.messenger(822): java.net.socketexception: sendto failed: epipe (broken pipe) 01-15 19:37:02.165: e/proton.messenger(822): @ libcore.io.iobridge.maybethrowaftersendto(iobridge.java:506) 01-15 19:37:02.165: e/proton.messenger(822): @ libcore.io.iobridge.sendto(iobridge.java:489) 01-15 19:37:02.165: e/proton.messenger(822): @ java.nio.socketchannelimpl.writeimpl(socketchannelimpl.java:378) 01-15 19:37:02.165: e/proton.messenger(822): @ java.nio.socketchannelimpl.write(socketchannelimpl.java:336) 01-15 19:37:02.165: e/proton.messenger(822): @ org.apache.qpid.proton.driver.impl.connectorimpl.write(connectorimpl.java:168) 01-15 19:37:02.165: e/proton.messenger(822): @ o...

java - Mail form in Play Framework 2.0.X -

i'm using play framework (2.0.4) , wonder best way create page form sending email. know there plugin sending email, isn't problem - can write controller method sends email. my question more action should provide (in routes file). should create post action takes arguments (sender name, sender email, subject, body)? or should somehow create model object filled in form , pass action in controller? best practice? , how glue (how should action in routes file, how should view like)? you need 2 views - 1 form (let's call mailform ), second - body ( bodyhtml ) of mail. (optionally can create bodytxt if want send html , txt version. dedicated model helper, use play's form<t> , if required able store sent messages in db. anyway can operate on map of strings - if plan make many dynamic forms (with unknown number of fields). after filling form go example sendemail() action, need fill form ( bindfromrequest ) create object , save db , pass bodyhtml view ...

Unicorn + Nginx Rails production error -

i'm following this tutorial deploy ror app capistrano i'm getting error in production server [error] 28314#0: *1 connect() unix:/tmp/unicorn.myapp.sock failed (111: connection refused) while connecting upstream, client: xx.xxx.xx.xx, server: , request: "get / http/1.1", upstream: "http://unix:/tmp/unicorn.myapp.sock:/", host: "myapp.cloudapp.azure.com" my /etc/nginx/sites-available/default upstream app { # path unicorn sock file, defined server unix:/tmp/unicorn.myapp.sock fail_timeout=0; } server { listen 3000; server_name localhost; root /home/deploy/apps/myapp/current/; try_files $uri/index.html $uri @app; location @app { proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_redirect off; proxy_pass http://app; } error_page 500 502 503 504 /500.html; client_max_body_size 4g; keepalive_timeout 10; } i changed server many different things, exac...

javascript - Promise inside a settimeout -

i'm trying run promises in 1 second delay each other, api server i'm working has 1 request per second limit. here code currently var delay = 0; return categories.reduce(function(promise, category) { var id = settimeout(function() { promise.then(function() { return client.itemsearch({ searchindex: configuration.searchindex, categoryid: category.id, keywords: currentkeyword }).then(function(results) { var title = results[0].title; var cat = category.name; var price = results[0].price; return db.insertproduct(title, cat, price); }); }).catch(function(err) { console.log("error", err); }); }, delay * 1000); delay += 1; }, promise.resolve()); for every time loops over, increases delay one, next item start delay of 1 second. so if first item, 0*1 = 0, 1*1 = 1, 2*1 = 2... on for reason, doesnt work, without settimeout works perfectly. as far can tell, there s...

javascript - Looping Through Array Until Solution Found -

so have array below first value of each array being road name, second value being connections road , third can ignore (all fake roads). trying find quickest route (least steps) 1 road looking @ connections.. code looking through phases defined myself, add further connections i'll have add further logic - there anyway of looping through undefined amount until finds best route (there no point can't find route)? array: var road = [ //name, connection, [left, middle, right] ["upper-g", ["lower-g", "left corner", "top corner"], []], ["upper-tw", ["lower-tw", "left corner", "right corner"], []], ["upper-rg", ["lower-rg", "upper-rg", "top corner", "right corner"], []], ["lower-g", ["upper-g", "left corner", "top corner"], [] ], ["lower-...

c# - Proper Architecture: Adding Attributes to Domain Model in .NET -

Image
background i jeffrey palermo's onion architecture model (similar hexagonal architecture ) prescribes domain model @ 'center' , concrete implementations of infrastructure, concrete repositories on periphery. so have domain model : //https://libphonenumber.codeplex.com/ using libphonenumber; namespace myapplication.domain { public class speaker { public virtual string name {get;set;} public virtual phonenumber phonenumber {get;set;} } } now need expose domain model other teams: the ui team hypothetically wants add several data validation attributes , custom json serialization attributes. the infrastructure team hypothetically wants add xml serialization attributes , custom attributes 3rd party database implementation. the public api team hypothetically wants add wcf attributes. i don't want give every team carte blanche add attributes domain model and don't want them adding of "layer specific" depend...