Posts

Showing posts from July, 2015

Reversing a list in python 3 -

using python 3, need reverse elements in lists given number (yet determined). example: list1 = edud - become dude list2 = mobbed - become bombed list3 = edud - remains same can use range , append functions, reverse function not used , needs in python loops. suggestions?? so far have this, it's wrong: def reverse(list, number): in range (0,length(my_list)-1): num in number: if num == number: new_list.append(my_list[i-num]) return new_list well, question little confusing me. "reverse" read list ending beginning. said, reversed version of mobbed should debbom . nevertheless, easiest way accomplish in python using slices . the basics: a = 'mother' a[::-1] = 'rehtom' a[2:4] = 'th' a[2:5] = 'the' any sort of transformation you're trying do, can done slicing , joining pieces again

r - How to adjust the labels on ggplot2 line graph to show the group, and add space -

Image
i have following data table: gin <- c("a_1","a_2","a_3","a_4","b_1","b_2","b_3","b_4","b_5","c_1","c_2","c_3") bc <- c(1219.79, 1486.84, 1255.80, 941.87, 588.19, 304.02, 279.71, 373.40, 179.89, 385.02, 218.76, 423.33) group <- c("a","a","a","a","b","b","b","b","b","c","c","c") ex <- data.frame("gin" = gin, "bc" = bc, "group" = group) i have 2 issues: (a) x-axis labels read value "group", not "gin'. also, (b) increase spacing between adjacent groups. a, b, , c close make larger graphs difficult on eye. the line here: ggplot(data=ex, aes(x=gin, y=bc, group=group)) + geom_line() + geom_point() + theme(axis.text.x = element_text(angle = 90, hjust = 1)) produces plot:...

c# - How to get the field names of a list inside foreach? -

i have following class: public class listofvariablestosave : list<list<int>> { public list<int> controldb { get; set; } public list<int> interacdb { get; set; } public listofvariablestosave() { controldb = new list<int> { 1, 2, 3 }; interacdb = new list<int> { 21, 22, 23 }; add(controldb); add(interacdb); } } and following code write content text file: listofvariablestosave mylistofvariablestosave = new listofvariablestosave(); streamwriter myfile = new streamwriter("filename.txt"); foreach (list<int> db in mylistofvariablestosave) { foreach (int vartosave in db) { myfile.writeline(vartosave); } } myfile.close(); what is: 1 2 3 21 22 23 what is: controldb 1 2 3 interacdb 21 22 23 is possible perhaps adding single line of code after first foreach ? i think doing this: public class listofvariablestosave : list<listofthings<int...

sql server - SQL joins on Null values -

hi have 2 tables , b table has 2 columns a1 (int) , a2(varchar(5)) table b has 2 columns b1 (int) , b2(varchar(5)) table has values a1 a2 1 aaa null bbb 2 ccc 3 ddd table b has values as b1 b2 1 app 2 new 3 disc i want result as a1 a2 b2 1 aaa app null bbb null 2 ccc new 3 ddd disc note-- bear in mind im joining a1 b1 a1 has null , want null in result. you can use called left join achieve these results. interpret it's functionality as: give me rows table on left , if rows table on right fulfill conditions, join them. otherwise use null values in place. so if select * left join b on ... , a on left , hence selected. b on right used if on condition satisfied. if isn't, null used in place of it's values, giving wanted! i'd point out things might weird if b ever has null value b1 . such, i'd add check this: select a1, a2, b2 left join b ...

logstash - How to performance debug elasticsearch -

i got set (not me) cluster (actually, 1 machine) collects logstash logs web application. logs flow isn't extremely active it's low/middle loaded web application. however, of time elasticsearch process takes 100% cpu; memory doesn't seems issue however, there's lot of free memory on instance. i can start guessing wrong, tinkering cluster settings , index analysers , on, i'm wondering: is there reliable way find performance bottleneck without guessing , i.e. built-in tool says takes resources?

twitter bootstrap - jQuery: Dynamically Adding Glyphicon -

i having slight functioning issue in firefox w/ jquery glyphicon. used bootstrap build portfolio , used jquery .load function load portfolio pages dynamically when click on them. i added jquery .append function append glyphicon close icon on each opened page, when open , close them on page in portfolio section keeps adding multiple glyphicons. adds more , more open , close. what happening here? can help? my code: $(".close").append('<span class="glyphicon glyphicon-remove-circle"></span>'); $(".glyphicon-remove-circle").click(function(e) { $(".portfoliocontent").fadeout(); }); you can try this: $(document).on('click','.glyphicon-remove-circle',function(){ $(".portfoliocontent").fadeout(); }); or way too: $('.close').on('click','.glyphicon-remove-circle',function(){ $(".portfoliocontent").fadeout(); });

Yii2, what the model parameter does in widget? -

echo select2::widget([ 'model' => $vendormodel, 'attribute' => 'id', 'data' => $vendor, 'options' => ['placeholder' => 'select vendor ...'], 'pluginoptions' => [ 'allowclear' => true ], ]); the above select2 widget (and of widgets same) require model attribute, don't know model in widget, because if put other model object, works. replaced model $usermodel doesn't relate vendor model @ , tried, , works. echo select2::widget([ 'model' => $usermodel, 'attribute' => 'id', 'data' => $vendor, 'options' => ['placeholder' => 'select vendor ...'], 'pluginoptions' => [ 'allowclear' => true ], ]); how should understand model? select2 widget instance of yii2 input widget , renders input model attribute. useful forms create/...

maven replacer plugin in not working -

here relevant part of pom.xml <plugin> <groupid>com.google.code.maven-replacer-plugin</groupid> <artifactid>replacer</artifactid> <version>1.5.2</version> <executions> <execution> <phase>pre-package</phase> <goals> <goal>replace</goal> </goals> </execution> </executions> <configuration> <file>target/swagger/api.json</file> <regex>false</regex> <token>$build_number$</token> <value>${project.version}</value> </configuration> </plugin> here api.json file { "apiversion": "$build_number$" "developers": ...

html - I have a few questions about white space, different browsers and image sizes for css -

to begin have 25% of screen of white space when people open page in chrome. finally, if want image have same size in different screens , should include e.g. width="100%" height="50%" in html.if yes , why w3 validator not correct use percentages.also think white space mentioned above appeared after removed percentages. i post link page bellow. http://portfolio.rumen182.dk/ edit: believe problem exists small circle image(logome) , first background image on top(image2222).the problem background 1 doesn't change it's width adjust other screen sizes leaves white space , little logo image changes it's position have no idea why. i'm pretty sure image2222 css not correct have no idea else it. </head> <body> <div class="image2222"> <img src="firstpage.png" alt="page" /> </div> <div class="nav ph-line-nav"> <a href="#">home</...

c# - Correct way to save data with mvvm when navigating between pages -

i'm working on universal app i'm confused best way save data when using mvvm. i'm using mvvm light project i have page (i.e. locationspage) listbox binded observable collection contains objects of type locationviewmodel. there 'new' button @ bottom of locationspage allow user create new location. when clicked, navigates page i.e. locationpage. this page contains necessary fields create new location , @ bottom of page, have 'save' button. when clicked, want returned locationspage contains list , add newly create location list , want save data file. is there way achieve without using code-behind (i.e. onnavigatedto, onnavigatedfrom)? i know quick fix make observable collection global between pages newly created location object added directly don't idea honest. can point me in right direction on how best handle this? thanks. perhaps passing collection "child" view model? or parent view model ilocations has addnew met...

python 2.7 - Transform this input file into a list of dictionaries, remove duplicate mongodb -

Image
code: with open('hocpersons.json.txt') f: arrayoftweets = [] line in f: arrayoftweets.append(json.loads(line)) how remove duplicate data? here example of data: arrayoftweets {u'105824': {u'caucus': u' conservative', u'constituency': u' niagara falls ', u'name': u'hon. rob nicholson', u'province': u' ontario'}, u'105825': {u'caucus': u' conservative', u'constituency': u' niagara falls ', u'name': u'hon. rob nicholson', u'province': u' ontario'}, u'105826': {u'caucus': u' conservative', u'constituency': u' niagara falls ', u'name': u'hon. rob nicholson', u'province': u' ontario'}, u'105835': {u'caucus': u' conservative', u'constituency': u' ottawa west\u2014nepea...

google dfp - Android DFP banner ads - what size is returned? -

dfp documentation states can use multiple ad sizes when requesting banner ads using setadsizes() method this: publisheradview adview = new publisheradview(this); adview.setadsizes(adsize.banner, new adsize(120, 20), new adsize(250, 250)); they if publisheradview changes size @ refresh time, layout should able automatically adapt new size. ok, how find out size returned server? know can set adlistener on adview , notified when ad loaded via callbacks onadloaded(), onadfailedtoload(int errorcode), etc. none of them seem offer option banner size returned server.

php - PDO lastInsertId in CLI Mode -

i working in cli mode , i'm getting fatal error. call undefined method supplier::lastid() in /var/www/vhosts/**********/httpdocs/content/mail/tr/critic_stock_mail.php on line 11 normaly works fine in normal mode. every 1 says beware using lastinsertid try catch block. not true. in normal mode works correctly. but remove lastinsertid part in try catch block. in cli mode not working also. should ? try{ $supplierobj->begin(); //mail gönderim tarihini güncelliyoruz $sql = "update ".prefix."product set supplier_mail_date = now() supplier = :supplier"; $supplierobj->query($sql); $supplierobj->bind(':supplier', $supplier_id, pdo::param_int); $supplierobj->execute(); //gönderilen mailleri tabloya yazıyoruz... $sql = "insert ".prefix."supplier_order (supplier_id, create_date) values (:supplier_id, now())"; $su...

In jenkins job, create file using system groovy in current workspace -

my task collect node details , list them in certail format. need write data file , save csv file , attach artifacts. not able create file using groovy scripts in jenkins using plugin "execute system groovy" build step import jenkins.model.jenkins import hudson.model.user import hudson.security.permission import hudson.envvars envvars envvars = build.getenvironment(listener); filename = envvars.get('workspace') + "\\node_details.txt"; //filename = "${manager.build.workspace.remote}" + "\\node_details.txt" targetfile = new file(filename); println "attempting create file: $targetfile" if (targetfile.createnewfile()) { println "successfully created file $targetfile" } else { println "failed create file $targetfile" } print "deleting ${targetfile.getabsolutepath()} : " println targetfile.delete() output obtained attempting create file: /home/jenkins/server-name/workspace/get_node_det...

nullpointerexception - Getting null pointer with recycler adapter -

my app crashing due null pointer recyclerview adapter in fragment code. i'm using adapter generate card view list cannot find out causing null pointer. log has happening when setting adapter r.setadapter(ra) in faucet class. fragment code public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { v = inflater.inflate(r.layout.faucetcards, container, false); r = (recyclerview) getactivity().findviewbyid(r.id.feedrecyclerview); ra = new recycleradapter(generatecards()); lm = new linearlayoutmanager(getactivity()); r.setadapter(ra); r.setlayoutmanager(lm); return v; } update: my error r or setting adapter. that's null pointer occurs though ra not null the nullpointer @ r.set adapter(ra) occurs because r null. the reason r being null tried find recyclerview in fragment's parent activity. recyclerview contained in fragment's layout, inflated in oncreateview method , stored in v. sh...

rdf - Configuring Virtuoso cartridges -

could please advise me on how configure virtuoso cartridges properly? followed documentation linkedin cartridge (the site has been updated since article written) configure extractor cartridge (added key , secret), , still unable pull data profile (after giving authorization). also other websites, google news, bbc, wikipedia not getting full information, example searched mr. barack obama on wiki , did about/data/xml option on both server , uriburner, , surprising server generated more data uriburner still did not tagged data birth-date or spouse etc. seems cartridges (extractor or meta???) not configured properly. i have been stuck here sometime (earlier facebook cartridge - no luck still) , grateful advise. there no short answer possible here. the long answer should refer -- virtuoso sponger documentation openlink virtuoso support forums openlink virtuoso users mailing list openlink software 's support site , case system

javascript - Accessing different level nested JSON values in jquery in same function -

what i'm trying achieve: 1. page 2 drop down lists , submit button; 2. when user selects values in 1 or both drop lists , clicks on submit; 3. system checks json file (extracted facebook graph api) , displays results values selected in drop list my issue: i'm able access nested objects parent > child, having trouble figuring out how access when goes deeper level. think issue if statement inside $.getjson code works when have val.genre.search, when add search location nested doesn't work.. on appreciated. here js: <script> $(window).load(function(){ $('#submit').click(function(e){ e.preventdefault(); var searchgenre = $('#genrelist').val(); var regexgenre = new regexp(searchgenre, "i"); var searchcity = $('#citylist').val(); var regexcity = new regexp(searchcity, "i"); var output = '<div class="row">'; ...

c# - Enforce Global Namespace in XAML -

in xaml, custom namespace can imported xmlns directive: xmlns:custom="clr-namespace:greatstuff" in c#, namespace can imported with using greatstuff; moreover, evaluation of namespace based on global (root) namespace can enforced follows: using global::greatstuff; how can enforce evaluation based on global namespace in xaml? background: i facing (admittedly obscure) situation there such namespace global::greatstuff , contains wpf control class named ... greatstuff (i.e. qualified, that's global::greatstuff.greatstuff in c#). in same namespace, want use control in wpf window. interestingly, in constellation, cannot use name / x:name attribute on controls of type global::greatstuff.greatstuff in xaml file window: the type name 'greatstuff' not exist in type 'greatstuff.greatstuff'. (cs0426) note same file compiles fine if not specify name / x:name attribute! now, why should compiler assume setting name / x:name attribu...

java - Unable to find TextView when populating ListView with ArrayAdapter -

i'm getting nullpointer exception @ following line, if textview i'm referring cannot found: descriptor.settext("single"); i checked id field , same in code , in xml, i'm not sure if have error somewhere else in adapter. logcat 06-02 23:24:08.903 11160-11160/com.example.albert.betterapp e/androidruntime﹕ fatal exception: main process: com.example.albert.betterapp, pid: 11160 java.lang.nullpointerexception @ com.example.albert.betterapp.displayallbets$mylistadapter.getview(displayallbets.java:464) @ android.widget.abslistview.obtainview(abslistview.java:2733) @ android.widget.listview.measureheightofchildren(listview.java:1274) @ android.widget.listview.onmeasure(listview.java:1186) @ android.view.view.measure(view.java:17396) @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5365) @ android.widget.linearlayout.measurech...

javascript - Get response code and parse to message via jQuery ajax -

i have structure: html: <input type="submit" name="_ninja_forms_field_7" class="ninja-forms-field popup-submit" id="ninja_forms_field_7" value="" rel="7"> js: $('#ninja_forms_field_7').click(function () { var name = $('#ninja_forms_field_6').val(); var surname = $('#ninja_forms_field_6').val(); var emailaddress = $('#ninja_forms_field_8').val(); var ecommercesiteurl = $('#ninja_forms_field_9').val(); var post_datas = emailaddress = +emailaddress+ & name = +name+ & surname = +surname+ & ecommercesiteurl = +ecommercesiteurl; $.ajax({ type: 'post', url: 'myserviceaddress', data: post_datas, success: function (answer) { console.log(answer); } }); }); it working good. want, if service response code 0, parse text in page. how can it? just add error: func...

javascript - Override Ember application.hbs template -

i have ember js application 99% of it's resources on root level, user has logged in access. resources, exception of /login , have same template. /login , however, has entirely different template (no nav bar, etc). what's best way override application.hbs template login page? most of answers see in other questions involve sort of parent route authenticated routes, so: this.route('login'); this.route('main', { path: '/' }, function() { this.route('posts'); }); that solution yields right url's, means link-to helpers , such have use 'main.posts', etc routes, rubs me wrong way, , i'd not have extraneous route level on place. in rails, i'd layout: nil , , and prevent main template being applied. there equivalent in ember, or way achieve same goal cleanly? to rid of {{link-to 'main.posts'}}. can add {resetnamespace:true} given route. this.route('main', {path:'/'}, () => { this...

jQuery load() keeping previous elements in memory? -

i have element, load... $("#pending").load("/pages/tipping/add-tips.php?pending=1&tip_comp=1"); whenever radio button checked, re-loaded... $(".comp_id").on("click",function(){ var compid=$(this).val(); $("#pending").load("/pages/tipping/add-tips.php?pending=1&tip_comp="+compid); }); inside loaded content inputs, upon clicking link cycle through these inputs... $("#submit").click(function(){ $("input.stake").each(function(){ alert("test"); }); }); however, every time content re-loaded, seems "remember" previous loads. example, there 1 input cycle through, upon loading page first time, 1 alert. if change input, , submit, 2 alerts, 3 etc etc. despite there being 1 input there whole time. what's causing this, , what's solution? it's dricving me little crazy. edit: so if cycle through inputs outside file, knows there 1. it...

rest - Symfony2 FOSRestBundle ParamFetcher JSON error -

i have symfony2 setup fosrestbundle , i'm using paramfetcher. i have route has requirements it's parameters , i'd show error messages api-user, in current setup error messages not shown in production , in development way extensive. parameter requirements offset requirement \d+ description result offset default 0 limit requirement \d+ description result limit count default 100 annotations: /** * list of users can limited result count , offset. * * max 30 users per request allowed. * * @apidoc( * resource=true, * description="load list of users", * statuscodes={ * 200="returned when successful", * 400="bad user input", * 500="in case of server error," * } * ) * * @view() * * @param paramfetcher $paramfetcher * @param int $offset integer offset (requires param_fetcher_listener: force) * @param int $limit integer result limit (requires param_fetcher_listener: force) * @queryparam(name=...

vba - Print error in Word 2013 -

i have print macro sends first page our letterhead printer , remaining pages plain paper printer. document printed second time on plain paper our records. while macro worked when using xp , word 2010, after recent upgrade windows 7 , office 2013, macro crashes entire word application. is, if run macro, word crashes. if step through macro, works fine. macro used multiple time day , hate lose due recent upgrade. any ideas save macro? macro code below which assign keyboard shortcut of ctrl + shift + p thank you public sub letterheadprint() ' sends page 1 letterhead printer (\\scprint04\ashplj5) ' sends page 2 regular printer (\\scprint04\astaxbill) ' prints copy on plain paper on cancel goto cancelled: on error goto cancelled: ' save current printer dim scurrentprinter string scurrentprinter = application.activeprinter ' print assessee copy ' page 1 letterhead printer application.activeprinter = "...

How to call a C dll generated by R CMD SHLIB, from C#? -

i call method in dll code written in c c # code can't that. error message is: unhandled exception: system.badimageformatexception: attempt made load program incorrect format. (exception hresult: 0x8007000b) @ displaymessagedll.program.dividetwo(int32 a, int32 b, int32* res) @ displaymessagedll.program.main(string[] args) in c:\users\mat\documents\visual studio 2013\projects\displaymessagefromdll\consoleapplication1\program.cs:line 30 press key continue . . . in fact, dll generated following command line in windows console: r cmd shlib --preclean simple.c code of simple.c class is: void dividetwo(int a, int b, int *result) { *result = a/b; } void rdividetwo(int *a, int *b, int *result) { dividetwo(*a, *b, result); } and c# code calls dividetwo() method : using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.runtime.interopservices; using rdotnet; using rdotnet.nativelibra...

c# - Convert generic object list to non-generic type list -

i trying convert list of system.object objects list of typed objects. here error getting: object of type 'system.collections.generic.list`1[system.object]' cannot converted type 'system.collections.generic.list`1[testapp.tsc_mrc_step]'. the purpose because writing business data layer project have name class , properties same name entities in database , data layer automatically populate referenced tables types declared in class. the business data layer uses reflection, generics , objects deal of this. below code tried put list of objects list of known types. thing is, object known type pass object....how convert known type without knowing is? bool iscoollection = false; type t = gettypeinsideofobjectbytypename(o, tablename, out iscoollection); list<object> objectcoll = new list<object>(); object obj = activator.createinstance(t); if (obj != null) { ...

How to embed python module in a script -

i have python script meant run standalone tool invoked via: python tool.py this requirement tool remain standalone script. issue i'm running i'm replying heavily on module, namely pexpect, , since it's not part of standard python library can't ask users install module via pip or other means , run script. the script in question commandline tool. there way me package script in such way pulls in code pexpect module? i've tried py2app etc no avail. tool meant run on macs. any appreciated. thanks! you can have pexpect module in directory have tool.py , import should work fine.

excel - Calculate standard deviation only on values between x and y -

i have range of data in column called mycol. values errors (ie, less 0 or on 100000. if don't omit values stdev highly skewed. therefore want calculate stdev on values >0 , < 100000. can please explain best way this? i thought creating named range consisting of within limits, i'm not sure if named ranges dynamic in way. with array formulas pretty straight forward. note array formulas entered with: ctrl + shift + enter use if statement references factor out values don't want include i.e. >0 , < 100000 , surround proper stdev formula. here example stdev.s , using range a1:a5 =stdev.s(if(((a1:a5>0)*(a1:a5<100000)=1),a1:a5)) if have mycol named range: =stdev.s(if(((mycol>0)*(mycol<100000)=1),mycol))

Kendo UI Grid column sorting refreshes entire page -

i have page contains 2 tabs. tab 1 contains kendo bar charts. tab 2 contains kendo grid search results , 2 tabs contain 1 kendo grid each detail information. "change" event of search results grid makes ajax call update 2 details grids details of item selected. want 2 details grids sortable. when click on column sort data, entire page refreshes , takes me first tab contains kendo bar charts. search results grid sortable , works expected. doesn't refresh entire page when click on column sort by. so, how allow 2 details grids resort without refreshing page? note: have noticed, when screen refreshes due sorting, controller action isn't being called. so, refreshing screen not re-executing controller code - not sure if helps or not. html gets replaced ajax call: <div id="groupdetails"> <div class="panel-body"> <ul class="nav nav-tabs" id="detailstabs"> <li class="active...