Posts

Showing posts from June, 2010

python - Is there any way to choose if a default parameter is used for a function? -

for example: def tune(a=2,b=3,c=4): return str(a) + " " + str(b) + " " + str(c) print tune(5, *default*, 7) so output be: 5 3 7 what put in place of *default* make happen? use default named arguments. explicitly mention c has take value of 7 >>> print tune(5, c= 7) 5 3 7

radgrid - telerik GridEditCommandColumn + pass row index to another page -

i have web form, mypage.aspx , use radgrid bind data entity data model using linq entities query. in radgrid have 2 columns data entities model , "edit" column ( telerik:grideditcommandcolumn ). when click on edit want pass id specific record in new page, mydetailspage.aspx . in page want edit specific row , save record. want pass id query string mypage.aspx mydetailspage.aspx . need pass id in linq entities query in mydetailspage.aspx in order retrieve data. in mydetailspage.aspx page have 2 textbox web server controls need bind values columns "systemname" , "title" mypage.aspx . thanks <mastertableview editmode="editforms" allowfilteringbycolumn="false" allowsorting="false" datakeynames="id" autogeneratecolumns="false"> <columns> <telerik:gridboundcolumn datafield="systemname"

java - networking javaSE applications -

this db class javase application. public class db { static connection c; public static connection get_connection() throws classnotfoundexception,sqlexception { if (c == null) { string ip = ""; string port = ""; string username = ""; string password = ""; try { bufferedreader br = new bufferedreader(new filereader(system.getproperty("user.home") + "/connectionsettings.txt")); ip = br.readline(); port = br.readline(); username = br.readline(); password = br.readline(); br.close(); } catch (exception e) { e.printstacktrace(); } class.forname("com.mysql.jdbc.driver"); c = drivermanager.getconnection("jdbc:mysql://" + ip + ":"+port + "/mydb", username,

javascript - What it the right way to be noticed when an element with specific directive attribute has been removed from DOM? -

i'm trying find way noticed in case element added , removed dom. in case element removed need ng-model value of element. for example: <div tell-me-when-removed ng-model="sometitle"></div> <a ng-click="removethedivabove()"></a> i'm trying "sometitle" you can use scope.$on('$destroy', function() { //your stuff here });

javascript - Handsontable is having issues - single row with readonly cells -

i'm using handsontable in project. working till last week. last 2 days not working (displaying single row readonly cells). i don't know issue , ensure didn't change in code. hot = new handsontable(document.getelementbyid('scid'), { rowheaders: true, mincols: 23, maxcols: 23, columnsorting: true, colheaders :['issuercode','productcode','componentcode','variantcode','platform','trackingcode','medicalplancode','pharmacyplancode','avvalue','metalliclevel','riders','network','scidstatus','contributionamountmin' ,'contributionamountmax','hiosdescriptor','hiosreason','linkedhios','caseeffectivedate','georating','discontinuedate','newexisting','note'], minsparerows: 1 }); anyone me resolve issue?

mongodb - How to create a website with a searchbar to query a mongo database? -

i have large mongodb database set , trying create website user can use searchbar query database remotely , have results posted on site (strictly read-only). i have experience databases data analysis, have never created website querying results. i'm don't have experience web development , don't know platforms (php? node.js?) use. thanks in advance. there following steps problem: create front-end, consist of html, css, , javascript. beginners find easiest work jquery , jquery ui, because well-documented , contain plugins possible scenarios (they should not, however, used create large complex applications!). bootstrap or foundation can html / css. create (probably) json api, front-end can communicate submit searches , retrieve results. use php, python, ruby, or many other languages this. simple site 1 you're describing, it's more matter of preference else. translate search request front-end mongodb query apis, , return results through api. use m

tcp - Android How to Configure XMPP Conference - Chat room -

i developing 1 chat application , not work properly, giving different-differet error 406 or 407 , please advice me following code proper or not , first login when application start : public void loginwithuser() { thread t = new thread(new runnable() { @override public void run() { saslauthentication.unregistersaslmechanism("org.jivesoftware.smack.sasl.javax.sasldigestmd5mechanism"); smackinitialization initialization = new smackinitialization(); xmpptcpconnectionconfiguration.builder config = xmpptcpconnectionconfiguration.builder(); config.setsecuritymode(connectionconfiguration.securitymode.disabled); config.setservicename(constants.service); config.sethost(constants.host); config.setport(constants.port); config.setresource("myresource"); config.setdebuggerenabled(true); config.setkeys

javascript - Cannot insert elements to custom elements dynamically in Polymer -

i new polymer. i want implement container in add other elements programmatically in application. cannot it. here custom component (ay-box.html): <dom-module id="ay-box"> <template> <div id="container" style="display: inline-block;"> <div id="content" class="content"> <content></content> </div> <div id="footer" class="footer"> <label># of items : </label> <label>{{item_count}}</label> </div> </div> </template> <script> polymer({ is: "ay-box", properties: { item_count: { type: number, value: 0 }, } }); </script> </dom-module> and in index.html <htm

python - How to sort keys in dictionary if values are same ? -

sort dictionary score. if score same sort them name import operator dt={ 'sudha' : {'score' : 75} , 'amruta' : {'score' : 95} , 'ramesh' : {'score' : 56} , 'shashi' : {'score' : 78} , 'manoj' : {'score' : 69} , 'resham' : {'score' : 95} } sorted_x1 = sorted(dt.items(), key=operator.itemgetter(1)) print sorted_x1 output : [('ramesh', {'score': 56}), ('manoj', {'score': 69}), ('sudha', {'score': 75}), ('shashi', {'score': 78}), ('resham', {'score': 95}), ('amruta',{'score': 95})] now want sort last 2 elements name because scores same . careful, code comparing dicts rather scores. ie {'score': 56} < {'score': 69} may cause surprises if there keys in dictionaries. can arrange key func return tuple of score , key . sorted_x1 = so

javascript - Click-triggered scrollTop takes random amount of time to fire -

i have comment section automatically scrolls view when scroll (using jquery scrolltop ), , button scrolls when click it. first scrolling action runs perfectly, second scrolling action takes seemingly random amount of time occur after button pressed. a live demonstration can found here: www.rouvou.com/kanyewest . go down comment section, , scroll fire first jquery scroll. click "back" button fire second scroll. might work instantly first few times try it, if enough, should delayed eventually. html <div id="comment-section"> <div id="comment-background-up">back</div> <div id="good_comments"><!--content--></div> <div id="bad_comments"><!--content--></div> </div> jquery $("#good_comments").scroll(function() { $('html, body').animate({ scrolltop: $("#good_comments").offset().top }, 700); $("#comment-background-up&quo

java - Read Field from another Thread -

i i'm creating textbased game while i'm learning java. i'm having issue when i'm trying read field thread. sleep class: package events; public class sleep implements runnable { public int sleep = 100; public void run() { while (true) { sleep--; system.out.println("sleep: " + sleep); try { thread.sleep(1000); } catch (interruptedexception e) { e.printstacktrace(); } if (sleep == 50) { system.out.println("you need eat"); } if (sleep == 25) { system.out.println("you realy need eat"); } if (sleep == 10) { system.out.println("you'r almoust dying go eat"); } if (sleep == 0) { system.out.println("you'r dead"); } } } public void printsleep() { system.out.println("sleep: " + sleep); } } then call method "print

javascript - Change table's column color through depending on select -

i have table 3 columns , want change it's color green depending on select on checklist (form). i want change in green column depending on city choose. example if choose new york, column new york become green. ideas? html - table: <table id="mytable"> <tr class="head"> <th></th> <th>new york</th> <th>chicago</th> <th>san francisco</th> </tr> <tr> <th>a poetic perspective</th> <td>sat, 4 feb 2012<br />11am - 2pm</td> <td>sat, 3 mar 2012<br />11am - 2pm</td> <td>sat, 17 mar 2012<br />11am - 2pm</td> </tr> <tr class="even"> <th>walt whitman @ war</th> <td>sat, 7 apr 2012<br />11am - 1pm</td> <td>sat, 5 may 2012<br />11am - 1pm</td> <t

ios - UIAlertController in tableViewCell - Swift -

i have button in each cell in tableviewcell . when button clicked, in cell coding page had action working already. decided let users confirm before action starts, added uialertcontroller inside action. alert controller works fine in uiviewcontroller , in uitableviewcell code below got error message: "does not have member named presentviewcontroller ". how can make work? code here. thanks @ibaction func followbtn_click(sender: anyobject) { if title == "following" { var refreshalert = uialertcontroller(title: "sure?", message: "do want unfollow person?", preferredstyle: uialertcontrollerstyle.alert) refreshalert.addaction(uialertaction(title: "yes", style: .default, handler: { (action: uialertaction!) in var query = pfquery(classname: "follow") query.wherekey("user", equalto: pfuser.currentuser()!.username!) query.wherekey("usertofol

ubuntu - How to resolve java errors that pop up when loading Mirth Connect Administrator -

i inherited server running mirth connect little documentation. mirth connect server running fine on server, , able connect web portal via port 8443 (and can log web-based administrator without issues). my problems occur when run ice tea java web start. things go fine until enter credentials , interface starts build; receive following error notice: could not load code template plugin: com.mirth.connect.connectors.http.httpsendercodete mplateplugin net.sourceforge.jnlp.runtime.jnlpclassloader.loadclass(jnlpclassloader.java:1535) java.lang.class.forname0(native method) java.lang.class.forname(class.java:191) com.mirth.connect.client.ui.loadedextensions.initialize(loadedextensions.java:131) com.mirth.connect.client.ui.frame.initializeextens ions(frame.java:484) com.mirth.connect.client.ui.frame.setupframe(frame .java:382) com.mirth.connect.client.ui.mirth.<init>(mirth.jav a:62) com.mirth.connect.client.ui.loginpanel$8.doinbackg round(loginpanel.java:438) com.mirth.conn

java - Bad SQLITE update Performance -

i new in sql (now working on sqlite application) , section in app when try piece of code: public void addsong(librarysong song){ for(int i=0; i<intopanel.getcomponentcount(); i++) //check if doublicates exist if(song.getname().equals(intopanel.getcomponent(i).getname())) return; intopanel.add(song); //add song database table try{ container.database.connection.preparestatement("insert '" + container.libwindow.libinfowindow.currentlib.getname()+ "'" //table name + " (path,stars,date,hour) values ('" + song.getname() + "'," + song.stars + ",'" + song.datecreated + "','" + song.hourcreated + "')").executeupdate(); }catch(sqlexception sql){ sql.printstacktrace(); }; } the problem: above method add song jtable , database table.the problem performance bad dat

ansi sql - Longest value of a data in a column -

query display name of user(s) having longest name, sorted name of user. please note there may leading or trailing spaces in names of users. i tried following query: select name, max(length(trim(name))) length user group name order name; but gives me length of values of name column without spaces. but need values have maximum length. suppose there 15 names in column , there 5 names of longest length, 5 names , corresponding length. table name: user column name , datatype: name varchar(255) select * users length(trim(name)) = (select max(length(trim(name))) users) order name

c++ - libstdc++ new standard library features support table -

is there table specifies new standards (11 , 14) support previous releases of gnu libstdc++? i found such table compiler , current lib state . but how can determinate if gcc version 4.6 supports std::queue::emplace , std::result_of_t . the manuals old versions of library linked https://gcc.gnu.org/onlinedocs , changes in each version listed in release notes e.g. https://gcc.gnu.org/gcc-4.6/changes.html

java - Looping javaBean atributes -

i have java bean public class bean { private object field1; private object field2; public object getfield1() { return field1; } public void setfield1(object field1) { this.field1 = field1; } public object getfield2() { return field2; } public void setfield2(object field2) { this.field2 = field2; } } i want set fields i'm doing hardcoded bean c1 = new bean(); c1.setfield1(hmap.get(headers[1])); c1.setfield2(hmap.get(headers[2])); i cycle because have 17 fields. for (count = 1; count < headers.length; count++) { c1.setfield1,2,3...("parameter_" + count, messages.getstring("field." + headers[count]));} how can implement this? using jdk 16 using reflection , follows: bean c1 = new bean(); c1.setfield1("object 1"); c1.setfield2("object 2"); (int count = 1; count < headers.length; count++) { //concatenate method name string methodname = "getfield"

excel - Creating a RANKX() calculated column which obeys filter context -

Image
i doing analysis of our customers , have existing column 'ranks' number of orders each customer has placed date ordered. mean if customer has placed 4 orders on 4 different dates 'persistantordercount' column have show follows: orderid | orderdate | customerid | persistantordercount 101 | 01/01/2015 | 1 | 1 102 | 01/02/2012 | 1 | 2 103 | 01/03/2015 | 1 | 3 104 | 01/04/2015 | 2 | 1 105 | 01/05/2015 | 3 | 1 106 | 01/06/2015 | 1 | 4 as can see in example customers orders ranked based on order date first order being 1 and, in case of customer '1', last order being 4. the formula use is: = rankx ( filter ( 'dataset', [customerid] = earlier ( [customerid] ) ), [orderid], [orderid], 1, dense ) the ranking of orders not change using formula based on filters have selected. what need similar column ranking based on filters have applied, in particular need able filter da

javascript - How to check if the user input is the correct answer or not? -

i making online application children picks random image database using following code: <script type="text/javascript"> var random_images_array = ['apple.gif', 'book.gif',...] function getrandomimage(imgar, path) { path = path || 'images/'; var num = math.floor( math.random() * imgar.length ); var img = imgar[ num ]; var imgstr = '<img src="' + path + img + '" alt = "">'; document.write(imgstr); document.close(); } </script> my question how can tell computer whether input user correct answer or not? example if programme showing apple image, user should type “apple” , system should return “correct” message. p.s. name of images represent content of image. the simplest way check user input against name of image, first, make num global variable can access in function. then, write function check user input against item in random_images_array @ index num - extension. here final code:

plugins - Neo4j server won't create data/log dir and files -

working neo4j server win service plugin extension. server not creating log files (which should found under data\log) , can't see why. went through conf files , fine. in app i'm writing logs via java.util.logging.logger instructed in documentation , suggested here: how can log neo4j server plugin? did had similar experience or can direct me solution? p.s plugin extension works fine. thank you.

regex - Non-greedy match from end of string with regsub -

i have folder path following: /h/apps/new/app/k1999 i want remove /app/k1999 part following regular expression: set folder "/h/apps/new/app/k1999" regsub {\/app.+$} $folder "" new_folder but result /h : many elements being removed. i noticed should use non-greedy matching, change code to: regsub {\/app.+?$} $folder "" new_folder but result still /h . what's wrong above code? non-greedy means try match least amount of characters , increase amount if whole regex didn't match. opposite - greedy - means try match characters can , reduce amount if whole regex didn't match. $ in regex means end of string. therefore something.+$ , something.+?$ equivalent, 1 more retries before matches. in case /app.+ matched /apps , first occurrence of /app in string. can fix being more explicit , adding / follows /app : regsub {/app/.+$} $folder "" new_folder

html - Insert data from form into MYSQL using Node JS -

i trying inserting data mysql using node , express framework html form. code form : <html> <head> <title>personal information</title> </head> <body> <div id="info"> <h1>personal information</h1> <form action="/myaction" method="post"> <label for="name">name:</label> <input type="text" id="name" name="name" placeholder="enter full name" /> <br><br> <label for="email">email:</label> <input type="email" id="email" name="email" placeholder="enter email address" /> <br><br> <label for="city">city:</label> <input type="text" id="city" name="city" placeholder="enter city" /> <br><br> <label for=&

javascript - Send request on unload and/or beforeunload doesn't work on mobile? -

i know issue has been answered on cannot make work on mobile browsers. i need send request server when web page closed (tab or window closed). here do: window.addeventlistener("unload",function(e) { var pl = "bla=blabla"; var req = new xmlhttprequest(); req.open("post","http://myapi/myendpoint",false); req.setrequestheader("content-type","application/x-www-form-urlencoded"); req.send(pl); },false); window.addeventlistener("beforeunload",function(e) { var pl = "bla=blabla"; var req = new xmlhttprequest(); req.open("post","http://myapi/myendpoint",false); req.setrequestheader("content-type","application/x-www-form-urlencoded"); req.send(pl); },false); this works fine on desktop (chrome , firefox) if page either refreshed or tab/window closed. on mobile, works w

python - socket.gethostbyaddr giving different returns -

i'm using python 2.7.9 , while trying use socket.gethostbyaddr , found perplexing behavior. my local computer has public ip, let's 111.111.111.111. if use on remote computer: import socket socket.gethostbyaddr('111.111.111.111')[0] i 'mycomputer.com' . however, using same command on local computer (or using 127.0.0.1 instead of public ip), instead 'mycomputer.com' . why there difference in capitalization? gethostbyaddr query hosts file - /etc/hosts on linux; windows has equivalent @ %systemroot%\system32\drivers\etc\hosts (location may vary older versions of windows) from remote computer, gethostbyaddr doing dns lookup , getting mycomputer.com. on local computer getting answer hosts file, contains upper case version of hostname.

uibutton - What is the equivalent of Android's weightsum in iOS -

Image
i have bunch of uibutton's want them equally distributed on screen screensizes. possible achieve without using autolayout? view fits on 640*960 screen, if larger there empty space in bottom. there equivalent of weightsum in ios? have attached 2 images shows how view looks on 640*960 (second image) , 640*1136 (first image) screen. i suggest choose auto layout kind of behaviour. in case pretty straightforward constraints set in ib. if prefer setting code, visual language. also, me, bit of overkill, may use uicollectionview

Rails 4 + AngularJS: App.js config and run functions don't work -

i'm working rails 4 , angularjs. i've got app working. controllers, directives, services, etc. however, main app.js file refuses fire config , run functions. i've got console.logs in there test how far gets. here's code: angular-app/app.js 'use strict'; console.log('we see app.js file'); // works var app = angular.module('bruno', []) console.log(app) //this works // stops working app.config(function ($httpprovider) { alert('config'); // can't see $httpprovider.defaults.headers.common['x-csrf-token'] = $('meta[name=csrf-token]').attr('content'); }) app.run(function () { console.log('app running'); // can't see }); like said, other controllers working fine. console doesn't show any errors , loads should. rails application.js file: //= require angular-app/app //= require_tree ./angular-app/templates //= require_tree ./angular-app/modules //= require_tree ./angula

google maps - How can I get value of html element in sap ui5 xml view -

i'm trying google maps api example sap ui5 , following xml view: <html:input id="pac_input" class="controls" type="text" placeholder="enter location" /> <html:div id="type_selector" class="controls"> <html:input type="radio" name="type" id="changetype-all" checked="checked" /> <html:label for="changetype_all">all</html:label> <html:input type="radio" name="type" id="changetype_establishment" /> <html:label for="changetype_establishment">establishments</html:label> <html:input type="radio" name="type" id="changetype_address" /> <html:label for="changetype_address">addresses</html:label> <html:input type="radio" name="type" id=&q

parse.com - How to delete all objects (rows) in Parse using c# -

basically, want clear table (or class parse names it) , repopulate new values. repopulation not issue, cannot figure out how delete objects in class. coding in c#. edit: have tried accomplish parseobject question = new parseobject("questions"); await question.deleteasync(); await question.saveasync(); i have tried grasp query, no avail. (think i) can run query, dont know how perform delete operation on data. parsequery<parseobject> query = new parsequery<parseobject>(); await query.findasync(); solved: ienumerable<parseobject> query = await parseobject.getquery(q_parse_table_name).whereequalto(q_parse_column_qset, qsetno).findasync(); foreach (parseobject po in query) await po.deleteasync(); well documentation not can give algorithmic steps can try. first, objects using query. once have got objects, can use destroy method delete data. execute save method. let me know if works. edit: try await myobject.deleteasync(); on

ruby on rails - PrawnPDF Flip Entire PDF -

i'm using prawn pdf create label send label printer, label prints upside down. important shipping labels use come print on it. setup i'm using (an ipad through lantronix xprintserver zebra printer) won't allow me flip using drivers. so i'm wanting know if there way using prawn (or rails) flip entire document (which contains 2+ pages) prints out correctly on labels. order of pages isn't essential. i haven't used prawn lately, i'm pretty sure using rotate method @ top of code work. you'll need either set origin center of page, or use translate reposition content after rotation. page 29 in manual (pdf) has example code.

hadoop - Spark-shell with 'yarn-client' tries to load config from wrong location -

i'm trying launch bin/spark-shell , bin/pyspark laptop, connecting yarn cluster in yarn-client mode, , same error warn scriptbasedmapping: exception running /etc/hadoop/conf.cloudera.yarn1/topology.py 10.0.240.71 java.io.ioexception: cannot run program "/etc/hadoop/conf.cloudera.yarn1/topology.py" (in directory "/users/eugenezhulenev/projects/cloudera/spark"): error=2, no such file or directory spark trying run /etc/hadoop/conf.cloudera.yarn1/topology.py on laptop, not on worker node in yarn. this problem appeared after update spark 1.2.0 1.3.0 (cdh 5.4.2) the following steps temporarily work-around issue on cdh 5.4.4 cd ~ mkdir -p test-spark/ cd test-spark/ then copy files /etc/hadoop/conf.clouder.yarn1 1 worker node above (local) directory. , run spark-shell ~/test-spark/

Will data saved in chrome.storage be synced if user switch to another computer with same google account? -

background: hi everyone, developing chrome extension in form of new tab. hyperlinks contained in new tab page fixed , wanna make links customizable. progress i did research in internet , found chrome.storage can provide data storage pages. however, wondering if can sync data between multiple computers when user logs in same google account? i looked further chrome.storage api description. luckily provide data sync user same google account across different computers! network again! chrome.storage usage to store user data extension, can use either storage.sync or storage.local. when using storage.sync, stored data automatically synced chrome browser user logged into, provided user has sync enabled. it's hard find useful information in chinese when facing problem, sof splendid.

authentication - LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1 -

ldap: error code 49 - 80090308: ldaperr: dsid-0c0903a9, comment: acceptsecuritycontext error, data 52e, v1db1 i know "52e" code when username valid, password invalid. using same user name , password in apache studio, able establish connection succesfully ldap. here java code string username = "*******"; string password = "********"; string base ="dc=psltestdomain,dc=local"; string dn = "cn=" + username + "," + base; hashtable env = new hashtable(); env.put(context.initial_context_factory,"com.sun.jndi.ldap.ldapctxfactory"); env.put(context.provider_url, "ldap://******"); env.put(context.security_authentication, "simple"); env.put(context.security_principal, dn); env.put(context.security_credentials, password); ldapauthenticationservice ldap = new ldapauthenticationservice(); // ldapcontext ctx; dircontext ctx = null; try {

org.apache.hadoop.hbase.DoNotRetryIOException: java.lang.IllegalAccessError: class com.google.protobuf.HBaseZeroCopyByteString cannot -

getting below exception while executing hbase client inside spark job:org.apache.hadoop.hbase.donotretryioexception: java.lang.illegalaccesserror: class com.google.protobuf.hbasezerocopybytestring cannot set spark configuration => spark.driver.extraclasspath", "hbase-protocol-0.96.2-hadoop2.jar. code: .setconf("spark.driver.extraclasspath", "hbase-protocol-0.96.2-hadoop2.jar")

oauth 2.0 - Google API HTTP 401 - Token invalid - AuthSub token has wrong scope -

i'm struggling google api few days while sending post request google sites api via c# application. first redeem authorization code google's servers request: https://accounts.google.com/o/oauth2/auth? scope=email%20profile& state=security_token%3d138r5719ru3e1%26url%3dhttps://oa2cb.mydomain/myhome& redirect_uri=http://localhost& response_type=code& client_id= // client id here... access_type=online& approval_prompt=auto in redirect uri got authorization code use claim access token: string requesturl; requesturl = "https://www.googleapis.com/oauth2/v3/token"; webrequest request = webrequest.create(requesturl); request.method = "post"; // create post data , convert byte array. string postdata = "code=4/apjahlvlglxw1fjkdcopeqjfovtndzyq7fzvrziuero#&" + "client_id=//cilent id here&" +

r - Get rid of anomaly appearing in the colour legend (ggplot2) -

Image
i have following plot: you can notice in colour scale, first item (lte only: red-dashed line), there anomaly in dashed line. somehow line gets thinner before actual whitespace. this anomaly disappears when don't plot data of blue color: note dashed line looks ok now. i use following code plot data: ggplot() + stat_summary( data = cellblocksutilizationul_lteonly, aes(x=roundedrealnumvehicles/2, y=(value), colour=as.factor(1), lty=as.factor(1) ) , fun.y=mean, geom="line", size=1 ) + stat_summary( data = cellblocksutilizationul_clust, aes(x=roundedrealnumvehicles/2, y=(value), colour=as.factor(2), size=as.factor(clusteringdistance), lty=as.factor(2) ) , fun.y=mean, geom="line", alpha=0.80 ) + scale_linetype_manual(values = c(2,1) , name ="protocol\ntype" , labels=c("lte only", "lte4v2x")) + scale_color_manual(values = mycolors , name ="protocol\ntype" , labels=c("lte only", "lte4v2

ruby - Rails create callback for 2 dependent resources -

i want know how can use create callback before_create or after_create 2 dependent models. class user < activerecord::base end class member < activerecord::base end lets suppose have 2 models called user , member , want create member whenever user created , want create user whenever member created . if use after_create or before_create callback in both models run never ending loop .so how can done. just check if either of association exists in db before creating in after_create callback, this: class user < activerecord::base after_create :create_member private def create_member unless self.member? # create member end end end class member < activerecord::base after_create :create_user private def create_user unless self.user? # create user end end end

plot - Tick and Feature labels in Biopython -

Image
with following minimal code from bio.graphics import genomediagram bio.seqfeature import seqfeature, featurelocation gdd = genomediagram.diagram('construct diagram') construct_track = gdd.new_track(1, scale=true, scale_format="sint", scale_smalltick_interval=10, scale_largetick_interval=100, scale_ticks=true, start=0, end=2222) track_features = construct_track.new_set() feature = seqfeature(featurelocation(50,100, strand=+1)) track_features.add_feature(feature, name="my feature name", label=true, label_angle=30) feature2 = seqfeature(featurelocation(500,550, strand=-1)) track_features.add_feature(feature2, name="my feature name", label=true, label_angle=30) gdd.draw(format="linear", fragments=1, start=0, end=2222) gdd.write("test.png", "png") i obtain following (hideous) figure: now, figure appearance can tweaked satisfaction, 2 notable exceptions: i cannot set scale labels correctly (ntice how major

python - django rest framework post method giving error "Method "POST" not allowed" -

i getting error 'method "post" not allowed' while running api. new drf , don’t know doing wrong. method working fine. have problem post method. my code given below view.py: django.contrib.auth.models import user django.http import http404 django.shortcuts import get_object_or_404 restapp.serializers import userserializer rest_framework.views import apiview rest_framework.response import response rest_framework import status django.http import httpresponse class userlist(apiview): def get(self, request, format=none): users = user.objects.all() serializer = userserializer(users, many=true) return response(serializer.data) def post(self, request, format=none): serializer = userserializer(data=request.data) if serializer.is_valid(): serializer.save() return response(serializer.data, status=status.http_201_created) return response(serializer.errors, status=status.http_400_bad_request) serializer.py: djang

writing c# program result to csv file -

i have c# program compared 2 database tables , uploaded results table in database. started getting maxpackets error..which understanding uploaded results large. my thoughts dump results csv file instead. have tried follow several examples, program stalls. have wrong? { string filepath = @"c:\users\rena\documents\test.csv"; string delimiter = ","; string[][] output = new string[][] { new string[] { "col 1 row 1", "col 2 row 1", "col 3 row 1"}, new string[] {"col 1 row 2", "col 2 row 2", "col 3 row 2"} }; int length = output.getlength(0); stringbuilder sb = new stringbuilder(); (int index = 0; index < length; index++) sb.appendline(string.join(delimiter, output[index])); if (!file.exists(filep

excel - Format cells if value matches any value in another sheet column -

so have sheet1 bunch of names in column d. want format of sheet 2 if name in sheet 2 matches names in sheet 1 d column formatting kicks in. i have tried variety of variations of format text contains: ('sheet1', !$d:$d) but cannot seem it. thank in advance you need use vlookup https://support.office.com/en-ca/article/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1 to test if column x contains value y, use formula =not(iserror(vlookup(y, x, 1, false))) vlookup fetches values, returns error if value not found in target range. iserror returns true if formula inside results in error value. not reverses result of iserror, formula saying "does range x contain value y?"

android - Google calendar crash on strart -

i followed steps google guide: https://developers.google.com/google-apps/calendar/quickstart/android but when try run app 1 crashes directly, logcat 07-14 16:15:57.779: d/dalvikvm(2246): late-enabling checkjni 07-14 16:15:57.803: d/androidruntime(2246): shutting down vm 07-14 16:15:57.807: w/dalvikvm(2246): threadid=1: thread exiting uncaught exception (group=0xa6300288) 07-14 16:15:57.807: e/androidruntime(2246): fatal exception: main 07-14 16:15:57.807: e/androidruntime(2246): java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.googlecalendar/com.example.googlecalendar.mainactivity}: java.lang.classnotfoundexception: com.example.googlecalendar.mainactivity 07-14 16:15:57.807: e/androidruntime(2246): @ android.app.activitythread.performlaunchactivity(activitythread.java:1983) 07-14 16:15:57.807: e/androidruntime(2246): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2084) 07-14 16:15:57.807: e/androidruntime(2246)

ruby - How to run Sinatra in background and then access it later on -

i looking start sinatra in background, stop/reload during tests... far reading has provided 2 solutions run sinatra in background, either forking process or starting in new thread... couldn't figure out how can stop/reload sinatra service within child process (when forked) or thread some code of doing run in background: thread.start sinatraapp.run! end or fork sinatraapp.run! end what want after starting sinatra, able set trigger sinatra/reload sinatraapp.set params but won't because sinatra running in different thread/process any thoughts?

if statement - SAS: update dataset if it exists, else create it -

i need update dataset mylib.dt_old using dataset dt_new, want first check if exists, otherwise error. in case not exist, want create dataset mylib.dt_old stores information contained in dt_new. tried following: if (exist(mylib.dt_old)) do; data mylib.dt_old; update mylib.dt_old dt_new; date var1 var2; run; end; else do; data mylib.dt_old; set dt_new; run; end; however error, when mylib.dt_old not exist error: file mylib.dt_old.data not exist. and sas goes on executing else statement (creates dt_old copying dt_new). instead if dt_old exist if (exist(mylib.dt_old)) -- 180 error 180-322: statement not valid or used out of proper order. what doing wrong? ps: beginner in sas. what you're trying qualify macro programming in sas, considered "advanced" topic. the normal if-then control logic you're using sas considers data-step code, i.e. it's valid in data step. there "macro" language looks similar,

ngsanitize - HTML encoded String not translating correctly in AngularJS -

i have html encoded string this: sign , &lt;span class=&quot;strong&quot;&gt;something free!&lt;/span&gt; when use ngsanitize , ng-bind-html in template this: <p ng-bind-html="sometext"></p> i html decoded string: sign , <span class="strong">something free!</span> but literally shows html decoded string in browser, instead of rendering html correctly. how can have render correct html in dom? you can decode html string first. here's working plunker example. angular.module('app', ['ngsanitize']) .controller('ctrl', ['$scope', '$sanitize', function($scope, $sanitize){ $scope.sometext = htmldecode("sign , &lt;span class=&quot;strong&quot;&gt;something free!&lt;/span&gt;"); function htmldecode(input){ var e = document.createelement('div'); e.innerhtml = input; return e.chi

sql server - Timeout expired. The timeout period elapsed prior to completion of the operation on Azure sql -

i need create 1 sql database on windows azure on global.asax application start event, got error: timeout expired. timeout period elapsed prior completion of operation or server not responding. failure occurred while attempting connect routing destination. duration spent while attempting connect original server - [pre-login] initialization=296; handshake=324; [login] initialization=0; authentication=1; [post-login] complete=94; my code follows: private void setupssm() { sqlconnectionstringbuilder connstrbldr = new sqlconnectionstringbuilder { userid = settingshelper.azureusernamedb, password = settingshelper.azurepassworddb, applicationname = settingshelper.azureapplicationname, datasource = settingshelper.azuresqlserver }; bool created=dbutils.createdatabaseifnotexists(connstrbldr.connectionstring, settingshelper.azureshardmapmgrdb); if(created)

ffmpeg - buffering period sei in JM reference codec -

can know how encode yuv420 video using jm such each idr frame must associated buffering period sei , picture timing sei messages. went through "encoder.cfg" configure file coudn't find options enable buffering period sei , picture timing sei messages. when went through encoder code, observed updating parameter " seibufferingperiod.nal_initial_cpb_removal_delay " present in buffering period sei. know whether jm supports buffering period , picture timing sei's or not. if supports how configure encoder , updating buffering period sei parameters in jm encoder.

twitter bootstrap - Responsive Gallery: overlayed captions will not line up to edges of images -

i putting simple responsive gallery using twitter-bootstrap. i have captions appear overlayed onto images. should aligned bottom, right corners of each image. i cannot them align, exceed edges of images. html <div class="container"> <div class="row "> <ul> <li class="col-md-8 image"> <img class="img-responsive" src="http://i.imgur.com/1lltchm.jpg" width="940px" height="627px" /> <div class="desc"> <h2>caption text here</h2> </div> </li> </ul> </div> css ul { list-style-type: none; } img { padding-bottom: 20px; } div.desc{ background-color: #000; bottom: 0; color: #fff; right: 0; opacity: 0.5; position: absolute; width: 80%; padding: 0px; } .image { width:100%; padding:0px; } you can see example here