Posts

Showing posts from July, 2014

Rails 4, how to update a model field from a different controller? -

i trying update invoice fields, when checking out in carts controller. these must present when checking out, or should fail. however, can't update, less validate them. here code: cart show view: <div class = "row"> <div class = "col-lg-3 col-lg-offset-6 text-left"> <strong>customer: </strong> <%= collection_select(:invoice, :customer_id, @customers, :id, :full_name, {:prompt => 'please select'}, class: 'form-control') %> </div> <div class = "col-lg-3 ext-left"> <strong>seller: </strong> <%= collection_select(:invoice, :employee_id, @employees, :id, :full_name, {:prompt => 'please select'}, class: 'form-control') %> </div> <div class = "col-lg-12 text-right"> <%= form_tag carts_checkout_path, method: :post |f| %> <%= submit_tag 'complete',

javascript - Angularjs filter: get attribute 'name' by ID -

in html have following. <div class="form-group"> <label class="col-sm-2 control-label">select plate:</label> <div class="col-sm-5"> <select class="form-control m-b-sm" id="plateid" ng-change="getselectedplate(selectedplate.item)" ng-model="selectedplate.item" ng-options="plate (plate.id + ' - ' + plate.serial_number) plate in plates" required="true" /> <option value=" ">----------</option> </select> </div> </div> upon selection of plate. have ng-model retrieves plate-type id well. <div class="form-group"> <label for="input-readonly" class="col-sm-2 control-label">project name: </label> <div class="col-sm-5"> <input type="text" class="form-control&q

java - Spring REST Docs: how to replace parameters -

in unit tests find this.mockmvc .perform(post("/authenticate") .contenttype(mediatype.application_form_urlencoded) .param("username", "user@example.com") .param("password", "supersecretpassword")) .andexpect(status().isok()) .anddo(document("preprocessed-request", preprocessrequest(replacepattern(pattern.compile("supersecretpassword"), "xxx")))); cf. spring rest docs documentation this generates build/generated-snippets/preprocessed-request/http-request.adoc content [source,http] ---- post /authenticate http/1.1 content-type: application/x-www-form-urlencoded username=user%40example.com&password=supersecretpassword ---- but expect password masked because of replacepattern(): [source,http] ---- post /authenticate http/1.1 content-type: application/x-www-form-urlencoded username=user%40example.com&password=xxx ---- what can do? the pattern replacemen

Python pandas json 2D array -

relatively new pandas, have json , python files: {"dataset":{ "id": 123, "data": [["2015-10-16",1,2,3,4,5,6], ["2015-10-15",7,8,9,10,11,12], ["2015-10-14",13,14,15,16,17]] }} & import pandas x = pandas.read_json('sample.json') y = x.dataset.data print x.dataset printing x.dataset , y works fine, when go access sub-element y, returns 'buffer' type. what's going on? how can access data inside array? attempting y[0][1] returns out of bounds error, , iterating through returns strange series of 'nul' characters , yet, appears able return first portion of data after printing x.dataset... the data attribute of pandas series points memory buffer of data contained in series: >>> df = pandas.read_json('sample.json') >>> type(df.dataset) pandas.core.series.series >>> type(df.dataset.data) memoryview if have colum

google chrome extension - how to set the focus on a external windows I created? -

in background.js, use open new external popup window chrome.windows.create({type:"panel", url: "https://www.example.com/", width:320, height:240}, function (_win) { win = _win.id; }); how can set focus later on popup window ? use chrome.windows.update : chrome.windows.update(windowid, {focused: true});

java - How to access the same variable between Activities in Android -

i'm wondering how go accessing same int variable between activity classes in android app. situation have variable represents number of points , i've placed in own class , want value same between every activity uses it. when user gets point, increases 1 let's user gets 12 points, want same throughout activity s. step 1: extend activity s common baseactivity class. step 2: put int variable in baseactivity , add protected , static qualifiers int variable: public class baseactivity extends activity{ .... .... protected static int points; .... .... } now can access points variable in every activity , have same value. there no need use singleton here other answers suggesting. simpler have common static variable. programming 101. try this. work.

html - How to make element occupy remaining width of container? -

i have inline div abc , inline div def . abc 's width 100px. how can let def appear on right while def 's width parent's width minus 100px? i cannot width:100%; since def appears next line. https://jsfiddle.net/h7k87vwx/ <div class="abc">abc</div> <div class="def">def</div> <div class="ghi">ghi</div> .abc { display:inline-block; background-color:lightblue; width: 100px; } .def { display:inline-block; background-color: lightyellow; width: 200px; } html <div class="abc">abc</div><div class="def">def</div><div class="ghi">ghi</div> css .def { display: inline-block; background-color: lightyellow; width: calc(100% - 100px); } demo: https://jsfiddle.net/h7k87vwx/6/ divs lined eliminate rendered white space. explanation see answer here: inline-block boxes not fitting in contai

python - How to plot 2 seaborn lmplots side-by-side? -

Image
plotting 2 distplots or scatterplots in subplot works great: import matplotlib.pyplot plt import numpy np import seaborn sns import pandas pd %matplotlib inline # create df x = np.linspace(0, 2 * np.pi, 400) df = pd.dataframe({'x': x, 'y': np.sin(x ** 2)}) # 2 subplots f, (ax1, ax2) = plt.subplots(1, 2, sharey=true) ax1.plot(df.x, df.y) ax1.set_title('sharing y axis') ax2.scatter(df.x, df.y) plt.show() but when same lmplot instead of either of other types of charts error: attributeerror: 'axessubplot' object has no attribute 'lmplot' is there way plot these chart types side side? you error because matplotlib , objects unaware of seaborn functions. pass axes objects (i.e., ax1 , ax2 ) seaborn.regplot or can skip defining , use col kwarg of seaborn.lmplot with same imports, pre-defining axes , using regplot looks this: # create df x = np.linspace(0, 2 * np.pi, 400) df = pd.dataframe({'x': x, 'y&#

datastax enterprise AMI - EC2 is experiencing some issues and has not allocated all of the resources in under 10 minutes -

we have followed steps deploy dse in aws outlined here . when configuring ec2 instance details' under advanced details user data , adding (replacing values username , password correct credentials) --clustername mydsecluster --totalnodes 6 --version enterprise --username my_name --password my_password --analyticsnodes 2 --searchnodes 2 ec2 instance starts up, however, once connect see following in log: [info] 10/09/15-23:59:42 reflector: received 1 of 2 responses from: [u'172.31.7.164'] [error] ec2 experiencing issues , has not allocated of resources in under 10 minutes. aborting clustering of reservation. please try again. [error] exception seen in ds1_launcher.py: traceback (most recent call last): file "/home/ubuntu/datastax_ami/ds1_launcher.py", line 22, in initial_configurations ds2_configure.run() file "/home/ubuntu/datastax_ami/ds2_configure.py", line 1170, in run file "/home/ubuntu/datastax_ami/ds2_configure.py", line 50

How to access running python in vagrant from host machine browser? -

i installed vagrant in windows, have virtual ubuntu , run python script : vagrant@precise32:/vagrant/flaskmysql/flaskapp$ ls app.py static storedpro.txt templates vagrant@precise32:/vagrant/flaskmysql/flaskapp$ python app.py * running on http://127.0.0.1:5002/ (press ctrl+c quit) my vagrantefile : config.vm.box = "hashicorp/precise32" config.vm.provision :shell, path: "bootstrap.sh" config.vm.network :forwarded_port, guest: 80, host: 4567 config.vm.network :forwarded_port, guest: 5002, host: 5002 i tried access above address browser in window, index.html page appears in couple of seconds disappears. update : vagrant@precise32:/vagrant/flaskmysql/flaskapp$ curl http://127.0.0.1:5000 <!doctype html public "-//w3c//dtd html 3.2 final//en"> <title>500 internal server error</title> <h1>internal server error</h1> <p>the server encountered internal error , unable complete request. either server overl

sql - Database design for two similar tables -

no code here! more of database design problem... working on access on "large" amount of data. facing interesting problem , didn't find answer specific case. i have table called " marque " has 2 fields : marq_name text primary key, marq_group text. this table generated again , again every 3 (or 6) months external source. the problem external source not give data want, why need create second table marque called "marque2" exact same columns "marque", , fill table "by hand" our data (so have data our external source plus our own data). can't put our data directly in "marque" table updated automaticaly regularly external source. when application needs these data join 2 tables "marque" , "marque2" gets data. but don't think database schema. best db schema particular problem of having 2 exact similar tables same columns, not possible use 1 table? i hope clear enough. help edit: he

java - Session management in client side -

in application want maintain session on client side, when user login first time had stored current time plus session time (lets 20 min) in preference. in baseactivity had written 1 method checks whether current time greater saved time if yes called loginactivity. every other activity in application extends baseactivity. is approach efficient? other suggestion appreciated. in advance.

android - How to create dynamically objects (textFields from native library), and add event to them -

i've dynamically created textfield using corona, can't add events these objects, because need store information of textfield in table. i used in c# using 1 event , asked focus of textbox, in case don't know do. property focus textfield doesn't exist (you can set focus, can't ask state). on other hand, tried create table functions, , pass these functions addeventlistener of textfield, does't work. i appreciate advice solve problem, thanks!!!! local widget=require("widget") local native=require("native") local listtextfields={} local positiony=display.contentcentery --handle textfield local function textfieldhandle( event ) if ( event.phase == "began" ) elseif ( event.phase == "ended" or event.phase == "submitted" ) --??? elseif ( event.phase == "editing" ) --??? end end --this button's event local function buttonevent_1 (event) listtextfields[#listtextfield+1]=native.

css - visibility:hidden in firefox how to? -

i have code this: .module::first-letter{ visibility:hidden; } but solution not working on firefox:( display:none; not working "::first-letter" css code :( how can hide first letter in firefox? you can try setting font-size:0 while not supported. .module::first-letter{ font-size:0 } <div class="module">hide letter h </div> or last resort color:transparent .module::first-letter { color: transparent } <div class="module">hide letter h</div> note difference between both, 1st removes letter space, second 1 doesn't.

php - How to define timeout for copy image from server -

i need copy image server in order create different types of images it, e.g. thumbnail. while works ok imagecreatefromjpeg($picture_location); create problem if image not available , take 30s timeout. therefore thought downloading first copy: copy('http://www.server.com/file.jpg', '/tmp/file.jpeg'); unfortunatelly there no way decrease timeout if connect fails or image has been removed. is there better way achieve intending? thank on this. you can download file via curl has timeout option. <?php $fp = fopen (dirname(__file__) . '/localfile.tmp', 'w+'); $ch = curl_init($url); curl_setopt($ch, curlopt_timeout, 50); //timeout curl_setopt($ch, curlopt_file, $fp); curl_setopt($ch, curlopt_followlocation, true); curl_exec($ch); curl_close($ch); fclose($fp); ?>

c# - Using Elvis operator in combination with string.Equals -

i wonder why following code works in c# 6.0: (in example data random class containing val public string) if ("x".equals(data.val?.tolower()) { } but following line isn't: if (data.val?.tolower().equals("x")) { } visual studio shows me following error: cannot implicitly convert type 'bool?' 'bool'. explicit conversion exists (are missing cast?) if ("x".equals(data.val?.tolower()) { } will return boolean because of equals call this: if (data.val?.tolower().equals("x")) { } when expression evaluated return system.nullable<bool> different bool (former struct can assigned value null while latter can true or false ) the if expects. also, in c# null value doesn't evaluate false (according c# specification).

web services - Ksoap2 Trouble consuming Webservices on Android -

i created webservices in .net there trouble when consuming android app. noticed webservice not getting parameters send android. however, consumed .net app , works ok. note: webservice (webservicex/globalweather .asmx) android app works perfectly. i put spaces in string url variable because can't publish more 2 links public class cargadatosws { private static final string soap_action = "http://www.esmerlinp.somee.com/getaccess"; private static final string method_name = "getaccess"; private static final string namespace = "http://www.esmerlinp.somee.com"; private static final string url = "http ://www. esmerlinp.somee .com/registro.asmx"; public string getacess(string email,string pwd){ string res=null; soapobject rpc; rpc = new soapobject(namespace, method_name); rpc.addproperty("email", email); rpc.addproperty("password", pwd); soapserializat

Multiple Resource server configuration in Spring security OAuth -

i trying use single auth server access multiple resource servers multiple clients. i trying access 2 resource servers same auth server , configuration of resource servers goes below. @bean @scope("prototype") protected resourceserverconfiguration resource1() { resourceserverconfiguration resource = new resourceserverconfiguration(); resource.setconfigurers(arrays.<resourceserverconfigurer> aslist(new resourceserverconfigureradapter() { @override public void configure(resourceserversecurityconfigurer resources) throws exception { resources.resourceid(resource_id1).tokenstore(tokenstore); } @override public void configure(httpsecurity http) throws exception { http .csrf().disable() .requestmatchers().antmatchers("/greeting") .and() .authorizerequests() .antmatchers("/users").hasrole("admin"); } } resource.setorder(4); retu

ios - Xcode debug inspector shows values as nil -

Image
i'm having weird problem - can see in picture below, debug shows program entered if statement, value of color shown nil !!! obviously that's can't true, , suspect xcode showing incorrect values on inspector \ variable view (at debug area). i have no idea - maybe xcode had vodka? any please??? updates: i tried restart mac - didn't help. my xcode version: 6.4 check scheme - run tab on left should have debug executable option checked. if running on adhoc \ release mode, debugger not show right values. change "build configuration" "debug".

theano - Is the use of 'givens' really necessary in the deeplearning tutorials? -

in deep learning tutorials , training data stored in shared array , index array passed training function slice out minibatch. understand allows data left in gpu memory, opposed passing small chunks of data parameter training function each minibatch. in previous questions , given answer why givens mechanism used in tutorials. i don't yet see connection between these 2 concepts, i'm missing out on essential. far understand, givens mechanism swaps out variable in graph given symbolic expression (i.e., given subgraph inserted in place of variable). why not define computational graph way need in first place? here minimal example. define shared variable x , integer index , , either create graph contains slicing operation, or create 1 slicing operation inserted post-hoc via givens . appearances, 2 resulting functions get_nogivens , get_tutorial identical (see debugprints @ end). but why tutorials use givens pattern? import numpy np import theano import theano.tensor

arcgis - Error using MODIS HDF files in ArcMap Raster Calculator -

i have downloaded several hdf files modis database. according documentation, layers have multiplied 0.1 obtain real values. i error when put name of hdf-layer in raster calculator, work when export new raster before. after multiplication 0.1 , still do not continuous scale image black , white areas. excluded 7 highest values indicated in documentation, still no change. another way of getting modis files use respective toolbox . data imported tool show correctly, cannot import of though available under link indicated above: failed execute (createcustomgeotransformation) failed execute (importevapotranspiration) has experienced similar?

xcode - iOS project has changed to OS X project -

Image
the house of cards xcode has changed project ios os x. it doesn't appear have schema because i've deleted that. in build settings, architecture settings drawing "os x default". how change back? i fixed 1 of projects restarting machine. 1 still incorrectly configured though. many answers elsewhere suggest overriding settings inherited "os x default", can see in following screen shot. ideally base settings should "ios default". check , set base sdk ios. go project (in upper left) -> project (project name in submenu) -> build settings . in architectures menu select base sdk 1 of ios sdk. also, said deleted xcode schemes. may cause this. try this: on left top corner of xcode click on scheme. click edit scheme. in new window change "executable" non name of project scheme "target".

html - Vertical align for div with text and other div with picture (BEM) -

Image
i'm working on third project, , need help. need align text , pic on added picture. html: ._colon { width: 700px } .big-cars-list { list-style-type: none; margin: 58px 0 0 0; padding: 0; } .big-cars-list__item { margin: 0 0 14px 0; padding: 0; } .big-cars-list__item__name { font: 700 53px verdana, sans-serif; margin: 0 0 18px -3px; color: #000; padding: 23px 0 10px; } .big-cars-list__item__price { font: 700 21px verdana, sans-serif; margin: 0 0 11px 0; color: #000; padding-top: 1px; } .big-cars-list__item__price span { text-transform: uppercase; } .big-cars-list__item__link { font: 400 14px verdana, sans-serif; border-bottom: 1px solid #e10025; position: relative; } .big-cars-list__item__link:link { text-decoration: none; color: #000; } .big-cars-list__item__img { display: inline-block; } .big-cars-list__item__img img { max-width: 100% } .desc_wrapper{ display: inline

java - Create Facets based on generic data model in Hibernate Search -

Image
our task implement application uses faceted search on hibernate search 4.6. our database model unfortunately mix of relational , generic tables , not possible change that. this simplified diagram of our model. our index based on entity of data stored key/value pairs in other 2 tables. key in table propertytype while value in table entityproperty . this leads these fields in index: entityname entityproperties.propertyvalue entityproperties.propertytypes.propertyname the field propertyname contain facet name while propertyvalue contains different possibilities. problem association between propertyname , propertyvalue lost. we considered move properties interested in faceting entity table not possible many of our entityproperties . stuck here , suggestion how solve issue highly appreciated.

Compile error in swift when accessing enum inside a Constant class -

i have code won't compile. idea want keep global constant class. viewcontroller.swift: var user = [string: string]() user[cuser.attribute.type] = usertypeswitch.on ? cuser.type.rider.rawvalue : cuser.type.rider.rawvalue cuser.swift class cuser { enum type: string { case rider case driver } class attribute { static let type = "type" } } error message this: "type 'cuser.type' has no member 'rider'" but when enclose enum type type in dummy class compiles fine. such that: user[cuser.attribute.type] = usertypeswitch.on ? cuser.dummy.type.rider.rawvalue : cuser.dummy.type.rider.rawvalue you cannot use type name inside class because it's metatype type . a metatype type refers type of type, including class types, structure types, enumeration types, , protocol types. the metatype of class, structure, or enumeration type name of type followed .type . metatype of protocol type—not co

java - Powermock counts more than actually call when verify -

is bug of powermock or i'm doing sth wrong? the following test should pass, failed with: trackbugpartialmockcountmore(com.xiaomi.finddevice.test.testcase.powermockbug) org.mockito.exceptions.verification.toomanyactualinvocations: classtomock.foo(); wanted 1 time: -> @ com.xiaomi.finddevice.test.testcase.powermockbug.trackbugpartialmockcountmore(powermockbug.java:24) 3 times. undesired invocation: -> @ com.xiaomi.finddevice.test.testcase.powermockbug.trackbugpartialmockcountmore(powermockbug.java:22) when remove @preparefortest(classtomock.class), every thing goes , test passed. import org.junit.ignore; import org.junit.test; import org.junit.runner.runwith; import org.powermock.core.classloader.annotations.preparefortest; import org.powermock.modules.junit4.powermockrunner; import static org.mockito.mockito.verify; import static org.powermock.api.mockito.powermockito.mock; import static org.powermock.api.mockito.powermockito.when; @runwith(powermockrunner.class

html - set same height for two divs which are not siblings of each other -

i have 2 divs not sibling of each other. have set height of both of them same in every case (i.e, if 1 of them grows in height other re-sizes accordingly). i have seen these 2 approach: http://jsfiddle.net/sdsgw/ http://jsfiddle.net/vkpmg/2/ but both of these sibling elements. i have tried http://jsfiddle.net/ders/z1f6blop/ still applicable when using class= "row". , doesn't work without it. html <div class="col"> <div class="c1" >lorem ipsum dolor sit amet, consectetur adipisicing elit.</div> </div> <div class="col"> <div class="cl">lorem ipsum dolor sit amet, consectetur adipisicing elit. ad omnis quae expedita ipsum nobis praesentium velit animi minus amet perspiciatis laboriosam similique debitis iste ratione nemo ea @ corporis aliquam. </div> </div> css .col, .cl { display: table-cell; padding: 1em; border: solid; } any solut

java - bufferedReader readline=null -

im trying write class take text file,reverse contents , write back. way want write lines in string[] array,reverse lines , write text text file. problem is, when start writing string array, writes off nulls , know text file not empty. im using copy of bufferedreader read lines. can't seem understand wrong. when initialize string array textfile down in code, have no problems reversing, when use string[] textfile = new string[getnumberoflines ()]; method, doesnt work. public void reverse() throws ioexception { bufferedreader reader = new bufferedreader(new filereader(work_folder_location + file_name)); string[] textfile = new string[3]; try { (int = 0; < textfile.length; i++) { textfile[i] = reader.readline(); textfile[i] = reverseline(textfile[i]); } } catch (ioexception e) { throw new ioexception("there problem while operating reader."); } { reader.close(); } writereverse

python modal logic K solver -

i working on modal logic tableau solver implemented in python (2.7.5 version). have function translates input string tableau format is: input: ~p ^ q parsed: ['and',('not', 'p'), 'q'] parsed , alpha rule applied: [('not', 'p'), 'q'] now, dealt alpha formulas intersection, double negations etc. problem encountering beta formulas , example union. for union formula need write function splits 1 list in 2 lists, example: input: ('and', 's', ('or', (not,'r'), 'q')) outputs: 1st list ('s',('not','r')) 2nd list ('s','q') i can once, how can recursively scan formula , generate these list later can scan them , verify whether closed or not? the final goal of create tableau solver generates graph model or return answer formula unsatisfiable. it' interesting project :). i'm myself in thesis modal logic right no

multithreading - Error in scheduled quartz job, unable to create new native thread -

2015-10-22 14:24:57,939 | system | | worker-5 | info | jacorb.orb.giop | clientconnectionmanager: created new clientgiopconnection 11.63.32.49:40000 2015-10-22 14:24:57,941 | system | | worker-5 | error | | not perform supervision cycle. error in scheduled quartz job. unable create new native thread is leak in quartz scheduler doubt be, if what's going wrong? application runs sometime , goes out of memory above error? resolve fast? didn't close orb resource opened properly. added below piece of code ensure same , viola no more out of memory issue :) if(null != orb) { orb.shutdown(true); orb = null; } thanks nick helping pointers fix problem. note: thread helped me find issue - http://www.jacorb.org/bugzilla/show_bug.cgi?id=632

convert string list to decimal list to 10 decimal points in python -

how convert folowing list: ['524.7940719572', '0.1874483617', '0.0321140582', '228.8002278843', '6843.5984811891', '29.9108027316', '60.2048797607', '220.7372120052', '556.828334181'] to: [524.7940719572, 0.1874483617, 0.0321140582, 228.8002278843, 6843.5984811891, 29.9108027316, 60.2048797607, 220.7372120052, 556.828334181] in python l = ['524.7940719572', '0.1874483617', '0.0321140582', '228.8002278843', '6843.5984811891', '29.9108027316', '60.2048797607', '220.7372120052', '556.828334181'] = 0 v in l: l[i] = float(v) = i+1 print l results following output: [524.7940719572, 0.1874483617, 0.0321140582, 228.8002278843, 6843.5984811891, 29.9108027316, 60.2048797607, 220.7372120052, 556.828334181]

java - Illegal character in query to maps.googleapis -

i'm developing android application use google maps. locate user , want show pois in vicinity through query maps.googleapis. in java code have string use httprequest obtain information. string is: "https://maps.googleapis.com/maps/api/place/nearbysearch/" + "json?location="+lat+","+lng+ "&radius=1000&sensor=true" + "&types=food|bar|store|museum|art_gallery"+ "&key=mykey"; where lat , lng 2 variables contains coordinates of position of user , mykey api key. when launch application in log section obtain "illegal character in query @ index 125" , conseguently in maps obtain no pois. if delete " , + characters in string , use link in browser obtain list of pois. how can obtain list in application?? don't understand error in string.. thx all according this link '|' character should replace '%7c'

java - Spring boot freemarker -

i exception when try import jsptaglibs in spring boot application. freemarker.template.templatemodelexception: no mapping defined http://www.springframework.org/tags/form hear part of ftl file, when try import it. <#import "/spring.ftl" spring/> <#assign form=jsptaglibs["http://www.springframework.org/tags/form"] /> get problem when starting application spring boot app, works if deployed on standalone tomcat war file. any ideas ? you need add code below give templates path. @configuration public class emailconfiguration { @bean(name ="freemarkerconfig") public freemarkerconfigurer getfreemarkerconfig() { freemarkerconfigurer configurer = new freemarkerconfigurer(); configurer.settemplateloaderpath("**classpath:mail**/"); map<string, object> map = new hashmap<>(); map.put("xml_escape", new xmlescape()); configurer.setfr

java - Using EJB to persist. How do I configure the Persistence Unit on it? -

i've been learning j2ee tech. i'm trying out crud in ejb, when try deploy web application, have these problems. don't have clue one. can give me tips it? this actual persistence.xml: <?xml version="1.0" encoding="utf-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="usuariopu" transaction-type="resource_local"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <jta-data-source>lp3</jta-data-source> <class>mack.entities.usuarioimpl</class> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <pr

XAMPP localhost redirects to localhost/dashboard -

i've installed xampp-win32-5.5.30 , in xampp control panel both apache , mysql started without error found: 1) localhost in browser redirects page localhost/dashboard/ , not xampp start page. 2) localhost/xampp shows following: index of /xampp [ico] name last modified size description [parentdir] parent directory - apache/2.4.17 (win32) openssl/1.0.2d php/5.5.30 server @ localhost port 80 in c:\xampp\htdocs\index.php file: <?php if (!empty($_server['https']) && ('on' == $_server['https'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_server['http_host']; header('location: '.$uri.'/dashboard/'); exit; ?> wrong xampp installation :-( is there wrong installation? this: header('location: '.$uri.'/dashboard/'); performs redirect localhost/dashboard/ everythi

java - Autoboxing/Unboxing while casting Integer to int using 'cast' method -

here simple case: trying cast object type primitive this: object object = integer.valueof(1234); int result1 = int.class.cast(object); //throws classcastexception: cannot convert java.lang.integer int int result2 = (int)object; //works fine this source code of cast method of class 'class' public t cast(object obj) { if (obj != null && !isinstance(obj)) throw new classcastexception(cannotcastmsg(obj)); return (t) obj; } private string cannotcastmsg(object obj) { return "cannot cast " + obj.getclass().getname() + " " + getname(); } why happening? same happening other primitives too. live example cast can't work primitives, given can't return value of actual primitive type, due generics in java... end boxing again anyway. , if you're not assigning straight int value, have boxed reason too. so basically, if want convert int , cast directly. isinstance documented return false primitives:

java - Eclipse plugin doesn't work in CDT -

i have implemented eclipse plug-in runs in test workbench, eclipse ide php developers , eclipse ide java developers doesn't work in eclipse cdt . there no error messages, dont't know, why. my plug-in adds popup menu entry , executes action. notices plug-in stops after line: ifile file = (ifile) ((istructuredselection) wbw.getselectionservice().getselection()).getfirstelement(); all ides run on kubuntu 14.04. the selection returned selection service user interface object rather ifile . need use iadaptermanager adapt object file. object selected = ((istructuredselection) wbw.getselectionservice().getselection()).getfirstelement(); iadaptermanager manager = platform.getadaptermanager(); ifile file = (ifile)manager.getadapter(selected, ifile.class);

javascript - Given URL is not permitted by the Application configuration: One or more of the given URLs is not permitted by the App's setting -

Image
i having issue facebook app. error : given url not permitted application configuration: 1 or more of given urls not permitted app's settings. must match website url or canvas url, or domain must subdomain of 1 of app's domains. i writing code , attaching screenshot of application setup page, understand issue. here code using : <script> window.fbasyncinit = function() { fb.init({ appid : 'app-id', xfbml : true, version : 'v2.5' }); // place following code after fb.init call. function onlogin(response) { console.log("calling onlogin.."); if (response.status == 'connected') { fb.api('/me?fields=first_name', function(data) { var welcomeblock = document.getelementbyid('fb-welcome'); welcomeblock.innerhtml = 'hello, ' + data.first_nam

Haskell inline-c multi-step build/link with Cabal -

i writing ffi-heavy library uses inline-c , , build process is: run ghc on inline-c files, produce c compile c produced in previous step dynamic libraries compile haskell interface while linking both object files produced in step 2 , dynlibs of wrapped library. question: i'm doing above in makefile (see https://github.com/ocramz/petsc-hs/blob/master/makefile ), i'd package in cabal file (working version : https://github.com/ocramz/petsc-hs/blob/master/petsc-hs.cabal ). sub-questions: how 1 control build/link sequence in cabal? are relative paths supported in cabal? couldn't find mentioned in guide , bash-like ~ doesn't work thank in advance pointers how 1 control build/link sequence in cabal? you can use build-type: custom in cabal file , control custom setup.hs . have @ userhooks data type of phases of cabal can control. some examples: sdl - uses autoconfuserhooks have cabal run configure script this answer contains l

javascript - Easier way to calculate numeric multiplier suffix -

function num(n) { if (n >= 1000 && n < 10000) return (n/1000).tofixed(3) + "k"; if (n >= 10000 && n < 100000) return (n/1000).tofixed(1) + "k"; if (n >= 100000 && n < 1000000) return (n/1000).tofixed(0) + "k"; if (n >= 1000000 && n < 10000000) return (n/1000000).tofixed(3) + "m"; if (n >= 10000000 && n < 100000000) return (n/1000000).tofixed(1) + "m"; if (n >= 100000000 && n < 1000000000) return (n/1000000).tofixed(0) + "m"; if (n >= 1000000000 && n < 10000000000) return (n/1000000000).tofixed(3) + "b"; if (n >= 10000000000 && n < 100000000000) return (n/1000000000).tofixed(1) + "b"; if (n >= 100000000000 && n < 1000000000000) return (n/1000000000).tofixed(0) + "b"; if (n >= 1000000000000 && n < 10000000000000) return (n/1000000000000).

c++ - Define bitset size at initialization? -

i want make bitset in c++. did bit of research. examples found this: bitset<6> mybitset; // but don't know size of bitset when define variable in class: #include <bitset> class test { public: std::bitset *mybitset; } this won't compile... and initializing doesn't work: int size = getdependentsizeforbitset(); mybitset = new bitset<size>(); boost has dynamic_bitset can use. alternatively, can use vector<bool> , (unfortunately) specialized act bitset. causes lot of confusion, , in general considered bad idea. that's how works, if that's need, might use it, suppose.

css - Group input to same row in Jquery mobile -

i'm using jquery mobile , group 2 input buttons (plus/minus) , 1 input text same row using data-type="horizontal" . fiddle show how looks today: http://jsfiddle.net/ezanker/hhken790/4/ i similar to: <div data-role="controlgroup" data-type="horizontal" > <a href="index.html" data-role="button" data-icon="minus" data-iconpos="notext">minus</a> <a href="index.html" data-role="button">value here</a> <a href="index.html" data-role="button" data-icon="plus" data-iconpos="notext">plus</a> </div> but input button support , value added input. you can effect content grid provided within jquery mobile. <div class="qtywrapper ui-grid-b"> <div class="ui-block-a"> <input type="button" value="-" class="qtyminus" /> </div&

How do Android applications receive input from touch screen? -

i want know how applications handle input touch screen. example, if user touch coordinates x,y, how opened (active in foreground) application know gadget (button example) @ coordinates x,y must clicked now? also, can control way apps handle touch input using app? mean, want build app uses services control how other apps handle inputs, of course needs app have permission access other apps settings, question is, possible? i have searched how apps handle touch input, found these results, useful, not relevant case, http://developer.android.com/training/gestures/index.html how android device handle touch screen input? also, know input hardware controlled hal (hardware abstraction layer) in android, every input device has own driver. how apps handles inputs coming these devices? thank you. there several ways handle touches in android. first buttons can set onclick() method automatically triggered when touch screen. another option attach ontouchlistener activ

How to manage settings in a custom IIS managed module -

i'm developing iis 7 managed module, distributed along server-side software. how can manage settings/configurations within iis module itself? example, how can let user set api-key internally used module? i know in apache or in nginx can add settings directly in virtualhosts file (apache) , in nginx configuration files (nginx). wonder if there "best practice" iis modules. yes there is, can use web.config files that, optionally define own configuration section, depending on how complex configuration is, maybe using existing appsettings section enough. module can read appsettings like: how read appsettings section in web.config file? and best thing includes built-in ux in iis manager manage application settings. bad part not give validation customers, nor "intellisense" guide them through configuration. if want define own section can at: http://www.iis.net/learn/develop/extending-iis-configuration/extending-iis-schema-and-accessing-the-custom-s

jquery - Reset Array in a function throw an exception AngularJS -

i have variable under scope , when try reset in function throwing me exception. controller variable declaration: angular.module('timesheetapp', []).controller('timesheetcontroller', function ($scope, $http) { $scope.timesheet = { tables: [{ projects:{ project: ":)", activities: [{ activity:"", sun: 0.00, mon: 0.00, tue: 0.00, wen: 0.00, thu: 0.00, fri: 0.00, sat: 0.00, total: 0.00 }], defaultprojecttext: "select project", isdisabled: true, projectnumber: 0, day: {} } }], }; }); when call function inside controller sends exception: $scope.setdays = function () { $scope.timesheet.tables = [{

linux - samb.conf: Where is the "security" parameter? -

i'm trying make files in linux virtual server browsable windows. i'm following instructions given here: https://help.ubuntu.com/lts/serverguide/samba-fileserver.html however, cannot find security parameter it's talking about. can create anywhere under [global] ? or there pretty specific place put it? yep, can specify "security=" parameter anywhere in global section. https://www.samba.org/samba/docs/man/manpages/smb.conf.5.html

ruby on rails - Cannot call model method from controller -

i've got model named profilelastlocation , i've got controller named singlesaroundcontroller . controller have such action: def in_area box = geocoder::calculations.bounding_box([params[:clat], params[:clng]], params[:distance]) in_area = profilelastlocation.within_bounding_box(box) render in_area.to_json end when controller action called - error undefined method `within_bounding_box' #<singlesaroundcontroller:0xb4f107fc> when copy rest of code error console - works. bet profilelastlocation model not accessable controller. my model code is class profilelastlocation < activerecord::base include sgltableprefix belongs_to :user has_one :profile_setting, through: :user has_one :profile_mandatory, through: :user has_one :profile_optional, through: :user scope :available, -> { joins(:user).where("sgl_users.online = ?", true) } def self.persons_in_area(clat, clng, distance) box = geocoder::calculations.bou

php - Only single record getting when i fetch data from another page -

i have created php page fetch data mysql , have page show data on webpage.... have php page page_1.php <?php include_once'db_localconnection.php'; $query="select * `table 5` base='home plans'"; $get_allplans=mysql_query($query) or die(mysql_error()); while($fetch=mysql_fetch_array($get_allplans)) { $plans_code=$fetch['plan_code']; $speed=$fetch['speed']; $data=$fetch['data']; $duration=$fetch['duration']; $gb_pm=$fetch['gb_pm']; $up_speed=$fetch['up_speed']; $price=$fetch['price']; $base=$fetch['base']; } ?> and have page show data have include needed pages <td><?php echo $plans_code; ?></td> <td><?php echo $speed; ?></td> <td><?php echo $data; ?></td> <td class="center"><?php echo $duration; ?></td

c# - ReactiveUI: R/W properties vs. Output Properties -

i have "close" button , expander linked in mvvm view so: this.bindcommand(viewmodel, vm => vm.closeresults, v => v.closebutton); this.onewaybind(viewmodel, vm => vm.hasexecuted, v => v.panel.isexpanded); if user clicks on button, expander should collapsed. in view model, have reactivecommand should take care of this: public reactivecommand<object> closeresults { get; protected set; } = reactivecommand.create(); in view model, hasexecuted output property supposed expand/collapse expander depending on value: private readonly observableaspropertyhelper<bool> _hasexecuted; public bool hasexecuted => _hasexecuted.value; so hook command button, i'm binding hasexecuted command so: closeresults.select(_ => false).toproperty(this, vm => vm.hasexecuted, out _hasexecuted); this doesn't seem anything. however, if use read-write property instead , hook this: closeresults.subscribe(_ => { hasexecuted = false; }); it

php - Dozens of forms handling -

i working on project has dozens of forms. : laptops_form | mobile_form | vehicles_form | form_45 . for each form data stored in different table in database. i have 45 forms. vast e-commerce web application. each database table has representational page in application visitors see posted ads. i intermediate level programmer. in scenario feel it's way it. right or there way achieve such goal in minimized way. it depends on type of data stored in tables, if, example, data fields similar need differentiate between forms, can create 1 table , add flag called form_type, , table store data forms. if data fields different, can have (like have right now) table each form, or can have few dynamic tables (like when you're building custom form). personally, favor approach because it's faster when comes performance. second approach, however, more flexible , you'll able add more forms if want without creating additional tables - additionally, reporting easi

android - How to make a Wheel picker -

Image
i trying make wheel picker this have tried downloading project files included in .zip download wheel-demo.apk , notes.txt. notes.txt not have instructions on how use file android studio. found post suggested using listviews create same effect. rather making own spent day searching internet , found source code here when imported files project ide showed dozens of errors. through trial , error managed fix 3 errors. pretty sure have put relevant code below mainactivity.java: onwheelscrolllistener scrolledlistener = new onwheelscrolllistener() { public void onscrollingstarted(wheelview wheel) { wheelscrolled = true;// "cannot resolve symbol wheelscrolled } public void onscrollingfinished(wheelview wheel) { wheelscrolled = false;// "cannot resolve symbol wheelscrolled updatestatus(); } }; // wheel changed listener private final onwheelchangedlistener changedlistener = new onwheelchangedlistener() { public void onchang