Posts

Showing posts from February, 2010

javascript - Query to find all users with a particular role in parse api -

i working pars javascript api. trying is, retrieving users of particular role. used code it. var query = (new parse.query(parse.role)); query.equalto("name", "admin"); query.first({ success: function(role) { role.relation('users').query().find({success: function(users) { }}); }}); the problem returns undefined value role . sops @ line role.relation('users').query().find({success: function(users) saying cannot call relation() undefined value of role.

css - Problems creating html layout using float and margin-left -

i have following html code displays div elements on page. <div style="float: left; width:182px; height:200px; border-style: solid; border-width:1px">left column</div> <div style="margin-left: 200px; border-style:solid; border-width:1px"> <div style="float: left; border-style: solid;border-width:1px;">div1</div> <div style="float: left; border-style: solid;border-width:1px;">div2</div> <div style="clear:left; border-style: solid;border-width:1px;">div3</div> <div style="float: left; border-style: solid;border-width:1px;">div4</div> </div> i div3 shown below div1 , div2, instead shown left column ends, there large space between div1/div2 , div3. how can div3 shown below div1/div2? important div3 uses whole available width. use may u <div style="float: left; width:182px; height:200px; border-style: solid;

ElasticSearch Query time - how to decrease the response time -

i executing queries on elastic search. of queries taking long time execute first time , on rerun response time reduces. however, first time execution nearing 16 secs of queries. i have increased vcpu 1vcpu 2vcpu (elasticsearch server running vm) , can see decrease in response time ("took" in elastic search). can please , summarize, factors (both hardware , software e.g. query construct) affect response time in elasticsearch. i using java query es. first query make full search, next 1 can use cache, that's why quicker. can check in elasticsearch indexes based on search fields. data may not indexed correctly dependending on kind of search, speed process. you can limit number of matches, if don't care results @ same time (managing pagination).

java - Access resource folder within jar -

i trying read contents of resource folder once jar built. resource folder marked source in ide settings (intellij). i have tried following methods: inputstream input = getclass().getresourceasstream("../objectlocation.json"); jsonreader jsonreader = new jsonreader(new inputstreamreader(input)); i have tried: jsonreader jsonreader = new jsonreader(new filereader("../resources/objectlocation.json")); both of these methods results in : which results in: java.io.filenotfoundexception: com/layers/resources/objectlocation.json (no such file or directory) file structure: src -com.layers -> myclasses -resources -> json edit: inputstream input = getclass().getresourceasstream("objectlocation.json"); jsonreader jsonreader = new jsonreader(new inputstreamreader(input)); results in a: java.lang.nullpointerexception not understanding difference between absolute , relative paths when loading resources in java

java - Group concatenated strings by 160 characters per group and do the same thing on the remaining -

i have table want data retrieved. managed retrieve these datas. twist want concatenate these data (which of strings) create string 160 characters. managed having code answered guy here in stackoverflow. the code this: list<pending> pending = db.getallpending(); string = ""; (pending pn : pending) { if (a.length() + pn.getpm_str().length() <= 160) { += pn.getpm_str(); } else break; } the code concatenates data until has formed 160 length string. disregard other data happened exceed limit. my problem is: how going same thing remaining data list (which not included in first batch of 160 length string)? want these data concatenated create same. the concept of program has sms sending. data concatenated , group 1 sms sent. need help. you need create list of resulting strings , add when concatenated string reaches limit: list<pending> pending = db.getallpending(); list<string> resultingstrings

java - Guava vs Google Play Services: Build Conflict -

i use guava , googleplayservices in same project. after added guava via gradle, got dex build error. able isolate conflicting culprit googleplayservices. can build using one, or other, not both. dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.gms:play-services:7.5.0' compile group: 'com.google.guava', name: 'guava', version: '18.0'} anyone else encounter this? solution appreciated. i think you've encountered 65k method limit issue. the easiest fix instead of including whole google play service library, include need. see https://developers.google.com/android/guides/setup#split for more information regarding 65k issue: see https://www.contentful.com/blog/2014/10/30/android-and-the-dex-64k-methods-limit/

How to show gif image in ImageView in android? -

i tried picaso library, not showing gif image. getting images json. tried following code :- picasso.with(mcontext).load( stationwithstate.station.getlogo()).transform(transformation).placeholder(r.drawable.ic_launcher).into(viewholder.stationimageview[i]); please me ? ok after doing google found out library in showing gif image json link ion.with(viewholder.stationimageview[i]) .placeholder(r.drawable.ic_launcher) .error(r.drawable.ic_launcher) .fitcenter() .load(stationwithstate.station.getlogo());

ios - Is there a way to go to "Settings" in URL schemes? -

i want know if there way open "settings" of device, wifi toggler, data toggler, air plane toggler... i have shortcut "prefs:root=wifi", don't know if can open wifi settings , simulate click on button go settings. i'm developing on ios 7 , greater. thanks. as read, not possible. answered @richard-venable in how open settings programmatically in facebook app? . there no url can use root level of settings app. you can send user app's section of settings app using uiapplicationopensettingsurlstring in ios 8. thanks @ saurabh-prajapati comment.

mousehover - Bootstrap tooltip and awesome bootstrap checkbox error -

so seems when using awesome bootstrap checkbox , bootstrap tooltip check icon showed after move mouse checkbox <div class="checkbox checkbox-circle"> <input id="checkbox7" type="checkbox" data-toggle='tooltip' data-placement='bottom' data-original-title="tooltip here" class='checkbox'> <label for="checkbox7"> rounded </label> </div> here's javascript (source: bootstrap) $(function () { $("[data-toggle='tooltip']").tooltip(); }); here's example: http://codepen.io/anon/pen/ejbyaz is there way fix this?

.net - Push Notification using C# -

i need send push notification ios,android , windows phone using c# . can please suggest 3rd party library available this. kindly suggest.. you can use pushsharp. here reference : https://github.com/redth/pushsharp

How to change sketch support in CATIA using vba? -

i want change sketch support 1 plane in macro. tried startcommand did not work. how can done without user input? i have tried following code did not work. catia.startcommand "change sketch support" selection1.add sketch3 sendkeys "{enter}", true selection1.add plane_a sendkeys "{enter}", true part1.update you trying winapi , not easiest way. have 2 alternatives: or use copy , paste method dim osel selection = catia.activedocument.selection osel.clear() osel.add(sketch3) osel.copy() osel.clear() osel.add(plane_a) osel.paste() dim rsltsketch sketch = osel.item2(1).value osel.clear() 'you can delete first 1 if want osel.add(sketch3) osel.delete() or define precise vectors dim arrayofvariantofdouble(8) arrayofvariantofdouble(0) = originpointx arrayofvariantofdouble(1) = originpointy arrayofvariantofdouble(2) = originpointz arrayofvariantofdouble(3) = directionhorizontalx arrayofvariantofdouble(4) = directionhorizontaly arrayo

ios - Customizing Google Place Picker widget -

i trying create mapview have 80% exact same functionality places picker provided google. i seeking way find way customise ui widget or source code doing. anybody have idea? the getcurrentplace() method return ordered list of places @ api believes device located. same list displayed in placepicker, using data returned api uitableview, should simple build own ui.

jsf - Spring Security SSO / Font Awesome primefaces not loading -

i have programmed sso kerberos / spring security. sso working charm, there 1 issue. primeface's font awesome isn't loaded , following exception printed on screen: error o.a.m.a.resourcehandlerimpl - error trying load resource fa/fontawesome-webfont.eot library primefaces :java.io.exception: existing connection has been terminated under software control host computer in web.xml i've added <context-param> <param-name>primefaces.font_awesome</param-name> <param-value>true</param-value> </context-param> why primefaces not loading font awesome after single sign on? how can load icons? idea appreciated. thanks!

java - Data model in a common web service -

in common restful service, there @ least 3 models, refer same thing, little different in different situation. the first model used accept data post request, field template_id valued "id12345". the second model db entity, have db entity, have template_id field, type of field int, it's internal template primary key in db, it's integer. so can't directly convert post data db entity insert db. the third model rest response, example, want add/remove field in model. can't directly convert db entity json response. so want know way process small differences between these 3 models. do need create 3 models named postdatamodel dbmodel responsemodel ? think it's not idea. the post data , rest response may same, both belongs representation layer. there example here. restlet-tutorial

ruby on rails - Implement Post ranking algorithm with Likes and Time difference -

how can rank posts likes , time difference(how old post) in ruby on rails. there suitable algorithm task. here code algorithm @rank = 0.00 s = post.likers(user).count order = math.log10([s.abs, 1].max) if s > 0 sign = 1 elsif s < 0 sign = -1 else sign = 0 end td = (time.now - post.created_at) td2 = td.days * 86400 + td.seconds + ((1000000*(td.seconds)).to_f)/1000000 seconds = td2 - 1134028003 @rank = (sign * order + seconds / 45000).round(7) post.update_attributes(popularity: @rank) post.save! how reddit ranking algorithms work . if posts can liked, is, if number of likes positive number can simplify equation removing y . update ruby implementation of linked algo def hot(ups, downs, date) s = ups - downs order = math::log([s.abs, 1].max, 10) sign = if s > 0 1 elsif s < 0 -1 else 0 end seconds = date.to_f - 1134028003 (sign * order + seconds / 45000).round(7) end note doesn't use time.now here. in implementation older po

php - hide/show issue with quicksand -

i'm trying load multiple lists quick sand. have 3 divs , 1 shows @ time , using hide/show display them. problem have when click show new div quicksand feature has strange behavior. link in list(s) disappears (display:none) , when clicking view tab other links present nothing shows until click 1 of tabs show content. <ul id="filteroptions" class="filteroptions"> <li class="active"><a href="#" class="all">all</a></li> <?php $i = 0; $pages = get_pages('child_of=181&sort_column=post_date&sort_order=desc&parent=181'); foreach($pages $page){ $count = 0; $id = $page->id; $count = count($children); ?> <li> <a href="#" class="<?php echo $page->id; ?>"><?php echo $page->post_title ?> &

java - UCanAccess "object not found" error for query that references its own column alias -

Image
since jdbc:odbc bridge in not longer supported java 8 try replace ucanaccess v3.0, ii facing issue, see following. this code use in order connect database : string url = "jdbc:ucanaccess://d:/adel/adel local/adel_data.accdb"; try { //class.forname("sun.jdbc.odbc.jdbcodbcdriver"); class.forname("net.ucanaccess.jdbc.ucanaccessdriver"); } catch (java.lang.classnotfoundexception e) { system.err.print("classnotfoundexception: "); system.err.println(e.getmessage()); errorfile.writeerror(thread.currentthread().getstacktrace()[2].getlinenumber(), e); } to run query same code using jdbc:odbc connection c = connectdb.doconnect(); string selectstring = "select distinct [maintenance input check due list].[interval (mos)], [maintenance input check due list].inputaircrafthours, [maintenance input check due list].inputaircraftlandings,

c# - Show dialog only once, not after level restart -

i have own dialog system gameobject collider. after triggering collider, canvas text component should show up. far, works. now, want make happen once. here how work: start level trigger showing dialog. game pretty hardcore player die. when player dies, call application.loadlevel(application.loadedlevel); (so restart level) if use in scrip collider private static bool firsttimetext = true; void ontriggerenter2d(collider2d coll) { if (coll.tag == "player" && firsttimetext) { getcomponent<boxcollider2d>().enabled = false; firsttimetext = false; } } everything works charm. except if make copy of gameobject, static variable in script "handle" every instantion of object have firsttimetext on false after trigger dialog first time. can use once. so there sollution making trigger run once , not reset after application.loadlevel ? also doesn't work void awake() { dontdestroyonload(transform.gameobj

ios - Container View bounds issue in Swift -

i'm writing function can height , width of container view: // container view's uiviewcontroller class selectionview: uiviewcontroller { override func viewdidload() { super.viewdidload() } func getbounds -> (cgfloat,cgfloat){ let x = self.view.bounds.width / 5 let y = self.view.bounds.height / 15 return x,y } } i write button call getbounds() , works well, when put in viewdidload() function override func viewdidload() { super.viewdidload() getbounds() } getbounds() returns me different height , width , not bounds of container view. i'm pretty sure i've linked class container view! view layout not setup in viewdidload . therefore resizing not done yet , size wrong(probably same declared in storyboard/xib). move getbounds in viewwilllayoutsubviews or viewwillappear , work correctly. please mind method won't called 1 time ;)

bash - egrep -v match lines containing some same text on each line -

so have 2 files. example of file 1 content. /n01/mysqldata1/mysql-bin.000001 /n01/mysqldata1/mysql-bin.000002 /n01/mysqldata1/mysql-bin.000003 /n01/mysqldata1/mysql-bin.000004 /n01/mysqldata1/mysql-bin.000005 /n01/mysqldata1/mysql-bin.000006 example of file 2 content. /n01/mysqlarch1/mysql-bin.000004 /n01/mysqlarch1/mysql-bin.000001 /n01/mysqlarch2/mysql-bin.000005 so want match based on mysql-bin.00000x , not rest of file path in each file differ between file1 , file2. here's command i'm trying run cat file1 | egrep -v file2 the output i'm hoping here be... /n01/mysqldata1/mysql-bin.000002 /n01/mysqldata1/mysql-bin.000003 /n01/mysqldata1/mysql-bin.000006 any appreciated. just compare based on / : $ awk -f/ 'fnr==nr {a[$nf]; next} !($nf in a)' f2 f1 /n01/mysqldata1/mysql-bin.000002 /n01/mysqldata1/mysql-bin.000003 /n01/mysqldata1/mysql-bin.000006 explanation this reads file2 in memory , compares file1. -f/ set field separat

Need help to show image from gallery only in portrait mode Android -

i new bie in android development. please bare english. struck problem unable show image gallery in portrait mode,it showing in landscape mode.here code reference,could please me solve issue.thanks in advance. what tried sofar is, have gone through below stackoverflow answers same issue , tried place same code in class image still sits in landscape mode only. stackvoerflow links followed are: 1. open image gallery in potrait mode 2. http://codereply.com/answer/5xf8di/android-detect-image-orientation-portrait-landscape-picked-gallery-setting-imageview.html 3. android: bitmaps loaded gallery rotated in imageview public class fragmenttab1 extends fragment { relativelayout homes; private static int result_load_image = 1; imageview bitmapview; bitmapfactory.options options; string filepath; button rot; private int mdegree = 0; @override public view oncreateview(layoutinflater inflater, viewgroup container,

service - Where does DTOS as InputModel / ViewModel Fit in Layered Archicture -

Image
i'm trying understand inputmodel , viewmodels fit @ 4 layer architecture. presentation | application | domain | infrastructure given application layer takes care exchange data beteween presentation layer , domain layer, supposed that, must live inside layer, adapter convert domain entity , vice versa. inputmodels, know commands, in asp.net mvc can coincide viewmodels. makes no sense me viewmodels inside presentation. application layer should return viewmodels presentation , receive viewmodels mapp domain entity. if have viewmodels inside presentation, , presentations refers application layer, have loop reference. and also, example, if have presentation build asp.net mvc , have necessity change windows application lost viewmodels fit on requisites, shame, given have built in change presentation technology. i'm reading book dino esposito , andrea saltarello, microsoft .net: architecting enterprise. don't talk application layer, that, 1 should orchestrate domai

database - Manually Close ODBC DSN Connection -

i have ms access database connects database via user level dns odbc data source. when connection first initiated odbc driver prompt me username , password. database connects on server dependent on username use. once connection established access retain / keep alive until close access database. is there way force access close open odbc connections, requiring me provide login credentials again when next try access object on server. want able switch database odbc connection accessing without having close access , re-open database. two things: 1) can make process of closing , re-opening access painless possible users doing: ' close , restart shell "restart.bat", vbnormalfocus application.quit with restart.bat consisting of like rem wait access close timeout 3 rem actual command line goes here msaccess.exe mydatabase.mdb 2) mentioned: what want able switch database odbc connection accessing the link posted gave me idea: any subsequen

php - how do I get the switch command to work if the field is empty to return n/a -

hello wrote following code i'm having small problem. in data base have field called gf_gemstone wrote switch script (below) the last part want write if field empty return n/a . no matter can't work. can body help. case "gf_gemstone_amazon1a": switch ($value) { case "agate": return "agate"; break; case "amethyst": return "amethyst"; break; case "aquamarine": return "aquamarine"; break; case "black diamond": return "black-diamond"; break; case "black sapphire": return "sapphire"; break; case "blue diamond": return "blue-

mysql - How to get 2nd highest salary from db -

to find highest salary db use max in query. how 2nd highest salary db. can 1 suggest sq query this should help: select max(salary) mytable salary < ( select max(salary) mytable )

c++ - segmentation fault on libusb_get_device_with_vid_pid -

i'm trying open connection camera raspberry pi 2 on usb. i'm able detect camera when try open connection using libusb_open_device_with_vid_pid(null, vendor id, product id); but receive segmentation fault. i've narrowed down , line of code causes segmentation fault. void opendevice(){ libusb_device_handle* dev; struct libusb_device_descriptor* desc; int err; dev = libusb_open_device_with_vid_pid(null,0x2a0b,0x00f8); if (dev == null){ printf("device not found\n"); } else { err = libusb_claim_interface(dev, 0); } } the message pi opened on putty on computer is. segmentation fault any ideas doing wrong? you getting null dev , , using anyway. add return statement after printf() , or else before libusb_claim_interface() .

javascript - Can't get a simple jquery slider to work -

i trying jquery slider work on site. have not programmed because cannot, i'm trying use there , works on demo site. have tried several ready use jquery slideshow , sliders, without success. have found simplest 1 available, think cannot make 1 work either although think have followed steps instructed.. 1 have " http://responsiveslides.com/ ", files on github though: https://github.com/viljamis/responsiveslides.js i have put in html <head> <!-- slideshow begin --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="js/responsiveslides.min.js"></script> <script> $(function() { $("#slider1").responsiveslides({ auto: true, speed: 500, timeout: 4000 }); }); </script> and in html <div class="welcome section"><!-- welcome section begin --> <img

Adaptive UI interface in iOS 8 through iphone 5 to iphone 6+ -

i have created app runs on different devices, when set in interface builder, looks despite of constraints, labels or buttons positioned differently in different devices in simulator. i.e.: have interface designed, use background image view in interface builder, using iphone 5 size reference. in image designed field, when put label in it, looks in different position in simulated iphone 5 , iphone 6, though has been constrained in same way. doing wrong? thx help!!! ps: assuming image view sizes proportional between iphone 5 , 6, should naturally have same aspect ratio hence label constraints i think easiest way explain setting constraints between different view sizes autolayout watch how it's done. here's excellent video stanford university's cs193p ios development course explaining how works. here you'll find resources course. can download full lectures itunesu.

javascript - Search and sort based on the value of the select element -

i whole table editable. data placed inside input, : <td> <input class="form-control dnsinput" type="text" value="{{ line.host }}" /> </td> the problem ordering/search of datatables not searching inside input. had idea span hidden data inside it, solved search problem, not filtering one. felt bad idea overall. i feel best way modify datatables's default behaviour, didn't find wanted in docs. basically shorten up, : put in every cell, input containing data (that did) , ordering , searching functionnalities of datatables go , search inside inputs. has ever had such thing? if yes, there "standard way" of doing ? solution you can use columndefs target specific column using zero-based index in targets option , render return selected value during searching ( type === 'filter' ) or sorting ( type === 'order' ). var table = $('#example').datatable({ columndefs: [

android - AmazonSNS - AwsCredentials.properties - NullPointerException -

Image
i new android studio , intellij. i trying work amazonsns - push. unable figure out how add awscredentials.properties file classpath of module. npe @ line 57 in image below(at method getresourceasstream()). added required keys in awscredentials.properties file. error: in questions have come across on stackoverflow regarding similar issues, suggested file should in root folder, where, src is. placed in same folder of src, still getting npe. tried placing file in com/test/ no use. how solve this? there other steps involved? edit after starting bounty - adding java files here did till now.. create android application called myapplication. imported classes(androidmobilepushapp.java, externalreceiver.java, messagereceivingservice.java) demo application. added required libs, , ran , got registationid response amazon. in same application, created new module called snspush , imported snsmobilepush.java file it. imported awscredentials.properties file same path of snsmob

c# - How to make exe run as scheduled task -

i created winform project in c# , added code file called loader.cs. in file have method called loaddata(). deleted default "form1" project changed logic in main() run loaddata() method. works when run in vs2008 ide. built release , moved resulting .exe different machine , set scheduled task trigger every hour , action pointing .exe /auto argument. task nothing, sits running , not doing of processing. have end task. same if run manually. if double click exe folder it's located nothing. how can exe run scheduled task or run independently? in program.cs: static class program { [stathread] static void main() { loader lc = new loader(); lc.loaddata(); } } and in loader.cs file: public void loaddata() { // ...processing } i try putting try { } catch { } in main , examining exception.

android - Delete null element in 2d array in Java -

help me please!, have array of strings: data2[3][2] = [[datos varios, datos empresa, null], [listado2, listado2 extendido, null], [pendientes validar, pendientes liquidar, liquidados], [pendientes aprobar, pendientes pago, pagados]] i found resize array obtain this: dont know way.. data2[?][?] = [[datos varios, datos empresa], [listado2, listado2 extendido], [pendientes validar, pendientes liquidar, liquidados], [pendientes aprobar, pendientes pago, pagados]] thanks in advance !! i thought problem possibly 2d structure of array, , suggested links 1d. here suggested solution 2d case build simple test on data. import java.util.arraylist; public class testapp { public static void main(string[] args){ string[][] data = {{"datos varios", "datos empresa", null}, {"listado2", "listado2 extendido", null}, {"pendientes validar", "pendientes liquidar", "liquid

serialization - Manually mapping with Realm for Objective C -

i'm using realm deserialize json , create entity. to deserialize json: name of property in json must identical property name of class. manually map names can different, possible? example of json: { "text":"hello" } example of class: @property (nonatomic, strong) nsstring* mytext; i want map "text" "mytext". thanks lot. sometimes need convert data being input realm if models don't line json response. there few libraries mantle , realm-json this. latter has been used community handle these kinds of situations. here's tutorial written on mantle

outputstream - Android Java Save Audiorecord / Audiotrack to a file -

i have short code streams recorded audio in realtime speakers if user push start button. after pushes stop button, buffered audio should saved in mp3 file. file created empty. if try play file cant hear anything. public class mainactivity extends activity { boolean m_stop = true; audiotrack m_audiotrack; thread m_noisethread; static final int buffersize = 200000; audiorecord arec; fileoutputstream os = null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } public void onstartstopclicked(view v) { button startbutton = (button)findviewbyid(r.id.startstop); if(m_stop) { start(); } else { stop(); } } runnable m_noisegenerator = new runnable() { public void run() { string filepath = environment.getexternalstoragedirectory().t

mysql - My sql query with MAX, MIN and third field for HAVING -

i'm trying minimum , maximum price on mysql(myisam) query. i'm using query for: select max(price_feed) max, min(price_feed) min, sqrt( pow(69.1 * (latitude_feed - 51.542980), 2) + pow(69.1 * (-0.149323 - longitude_feed ) * cos(latitude_feed / 57.3), 2)) distance feed listing_type_feed = 'rental' , property_type_feed in ("flat", "apartament", "penthouse", "studio") having distance < 2 but returns nothing, while when try select price_feed max, price_feed min, sqrt( pow(69.1 * (latitude_feed - 51.542980), 2) + pow(69.1 * (-0.149323 - longitude_feed ) * cos(latitude_feed / 57.3), 2)) distance feed listing_type_feed = 'rental' , property_type_feed in ("flat", "apartament", "penthouse", "studio") having distance < 2 it returns 2600 rows. thanks you need nested query or cte depending on rdbms first calculat

ASP.NET MVC Multiple form in one page: Validation doesn't work -

i creating register login page in asp mvc , need, page has 2 models , 2 form actions. every thing ok validation. models are: public class account_index_viewmodel { public useraccount_login_viewmodel useraccount_login_viewmodel { get; set; } public useraccount_register_viewmodel useraccount_register_viewmodel { get; set; } } public class useraccount_login_viewmodel { [required] [datatype(datatype.password)] public string pass { get; set; } [required] public string loginname { get; set; } // nickname/email/mobilephone } public class useraccount_register_viewmodel { public string nickname { get; set; } public string passw { get; set; } public string passconfirm { get; set; } public string email { get; set; } public string mobilephone { get; set; } } and view : @model ghafasehwebsite.models.account_index_viewmodel @{ viewbag.title = "index"; } <h2>index</h2> <div class="accountbook">