Posts

Showing posts from April, 2014

jquery - Is it possible to know if page is accessed from Browser / Mobile / Tablet -

i have simple html file <!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>if click on me, disappear.</p> <p>click me away!</p> <p>click me too!</p> </body> </html> is possible know device page accessed , mean browser or mobile / tablet ?? i sorry if not related jquery section . check out user agent in javascript :) or use made script - check site: http://detectmobilebrowsers.com/

java - How do I use a timer to run code again and again until a boolean value e.g. Testing is equal to true? -

this easy question but, how use timer run code again , again until boolean value e.g. testing equal true? obviously use while loop don't want stop rest of work taking place on main ui thread if process running simultaneously, use handler , use postdelayed(runnable, long) post callback implementing runnable interface. a rather naive example: final handler = new handler(); final runnable r = new runnable() { public void run() { if (<expression>) { // evaluated true, stuff , exit polling loop. } else { handler.postdelayed(this, <timeout>); } } handler.postdelayed(r, <timeout>);

Mysql update data with regex -

is there anyway update rows of 1 text column , remove spaces in between string, the data json string, following example string {"id" :"95703", "lastname" :"trigger", "firstname" :"test", ... } if notice there annoying white spaces between "id" , value :"95703" , is there anyway can (in update query) update rows , remove white space (using regex) the sample query can run on table is update `user_log_data` set data = {regex part} "[ ]+: try this.replace ": .see demo. http://regex101.com/r/lz5mn8/31

angularjs - Adding form validation to custom directive in angular -

i aware question has been asked before not know how implement asnwers problem. have tri-state boolean directive in angular , not sure how add validation states directive form can see value valid (not null) app.directive('customboolean', function(){ return { restrict: 'e', replace: true, scope: { boolvalue: '=', required: '@' }, template: '<button class="btn btn-default btn-xs" ng-click="toggle()" style="width: 70px">{{ boolvalue | bool_to_string }}</button>', controller: function ($scope, $element){ $scope.toggle = function(){ if ($scope.boolvalue == null) { $scope.boolvalue = true; } else if ($scope.boolvalue == true) { $scope.boolvalue = false; } else { $scope.boolvalue = $scope.required ? true : undefined; } }; } } }); below plnkr link of have far. have ideas? plnkr link use ngmodel inste

Convert MongoDB console aggregate to php with array -

i failing convert following mongodb console command: db.customers.aggregate( [ { $group : { _id: { year : { $year: "$since" }, month : { $month: "$since" } }, count: { $sum: 1 } } }] ); which works php $customers->aggregate(array( '$group' => array( '_id' => array( 'year' => array('$year' => '$since'), 'month' => array('$month' => '$since') ) ), array( 'count' => array( '$sum' => 1 ) ), ) ); which returns exception: pipeline stage specification object must contain 1 field. tried '"$since"' no luck the count field must part of group . $customers->aggregate(array( '$group' => array( '_id' => array( 'year' => array('$year' => 

c# - EF 5.0 Oracle Code First set Precision to number types -

with entity framework 5.0 , odp.net trying build code first dbcontext existing oracle database. know approach not supported officially odp, maybe there workaround only problem still need solve. all tables have keys of type number(18,0) . simple example: table > describe t_user kuser not null number(18,0) domain object public class user { public long id { get; set; } /* ... */ } mapping configuration modelbuilder.entity<user>() .totable("t_user"); modelbuilder.entity<user>() .property<long>(x => x.id) .isrequired() .hascolumntype("number") .hascolumnname("kuser"); i cannot specify precision attribute though, because decimalpropertyconfiguration class (.property()) exposes precision , scale properties. the result translated queries contain cast number 19 digits precision (default mapping int64), like: select cast( "extent1"."kuser" number(19,0

c++ - Do-while loop issue: Try to develop a simple game -

Image
well, i'm writing make dice game. tried searching dice game here none of seems answer question. isn't problem dice roll thing anyway. it's while loop. new site, found out via maximum pc magazine please bear me. new programming. here code: #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main(){ srand(time(null)); int userroll = rand() % 6 + 1 ; int computerroll = rand() % 6 + 1 ; string yesornochoice; string commandtothrowdie; do{ cout << "please enter \"throw\" (lowercase) roll die: "; cin >> commandtothrowdie; } while(commandtothrowdie != "throw"); do{ cout << "you rolled: " << userroll << endl << "the computer rolled: " << computerroll << endl; if (userroll < computerroll){ cout << "you lose. try again? [yes/n

php - Yii unserialize and diff -

i have problem, trivial can not deal because snap out of still gets there error type: unserialize (): error @ offset 0 of 31 bytes controller: public function actionhistory($id) { $post=mymodel::model()->findall('id='.$id); if($post == null){ $error = yii::app()->errorhandler->error; if ($error) $this->render('error', array('error'=>$error)); else throw new chttpexception(404, 'page not found.'); } $dataprovider=new cactivedataprovider('mymodel',array( 'criteria'=>array( 'condition'=>'id='.$id, 'order'=>'id desc', ) )); $this->render('history',array( 'dataprovider'=>$dataprovider, 'id'=>$id, )); } and view file: <div class="view" style="float: left; width:100%;"> <b&g

ios - Why do brackets mess up this math in objective-c? -

why 2 calculations have differing results? xcode 6.1. (lldb) print newbounds.size.height (cgfloat) $0 = 446.5 (lldb) print newbounds.size.height * 6/4 (double) $1 = 669.75 (lldb) print newbounds.size.height * (6/4) (double) $2 = 446.5 it's integer math , usual rules promotion of types. height * 6/4 == (height * (double)6) / (double)4 == (height * 6.0) / 4.0 whereas: height * (6/4) == height * (double)(1) == height * 1.0 since 6/4 == 1 , parentheses force evaluated first before promoting double . this same behaviour in c, c++, objective-c, et al , shouldn't surprised see in debugger too.

Iframe in sencha Touch -

i need use facebook button iframe in android app...if use code see on pc desktop don't see in android. do know why , if exist method display button in android? i'm using sencha architect , touch 2.3 thank you <iframe src="//www.facebook.com/plugins/likebox.php?href=https%3a%2f%2fwww.facebook.com%2ffacebookdevelopers&amp;width&amp;height=62&amp;colorscheme=light&amp;show_faces=false&amp;header=false&amp;stream=false&amp;show_border=false&amp;appid=780849738633803" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:62px;" allowtransparency="true"></iframe> it you. this code: htmlstrbase1 = '<iframe src="//www.facebook.com/plugins/like.php?href=https%3a%2f%2fwww.facebook.com%2fopticaltrend12345%2f&amp;width&amp;layout=button&amp;action=like&amp;show_faces=false&amp;share=false&amp;height=35&amp;appid=

javascript - Make onclick function return url without hash -

i trying variable local page link i'm trying this: <a href="#mylink" data-toggle="tab" onclick="location.href=this.href+'?currenttab=mytab;';return false;">mylink</a> this returns: http://mysite.php#mylink?currenttab=mytab is there way of stopping displaying hash? want show variable. for example: http://mysite.php?currenttab=mytab simply make href attribute empty. valid , fix issue. note, however, little preview appears on bottom left corner of browser misleading. unless have reason use javascript, it'd better include query string (which hard coded anyway) href . hover on both links in snippet below see i'm talking about. <a href data-toggle="tab" onclick="window.location = location.href +'?currenttab=mytab;';return false;">link</a> <a href="?currenttab=mytab" data-toggle="tab">link</a>

git - Invalid syntax in python script for pre commit hook -

this question has answer here: syntax error on print python 3 [duplicate] 10 answers i using following python code hook pre commit hook jshint when execute git commit -m "commit comment" shows error file ".git/hooks/pre-commit", line 29 print error ^ syntaxerror: invalid syntax here code #!/usr/bin/env python import os, sys """ checks git commit jshint. checks staged files """ def jshint(): errors = [] # staged files f = os.popen('git diff --cached --name-only --diff-filter=acm') file in f.read().splitlines(): # makes sure we're dealing javascript files if file.endswith('.js') , not file.startswith('node_modules/'): g = os.popen('jshint ' + file) # add errors files err

javascript - Laravel and custom editor form macro -

is possible have javascript on laravel form macro? trying extend laravel have custom editor (like tinymce or ckeditor) examples see far create html portion of editor , not add javascript capabilities. i thinking on creating run required javascript portion of textarea hijacking, there instances. example might want 3 textareas editor: {{ form::myeditor(...); }} <br/> {{ form::myeditor(...); }} <br/> {{ form::myeditor(...); }} <br/> and generate 3 editors on same page.

postfix notation - InFixToPostFix java with equations -

using 1 input file map variable value , file equations. problem equation such ((a+b)-(c-d))/(e-f) calculates correctly until (a+b)-(c-d) know has map.put('z', temp) , as.push('z') don't know how else make work properly. input file one: a = 8.0 b = -1.0 c = 7.0 d = -4.0 e = 11.0 f = 9.0 g = 3.2 h = 6.325 = 8 j = -3.333894 input file two: (((a + b) - (c - d)) / (e - f)) (((a))) (a) ((a (b d) d)) program: import java.util.*; import java.io.*; public class infixtopostfix { static final string p_error = "parenthesis match error"; static final string e_error = "empty infix expression error"; static map<character, integer> out_stack = new hashmap<character, integer>(); static map<character, integer> in_stack = new hashmap<character, integer>(); public static void main(string[] args) { map<character, double> map = null; try { map = populate();

.net - How can create an installer from my Application C# -

i create wizard create installer in c#. how can that? please help.. need pack executable files , mdb database application creator. database dynamically generated. usual setup project won't work. in order have more flexible (custom) installer, recommend using wix you can start here download wix here or the faster (typical) way not flexible (custom) is: new project -> other project types -> setup , deployment

c# - How do I identify a user returning to my ASP.NET MVC site from elsewhere? -

how can determine if user hitting site elsewhere (i.e. new tab or site)? need present 'welcome back' message returning users still logged in, don't want appearing if they're navigating within site or, say, reloading homepage. i've considered using onload/onbeforeunload (or similar) keep track of whether there view open, adds complexity. can assume if request.urlreferrer doesn't contain domain it's 'fresh' visit? try this, if(request.urlreferrer != null && request.urlreferrer.host != request.url.host) { // user visit page site/domain }

Facebook with actionscript 3 on Flashdevelop : JSON Conventions Issue -

i'm trying use facebook actionscript 3 on flashdevelop, i've been following tutorial setting facebook : http://supertommy.me/content/2012/getting-started-open-graph-as3/ the code seems clean error : warning: content targeting flash player version 14 or higher, externalinterface escapes strings using json conventions. maintain compatibility, content published earlier flash player versions continues use legacy escaping behavior. i checked flash player target on flashdevelop in project properties, in tab output flash player set 10.1, missing ? use clause @ end: content published earlier flash player versions continues use legacy escaping behavior. as warning newer players may render json string differently 1 in flashdevelop, may need test using newer debug player avoid security issues. references adobe security bulletin: apsb13-08 v-100: adobe flash player bugs let remote users execute arbitrary code

java - insert blob data in to database -

think have little problem code: when try insert in database value recived 1 error. ps: try use : setbinarystream(int parameterindex, inputstream x) - data read inputstream needed until end-of-file reached. added in jdbc 4.0 (java 1.6). setbinarystream(int parameterindex, inputstream x, int length) - data read inputstream needed "length" bytes. setbinarystream(int parameterindex, inputstream x, long length) - data read inputstream needed "length" bytes. added in jdbc 4.0 (java 1.6). but everytime recived simple error. don t know doing ..... m code monkey... this class: public class dataservlet extends httpservlet{ public void dopost(httpservletrequest request,httpservletresponse response)throws servletexception,ioexception { connection conn = connectiontodb.connettidb(); inputstream inputstream = null; part filepart = request.getpart("image"); inputstream = filepart.getinput

How to change screen orientation, without creating a new activity on android? -

i not know if title correct, here happens. i have application works differently on phone , on tablet, on phone shows portrait on tablet shows landscape. to achieve created class called coreactivity extended activities , following: public class coreactivity extends activity { protected boolean _landscape = false; public boolean isphone() { int layoutsize = getscreenlayoutsize(); return (layoutsize == configuration.screenlayout_size_small || layoutsize == configuration.screenlayout_size_normal); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if (isphone() && !_landscape) { this.setrequestedorientation(activityinfo.screen_orientation_portrait); } else { this.setrequestedorientation(activityinfo.screen_orientation_landscape); } } protected int getscreenlayoutsize() { return (getresources().getconfiguration().

android - OncreateView in Fragment is not calling with an singleInstance -

i have 2 activities , b extending 1 base class main , base class has 1 framelayout in layout including in both of activities , b respective layouts. i checking instance creation of fragment in fragment inflating when go particular acitivity. here code : public class baseacitvity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_base_acitvity); } } here firstactivity:: public class firstactivity extends baseacitvity { public firstfragment firstfragment ; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.firstactivitylayout); firstfragment = new firstfragment(); fragmentmanager fragmentmanager = getfragmentmanager(); fragmentmanager.begintransaction().replace(r.id.card_view_layou

jmeter - In stress test do you control hits/second? how do you do stress test -

i have stress test 500 users on web site. how approach one. need control hits/second jmeter makes server or need ramp threads , let whatever maximum hits can do. should user step in delay(eg: 1 user/thread starts every 15sec or 20 sec). should delay between samples. thanks in advance. i suggest 500 users 1500 ramp-up — gives 3 seconds new user come up. additionally force 500 users loop infinity or let's 100 times. of 500 on system @ same time , in different places. suggest more real testing scenario. moreover, suggest put random timers between samplers well. test goes through requests without delays fake gets. can switch between pages in 35ms? of course not, why should test that.

ember.js - Emberjs Routing: Page reloads on every link click -

i have ember js app, pushstate enabled. on page www.xyz.com/start , have proper link on page ( www.xyz.com/abc/def ) , have defined route in ember /abc/def . every time click on link, page reloaded instead of directly being served ember router. correct way this? you have use link-to helper instead of basic href links. {{#link-to 'abc/def'}}go def{{/link-to}} where 'abc/def' route name. see : http://emberjs.com/guides/templates/links/

c# - Custom Validation Attribute reading from a form field -

i trying create own validation attribute isunique checks existing values given property. understand isvalid() must overridden custom validation attribute can work. far have seen examples validate attributes take string parameters compared hard coded values inside isvalid() method. i need isvalid() method access property , value further compare values in database. this have done far: public class isunique : validationattribute { private string codeno { get; set; } : base("{0} in use") public isunique (string codeno) { this.codeno = codeno; } public override validationresult isvalid(object value, validationcontext vcontext) { if (value != null) { mydbcontext db = new mydbcontext(); student studentscodeno = db.students.firstordefault(r => r.codeno== (string)value); if (studentscodeno != null)

matlab - Understanding the output of of convhull -

can please explain me values stored in kk for a=[2 0 0; 0 2 0; 0 0 2; 1 1 sqrt(2)]; kk= convhull(a); values in kk : 1 2 4 1 3 2 1 4 3 2 3 4 have read documentation of convhull ? it explains (for 3d case): k = convhull(x,y,z ) returns 3-d convex hull of points (x,y,z), x, y, , z column vectors. k triangulation representing boundary of convex hull. k of size mtri-by-3, mtri number of triangular facets. is, each row of k triangle defined in terms of point indices. in example convex hull of the 4 points in a defined 4 triangular facets [1 2 4] --> [ (2,0,0), (0,2,0), (1,1,sqrt(2)) ] %// first triangle [1 3 2] --> [ (2,0,0), (0,0,2), (0,2,0) ] %// second triangle ...

html - jquery validation for field with default value -

this question has answer here: jquery.validation - how ignore default values when validating mandatory fields 8 answers http://jqueryvalidation.org/files/demo/ i using above plugin jquery validation of registration form it working properly, in form there 1 field name "domain" default value has been set "www." user have write other part domain. so practically not blank time, not validating if user left filed default value, here jquery , html code <script> $().ready(function() { $("#frm").validate({ rules: { domain: "required", uname: "required", password:'required', cpassword:'required', fname:'required', lname:'required', bussname:'re

ios - UITapGestureRecogniser in GMSMapView -

i creating app using swift. in 1 of viewcontroller, have gmsmapview create programatically. want user have capability triggering action when clicking on map. what have done : import uikit class mapviewcontroller: uiviewcontroller, gmsmapviewdelegate { let mapview = gmsmapview() override func viewdidload() { super.viewdidload() mapview.delegate = self mapview.settings.scrollgestures = false mapview.frame = cgrectmake(0, 65, 375, 555) view.addsubview(mapview) var tap = uitapgesturerecognizer(target: self, action: "tap:") mapview.addgesturerecognizer(tap) } func tap(recogniser:uitapgesturerecognizer)->void{ println("it works") } } i have tried override touchesbegan, didnt work. have tried insert mapview.userinteractionenabled = true, didnt work... any idea? i managed func mapview(mapview: gmsmapview!, didtapatcoordinate coordinate: cllocationcoordinate2d) { pri

javascript - on selecting checkbox its should open its respective card only in the wizard and remaining should hide -

how go respective card on selecting checkbox tried iam not able move resp card in wizard please can me. if select network in wizard should open network card remaining application , dependent services should hide , same thing remaining. <div class="wizard" id="addservicedefinationwizard" data-title="add admin"> <button type="button" class="close wizard-close" aria-hidden="true">×</button> <h1>add admin wizard</h1> enter code here × add admin wizard <div class="wizard-card" data-cardname="card1"> <h3>basic information</h3> <div class="form-group col-xs-12"> <label>name of service</label> <input type="text" class="form-control" name="service" placeholder="service name&quo

linux - How to resize an image from an rgb buffer using c++ -

i have (char*)rgb buffer has data of actual image. let's actual image resolution 720x576. want resize resolution , 120x90. how can using https://code.google.com/p/jpeg-compressor/ or libjpeg ? note: can use other library, should work in linux. edited: video decoder decodes frame in yuv, convert rgb. these happen in buffer. need resize rgb buffer make thumbnail out of variable size. thanks in advance i did following achieve goal: #define tn_width 240 #define tn_height 180 #include "jpegcompressor/jpge.h" #include "jpegcompressor/jpgd.h" #include <ippi.h> bool createthumnailjpeg(const uint8* psrc, int srcwidth, int srcheight) { int req_comps = 3; jpge::params params; params.m_quality = 50; params.m_subsampling = jpge::h2v2; params.m_two_pass_flag = false; file *fpjpegtn = fopen("resource\\jpegcompressor.jpeg","wb"); int dstwidth = tn_width; int dstheight = tn_height; int uidstbuffersize = dstwidth * dstheight

github - Using GIT Bash, ERROR: Repository not found - fatal: Could not read from remote -

my friend's project in git repository, have downloaded 'git-1.9.4-preview20140929.exe' , installed git bash pull project end, did using $ git clone <with ssh clone url> i got project in local system, , have done few changes want push changes repository, did $ git init reinitialized existing git repository in c:/users.... and $ git add . $ pom.xml ./pom.xml: line 1: project: no such file or directory ./pom.xml: line 2: syntax error near unexpected token `newline' ./pom.xml: line 2: ` xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http ://maven.apache.org/maven-v4_0_0.xsd">' and $ git commit -m 'first commit' on branch master branch ahead of 'origin/master' 2 commits. (use "git push" publish local commits) nothing commit, working directory clean and $ git push -u origin master:master enter passphrase key '/h/.ssh/id_rsa': error: repository not found. fatal: not read remote repos

java - Spring MVC, Excel file download, corrupts file -

i'am working on excel export functionality in 1 of webapps. set little test case , got download working, xlsx file corrupted , don't know else try. if write excel file opens without problem, error must occure when downloading. the setup: spring-mvc 3.2.7 poi 3.10.1 tomcat 8.0 controller method: @requestmapping(value = "/download", method = requestmethod.get) public modelandview downloadexcel() { // create sample data list<book> listbooks = new arraylist<book>(); listbooks.add(new book("effective java", "joshua bloch", "0321356683", "may 28, 2008", 38.11f)); listbooks.add(new book("head first java", "kathy sierra & bert bates", "0596009208", "february 9, 2005", 30.80f)); listbooks.add(new book("java generics , collections", "philip wadler", "0596527756", "oct 24, 2006"

sql - How to change subQuery to Co-related Subquery? -

query select firstname, lastname adventureworks.person.contact inner join [adventureworks].[humanresources].[employee] b on a.contactid = b.contactid b.employeeid in ( select salespersonid adventureworks.sales.salesperson c c.bonus = 5000) how change above subquery co-related subquery? i think you're looking for. move query from section , use join filter results based on same conditions had in where clause, except time reference result set (rs) returned subquery. select firstname, lastname adventureworks.person.contact inner join [adventureworks].[humanresources].[employee] b on a.contactid = b.contactid inner join (select salespersonid adventureworks.sales.salesperson c c.bonus = 5000) rs on b.empoyeeid = rs.salespersonid although functional, done easier , faster using join salesperson table directly. select firstname, lastname adventureworks.person.contact inner join [adventureworks].[humanreso

html - Upload Image using Php and mySQL -

i trying upload image using php , save in mysql database accept different extension of such bmp, jpeg etc. using following codes, of uploaded images displayed incomplete. this uploadform: <html> <form method="post" action="updateimage1.php" enctype="multipart/form-data"> <table border=0> <tr> <td><center><img src="getimage.php?id='.$row["no"].'" width=250 height=180/></center><br> <input type="file" name="s4"><br> <input name="update" type="submit" id="update" value="save changes" class="btn btn-primary" > &nbsp &nbsp </form><a href="admin3.php"><button type="button" class="btn btn-primary">cancel</button></a> </tr> </table> </html> this updateimage1.php: &

java - MboxIterator not in Apache Mime4J -

i downloaded binaries of latest stable version of apache-mime4j (0.7.2). yet, fail compile next code since mboxiterator & charbufferwrapper classes not found. final file mbox = new file("path/name.mbox"); (charbufferwrapper message : mboxiterator.fromfile(mbox).charset(encoder.charset()).build()) {do something} the jars included in build path: apache-mime4j-core-0.7.2.jar , apache-mime4j-dom-0.7.2.jar . am using wrong jars or version? i had same problem ended getting work doing little research. the classes mention, @ least found, not included mime4j, have code them yourself. devs, got them uploaded in following link: mboxiterator needed classes . hope solve problem.

hibernate - Weld and a EntityManagerFactory Container Managed -

i need know how ensures container closes emf (using wildfly 8.0 , hibernate-jpa). every time undeploy app instance of weldjpainjectionservices$entitymanagerresourcereferencefactory stays on memory holding emf instance. this causing oom exception after deploys/undeploys. i'm not using emf references in code, entitymanager @produces , @persistencecontext annotation. it happening on wildfly 8.0, 8.1 , 9.0alpha, java 7 , 8. leak related keep-alive , read-timeout properties of undertow. in new version of wildfly (8.2) can define these properties: <subsystem xmlns="urn:jboss:domain:undertow:1.2"> <buffer-cache name="default"/> <server name="default-server"> <http-listener name="default" socket-binding="http" tcp-keep-alive="true" read-timeout="30000"/> after setup no more leaks on deploy/undeploy. issue: wfly-3536 - wildfly 8.1

svg - d not being set with expected information -

i'm trying draw simple svg pie chart d3. here's code generates pie chart , data set: /* data */ var pielayout = d3.layout.pie(); var piedata = pielayout([21, 32, 35, 64, 83]); /* generator */ var piegenerator = d3.svg.arc() .innerradius(20) .outerradius(50) .startangle( function(d){ console.log(d) return d.startangle } ) .endangle( function(d){ console.log(d) return d.endangle }); /* usage */ svg.append('path').data(piedata).attr('d', piegenerator) for whatever reason, 1 segment of pie chart appearing. why this? see console.log s inside .startangle function , .endangle function? log first object inside piedata : object {data: 21, value: 21, startangle: 5.721709173346517, endangle: 6.283185307179587} (index):189 object {data

mongodb - Mongoose + node.js findOne(), find() not giving results -

i have taken learning node.js few days , facing problem while retrieving data. i using mongoose in node.js , save() function working when try retrieve data using find() or findone() page keeps loading long time , not give result. models/chatrooms.js var mongoose = require('mongoose'); var schema = mongoose.schema; var tblchatroomsschema = new schema({ chatusers: { type: schema.objectid, ref: 'tblchatrooms' }, chatroomid: {type: number, required: true, index: { unique: true }}, // every chat has 1 room id totalmember: number, // indicates total number of members status: number, // 0 = closed, 1 = open created: date, chatlog: string }); module.exports = mongoose.model('tblchatrooms', tblchatroomsschema); routes.js > var tblchatrooms = require('./models/tblchatrooms'); > ...... > ...... > > app.get('/member', function (req, res) { > >

java - how to set a specific position of image in hidden object game -

i developing hidden object game android in eclipse. have settle background , want put small images on background on specific positions using x , y axis. how it. have searched lot haven't found helping. giving code. , yes have used java prams imagebutton method , set(x) , (y) method well(which available in honeycomb 3.0). here xml code: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/bg_level1" > <imagebutton android:id="@+id/ibcross" android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/cross" /> </linearlayout> stage.java package com.findmystuff; import android.app.activity; import android.os.bundle; import android.widget.abso

php - sorting an array of objects by datetime variable -

i want sort array of object datetime variable, dates situated in future , want date thats closest current date first one. i'm using following controlleraction in symfony2: public function fixturesaction(){ if (false === $this->get('security.context')->isgranted('is_authenticated_fully')) { throw $this->createaccessdeniedexception('unable access page!'); } $user = $this->get('security.context')->gettoken()->getuser(); $team = $this->getdoctrine() ->getrepository('loginloginbundle:team') ->findbyuseruserid($user->getuserid()); $matchgameshome = $this->getdoctrine() ->getrepository('loginloginbundle:matchgame') ->findbyhometeam($team[0]->getname()); $matchgamesaway = $this->getdoctrine() ->getrepository('loginloginbu

excel - Can't set target worksheet from macro -

i have sub processed macros added 2 excel files , worked. now i've learned files processed won't have these macros , should store them elsewhere. put them in empty workbook , can call macro. the problem is, it's target (an empty workbook). need to work on excel have opened (x1) it originally xl.run macroname the macro , target worksheets contained here now have need run on worksheets of x1, not itself. mymacro.run macroname 'runs no worksheets here here full code of sub sub preparereport(macroname string) dim mymacro object dim xl object dim filepath string dim filename string filename = determinefilenameauto(macroname) filepath = currentproject.path + "\source_files\" + filename 'load macro-excel files set mymacro = createobject("excel.application") mymacro.workbooks.open (mymacrofilepath) 'load excel file, open target workbook. set xl = createobject("excel.application") xl.workbooks.open (filepath) 

appcelerator - titanium app no longer connects to facebook -

i until last 2 weeks able use following code sign facebook , publish feed (or wall, or whatever they've decided call it): fb.appid = id; fb.permissions = ['publish_actions']; //nee publish_stream fb.addeventlistener("login", secondnamedfunction = function(e){ fb.removeeventlistener("login", secondnamedfunction); logineventfunction(e, handlesuccesssend, handlefailsend, handlecancelsend); }); fb.authorize(); however, yesterday when attempted didn't work. went sign-in page, entered username , password, hit "log in", , loading graphic appeared. , nothing else happened. i tried several times - after around minute loading graphic go away, , on log in page, needing enter username , password. i know put app "review" on facebook (which, record, think not thing ask developers do, review questions confusing). however, listed admin app itself, not have thought issue. no error code sent back, think request hung. have s

java - Design Pattern to deal with a class with many members (not Builder) -

i have class many members (~20). initialize nicely constructor not option (due many parameters) because of bad code readability. so tried use builder dp. problem it's nasty when comes extending such class. any suggestion on design patter should use deal nicely situation (class many members)? thanks lot! as say, 20 fields lot constructor. regarding readability, pattern comes mind static factory methods (but in sense of joshua bloch's effective java , not factory method of gof book ). as says in book (in item 1), static factory methods have names (unlike constructors) static method well-chosen name easier use , resulting client code easier read. class manyfields { t a; u b; (...) v t; } that way, things like manyfields.withatofzeroed(g, h, i, ..., t) manyfields.onlygandj(g, j) manyfields.consonantszeroed(a, e, i, o, u) (...) that is, adapt/coin new static factory methods addressing different usage patterns in code easier , more read

java - How to apply DRY for Liquibase data source config and persistence.xml? -

i using liquibase , java ee jboss. configure persistence.xml file in project specify data source want use. in jboss configs: <datasources> <datasource jta="true" jndi-name="java:jboss/datasources/webstoriesds" pool-name="java:jboss/datasources/webstoriesds" enabled="true" use-java-context="true" use-ccm="true"> <connection-url>jdbc:postgresql://127.0.0.1:5432/mydatabase</connection-url> <driver>org.postgresql</driver> <security> <user-name>postgres</user-name> <password>postgres</password> </security> </datasource> <drivers> <driver name="org.postgresql" module="org.postgresql"> <xa-datasource-class>org.postgresql.xa.pgxadatasource</xa-datasource-class> </driver> </drivers> </datasour

php - Compare Value to String IF/FOR Statement -

i'm trying compare value of each saved entity , organize results sections. can't life of me find how compare variable string using twig. i've tried error's except following code instead of failing, skips if's , shows else. i'm assuming i've got wrong twig documentation has no mention of how (i think) , i'm beginning think i'm going wrong way. maybe should doing in controller? {% product in entity.product %} {% if product.dish.dishcat == 'starter' %} <h3>starter</h3> <p>{{ product.dish }}</p> {% elseif product.dish.dishcat == 'main'%} <h3>main</h3> <p>{{ product.dish }}</p> {% elseif product.dish.dishcat == 'desert'%} <h3>desert</h3> <p>{{ product.dish }}</p> {% else %} // get's here. <p> fail!</p> <p>{{product.dish.dishcat}} {{product.dish.id}}</

jquery - mouseover function occurring multiple times in a queue -

i have code fades div on 1 upon mouseover, , fades out when cursor leave viewing area. example: http://jsfiddle.net/3vgbemgu/ $('.under').hover(function () { $('.over').fadein(); }, function () { $('.over').fadeout(); }); however, if user moves mouse on area multiple times, animation creates queue, meaning div fades in , out various times 1 after another. more obvious there multiple instances of animation on screen, or if fade in , out times longer. how stop animation retriggering while still occurring first time? you can use jquery .stop() : $('.under').hover(function() { $('.over').stop(true, true).fadein(); }, function() { $('.over').stop(true, true).fadeout(); }); .frame { position: absolute; width: 400px; height: 300px; } .under { width: 100%; height: 100%; z-index: 1; } .under img { width: 100%; height: 100%; } .over { position: absolute; width: 100%; height

java - Use Hibernate to set value to uppercase -

i need set value being saved db uppercase. environment in java, , i'm using jsp/hmtl/js front end forms. i have had suggestions modify model's getter/setter believe may dangerous seeing model may used in variety of places, not of may want strictly uppercase value. previously have tried set value uppercase on web form, using style="text-transform:uppercase" however when value saved db retains lowercase value. is there annotation, or idea has on this? thanks, dearg update: @vimal bera did try this: $('#xyz').on('input', function() { $('#xyz').val().touppercase(); }); but admit js experience isn't great, needless did not work. text-transform: uppercase in css display client text shown uppercase. javascript point of view, text remains lowercase. made test can shown in jsfiddle the way value input var textinput = document.getelementbyid("yourinput").value; before submitting db, should make su