Posts

Showing posts from January, 2010

php - Join tables from different databases using doctrine symfony2 -

i found can define different database connections doctrine in symfony2 so, want know if possible execute query join using tables different databases, have been trying without success far.

Django: Display DB data to only logged in users with multiple filters -

Image
i have db table below. url display db data is url(r'^editinvoice/(?p<pk>\d+)/$',views.edit_invoice,name='editinvoice'), template.html code redirects page is <a href="{% url "editinvoice" pk=invoices.id %}">{{ invoices.invoice_number }}</a></td> invoices.id foreign key of above db table. the link passes correct pk , details correctly displayed. if change id in url, can see information if not user related it. should done information should available logged in user if user if owner of it. for views method edit_invoice , use @login_required decorator. in method raise 403 error: from django.core.exceptions import permissiondenied def edit_invoice(request, pk): invoice = invoice.objects.get(pk=pk) if invoice.user != request.user: raise permissiondenied see django docs @login_required . also see django doc permissiondenied . edit: yea having "does not exist" makes more s...

to evaluate polynomial in Haskell -

i have function( eval ) evaluate polynomial. eval coeffs value = ....... coeffs list of coefficents. value x in math ex) calculate 3x^2 + 2x + 1 x=20 coeffs stored reverse order. when type coefficient above, stored [1,2,3] program working , last part wrong (the value of polynomial): here code getcoeff 0 ls = return ls getcoeff n ls = putstr "what x^" putstr (show(n-1)) putstr " coefficient: " v <- getline w <- getcoeff (n-1) ((read v :: float):ls) return w evalpoly = putstr "what degree of polynomial: " v <- getline l <- (getcoeff ((read v :: int)+1) []) putstr "what value want evaluate at: " x <- getline putstr "the value of polynomial is: " putstr (show (polyevaluate (l) (read x :: float))) putstr "\n" eval [] x = 0.0 eval (l) x = what degree of ...

twitter - Tweeting Images Programatically -

i have business requirement project i'm working on allow users print, email , share image on facebook , twitter. first 3 simple whereas i'm finding impossible find succinct example of how post tweet image using client side scripting. i've seen various solutions using twitter api , of them php based. surely can't difficult. any appreciated. this example uses twitterapi python library. from twitterapi import twitterapi tweet_text = 'some tweet text' image_path = './some_image.png' consumer_key = '' consumer_secret = '' access_token_key = '' access_token_secret = '' api = twitterapi(consumer_key,consumer_secret,access_token_key,access_token_secret) # step 1 - upload image file = open(image_path, 'rb') data = file.read() r = api.request('media/upload', none, {'media': data}) print('upload media success' if r.status_code == 200 else 'upload media failure') # step 2...

networking - Detect a captive portal on iOS -

so i'm able detect whether or not user has basic internet connection fine using apple's reachability class. however, when try detect whether or not connected wi-fi network utilizes captive portal, networkstatusreachableviawifi , makes sense. however, returned if user using wifi connection. i need able detect both no internet connection , captive portal situation, no internet. are there reliable api's can accomplish task? based off article, http://blog.erratasec.com/2010/09/apples-secret-wispr-request.html#.vxkmrjmriy5 , apple pings internal address when connect wifi check captive portal. i'd prefer avoid pinging outside networks, if must, know how ping same apple address , use response tell if user has captive portal up? edit: i've come across nsurlconnectiondelegate , method connection:willsendrequestforauthenticationchallenge: . think method may able need, can send basic request www.google.com , make myself delegate, , if method gets hit need do. think ...

java - Spring RestTemplate unable to get JSESSIONID cookie -

in spring boot/spring security application i'm trying login spring resttemplate. this code: final keystore keystore = keystore.getinstance("pkcs12"); keystore.load(new fileinputstream(new file("keystore.p12")), "changeit".tochararray()); final sslcontext sslcontext = new sslcontextbuilder().loadtrustmaterial(null, new trustselfsignedstrategy()).loadkeymaterial(keystore, "changeit".tochararray()).build(); final sslconnectionsocketfactory socketfactory = new sslconnectionsocketfactory(sslcontext, noophostnameverifier.instance); final httpclient httpclient = httpclientbuilder.create().setsslsocketfactory(socketfactory).setredirectstrategy(new laxredirectstrategy()).build(); final clienthttprequestfactory requestfactory = new httpcomponentsclienthttprequestfactory(httpclient); final resttemplate resttemplate = new resttemplate(requestfactory); final httpheaders headers = new httpheaders(); headers.add("cookie...

java - Looking for a way to replace a string from a pdf by retaining the formatting -

i have 2 static pdfs. second pdf having few place holders.at runtime replacing place holders strings application property file.finally append second pdf first pdf. formatting lost while doing it.please see code below, private void appendpdf() throws documentexception, ioexception { //source pdf pdfreader reader_glossary = new pdfreader(gloosary); pdfstamper stamper = new pdfstamper(reader_glossary, new fileoutputstream(dest)); //adding new page in end of src pdf stamper.insertpage(reader_glossary.getnumberofpages() + 1, reader_glossary .getpagesizewithrotation(1)); pdfcontentbyte srccbytes = stamper .getovercontent(reader_glossary.getnumberofpages()); pdfreader readerout = new pdfreader(src); pdfreadercontentparser parser = new pdfreadercontentparser(readerout); textextractionstrategy strategy = parser.processcontent(1, new locationtextextractionstrategy()); string data = new string(strategy.getresultantt...

node label/key in XText when translating from grako -

in grako 1 can use following name:e add result of e ast using name key. example var_def = var+:id {',' var+:id}* what translation of xtext? tried var_def: var=id (',' var=id)*; which not failing, raising following warning multiple markers @ line - possibly assigned value of feature 'var' may overridden subsequent assignments. - assignment override possibly assigned value of feature 'var'. i think trying mimic name behavior, not have success. with solution last id available in ast. assume var should multi-valued feature holding ids, not last one. can expressed as var_def: var+=id (',' var+=id)*; in resulting ast var list of ids.

python - How to create global variables? -

i need create variable (an array of floats) accessible , modifiable python controllers. if want know why need this, i'm trying implement neuroevolution , need store neural network parameters. i'm new python. there dictionary ( https://docs.python.org/2/tutorial/datastructures.html ) accessible globally in blender. it comes gamelogic-library , called globaldict http://wiki.gameblender.org/index.php?title=globaldict usage: import gamelogic ... gamelogic.globaldict['key'] = value ... value = gamelogic.globaldict['key']

css3 - responsive design with bootstrap -

i m trying have responsive page has 2 buttons on top , supposed centered. under buttons added google map should cover rest of page. when try code bellow, buttons not centered , not responsive. , somehow map height longer page scrollbar shows up. , ideas m doing wrong ? <div class="container"> <div class="row"> <div class="col-md-4 center-block"> <button >click me</button> <button >click me</button> </div> </div> </div> <div class="map_container"> <div id="googlemap" class="map_canvas"></div> </div> css .map_container{ overflow:hidden; padding-bottom:56.25%; position:relative; height:0; } .map_container .map_canvas{ left:0; top:0; height:100%; width:100%; position...

dictionary - c++ using structs as data for a <map, <map, vector>> -

i having problem trying load map has map/vector combination value structs. below code have tried simplify as could: //these structs struct order { std::string a; std::string b; }; struct card { std::string c; std::string d; }; struct item { std::string e; std::string f; }; //this method read , load map void loadmap(listofvalues object) { std::map<order, std::map<item, std::vector<card>>> records; //this data structure i'm trying store //listofvalues list passed holds these values need put map for(std::vector<listofvalues>::iterator viter= object.begin(); viter != object.end(); ++viter) { std::string sreceiptrecord = (*viter).getreceipt(m_stdorderconfirmver); order order = {(*viter).geta,(*viter).getb}; item item = {(*viter).getc,(*viter).getd}; c...

android - RecyclerView parameters stick around after re-drawing the list -

Image
so, i've got recyclerview textviews on cards. 1 of these can turn red&bold, based on parameters, using holder.devicetv.settextcolor(color.red); & holder.devicetv.settypeface(null, typeface.bold); works fine, can see in image below, above black bar. later, remove cards red&bold textview, , notify adapter. results in see below black bar in image, should not case. i'm guessing because (duh) recyclerview , parameters set on before, have stayed around. don't know why chooses use cards red&bold text, does, every time. what best way fix issue? you need call holder.devicetv.settextcolor(color.black) , holder.devicetv.settypeface(null); in onbindviewholder method make sure displayed want. there might small overhead it's faster creating new view scratch.

mysql - Get max and min values along with all values and multiple where clause -

Image
i have query works good select cm.id ,cm.edited,cm.date_edited,cm.voteup,cm.votedown chat_messages cm timestampdiff(second,cm.date_edited,'$now') < 10 group cm.id which gives me entries edited in less 10 seconds. but along im trying max(voteup) , min(votedown) but dont affect first entries of first query . how can combine entries need ? example: if im getting 3 newly updates entries . want them 3 plus max of voteup , votedown . example: id edited date_edited voteup votedown 37 0 2016-03-05 22:13:03 5 0 38 0 2016-04-02 11:15:00 3 7 39 0 2016-03-05 22:10:06 10 6 40 0 2016-03-20 21:40:06 5 0 41 1 2016-04-20 22:28:59 5 0 42 1 2016-03-20 21:59:15 0 20 43 1 2016-04-21 22:20:25 8 0 <---- new updated my wished result id edited date_edited ...

c# - How to protect a website with authorization without a user signing in? -

the scenario a signed in user prepares material , dispatches number of email addresses. in each email, there's link webpage visitors can read , leave suggestions. since can't request visitors register themselves, pages visited exposed without authorization. 1 requires valid guid hit existing page, though. my question if there's method provide authorization of users not signed in . guid token sent out email accounts best protection can offer, given can't bothered sign in manually themselves? i rejected idea of tracking ip numbers since can't guarantee won't accessing website different locations. you can use shared access signature approach. azure uses getting access storage (with policies expiration time, etc), onedrive uses similar approach sharing files, etc. think (you mentioned azure) can use azure storage sas mechanisms that. without expiration , other policies , guid, believe, not ideal solution.

android - Cardboard unity sdk 0.7 CardboardAudio Renderer effect not found -

Image
recently downloaded new version(0.7) of google cardboard sdk unity. while importing package error occurred, know it's everybody(and have been told hitting cancel has no effect). (odmowa dostępu means acces denyed) but then, after hitting cancel error occurres: effect cardboardaudio renderer not found. check project contains correct native audio plugin libraries , importer settings set correctly. effect cardboardaudio renderer effect of master group of cardboardaudiomixer. before upgrading sdk 0.7 worked fine. do know how can fix that? appreciated. if not clear let me know. i removed effect ( see below ) worked. check lib: in case libaudiopluginvrunity.so file copied on new project under assets/plugins/libs/armeabi-v7a/ . can check see if it's missing: in project tab click on assets->plugins->android->libs->armeabi-v7a in window right of doubleclick on libaudiopluginvr. this should bring information in inspector showing path verif...

javascript - Converting node async code to promises -

i'm experimenting promises - namely when.js - , want convert test code - little unclear how after reading docs. experiments far have been far messier standard callback pyramids think missing shortcut. here's sample code replicate: async1(function(err, res) { res++; async2(res, function(error, result) { done(); }) }) nodefn.call(async2, nodefn.call(async1)).ensure(done); here, async2 gets called synchronously , promise async1() argument - doesn't wait async1 resolve. chain them, need use nodefn.call(async1).then(nodefn.lift(async2)).ensure(done); // equivalent to: nodefn.call(async1).then(function(result) { return nodefn.call(async2, result); }).ensure(done); i want perform logic between 2 calls then need put function in chain, or modify 1 of functions in chain: nodefn.call(async1) .then(function(res){return res+1;}) // return modified result .then(nodefn.lift(async2)) .ensure(done); // or nodefn.call(async1).then(funct...

sql server 2012 - Conditional Row Deleting in SQL -

i have table contains 4 columns. need remove of rows based on code , id columns. code of 1 initiates process i'm trying track , code of 2 terminates it. remove rows specific id when code of 2 comes after code of 1 , there not additional code 1. example, current data set looks this: code deposit date id 1 $100 3/2/2016 5 2 $0 3/1/2016 5 1 $120 2/8/2016 5 1 $120 3/22/2016 4 2 $70 2/8/2016 3 1 $120 1/3/2016 3 2 $0 6/15/2015 2 1 $120 3/22/2016 2 1 $50 8/15/2015 1 2 $200 8/1/2015 1 after run script this: code deposit date id 1 $100 3/2/2016 5 2 $0 3/1/2016 5 1 $120 2/8/2016 5 1 $120 3/22/2016 4 1 $50 8/15/2015 1 2 $200 8/1/2015 1 in have 150,000 id's in actual table general idea. you can ids using logic this: select t.id t group t....

Bootstrap radio buttons - adding variables with jquery -

i built form using bootstrap. user clicks radio button , number displayed @ bottom of page. <!-- footer --> <div class="container"> <div class="row"> <div class="col-lg-offset-3 col-xs-12 col-lg-6"> <div class="jumbotron"> <div class="row text-center"> <div class="text-center col-xs-12 col-sm-12 col-md-12 col-lg-12"> <h2>broadband speed calculator</h2> </div> <div class="text-center col-lg-12"> <!-- contact form https://github.com/jonmbake/bootstrap3-contact-form --> <form class="form-horizontal" role="form" method="post" action="" id="broadbandform"> <div class="form-group"> <label for="video" class="col-xs-12 ...

how do you change the following haskell code into a high order function? -

define function rmdups :: eq => [a] -> [a] that removes duplicates list. example, rmdups "ababca" should return "abc" . order of elements in output list not important here have done far: works: rmdups :: eq => [a] -> [a] rmdups [] = [] rmdups (x:xs) = x : rmdups (filter(/= x) xs) this not work, doing wrong: rmdups = map head . group . sort you this: import data.list (nub) rmdups = nub but assume you're not allowed. otherwise, solution ( rmdups = map head . group . sort ) works me. if compiler says group or sort not in scope , import data.list . ps: believe meant "point free style", not "higher order function" edit: user3217013 pointing that out.

r - plot time series with constraint -

i have big dataset , i'd plot zizi vs hour each hour while variables looks this: > datasetjc$hour[1:100] [1] 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 [40] 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [79] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > datasetjc$zizi[1:100] [1] 2 27 2 3 45 0 6 0 15 8 3 1 4 0 0 15 1 13 0 15 23 8 21 2 0 9 43 26 31 33 11 0 4 7 26 2 25 14 1 [40] 3 1 6 3 4 3 2 27 2 3 45 0 7 0 15 8 3 1 4 0 4 26 0 15 1 4 0 15 14 12 23 8 3 21 13 2 0 32 43 [79] 31 11 4 0 4 7 26 10 2 25 25 1 1 4 4 23 3 2 27 2 45 0 > i have minutes, dates , days vaiables. each data separated 5 minutes. how can plot? thx if take question "how hourly summaries of data taken @ 5 minute intervals", classic split-apply-comb...

node webkit - Electron container SyntaxError on generated code -

Image
i trying continue development of app using node webkit v0.12.2 , electron v0.29.2. legacy code previous employee after doing fresh npm install , running task builds executable error when trying run it. however refers syntax error in file generated... idea can solve this? token refered assuming first tag landing html of app desktopdevelopclient.html... wht wrong there? html looks fine. please help, pointers appreciated since can't seem find consice solution online

zip - Can zipped files be detected as pirated material? -

are zipped files resistant being found containing copyright material? don't understand nature of compression , whether uncompressed file still visible in manner. they resistant if encrypted, if it's not encrypted can still read contents without unzipping it. dropbox/google/whoever might check see what's inside, doubt unzip , check contents of zip file. plus, if encrypt both sets, wouldn't able (unless allocated resources cracking password every zip file process). if want sure won't read, zip them split files password, zip multiples zip password.

java - AsyncTask of 'Activity A' doesn't execute if I re-open 'Activity A' before the original AsyncTask has finished executing -

i have asynctask implemented follows: asynctask asynctask = new asynctask() { @override protected object doinbackground(object[] params) { //downloading images google places api } @override protected void onpostexecute(object o) { } } }; asynctask.execute(); this asynctask triggered run multiple times , it's executed scope of doinbackground() method of asynctask. runs fine the first time load activity, , if let data download , exit activity (so onstop() called) , reopen activity runs fine then, but , if exit activity before data downloaded won't run when reopen activity. does know why is? can recommend better approach doesn't involve asyntask? note: have tried using executeonexecutor() hasn't solved issue. thanks in advance asynctasks run on single thread, in order received. if ex...

java - Why does the program fail to check if an element already exists in an array? -

well, have grades database including student id registration, i'm stuck since have code loops , arrays. know easy me use classes teacher wants loops :/ where i'm stuck @ first case on switch,i have ask student id , validate if it's in array belongs id, tried using 2 do while loops , worked while if it's in array id put in array anyway. tried asking teacher said have seen loops in class , should able without help. i'm pretty sure saw basic examples of loops, not kind of thing have compare 2 arrays. appreciate help, , sorry bad english. reading post. public class reg_al { public static void main(string[] args) { scanner sc = new scanner(system.in); string evaluation[] = {"id", "group", "exam 1", "exam 2", "exam 3"}; int data[][] = new int[10][6]; int opc, x, = 0; boolean b = true, = false; { system.out.println("uanl-fcfm"); ...

jquery - How would I separate multiple elements added from javascript into my HTML? -

Image
i trying reproduce following image in html / javascript: this how far have got: this code in javascript: function createlink(text, parentelement) { var = document.createelement('a'); var linktext = document.createtextnode(text); a.appendchild(linktext); temp1 = text.replace("/","-"); temp2 = res1.replace("/","-"); a.href = "http://www.drakedesign.co.uk/mdmarketing/uploads/" + temp2 + ".csv"; parentelement.appendchild(a); } var txtfile8 = new xmlhttprequest(); txtfile8.open("get", "http://www.drakedesign.co.uk/mdmarketing/uploads/date.txt", true); txtfile8.onreadystatechange = function() { if (txtfile8.readystate === 4) { // makes sure document ready parse. if( (txtfile8.status == 200) || (txtfile8.status == 0) ) { // makes sure it's found file. alltext8 = txtfile8.responsetext; arrayoflines8 = alltext8.match(/[^\r\n]...

multithreading - Java Socket client/server pair can only send one message at a time -

a successful conversation can carried out between client , server. if 1 message sent between client , server. example (works): client: hello server: helloo client: time server: let me example (does not work): client: hello server: helloo server: *how today* server: *test message* client: yes the messages between asterisks not appear on client side untill client sends 2 messages. understand seems work net-message system number of messages sent server has equal n+-1 number of messages sent client, messages shown. client side code: try { socket client_socket= new socket(hostname,port_number); printwriter output = new printwriter(client_socket.getoutputstream(),true); bufferedreader input = new bufferedreader(new inputstreamreader(client_socket.getinputstream())); bufferedreader stdin=new bufferedreader(new inputstreamreader(system.in)); string fromuser,fromserver; while ((fromserver=input.readline()...

c# - How to update record correctly? -

could tell me how solved problem: i want update record in db: internal static void releasemachine(int idmachine) { machine machine = getbyid(idmachine); if (machine != null) machine.idworker = null; } internal static machine getbyid(int idmachine) { return (from m in database.current.machines m.idmachine == idmachine select m).firstordefault(); } but when try, program throws exception: system.data.linq.foreignkeyreferencealreadyhasvalueexception , operation not valid due current state of object. thanks help i'm guessing idworker foreign key, , setting foreign key null isn't allowed foreign key no longer match record in referenced table. create orphaned record in referenced table. have delete worker database first before can remove foreign key. if try same thing in sql query on database directly won't allow set idworker null either. if allow set idworker null in databa...

javascript - Prevent input from being edited in Google Sheets -

how prevent timstamp being edited user has editing permisions on sheet. have sheet inputs date , time in 1 column after column edited, know if posible permit other users see date in column b when edit column after date set make no 1 can edit or erase it, column entry time recorded. thanks in advance. ps: using code function onedit(event) { var timezone = "gmt-04:00"; var timezone2 = "gmt-04:00"; var timezone3 = "gmt-04:00"; var timestamp_format = "mm-dd-yyyy hh:mm:ss"; // timestamp 12hour format var timestamp_format2 = "mm-dd-yyyy hh:mm:ss"; // timestamp 12hour format var timestamp_format3 = "mm-dd-yyyy hh:mm:ss"; // timestamp 12hour format var updatecolname = "cantidad"; var timestampcolname = "solicitado" var updatecolname2 = "cantidad ordenado"; var timestampcolname2 = "fecha ordenado" var updatecolname3 = "cantidad entregada"; var timestampco...

C# ByteArray to Image -

i need convert byte[] image , cannot make work in c#. if save bytearray file this: using (system.io.filestream fs = system.io.file.create("test.jpg")) { fs.write(bytearray, 0, (int)lenght); fs.close(); } and test.jpg shows properly. when try make image bytearray this: memorystream ms = new memorystream(bytearray); picturebox1.image = image.fromstream(ms); it shows black box. i guess 1 problem since creating test.jpg, doesn't have data , bytearray empty. do :- byte[] filedata = null; using (var fs = new filestream("c:\\1\\roses.jpg", filemode.open, fileaccess.read)) { var totallength = (int)fs.length; using (var binaryreader = new binaryreader(fs)) { filedata = new byte[totallength]; fs.read(filedata, 0, totallength); fs.close(); } memorystream...

ios - Animate UIImageView from a subview to parent view -

i'm working on project allowing users play chess. have parent view represents board, each square added board subview. chess piece uiimageview , added square subview. occupyingpieceimageview = uiimageview(frame: cgrectmake(0, 0, size, size)) self.addsubview(occupyingpieceimageview) to animate chess move want change position of piece 1 square other, understand means changing uiimageview's frame don't know how, frame within it's parent view (square). doesn't work: func move(destsquare: square){ var imgview = self.occupyingpieceimageview var thispiece = self.piece uiview.animatewithduration(3, animations: { self.clearpiece() imgview.frame = destsquare.frame }) destsquare.setpiece(thispiece) } consider adding pieces board rather squares. architecture allow animate movement, including placing piece on line between 2 squares.

azure - How is the RowKey formed in the WADMetrics*** table? -

i'm looking understand data returned wadmetricspt1hp10dv2s20160415 table inside azure's storage account. it has partitionkey, rowkey , entityproperties. partitionkey, understand. translates resource id of resource inside storage account. however, partially understand rowkey. example rowkey is: :005cnetworkinterface:005cpacketsreceived__2519410355999999999 i understand first part, metric name. don't understand in number/digits follow. assuming timestamp, can't sure. i attempting use rowkey filter, due added wrinkle it's impossible generate rowkey , use filter. know how generate numbers/digits in order create rowkey filter? if you're curious know 2519410355999999999 number is, reverse ticks derived subtracting event date/time ticks max date/time ticks value. derive date/time value number, here's can do: long reverseticks = 2519410355999999999; long maxticks = datetime.maxvalue.ticks; var datetime = new datet...

How to destroy an unselect tab? or replace the current tab with a new one? TABLAYOUT android -

i´m trying delete/remake/replace or destroy tabs aren´t selected. can reload/create tab , content refreshed. since onresume doesn´t work on tablayout. i´m using tablayout here mainactivity code: public class mainactivity extends appcompatactivity{ // declaring view , variables toolbar toolbar; viewpager viewpager; viewpageradapter adapter; tablayout tablayout; charsequence titles[]={"participantes","torneio","classificação"}; int numboftabs =3; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar = (toolbar) findviewbyid(r.id.tool_bar); viewpager = (viewpager) findviewbyid(r.id.viewpager); tablayout = (tablayout)findviewbyid(r.id.tablayout); // creating toolbar , setting toolbar activity setsupportactionbar(toolbar); // creating viewpageradapter , passing...

python - How to use hex numbers as a parameters -

my job program write function titled drawpolygonfilled() has 3 parameters (the number of sides polygon, color of edge, , color of fill). using value received parameter, draws regular polygon using “for”, colors edges , fills shape according parameter values. parameters colors must in hex notation. i've written code draw polygons. working on trying fill polygons color, problem how use hex notation in parameters of function? code: from turtle import * #use #dccdc def drawpolygonfilled(n, filledcolor): filledcolor = hex(filledcolor) turtle() begin_fill() in range(n): left(360/n) forward(100) color(filledcolor) end_fill() done() drawpolygonfilled(4,dccdc) #error you can specify color string this: drawpolygonfilled(4, "#dccdc") note not need convert hex remove code.

c# - Resolving a type with Structuremap at runtime through a configurable option -

i not have experience di yet, have project have 2 implementations of interface , want able switch between them after application has been compiled. assumed xml config natural choice has been deprecated in current release of structuremap. the code uses hard coded concrete name of 1 of implementations assigns interface, not have code edit implement injection, few places instance new'ed up. not see how configure ability 1 or other after app compiled. what preferred pattern accomplish after compilation?

Azure Traffic Manager routing to Azure Website configured as External Endpoint -

Image
here's did, created azure website ( http://myapp1.azurewebsites.net ) in standard tier configured azure traffic manager , added endpoint azure endpoint. trafficmanager routes website. nice! removed endpoint , and added endpoint external endpoint. trafficmanager routes 404 page. provided fqdn (fully qualified domain name) myapp1.azurewebsites.net. what wrong it? doesn't azure allow have .azurewebsites.net sites define endpoint urls? endpoint details, status - enabled monitor status - degraded type - external endpoint complete error page details, error 404 - web app not found. web app have attempted reach not available in microsoft azure app service region. due 1 of several reasons: 1. web app owner has registered custom domain point microsoft azure app service, has not yet configured azure recognize it. click here read more. 2. web app owner has moved web app different region, dns cache still directing old ip address used in previous region. click here rea...

html - media query was working fine but suddenly doesn't work anymore -

Image
it worked before of sudden stopped working :( @media screen , (max-width: 768px) { form, button, input { width: 80vw !important; } } <meta name="viewport" content="width=device-width, initial-scale=1"> i have html, css , js code included in link below: demo: codepen the problem invisible special character inserted code. it's making declaration invalid, calls css error-handling play, , rule ignored. if copy , paste code notepad, you'll see it. in computer science call a focused, non-repeating phantasm, or class-5 free roaming vapor... real nasty one, too! :-) the simple solution delete media query , re-type it.

Ansible: Is there any way to use or pass ansible vars to a bash script I am deploying? -

i hacking ansible solution deploy notify.sh bash script part of pam.d / pam_exec configuration. the script uses bunch of variables have been told need part of separate yml file (so others can change or update them) instead of being defined in script directly, used doing. i have constructed vars file have defined variables script should using @ runtime. now problem want able access ansible variables in standard format {{my_variable}} bash script deploying. is possible? if isn't possible, suggestions inserting variables script after installed? i have feeling close answer, scowering ansible files has not yielded yet. the thing kinda figured use lineinfile module update shell script after installed, feel maybe bit hacky , there more elegant solution here. i appreciate , answers. sure – in /vars/main.yml automatically available, or can load custom file http://docs.ansible.com/ansible/include_vars_module.html . then, use template , deploy script this: templa...

openmp - omp_outlined in omp program compiled with LLVM -

when compiling cpp program omp directives using llvm clang++ 4.9.2 see hidden function @.omp_outlined. generated in bitcode. wonder hidden function , if possible avoid generating it. no, cannot prevent generation of outlined code in clang. outlining parallel region code own function how openmp implemented clang , many other compilers, including gcc, intel, , msvc. more details on how gcc implements can found here , here . clang follows more or less same method. to knowledge, openmp compiler not explicitly outline openmp parallel regions 1 pgi. stack frame magic enable multiple threads execute portions of function code.

How to modify a Pie Chart created by GNUPlot -

Image
input: i have myfile.csv file has following information: shift,percentage day shift, 39.94 night shift, 60.06 gnuplot processing: the myfile.csv file fed pie_chart_generator.gnuplot file is: #!/usr/bin/gnuplot -persist reset set title "\n" set label 1 "my pie chart\nshift usage break down" @ graph 0,1.125 left set terminal wxt unset key set datafile separator "," set terminal png set size square set output "piechart.png" stats 'myfile.csv' u 2 noout # stats_sum (sum of column 2) ang(x)=x*360.0/stats_sum # angle (grades) perc(x)=x*100.0/stats_sum # percentage #set size square # square canvas set xrange [-1:1.5] set yrange [-1.25:1.25] set style fill solid 1 unset border unset tics unset key ai = 0.0; bi = 0.0; # init angle mid = 0.0; # mid angle = 0; j = 0; # color yi = 0.0; yi2 = 0.0; # label position plot 'myfile.cs...

hdfs - file not found exception in reading data from hadoop url -

i trying follow tom white's hadoop definative guide , stuck @ reading data hadoop url. have tried out various tweaks keep keep getting 'file not found error' file's path on hdfs. here java class: package javainterfacepractice; import java.io.inputstream; import java.net.uri; import java.net.url; import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.filesystem; import org.apache.hadoop.fs.fsurlstreamhandlerfactory; import org.apache.hadoop.fs.path; import org.apache.hadoop.io.ioutils; public class urlcat { static{ url.seturlstreamhandlerfactory(new fsurlstreamhandlerfactory()); } public static void main(string[] args) throws exception { string uri = args[0]; inputstream in=null; configuration conf = new configuration(); conf.addresource(new path("/usr/local/hadoop/etc/hadoop/core-site.xml")); conf.addresource(new path("/usr/local/hadoop/etc/hadoop/hdfs...

java - First play of ogg file works, LineUnavailableException on second play -

i'm attempting loop ogg audiofiles in java. i'm using vorbisspi . i able play file once. when try play file again, or play file, lineunavailableexception: line format pcm_signed 44100.0 hz, 16 bit, stereo, 4 bytes/frame, little-endian not supported. i don't know i'm doing wrong. method below. public static void testline(file file) { try (audioinputstream in = audiosystem.getaudioinputstream(file)) { audioformat informat = in.getformat(); audioformat outformat = new audioformat(pcm_signed, informat.getsamplerate(), 16, informat.getchannels(), informat.getchannels() * 2, informat.getsamplerate(), false); info info = new info(sourcedataline.class, outformat); sourcedataline line = (sourcedataline) audiosystem.getline(info); if (line != null) { line.open(outformat); floatcontrol volume = (floatcontrol) line.getcontrol(floatcontrol.type.master_gain); volume.set...

java - Convert UTF-8 code (e.g., E052E472E04F) to text -

i'm working resource found online contains utf-8 codes instead of real texts (since it's arabic), , have no idea @ how convert real texts in java. for example: breakme~e052e472e04fe46ce04ee051e46f0020e027e04be43ee052e484e04ee4370020e052e027e47ee04fe478e050e473e412e04ee4630020e052e472e04fe46ce050e051e421e04ee051e0310020e476e050e4730020e050e051e466e04ee434e052e46fe41ee050e4210020e04fe044e47ee04fe443e04ee051e43ee46fe0270020e04fe472e04fe46be021e41ee04ee42f0020e052e43ae04ee4670020e04fe033e41ee04ee051e478e46fe0270020e41ee04ee47ce04fe051e483e04ee0230020e41ee04ee483breakme thank you. edit: i reverse engineered source code , here's found: public char[] getunicodestring(string paramstring) { int j = paramstring.length() / 4; char[] arrayofchar = new char[j]; int = 0; (; ; ) { if (i >= j) { return arrayofchar; } arrayofchar[i] = ((char) integer.parseint(paramstring.substring(i * 4, * 4 + 4), 16)); += 1;...

javascript - lists are not clickable in reactjs -

i have list of destination name should clickable , show result lists not clickable .i have tried writing console.log in click event function nothing traced in console too. destination-list var react = require('react/addons'); var destination = require('./destination.js.jsx'); var destinationslist = react.createclass({ mixins: [ react.addons.purerendermixin ], ondestinationclick: function(destination) { console.log('destination clicked'); console.log(destination); this.props.ondestinationclick(destination); }, renderdestinations: function() { var _self = this; var selecteddestination = _self.props.selecteddestination; return this.props.destinations.map(function(destination, idx) { var name = destination.name; var slug = destination.slug; var image = destination.image; return <destination destination={destination} selecteddestination={selecteddestination} ondestinationclick={_self.ondestinat...