Posts

Showing posts from April, 2014

In Python a tuple is immutable object but allows mutation of a contained list? -

in python: >>> tup = (1,"a",[1,2,3]) >>> tup (1, 'a', [1, 2, 3]) >>> tup[2][1] = "a" >>> tup (1, 'a', [1, 'a', 3]) from above modify list contents part of tuple. since tuple immutable how possible? did understood immutable part in wrong way? you did understand immutable part wrong way. tuple indeed immutable, cannot change list: in [3]: tup[2] = [] --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-3-02255d491606> in <module>() ----> 1 tup[2] = [] typeerror: 'tuple' object not support item assignment the reference list immutable in tuple. however, list mutable, , hence can modified, know. in other words, tuple, immutable, contains 3 elements: integer 1 string "a" a reference list. you can imagine adress of list, if know c. if d...

curl - download part of gzipped text file -

i have large gzipped text files on ftp server, updated regularly, ie. lines added text files , gzipped again. there way access new lines without having download new .gz each time updated? my extremely naive try was curl -o part_of_file.gz -r0-10000,-10000 ftp.<source>/file.gz to download first 10000 bytes (in case there header) , last 10000 data i'm interested in, but, without surprise gunzip gives "unexpected end of file" error apparently gzip not work way. no, not possible. need decompress of data in gzip file in order uncompressed data @ end.

javascript - window.location.replace() not working in a form -

i'm trying set login form redirects user page after submitting form. neither window.location.replace() , window.location.href , or window.open() seem work , can't figure out why. checked on developer tools , gives me no error. here's javascript: function loginutente(){ var email = document.getelementbyid('loginemail').value; var password = document.getelementbyid('loginpassword').value; var utente = localstorage.getitem(email); if( utente != null && json.parse(utente).password == password){ window.alert("login effettuato!"); window.location.replace("http:/www.google.it"); } else{ window.alert("utente o password non corretti"); } return false; } and here's html: <form class="form-group" id="formlogin" onsubmit="loginutente()"> <label>email</label> <div class="in...

Android app doesn't start at system boot -

i've reciever public class mybroadcastreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { intent mystarterintent = new intent(context, mainactivity.class); context.startactivity(mystarterintent); } } and have modified androidmanifest.xml, adding these lines <receiver android:enabled="true" android:name=".mybroadcastreceiver" android:permission="android.permission.receive_boot_completed" android:exported="true"> <intent-filter> <action android:name="android.intent.action.boot_completed"/> <category android:name="android.intent.category.default" /> </intent-filter> </receiver> to section. application still not start on system boot..any ideas appreciated. @ least how can monitor going on after device reboot (because cant use breakpoints in case) you...

javascript - React testing with asynchronous setState -

i'm new react testing , i'm having hard time figuring out following issue: i'm trying simulate input onchange event. it's text input filters results in table. interactivetable has controlled input field ( controlledinput ) , instance of facebook's fixeddatatable . this test: let filter = reacttestutils.findrenderedcomponentwithtype(component, controlledinput); let input = reacttestutils.findrendereddomcomponentwithtag(filter, 'input'); input.value = 'a'; reacttestutils.simulate.change(input); console.log(component.state); on input change component updates state value of input, since setstate asynchronous, here console.log log out previous state, , can't query structure of component testing, because it's not updated yet. missing? edit: clear, if make assertion in settimeout, pass, it's problem asynchronous nature of setstate. i found 1 solution, overwrite componentdidupdate method of component: component.componentdidup...

javascript - Infinite scroll in Elm -

i building simple application in elm show list of divs 1 under other, , add infinite scroll functionality, add new content every time last div of page appears in viewport. is there way in elm know when div appears in viewport? alternative, in there way track, signal, mouse scroll event? there no elm support scroll events, you'll have resort using ports. here's simple example. we need javascript function tell whether last element in list in view port. can take iselementinviewport code this stackoverflow answer (copied here future reference): function iselementinviewport (el) { //special bonus using jquery if (typeof jquery === "function" && el instanceof jquery) { el = el[0]; } var rect = el.getboundingclientrect(); return ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerheight || document.documentelement.clientheight) && /*or $(window).he...

linux - How to make MongoDB's mongorestore update and replace files with the same _id -

so we've setup sharding , we're migrating of data several clients across several smaller databases bigger, sharded one. problem is, if try move data production , mongorestore , files won't update if have same _id . problem, because several mongorestores might necessary test sharded database , customer production data changes on testing period. i don't want use --drop , since drop whole collection instead of replacing old files. there way of doing properly? cheers i came solution, although not ideal. i'll use mongoimport --upsert option, instead of mongodump . whole database, might need write script mimic mongodump, oh well.

Google Maps API Javascript: Activating infowindows on markers from Places search box -

i have implemented places search box strictly following google developer documentation . markers displayed on map, based on specific search term (e.g. "restaurants"). of course want show infowindow when user clicks on marker, give user information place. have followed google developers documentation in order activate infowindows, withouth success (the changes have made in code illustrated comments 1, 2 , 3). earlier posts here didn't me out either. appreciated. <script> function initmap() { var map = new google.maps.map(document.getelementbyid('map'), { center: {lat: -33.8688, lng: 151.2195}, zoom: 13, maptypeid: google.maps.maptypeid.roadmap }); var input = document.getelementbyid('pac-input'); var searchbox = new google.maps.places.searchbox(input); map.controls[google.maps.controlposition.top_left].push(input); map.addlistener('bounds_changed', function() { searchbox.setbounds(map.getbounds()); }); // 1: ...

java - Saving/Flushing Eclipse state without close IDE -

is there way save current workbench state without close ide? it not necessary, have faced, many times, workbench freezes, make me kill eclipse process, , lose workbench state (new packages, new imports, ...) had before. i great if flush workbench changes easy save class, or @ least such flush take place automatically in times intervals. there 'workspace save interval' configuration in eclipse preferences on 'general > workspace' page.

android - Resize a Image Picked from Gallery to Image View -

my app have activity imageview pick picture phone gallery , set in imageview user's profile picture. my problem pictures when picked make app stop cause big, want know if can code , me how can resize picked picture, after set in image view, how can user cut picture before set, here below code pic picture. greatful if needed changes , give me code cause dont know developing. thank you. @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (requestcode == result_load_image && resultcode == result_ok && null != data) { uri selectedimage = data.getdata(); string[] filepathcolumn = { mediastore.images.media.data }; cursor cursor = getcontentresolver().query(selectedimage, filepathcolumn, null, null, null); cursor.movetofirst(); int columnindex = cursor.getcolumnindex(filepathcolumn[0]); string pi...

ruby - Redmine install Apache2 Bundler PermissionError -

i trying install redmine using tutorial : unfamiliar ruby. whenever go http://localhost/redmine or http://localhost/redmine/settings?tab=general in browser page message: we're sorry, went wrong. we've been notified issue , we'll take @ shortly. so decided in apache2 error log: sudo nano /var/log/apache2/error.log i found following message, changed permission of bundler folder everyone, , restarted apache. did not still same message in browser. doing wrong? using ubuntu 14.05 /var/log/apache2/error.log [ 2016-02-05 15:26:39.0461 24027/7fca480e5700 age/cor/app/implementation.cpp:304 ]: not spawn process application /usr/share/redmine: error occurred while starting preloader. error id: d4625db4 error details saved to: /tmp/passenger-error-ygu5vm.html message application: bundler::permissionerror (bundler::permissionerror) /var/lib/gems/2.1.0/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:116:in `rescue in filesystem_access' /var/...

java - if contains two words -

i brand new @ coding , can not application run right. please help! i have written following code hw assignment: import java.util.scanner; public class hw1q2 { public static void main(string[] args) { scanner keyboard = new scanner(system.in); string sentence, str1, str2; system.out.println("enter sentence containing either word \"blue\" or word \"green\" both or neither"); sentence = keyboard.nextline(); str1 = "blue"; str2 = "green"; if(sentence.contains("blue")); if(sentence.contains("green")){ system.out.println("sunny");} else{ if(sentence.contains("blue")){ system.out.println("ocean");} else{ if(sentence.contains("green")){ system.out.println("garden");} else{ system.out.println("dull"); ...

json - Javascript read gz files from node/express server -

a .net service export *.gz files nodejs server. files gziped json strings. this node route saving files locally. router.post("/", function (req, res) { var filepath = path.join(__dirname, "../public", "data", req.header("filename")); var writestream = fs.createwritestream(filepath); req.pipe(writestream); req.on("end", function () { writestream.close(); res.sendstatus(200); }); }); now have .gz files in public/data directory. i request file client side js that: static fetchjsonfile(path:string, callback:function):void { let httprequest = new xmlhttprequest(); httprequest.onreadystatechange = function () { if (httprequest.readystate === 4) { if (httprequest.status === 200) { let data = json.parse(httprequest.response); if (callback) callback("ok", data); } else if (httprequest...

java - Xtend: Extending interface with interface -

i new xtext. need extend interface interface. need this: import org.springframework.data.jpa.repository.jparepository; @repository public interface phrrepository extends jparepository<planthirerequest, long> { } my grammar: repository: 'repo' name=validid ':' type=jvmtypereference body=xblockexpression; my jvminferrer code: @inject private typesfactory typesfactory; @inject private typereferences references; public static string repository = "org.springframework.stereotype.repository"; public static string jparepository = "org.springframework.data.jpa.repository.jparepository"; //repositories def dispatch void infer(repository repo, ijvmdeclaredtypeacceptor acceptor, boolean isprelinkingphase) { acceptor.accept(repo.tointerface(repo.name, null)) [ documentation = repo.documentation annotations += annotationref(repository); s...

gradle - 'gradlew eclipse' command is not working -

i have checked in code following url https://github.com/spring-projects/spring-integration-samples now try build code , give command 'gradlew eclipse' and getting 522 error code. please resolve erro eclipse task not available in root project because eclipse plugin not applied on project. add apply plugin:'eclipse' near top of build.gradle , try again.

javascript - React-native ListView keys -

i'm getting warning on app bothers me. react keeps saying need add key each row, no matter cannot add these keys. my code looks this: <listview style={styles.listview} datasource={this.state.favs} renderseparator={() => <view style={styles.listseparator}/>} renderrow={(rowdata,i) => <card data={rowdata} onpress={this.oncardpress.bind(this,rowdata)} /> } /> i try add key on component <card key={rowdata.id}/>/ , tried key props inside component , add in first element of component on case touchbleopacity <touchablewithoutfeedback key={this.props.key} style={styles.cardbtn}> someone hive me hint? or should should ignore warning? actually renderrow gets 4 arguments (rowdata, sectionid, rowid, highlightrow) , , need third , not second one. renderrow={(rowdata, sectionid, rowid) => <card key={rowid} data={rowdata} onpress={this.oncardpress.bind(this,rowdata)} />...

listview - Cannot get Android tabs with swipable view to correctly pass information from one tab to another and display it correctly -

edit: @ankit aggarwal, got 1 part working, tab 1 not switching tab 2. still need assistance on view not refreshing in tab 2. i working on app, in using tabs. based app on example found on internet here . what have listview in tab 1. want happen when click on item in list, send id tab 2, want populate listview based on passed data. having issues getting work properly. currently, have working if click item in list on tab 1, tab 2 data , populates new list, adds view on tab 2 instead of refreshing/overwriting/etc., , app not automatically switch new tab. have layout in tab 2 (i.e., receiving tab): person.xml <linearlayout android:id="@+id/person_information_layout"> <textview android:id="@+id/header_row" /> <linearlayout> <textview android:id="@+id/column1_row_header" /> <textview android:id="@+id/column2_row_header" /> <textview android:id="@+id/column3_row_heade...

Range in Array Java -

i need complete task. not entirely sure how range array. think supposed use loop somehow not work. this have far: import java.util.*; public class a2_1 { static scanner x = new scanner(system.in); public static void main(string[] args) { int [] myarray = new int [1000000]; int x; ( x = 0; x <= 100; x++) { myarray [x] = x+1; } system.out.println(myarray); } } this task: "create program generates 1,000,000 integer random values in range of [1,..,100] , given x (between 1 , 100) taken user input computes "(𝑇𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑒𝑙𝑒𝑚𝑒𝑛𝑡𝑠 𝑙𝑒𝑠𝑠 𝑡ℎ𝑎𝑛 𝑜𝑟 𝑒𝑞𝑢𝑎𝑙 𝑡𝑜 𝑥)/1,000,000". value must comparable cdf of uniform distribution u[1,100] @ point x." im not going give answer since sounds homework break down manageable chunks. first, generate 1000000 random numbers between 1 , 100. on right track , combine dawnkeepers hint. int[] randoms = new int[1000000...

xml - Can't write out elements when useing xsl:if and count() together -

i want write out artist elements if total number of artist elements greater x. have following xml: <catalog> <cd> <title>empire burlesque</title> </cd> <cd> <title>hide heart</title> <artist scale="28">bonnie tyler</artist> </cd> <cd> <title>greatest hits</title> <artist scale="30">dolly parton</artist> </cd> <cd> <title>still got blues</title> <artist scale="24">gary moore</artist> </cd> i have following in xsl: <xsl:for-each select="/"> <xsl:if test="count(catalog/cd/artist) &gt; 26"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:if> </xsl:for-each> what doing wrong? there severa...

Azure mobile services Custom API GET not returning XML instead Json -

lately started looking azure mobile services , liked it. prefer working asp.net web api mobile solutions or fast rest api development liked approach. trying figure out custom apis, when added controller/custom api on of web apis code mobile project. it's working pretty , simplified when see response it's giving xml json response compared other todo items api's. using system; using system.collections.generic; using system.linq; using system.net; using system.net.http; using system.web.http; using microsoft.windowsazure.mobile.service; using system.threading.tasks; using projectservice.models; using newtonsoft.json; namespace projectservice.controllers { public class projectcontroller : apicontroller { public apiservices services { get; set; } // api/search public async task<movie> get(string term) { system.net.servicepointmanager.servercertificatevalidationcallback = delegate { return true; }; var...

haskell - Couldn't match expected type -

area (x0:x1:xs) = determinant x0 x1 + area(x1:xs) + determinant x0 xs i keep getting error can't match expected type last part determinant x0 xs namely xs part determinant :: a-> -> ... determinant x0 x1 determinant :: a-> [a] -> ... determinant x0 **xs** what type determinant supposed have? in first call takes x0 x1 have both type a. in second call pass determinant x0 xs xs list of ([a]).

javascript - Bootstrap Button Group to dynamically Change Text, HREF and Icon - JQuery -

i have bootstrap button group used split button dropdown. want when select option dropdown, text, href , icon change on button. can text change fine, i'm getting stuck changing href attribute , icon. html <div class="btn-group"> <a href="http://google.com" type="button" class="btn btn-default"><span class="standard">search</span><span class="mobile"><i class="fa fa-search"></i></span></a> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#" data-value="http://google.com" data-icon="fa fa-search">search</a></li> ...

python - How to send AT commands using to USB modem on Ubuntu -

like command: *342*55*225*5# i installed ubuntu , minicom on it. tried follow guide written in this article , blocked because when entered @ , clicked enter, did not respond... on python following method when entered command comport = serial.serial('ttyusb4') i got error : self.fd = os.open(self.portstr, os.o_rdwr|os.o_noctty|os.o_nonblock) oserror: [errno 2] no such file or directory: 'ttyusb4' try provide full path device: comport = serial.serial('/dev/ttyusb4') but prefer udev paths, not change if plug in devices in other order: comport = serial.serial('/dev/serial/by-id/<nameofyourdevice>')

iis - Trailing slashes on GETs cause 404 on Azure -

this strange behaviour has lost me days putting out there see if can shed light. i have rest api created in servicestack, works fine: api/tasks/overdue?assignedtoteam=administration this runs in azure websites fine several days. then, without changes or deployments, rest call returns 404. at point, if use api/tasks/overdue/?assignedtoteam=administration it works. (note trailing slash in front of "?"). re-deploying same code, start working again. anyone come across type of behaviour? i've never seen happen, i'd @ enabling debugmode ` add ?debug=requestinfo querystring should return debug info request , see if there's difference in request servicestack gets before , after 404.

angularjs - Accessibility of $index in ng-show -

Image
i try displaying select when previous select checked. <div ng-repeat="item in collection"> <div ng-show="$index === 0 || $parent.list[$index].nom"> <select ng-model="$parent.list[$index].nom" ng-options="..."></select> </div> 1) <div ng-repeat="item in collection"> i loop through collection , create many selects there item in collection. 2) <div ng-show="$index === 0 || $parent.list[$index].nom"> i want display/hide parent div of selects 2 conditions : i show div if index equal 0 (for display first select) i show div if current ngmodel contains nom 3) <select ng-model="$parent.list[$index].nom" ng-options="..."> i put dynamic ngmodel each select has own model : test exemple : have 3 options in select, want give opportunity member choose each option of select. if member choose option of select 1 seconde select show on , if se...

How to combine objects to array without removing duplicates in PHP -

i have 3 objects , want them combine 1 array. there duplicate property names in objects, want them (with renames property name). how can that? $object1 = { "id": "10", "unit_number": "12565" }, $object2 = { "id": "20", "full_name": "lorem ipsm" }, $object3 = { "id": "30", "phone": "123456789" } i want output like, array = ( "id1" => "10", "unit_number" => "12565", "id2" => "20", "full_name" => "lorem ipsm", "id3" => "30", "phone" => "123456789" ); i have tried assign them 1 array like, $arr = array(); $arr['obj1'] = $object1; $arr['obj2'] = $object2; $arr['obj3'] = $object3; now thought of doing foreach, stuck. actual object big. there many dupli...

javascript - JS cookie drop and countdown timer not working -

hi can have @ below , tell me why not working? i trying create popup box countdown timer , set cookie doesn't popup box on every page. it's supposed set cookie , detect , think it's doing count down timer isn't visibly counting down. $(document).ready(function() { if(readcookie('oldsite') != 'stay') //unless find cookie, show banner ... { var time_left = 12; var cinterval; cinterval = setinterval('time_dec()', 1000); var id = '#dialog'; //get screen height , width var maskheight = $(document).height(); var maskwidth = $(window).width(); //set heigth , width mask fill whole screen $('#mask').css({'width':maskwidth,'height':maskheight}); //transition effect $('#mask').fadein(500); $('#mask').fadeto("slow",0.9); //get window height , width var winh = $(window).height(); var winw = $(window).width(); //set popup window center $(id).css('top', winh/2-$(id).he...

javascript - Nunjucks nl2br does not exist? -

i need filter jinja "nl2br", in nunjucks. in documentation mention ( https://mozilla.github.io/nunjucks/templating.html ), searched in nunjucks code ( https://github.com/mozilla/nunjucks/blob/master/src/filters.js ) , not exist. somebody knows how solve equivalent filter or solution? or need create filter? nunjucks has built-in escaping. if set {autoescape: true} when settings nunjucks, don't need anything. otherwise, can use escape filter. if want escape newlines, this: env.addfilter('nl2br', function(str) { return str.replace(/\r|\n|\r\n/g, '<br />') }) and use newly created nl2br filter. note: env nunjucks environment.

npm - Phoenix 1.1.4 issue with Brunch -

trying start new elixir/phoenix project. can't past error: ▶ mix phoenix.server [info] running test.endpoint cowboy using http on port 4000 05 feb 16:32:57 - error: initialization error - need execute `npm install` install brunch plugins. error: cannot find module 'babel-runtime/helpers/interop-require-default' @ /home/vagrant/test/node_modules/brunch/lib/plugins.js:103:17 @ array.map (native) @ deps.filter.dependency.map (/home/vagrant/test/node_modules/brunch/lib/plugins.js:91:8) @ packages.filter.plugin.filter.plugins.map.plugin.filter.deps.filter.allplugins.filter (/home/vagrant/test/node_modules/brunch/lib/plugins.js:110:19) @ object.packages.filter.plugin.filter.plugins.map.plugin.filter.deps.filter.exports.init.teardownbrunch [as init] (/home/vagrant/test/node_modules/brunch/lib/plugins.js:133:20) @ /home/vagrant/test/node_modules/brunch/lib/watch.js:81:19 versions: machine : ubuntu 14.04 on vagrant 1.7.4 node -v : v4.2.6 npm -v : 2.14.12 ...

Android extended LinearLayout height matches parent, but children do not -

Image
i extending linearlayout matching parents height , width. inside linearlayout, inflating view set match parent height , width well. inflated views width matches parent, inflated views height not. i have tested on 2 devices, 1 running kitkat (api 19), in case problem occurs, , 1 running marshmallow (api 23), in case problem not occur. this extended linearlayout: public class messagebackground extends linearlayout { public messagebackground(context context) { this(context, null); } public messagebackground(final context context, attributeset attrs) { super(context, attrs); layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); inflater.inflate(r.layout.message_background_layout, this, true); this.setbackgroundcolor(context.getresources().getcolor(r.color.red)); } } this inflated xml layout: <?xml version="1.0" encoding="utf-8"?> <relativelay...

c++ - Object B in object A and reference of object A in object B without pointers -

Image
so wanted store: object b in object , reference of object in object b while not using pointers. the difference between using pointers , references try avoid accessing syntax. don't want write '->' each time access object in object b. code thought work throws segmentation fault: a.h #ifndef a_h #define a_h class b; class a{ b b; public: a(); }; #endif b.h #ifndef b_h #define b_h class a; class b{ a& a; public: b(a &_a); }; #endif a.cpp #include "a.h" #include "b.h" a::a():b(b(*this)){} b.cpp #include "b.h" #include "a.h" b::b(b &_b):a(_b){} first thing thought causing segmentation fault using 'this' keyword (of uninititialized instance) in initializer-list, i've read long don't access should ok. constructors empty don't wrong. is possible similar how doing it? , if no why , there allow me not write '->'? edit: indeed there compil...

Writing Fibonacci sequence in Java starting from certain term -

i trying write fibonacci sequence generator based on java. saw many examples on internet instance: public class fibonacci { public static void main(string[] args) { generatefibonacci(20); // generate first 20 fibonacci numbers } public static void generatefibonacci(long limit) { long first = 0; long second = 1; system.out.print(first+", "+second); for(long i=1;i<limit;i++) { long next = first + second; system.out.print(", "+next); first = second; second = next; } system.out.println(); } } and works fine. problem not want generate first 20 numbers, need specify starting point. example: public list<long> generatefibonacci(long startfrom, long numberterms) { } doing: generatefibonacci(5, 10); should output: 8l 13l 21l 34l 55l 89l 144l 233l 377l i have tried following code doesnt seem performing desired action: p...

galaxy - Android Toast moves around on screen -

Image
my android app displays several toast messages. installed on galaxy s6, running android 5.1.1 , noticed messages displayed around center of screen, move proper position (near bottom, if no gravity specified), initial position before fading away. context context = getapplicationcontext(); string newmsg = getstring(r.string.wild_card_msg); toast mtoast = toast.maketext(context, newmsg, toast.length_long); mtoast.setgravity(gravity.center, 0, 0); mtoast.show(); update: i have upgraded support libraries set compile-sdk , target sdk latest api. did not fix issue i have removed .setgravity() calls. no change. i have noticed toast messages behave @ first execution after installation (be in usb debug mode or via download playstore), issue reoccurs @ (all) subsequent runs. i have discovered toast messages disappear if touch screen (anywhere). thought toast displays cannot influenced user interaction. anyone else having issue, know how fix or know workaround? please note hav...

java - parameterized IN clause using multiple columns -

i have query along these lines, trying filter result set comparing tuples (like sql multiple columns in in clause ): select * mytable (key, value) in (values ('key1', 'value1'), ('key2', 'value2'), ... ); this valid syntax , works fine on postgres 9.3 database. i want invoke query through spring jdbc in value pairs come list<map<string,string>> . it nice this: list<map<string, string>> valuesmap = ...; string sql = "select * mytable (key, value) in (values :valuesmap)"; sqlparametersource params = new mapsqlparametersource("valuesmap", valuesmap); jdbctemplate.query(sql, params, rowmapper); when try this, get: org.postgresql.util.psqlexception: no hstore extension installed. @ org.postgresql.jdbc2.abstractjdbc2statement.setmap(abstractjdbc2statement.java:1707) ~[postgresql-9.3-1101-jdbc41.jar:na] @ org.postgresql.jdbc2.abstractjdbc2statement.setobject(abstractjdbc2statement.java:19...

Elasticsearch: Index 2GB of documents at once -

i use the mapper-attachments-plugin index , analyze pdfs in elasticsearch index (1 node, 5 shards). works fine problem initial import of 1.800 pdfs (about 2gb) blob table in mysql database. i use native java client (transport mode), documents database, encode them base64 , send them elasticsearch. run outofmemory errors after 300 documents. when give more memory import application, elasticsearch master node blocked after. is there better way import documents? perhaps "bulk-index-client" or so?

java - JPA composite foreign keys -

i have relationship cannot quite right in jpa. implementation hibernate. i have these basic entities: volunteer (personal details) area (information work area) session (time slot - start & end time) there's many-to-many relationship between volunteer & session, volunteer_session , indicating volunteers willing work when. there's many-to-many relationship between volunteer & area, volunteer_area , indicating volunteers willing work in areas. there's many-to-many relationship between area & session, area_session additional column indicating how many volunteers needed in area during session. so far, have relationships set correctly in jpa. the next stage tricky - assignments. volunteers may assigned area willing work in, during session willing work. the table structure this: assignment ---------- volunteer_id session_id area_id where volunteer_id , session_id comprise primary key, , foreign key volunteer_session table. also, vo...

php - php7.0-dbg Installed and don't work -

Image
i installed php7.0-dbg using ppa:ondrej/ph ubuntu lts 14.04. after installation tryed run phpdbg command, received message: phpdbg: command not found did understand wrong? package? my dpkg -l php7.0 * from documentation, can start debugger typing in command: $ gdb and run: > run path_to_php_script.php finally see trace log: > bt

html - ajax causing to stop further actions on php page -

i have page generates tables utilizing loop. (the syntax works fine in php file, copy paste, disregard syntax errors prototype) <form id="formid" name="formname" method="post" action=""> <input type="hidden" name="class" value="someclass"> <input type="hidden" name="section" value="somesection"> <select name="school" id="school"> $lengtharray = count($array); ($k = 0; $k < $lengtharray ; $k++) { <option> . urldecode($array[$k]) . </option>; } </select> </form> my ajax following : $("#school").change(function () { // resetvalues(); var data = $("#formid").serialize(); jquery.ajax({ url: 'unexisting.php', type: "post", datatype: "xml", data: da...

java - Take a word and print it out in the shape of a triangle as shown below - Parameters and methods -

thanks taking time check out question. have write code in dr. java takes in word , prints out in specific pattern. here examples: input: fishy output: f fifi fisfisfis fishfishfishfish fishyfishyfishyfishyfishy basically, i'm adding character previous 1 , printing out many number of times. here attempt @ solution: string wordcopy = word; int size = wordcopy.length(); (int i=1; i<=size; i+=1) { (int j=0; j<i; j++) { system.out.print(word.substring(0,j+1)); } system.out.println(""); }} i have set parameters that's fine. thing seem missing method prints out it's supposed to. can please me problem , how can go here? thanks! replace word.substring(0,j+1) word.substring(0,i) : string wordcopy = word; int size = wordcopy.length(); (int = 1; <= size; += 1) { (int j = 0; j < i; j++) { system.out.print(word.substring(0, i)); }...

javascript - Mongoose - use a post method to create a new empty collection -

libraries in use: express, mongoose, express-restify-mongoose problem: trying figure out how create post request provide schema in req.body. want create new collection if not exist , enforce new schema. when use following code: app.use('/api/v1', function(req, res, next) { if(req.path[0] === '/' && -1 === req.path.indexof('/', 1) && req.method === 'post') { var collection_name = req.path.substr(1, req.path.length - 1).tolowercase(); if(mongoose.modelnames().indexof(collection_name) === -1) { // create if model not exist console.log(req.body); var schema = new mongoose.schema({}, { strict: false, collection: collection_name }); var model = mongoose.model(collection_name, schema); restify.serve(app, model, { plural: false, name: collection_name }); } } next(); }); it posts empty document collection. if change code ever var schema uses post's req.body determine schema post req...

sql - How do I optimize this mysql query with nested joins? -

below query need optimize. select upper(ifnull(op.supplier_payment_method,s.default_payment_method)) payment_method, op.supplier_payment_date payment_date, date_format(ifnull(op.supplier_payment_date,op.ship_date),'%m %y') payment_month, s.supplier_name farm, op.sub_order_id order_num, date_format(op.ship_date,'%b-%d-%y') ship_date, op.farm_credit farm_credit, op.credit_memo credit_memo, op.credit_description credit_description, opb.boxes box_type, concat('$',format(op.box_charge,2)) box_charge, op.invoice_num invoice_num, concat('$',format(op.invoice_amt,2)) invoice_amt, concat('$',format(op.total_invoice_amt,2)) total_invoice_amt, concat(op.um_qty,' ',op.um_type) st_bu_qty, op.po_product_name invoice_desc, concat('$',format((op.price_um*op.um_qty),2)) cost_product_cms, op.suppli...

Opening Excel workbook containing macros (.xlsm) using ADO and getting macros to run -

i've been using ado process many excel .xls , .xlsx workbooks without problems. tried process .xlsm workbook load access database. workbook contains several macros run every time user opens desktop version of excel. macros update "yesterdays" data "todays" data. unfortunately when read workbook programmatically ado returning "yesterdays" data. means me macros not running when open workbook ado. suggestions. hope don't need rewrite code open instance of excel handle workbook. ado accesses data saved in workbook. nothing vba (or other) code dynamically when workbook opened in excel available. excel macros can run when workbook open in application interface. either process needs duplicate macro(s) doing in order update sheet data or, yes, indeed, need first open workbook in excel environment , execute macros, save changes workbook.

amazon web services - 'ansible_date_time' is undefined -

trying register ec2 instance in aws ansible's ec2_ami module, , using current date/time version (we'll end making lot of amis in future). this have: - name: create new ami hosts: localhost connection: local gather_facts: false vars: tasks: - include_vars: ami_vars.yml - debug: var=ansible_date_time - name: register ec2 instance ami ec2_ami: aws_access_key={{ ec2_access_key }} aws_secret_key={{ ec2_secret_key }} instance_id={{ temp_instance.instance_ids[0] }} region={{ region }} wait=yes name={{ ami_name }} with_items: temp_instance register: new_ami from ami_vars.yml: ami_version: "{{ ansible_date_time.iso8601 }}" ami_name: ami_test_{{ ami_version }} when run full playbook, error message: fatal: [localhost]: failed! => {"failed": true, "msg": "error! error! error! 'ansible_date_time' undefined"} h...