Posts

Showing posts from September, 2014

java - How can I retrieve all of the maximum values from a list? -

i have class called employee implements comparable interface. now have 5 employee objects in list, each of has own salary property. want find of employee objects have max salary. i can single object using employee employee = collections.max(employeelist); but returns single employee , while trying retrieve array or list of of objects same max value. how can this? to efficient, should iterate through list , find max elements yourself: list<employee> result = new arraylist<>(); employee currentmax = null; (employee e : list) { if (currentmax == null || e.compareto(currentmax) > 0) { currentmax = e; result.clear(); result.add(e); } else if (currentmax!= null && e.compareto(currentmax) == 0) { result.add(e); } } this solution o(n), , requires single pass through list.

Reloading a Commons Configuration 2 Spring bean -

i've been using reload feature of commons configuration v1 without coding when exposing configuration object spring @bean, because reload check performed every time configuration accessed. i'm trying migrate commons configuration v2 , read reload effective on new configuration objects created builder. in other words, while in v1 like @bean public configuration config() { ... return builder.getconfiguration(); } then inject configuration with @autowired configuration config; and expect reload (when needed) on config.getstring("somepath"); now should call builder.getconfiguration() again each time want fresh configuration. so how go it? can in spring me "refresh" @bean has been injected in many @controllers? doesn't have automatic: implement "reload" button in admin console trigger it. maybe have wrap configuration in myconfiguration class, exposed @bean, method rebuilds configuration, called console. l

javascript - Load JSON data and display in various divs -

i'm new json, , rusty on javascript, has been bit of struggle. i'm trying load json data file, , split div containers. i'm being asked create shell page load json data , populate page based on markup , data in json file can include of: links, text, or embed code. results on here extremely mixed methods used either not explained, or deprecated. a json structure came was: {"week1":[ {"desc":"description", "link":"linkhere", "mda":"mediahere"} ]} my concern chiefly, loading correctly without fluff local file , displaying it. i'm looking fresh perspective on , coding help. here example, week create div, , array inside week, create elements inside div var myjson = {"week1":[ {"desc":"description", "link":"linkhere", "mda":"mediahere"}, {"desc":"description2", "link":"linkher

html - Content Scrolls over image -

so have image isn't set background, takes entire width , of height. want image remain in it's position , user scrolls, content below scrolls on top of image. i tried using: position: fixed; z-index: -1; /* or value */ but neither or worked. what have without position or z-index applied: https://jsfiddle.net/hhcvmrfx/ i want div container appear under image , overlap image when user scrolls. to overlap container below when user scrolls down, you'll need set padding-top value, parent .container , equal or less height of fixed image in question. apply background colour nested div element instead. body { padding: 0; margin: 0; background-color: #f7f7f7; overflow-x: hidden; } /* images */ #head-banner-img { border-bottom: 5px solid #222222; position: fixed; } /* container content */ .container { width: 100%; height: 500px; background-color: transparent; padding-top: 947px; font-size: 30px;

Grails using native queries,Hibernate addEntity, and a getting a map -

when map gorm entities native query results, list back, want map. so want each row have team property(team instance) , several custom properties/columns produced query. i map team using lookup.addentity(t,team.class); lookup.setresulttransformer(aliastoentitymapresulttransformer.instance); return lookup.list(); the result list of lists.i have do... returnedlist.each{ println it[0].id;//team instance println it[1];//custom column } less read friendly next developer i'd like. there way map back? (not counting writing own list-to-map function, if there not built in solution) found hibernat.transform.transformers class import org.hibernate.transform.transformers ... lookup.setresulttransformer(transformers.alias_to_entity_map) returns map instead of list.

playframework - Generate Eclipse project using SBT -

i'm upgrading activator 2.3.x 2.4.x (and eventually, 2.5.x). part of migration, can no longer use activator eclipse command generate eclipse project play application. i work on team, of use intellij. so, cannot make these changes each project, since it'd unuseful intellij users, , it'd inappropriate version project source. i've been following these instructions. here steps migration i've taken far: change project/plugins.sbt use 2.4.6 in project/application.conf, change evolutionplugin=disabled play.evolutions.enabled=false in project/build.sbt, remove javaebean librarydependencies eclipse users a. download , install sbt: http://www.scala-sbt.org/ - extract c:\dev\.sbt\0.13 b. create sbt_home environment variable - sbt_home=c:\dev\.sbt\0.13 c. add %sbt_home%\bin path - path=...;%sbt_home%\bin; d. create 'plugins' folder @ %sbt_home% - c:\dev\.sbt\0.13\plugins e. create plugins.sbt file in plugins directo

java - Libgdx Texture Region is not flipping -

i had completed drawing texture region when trying flip texture region not working , isn't working when trying draw multiple frames. tried check velocity of body inside frame method gives me 0 when use code: gdx.app.log(string.valueof(b2body.getlinearvelocity().x),"hi"); can me. code: public class collector extends sprite { public enum state{standing,running,dead}; public state currentstate; public state previousstate; public world world; public body b2body; private textureregion collectorstand; private animation collectorrun; private float statetimer; private boolean runningright; public collector(world world,playscreen screen) { super(screen.getatlas().findregion("myboy1")); this.world=world; currentstate=state.standing; previousstate=state.standing; statetimer=0; runningright=true; array<textureregion> frames=new array<textureregion>();

Adding rails web-site to a server running php web-site (linux) -

i have 2 sites hosted on 1 server, site1.com , site2.com , both of them written on php site1.com points default location /var/www/html/ site2.com configured in /etc/apache2/sites-available/site2.com.conf file. contents of file: <virtualhost *:80> servername site2.com serveralias www.site2.com serveradmin webmaster@site2.com documentroot /var/www/html/site2/ </virtualhost> now wrote web-application, site3. site3 written on ruby on rails framework. @ moment start rails server -b 0.0.0.0 command @ /var/www/html/site3/ directory , access entering 'site1.com:3000' url in browser. what want do: create configuration, map ' http://site3.com ' url /var/www/html/site3/ directory.

.htaccess remove http://www from url -

i want url of form http://www.example.com redirects to example.com how can achive this? found .htaccess remove www url + directories comes pretty close question, not know how change appropriately. to remove www ,you can use : rewriteengine on rewritecond %{http_host} ^www\.(.+)$ rewriterule ^ http://%1%{request_uri} [ne,l,r] or rewriteengine on rewritecond %{http_host} ^www\.example\.com$ rewriterule ^(.*)$ http://example.com/$1 [ne,l,r]

sql - Combine two tables on same columns -

i have 2 tables showen below: table 1: name age weight(kilo) tom 16 56 alex 29 89 table 2: name age sex tom 16 m alex 29 m what want get: table 3: name age sex weight(kilo) tom 16 m 56 alex 29 m 89 i have tried union/union , doesn't work. tried use join gives me table duplicate values. idea how this? assuming name/age values match between 2 tables, join you're looking for. select t1.name, t1.age, t2.sex, t1.weight table1 t1 join table2 t2 on t1.name = t2.name , t1.age = t2.age if there possibility there no match between tables, start 1 larger number of records, left outer join: for example, assume table1 has every person, table2 may missing some: select t1.name, t1.age, t2.sex, t1.weight table1 t1 left join table2 t2 on t1.name = t2.name , t1.age = t2.age if might have records in either table aren't in other, full outer join work: select

ruby - Giving a YAML file more than one key, while only using one value for the keys -

i have issue need make yaml file contain following keys: eta sol vets emc from these keys need 1 value email address 4 of keys same email address, possible make yaml file more 1 key, , 1 value..? for example: agencies: - eta - sol - vets - emc advocate_email: "example@example.com" #<= give these 4 same value - - other - ones advocate_email: "example1@example1.com" #<= give 3 value.. 1 , forth ** update ** think have multiple emails , each group has longer list. group1: email: me@email.com list: - eta - sol - vets group2: email: me2@email.com list: - 1 - 2 - 3 ** end update ** if understand correctly , want same email: email: &email me@email.com emails: eta: *email sol: *email vets: *email output: pry(main)> yaml.load(file.read('foo.yml')) => {"email"=>"me@email.co

c# - How to remove a AppBarButton from a CommandBar -

i have commandbar set xaml: <page.bottomappbar> <commandbar x:name="maincommandbar" verticalalignment="top" margin="0"> <!--toolbar--> <appbarbutton x:name="appbarbuttonscan" label="scan" click="appbarbutton_click" icon="scan" /> <appbarbutton x:name="appbarbuttonstop" label="stop" click="appbarbutton_click" isenabled="false" visibility="collapsed" icon="stop" /> <appbarbutton x:name="appbarbuttonpair" label="pair" click="pairbutton_click" isenabled="false"

rename - Weird behaviour in PowerShell bulk file renaming -

i'm new powershell , try rename 120 files in folder , encounter weird behavior. what have files named 0001.txt, 0002.txt, ... 0120.txt total of 120 files. want add 'a' in front of each of file name. came command: ls | ren -newname {$_.name -replace '(\d+)','a$1'} but after execution, numerous error this: "the specified path, file name, or both long. qualified file name must less 260" and when folder, file names from aaaaaaaaaaaaaaaaaaaaaaaaa(repeat until hit system limit on path length)....a0001.txt ... ... ... aaaaaaaaaaaaaaaaaaaaaaaaa(repeat until hit system limit on path length)....a0120.txt upon further inspection using -cf switch, turns out powershell attempts renaming process recursively. after first pass of renaming 120 files, went on again applying command a0001.txt adding 'a' in front of filename. , went on until hit path length limit , reported error. can tell me if there wrong in renaming command?

c - SimGrid. Create subprocess with argument -

i have process declared in main.c : msg_function_register("dispatcher", dispatcher); the dispatcher function gets arguments deployment.xml file: int num = xbt_str_parse_int(argv[1], "invalid argument %s"); int id = xbt_str_parse_int(argv[2], "invalid argument %s"); then dispatcher creates subprocess: msg_process_create_with_arguments("ts", subprocess, null, msg_host_self(), agrc, argv); how can pass num , id subprocess function? int subprocess(int argc, char* argv){ return 0; } how can call argv inside subprocess function? you have 2 ways pass arguments msg processes: either via argv; or via data argument. pass data via argv in first solution, have create new argv : // create argv child process char** newargv = xbt_new(char*, 3); newargv[1] = xbt_strdup("ts"); newargv[2] = xbt_strdup(argv[0]); newargv[3] = xbt_strdup(argv[0]); // create process new argv: msg_process_create_with_arguments

asp.net mvc - Request.Url.Host returns the wrong host? -

i have single umbraco 7 instance has 2 root nodes . 1 node points stage.sctflash.com , other node points stage.bullydog.com . when navigate http://stage.bullydog.com/products/accessories/podmount , request.url.host stage.bullydog.com . now, if open tab , go http://stage.sctflash.com/products/accessories/podmount , request.url.host might stage.sctflash.com , sometimes, changes stage.sctflash.com . the 1 strange thing noticed if view accessories node in umbraco , noticed parent of stage.bullydog.com no matter if on stage.sctflash.com or stage.bullydog.com i using request.url.host determine query parameter database. getting brand this: if(request.url.host == "stage.sctflash.com") return "sct"; else return bullydog"; so if request.url.host intermittently wrong, wrong query parameter. to see in action, if go http://stage.sctflash.com/products/accessories/podmount , see sct logo, go http://stage.bullydog.com/products/accessories/podmount ,

Installing TensorFlow, where is cuda home on Ubuntu? -

since upgrading ubuntu 16.04 have been forced use cuda repository came ubuntu due issues new security features in package manager. installed cuda using sudo apt-get install nvidia-cuda-toolkit . works else have been doing. unlike packages provided nvidia not create cuda directory @ /usr/local/cuda . trying install tensorflow source , wants know cuda home directory is. not sure have 1 when using ubuntu repo. of know or how might around issue? i able install cuda 7.5 in ubuntu 16.04 sudo apt-get install nvidia-cuda-toolkit , located in /usr/local/cuda-7.5

ruby on rails - Gain the javascript context within the *.js.erb response -

i not having javascript code in global scope. moduralize it. when use rails built-in ajax helpers, so: <%= select_tag "task", options_for_select([ ["today", "0"], ["yesterday", "1"], ["next 7 days", "2"] ]), remote: true, 'data-params' => "task_category_id_is=#{category.id}&sort=#{params[:sort]||'date_due'}&embedded=true", 'data-url' => tasks_path, 'data-type' => 'html' %> i can hook using rails jquery-ujs functionaility e.g. 'ajax:success'. my_app.utilities.card('.card-holder').init(); my_app.utilities.card = function (card_holder) { var $card_holder = $(card_holder); return { card_filter: function(){ $card_holder.on('ajax:success', '.card-filter', function(event, data, status, xhr) { $('.loading').hide(); var $current_card_holder = $(this).

android - Mac OSX - minSdk(API 18) > deviceSdk(API 15) -

i'm using android studio 2.1.1 on mac (version 10.9.2) , i'm receiving above error when trying run application i'm developing on android phone have connected. android phone samsung galaxy s blaze sgh-t769, android version 4.0.4. i'm new android app development, appreciated. your application's minsdkversion set 18, corresponds android 4.3. device android 4.0.4 devices, api level 15. cannot run minsdkversion 18 app on api level 15 device. if objective able run app on device, edit minsdkversion ( app/build.gradle or via file > project structure android studio main menu) 15 (or lower) instead of 18.

Android Firebase Query -

Image
i have structure now, im making query this: databasereference myref = database.getreference("users"); myref.equalto("6991580","ci").addlistenerforsinglevalueevent(new ... i expecting second node result.. get: datasnapshot { key = users, value = null } so, wrong query? or maybe im doing wrong? best regards , reply. you need tell firebase child property want order/filter on: myref.orderbychild("ci").equalto("6991580").addlistenerforsinglevalueevent(... the other format of ordering commonly misunderstood version. i'd recommend staying away it.

python - Youtube search in Django -> manage.py: error: unrecognized arguments: shell -

youtube code if use code in idle - ok, when use in django project, i.e. run via python manage.py shell see next: usage: manage.py [--auth_host_name auth_host_name] [--noauth_local_webserver] [--auth_host_port [auth_host_port [auth_host_port ...]]] [--logging_level {debug,info,warning,error,critical}] [--max-results max_results] manage.py: error: unrecognized arguments: shell i found error occurs @ line: args = argparser.parse_args() , can not find how fix that. can help? edit: once launched shell, call youtube_search(), when interpreter executes line args = argparser.parse_args() , shell closes , see message above. as don't need pass arguments command line function, removed this: argparser.add_argument("--q", help="search term", default="google") argparser.add_argument("--max-results", help="max results", default=25) args = argparser.parse_args() and

maven-javadoc-plugin sourceFileExcludes not working -

i'm not sure right way use tag, use this: <sourcefileexcludes> <exclude></exclude> <exclude></exclude> </sourcefileexcludes> it doesn't work @ all. seems there known bug in maven tag won't work found these threads: https://stackoverflow.com/a/26223872/3209177 but while ago. didn't find useful information on maven website well. so how can exclude source files / classes while build javadoc using maven? finally figured out. first, there known bug tracked in page: https://issues.apache.org/jira/browse/mjavadoc-365 , patch went plugin 2.10.2. after version, bug fixed. however, using earlier version. second, use schema: <sourcefileexcludes> <sourcefileexclude></sourcefileexclude> <sourcefileexclude></sourcefileexclude> </sourcefileexcludes> to exclude file. third, in sourcefileexclude, used someclass.java, not right. instead, used someclass.* , works me.

jquery - Slide doesn't work at the second time -

when click on navigation links, current div should slide , new should come down, works once. jsfiddle $(".nav-link").click(function(){ var page = $(this).data("page"); var active = $("#viewport").data("active"); $(active).slideup(500, function(){ $(active).css({'display':'none'}); $(page).slidedown(250); $("#viewport").attr("data-active", page); }); }); i have no idea wrong. thanks! try using .data() instead of attr() , they're not exact same $(".nav-link").click(function(){ var page = $(this).data("page"); var active = $("#viewport").data("active"); $(active).slideup(500, function(){ $(active).css({'display':'none'}); $(page).slidedown(250); $("#viewport").data("active", page); // updated row }); }); for furt

include - PHP require path - same directory -

i have index.html in root , supporting files in /html. have google analytics code in file in html directory. works index.html code in between head tags... <?php require('html/googleanalytics.html'); ?> but not in of supporting files in html directory, same directory file i'm trying require/include code... <?php require('googleanalytics.html'); ?> from php.net "...include check in calling script's own directory , current working directory before failing" what doing wrong? from php 5.3 (which @ time after end of life cycle) , later can use __dir__ constant , http://php.net/manual/en/language.constants.predefined.php require(__dir__ . '/googleanalytics.html');

ruby on rails - Using a single large controller or multiple controllers -

rails 3.2 ruby 2.1.5 i working on application create tickets (service orders). ticket going have number of sections. rather create single large controller, better if had multiple controllers/models, 1 each section of ticket, , have single view display sections in single form? i have views/tickets/shared set of views (one each section), , main view, render each needed inside div in main view. you should use multiple controller application until know controller object start violate single responsibility principle , making future changes code base difficult , error-prone.

python - Correcting to the correct URL -

i have written simple script access json keywords needed used url. below script have written: import urllib2 import json f1 = open('catlist.text', 'r') f2 = open('sublist.text', 'w') lines = f1.read().splitlines() line in lines: url ='https://en.wikipedia.org/w/api.php?action=query&format=json&list=categorymembers&cmtitle='+line+'&cmlimit=100' json_obj = urllib2.urlopen(url) data = json.load(json_obj) item in data['query']: in data['query']['categorymembers']: print i['title'] print '-----------------------------------------' f2.write((i['title']).encode('utf8')+"\n") in script, program first read catlist provides list of keywords used url. here sample of catlist.text contains. category:branches of geography category:geography place category:geography awards , comp

excel - How to work with arrays and display them in a MsgBox VBA -

i need write sub take single argument input box searches stock price in list. sub searches down list of prices "b3:b20" , when finds first price exceeds price displays date displays in column next in column in msgbox. code have far having trouble figuring out how display corresponding data price found:(i believe problem has array created) sub recordhigh1() dim searchprice currency dim rng range dim date1() string dim price() string dim ndates integer dim integer wsdata.range("a3") ndates = range("a3", range("a3").end(xldown).value) redim date1(1 ndates) redim price(1 ndates) = 1 ndates date1(i) = .offset(i, 0).value price(i) = .offset(i, 1).value next end searchprice = inputbox("enter price") set rng = range("b3", range("b3").end(xldown).address) each cell in rng if cell.value > searchprice msgbox "the first date waltech stock price exceeded " & searchprice & " & date

python - Selenium Error: BadStatusLine -

hi new in selenium webdriver , creating test case specific function. i have current test case working function, when include new test case , run it. receive error: badstatusline . also when run individual test case work fine, when run whole test receive error: badstatusline . error: test_task_xml (__main__.testactuserlayouts) test if task xml hidden ---------------------------------------------------------------------- traceback (most recent call last): file "acttemplate_layouts.py", line 25, in setup driver.find_element_by_name("password").submit() file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 84, in submit self._execute(command.submit_element) file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 457, in _execute return self._parent.execute(command, params) file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/

react native - RCTUIManager.m Error frame is not a descendant of <RCTShadowView> IOS -

i'm having error when toggle text input , while keyboard being shown. text input inside animated.view present modally. [error][tid:com.facebook.react.shadowqueue][rctuimanager.m:1188] view <rctshadowview: 0x1284daae0; viewname: rcttextfield; reacttag: 318; frame: {{0, 27.5}, {256, 18}}> (tag #318) not descendant of <rctshadowview: 0x12827bd40; viewname: rctview; reacttag: 256; frame: {{0, 0}, {320, 799}}> (tag #256) the problem the main cause of error, i've found, when multiple views listening keyboard @ same time. can happen, example, when multiple scroll views inside navigation stack listening keyboard events in order scroll text input. issue has come several times react-native-keyboard-aware-scroll-view , when users of library push multiple scroll views onto same navigation stack. this known issue within rn. might find discussion around pr helpful: https://github.com/facebook/react-native/pull/7876 current solution i don't know use

nanohttpd - The string contain "/" can't be compared in android? -

this question has answer here: how compare strings in java? 23 answers i think method displays "ok", in fact displays "fails". method b can correct result "ok". i'm sure function fi.iki.elonen.nanohttpd.getmimetypeforfile("my.css") return result "text/css". i don't understand why method can't correct result. there bugs function fi.iki.elonen.nanohttpd.getmimetypeforfile ? btw, method c can correct result "ok". method a string a="text/css"; string b= fi.iki.elonen.nanohttpd.getmimetypeforfile("my.css"); utility.logerror("b: "+b); if (a==b){ utility.logerror("ok"); }else{ utility.logerror("fails"); } method b string a="text/css"; string b= fi.iki.elonen.nanohttpd.getmimetypeforfile("my.css");

spinner - Android Custom Multispinner: Implement FadingEdge scroll -

i android newbie , have used code here: https://stackoverflow.com/a/17577310/6412402 create custom multispinner (it works great!) graphic designer friend hates me/the current layout , wants ios-like scroll options user has passed fade view (similar how scrollview has fadingedge length) how give custom spinner fading edge length similar this: fading scroll except fading scroll image text , want items in custom spinner have property. doesn't have picture need kind of fading property. please help! here code in java class multispinner: package packagename; import android.app.alertdialog; import android.content.context; import android.content.dialoginterface; import android.content.dialoginterface.onmultichoiceclicklistener; import android.content.res.typedarray; import android.util.attributeset; import android.widget.arrayadapter; import android.widget.spinner; import java.util.list; public class multispinner extends spinner { private charsequence[] entries; private boolean

ruby on rails - Object expected, got ActiveSupport::HashWithIndifferentAccess Nested form -

i getting error haven't seen before, have tried solutions similar questions here, trying select council tenant lives pre-populated council model, using through council history, form shows when press submit keep getting error. appreciate problem. started put "/properties/6/build/council" 127.0.0.1 @ 2013-08-18 22:32:55 +0100 processing properties::buildcontroller#update html parameters: {"utf8"=>"✓", "authenticity_token"=>"wbwqaxtbioqzglkhurstqs+cfd/xveutxnj0jwntsa0=", "property"=> {"council_history"=>{"id"=>"1"}}, "commit"=>"save property[council history]", "property_id"=>"6", "id"=>"council"} property load (0.3ms) select "properties".* "properties" "properties"."id" = ? limit 1 [["id", "6"]] (0.1ms) begin transaction ( 0.1m

php - Passing status code from Laravel not received by Angular http -

i'm building front end angular app, , separate laravel 5.1 api. i'm testing registration validation posting duplicate e-mail addresses. when throws error status code, return new jsonresponse($errors, 422); my angular $http method doesn't receive response @ all, , therefore success nor error methods called on angular response. however, if remove status code 422 jsonresponse : return new jsonresponse($errors); i can receive response angular. i find odd because using status code 422 still returns response network tab, it's not received angular: 422 (unprocessable entity) response: email : ["the email has been taken."] i'd pass along status code laravel because want non 200 trigger angular $http .error response. code snippets: angular : signup: function(params) { return $http({ method: 'post', url: url + ver + '/auth/register', data: params, cache: true }); } auth.si

postgresql - Join tables on string value -

i have 2 tables , b. each of them has column "name" of type string. want records joining operation a.name sub string of b.name. select * inner join b on a.name concat('%',b.name,'%'); the result empty table. goes wrong query, because got results if test via select * cross join b a.name 'test' , b.name '%test%'; there got records static value "test". the first query matching b substring of a. need: select * inner join b on b.name concat('%',a.name,'%'); or select * inner join b on position(a.name in b.name) > 0;

linux - Aborted (core dumped) using opencv_createsamples -

i have cloud server ubuntu 14.04 x64 i'm trying create samples with opencv_createsamples -img pos/comedon1.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 300 with files: -opencv/ -- ... -data/ -info/ -pos/ --comedon1.jpg -- ... -neg/ -- ... -bg.txt i have 1100 background images in neg/ listed on bg.txt i'm getting error create test samples single image applying distortions... *** error in `opencv_createsamples': free(): corrupted unsorted chunks: 0x0000000001c608e0 *** aborted (core dumped) how can know if i'm getting out of memory? or may causing it? can solve error? if positive image size bigger negative image can error. your positive image measure must smaller negative image. so project pos/comedon1.jpg size should bigger think.

java - How to make my Android library source code visible when a user adds the gradle dependency (so code doesn't have to be decompiled in Android Studio) -

i have android library on jitpack.io , let devs add library adding dependency. i've noticed if dependency added, library classes have decompiled view code. so example, have class in library called viewstack. when try go class file view source code, it's decompiled version of .class file. , thus, documentation not there. how can make code entirely viewable (no decompiling necessary) , docs come through if user adding library gradle dependency? this library if curious: https://github.com/jayyyr/pancakesonplates it depends if you're publishing library aar or jar. for aar files doesn't seem possible @ moment how publish android .aar sources make android studio automatically find them? for jar need publish -sources.jar file along main jar.

php - How to insert data into mysql in prestashop 1.6 -

dear: helper try insert data mymodulenamevalidationmodulefrontcontroller extends modulefrontcontroller class in validation.php. want data new table created in mysql when payment way complete can't insert me please? this function public function getorderinfo($point_id){ $insertdata = array( 'point_id' => $point_id, ); if (!db::getinstance()->insert(_db_prefix_."order_info", $insertdata)) echo "errors insert data"; exit(); } i errors insert data time. a first error see use _db_prefix_ in front of table name. should not put prefix, prestashop add later in insert() method. if there still error please, add structure of table in question. add var_dump of $insertdata array.

python - Please explain Generator mechanics in this example -

can explain mechanics of why prints 3 lines, instead of 24. know due fact generator function exhausted, how? def counter_gen(size): cur=1 while cur <= size: yield cur cur +=1 c1=counter_gen(8) c2=counter_gen(3) x in c1: y in c2: print x,y c2 reaches end after 3 iterations. iterating on again nothing. that's what's meant "exhausting" iterator. so, after 3 items, stops. outer iterator goes 8 times, because inner iterator goes 3 times, first outer iteration anything. next 7 try iterate on exhausted iterator, , nothing happens. if want new iteration of c2 start each iteration of c1 , write way! c1=counter_gen(8) x in c1: c2=counter_gen(3) y in c2: print x, y or, away c1 , c2 entirely: for x in counter_gen(8): y in counter_gen(3): print x, y

Save in a variable and multiply double value query result C#/MySql -

Image
i'm trying save unique value resulting query double variable, since same stored in database double, can later able multiply counter, following code: public partial class coronaclaracant : form { private int conteocliks = 0; private string producto = "coronaclara"; private double precio; public coronaclaracant() { initializecomponent(); } private void coronaclara_click(object sender, eventargs e) { mysqlconnection conn = new mysqlconnection("server=localhost;database=database;username=root;password=***"); conn.open(); string select = "select precio productos prodnom = '" + producto + "';"; mysqlcommand cmd = new mysqlcommand(select, conn); double result = cmd.executenonquery(); conteocliks++; precio = result; double total = (precio * conteocliks); lblcantidad.text = conteocliks.tostring(); lblprecio

c++ - Qt TableWidget - The image that appears when you click the cell -

Image
i use qtablewidget 2 columns. first column display images. second column display text. i'm calling qbrush::settexture on first column, not seticon function. i want first column images change when click on cell there problem image appears when click cell. this image expect: this image get: here code .h file class kcbackgrounddelegate : public qstyleditemdelegate { public: explicit kcbackgrounddelegate(qobject *parent = 0) : qstyleditemdelegate(parent) { } void paint(qpainter *painter, const qstyleoptionviewitem &option, const qmodelindex &index) const { qvariant background = index.data(qt::backgroundrole); if (background.canconvert<qbrush>()) painter->fillrect(option.rect, background.value<qbrush>()); qstyleditemdelegate::paint(painter, option, index); if(option.state & qstyle::state_mouseover) { if(index.column() == 0 ) {

java - Can this reference in run() refer to Thread object when implementing Runnable? -

sorry if question unclear i making simple multithread program has linked list store thread created except main thread. want send signal terminate main thread when other threads have closed , intend making when thread close, remove linked list main thread check if list size == null or not here code public class mainprogram { //some global static variable static list<thread> threadlist = new linkedlist<thread>(); public void main() throws ioexception { serversocket serversocket; serversocket = new serversocket(1234); while(true){ if(shutdown_handler.shutdown==true){ //wait other thread close/terminate return } socket s = serversocket.accept(); clientthread x = new clientthread(s); thread y = new thread(x); threadlist.add(y); y.start(); } } } when shutdown_handler.shutdown==true main check threadlist if

c# - LINQ union 2 tables -

i have table (t) has references 2 additional tables ( a , b ) (both references null-able, there still 1 filled in per row). need union data 3. if row in (t) references a , need data a , if b , data b . not problem, need project type, there collection of strings in table a , table b there no (assigning null or enumerable.empty<string>() or new list ... produces error). ideas? illustration : (from t in context.t join in context.a on t.refa_id equals a.id select new projectiontype { ... collectionproperty = a.collection }).union( t in context.t join b in context.b on t.refb_id equals b.id select new projectiontype { ... collectionproperty = what_should_i_put_there??? // needed because of union }) edit: maybe simple question be: how project empty collection in linq entities? edit2: exception: a type implements ienumerable 'system.collections.generic.list...' cannot initialized in linq entities query. it seems, defining dummy variable outs

angularjs - Google webtools: Fetch and Render shows blank page -

website made using angularjs nginx. partial status in fetch , render due fetching user info without authentication fine. googlebot renders perfect blank page on doing fetch , render. site rendering fine in chrome, firefox , safari. there must errors when googlebot renders page. where can find log of errors? or developers console exist googlebot too? i used window.onerror handler error information. can find more details in this blog post wrote experience.

Storing null values in realm using Android -

previously, when there no stable version of realm java (android), not store null values in realm , had perform unnatural hack able so, explained in this post . but of realm 1.0 released, there update being able store null value? for example : unfortunate cases when there no field in json want store in realm after parsing haven't handled manually. i have following code: realmobject.setdata(jsonobject.getstring("selector")); the program flow stops , exits block code located inside. the logcat shows w/system.err: org.json.jsonexception: no value selector but when do: realmobject.setdata(null); the program flow not stop , continues across realm statement realmobject.setdata(null); in cases, there no value tag "selector" in json file. , want null in default. i found out problem : jsonobject.getstring("selector") not whole statement: realmobject.setdata(jsonobject.getstring("selector")); so fix me