Posts

Showing posts from January, 2014

perl - Email::MIME can't parse message from Gmail -

so i'm using perl , email::mime email gmail. here code: use net::imap::simple::gmail; use email::mime; # creat object read emails $server = 'imap.gmail.com'; $imap = net::imap::simple::gmail->new($server); # user , password $user = 'username@gmail.com'; $password = 'passowrd'; $imap->login($user => $password); # select inbox , returns number of messages $numberofmessages = $imap->select('inbox'); # let's go through messages top ($i = 1; $i <= $numberofmessages; $i++) { $top = $imap->top($i); print "top = $top\n"; $email = email::mime->new( join '', @{ $imap->top($i) } ); $body = $email->body_str; print "body = $body\n"; }#end when run it, following error: can't body string multipart/related; boundary="----=_part_6796768_17893472.1369009276778"; type="text/html" @ /library/perl/5.8.8/email/mime.pm line 341 email::mime::body_str...

css - How to select all classes inside a class with jQuery selector -

how go selecting classes in class using jquery selector? think $(".content .*").click(); work. in addition, on click of class in .content want store class name of clicked class in variable. here selector elements have @ least 1 class specified $('.content [class]') or here elements $('.content *') or better: $('.content').on('click', '*', function() { //handler here }); your second question doesn't make sense , needs rephrased

php - Form header:location sequence order -

hi i'm trying redirect next page after data sumbmitted mysql. have far <?php $name = ""; $email = ""; $msg_to_user = ""; if ($_post['name'] != "") { include_once "newsletter/connect_to_mysql.php"; // sure filter data deter sql injection, filter before querying database $name = $_post['name']; $email = $_post['email']; $sql = mysql_query("select * newsletter email='$email'"); $numrows = mysql_num_rows($sql); if (!$email) { $msg_to_user = '<br /><br /><span style="font color="ff0000">please type email address ' . $name . '.</span>'; } else if ($numrows > 0) { $msg_to_user = '<br /><br /><font color="ff0000">' . $email . ' in system.</font>'; } else { $sql_insert = mysql_query("insert newsletter (name, email, dat...

MYSQL PHP PDO order of statements in a transaction -

i using innodb in mysql , accessing table php pdo. i need lock table, select , then, depending on result of either insert row or not. since want have table locked short time possible, can this? prepare select prepare insert begin transaction lock table execute select if reservation time available execute insert unlock table commit or prepares have inside transaction? or have after lock? should transaction include insert, or make difference? begintransaction turns off autocommit mode, affects queries commit changes. means prepared statements, select , , lock tables not affected transactions @ all. in fact, if you're doing single insert there's no need use transaction; need use them if wanted multiple write queries atomically.

php - Creating dropdown list with data from sql and when post is called, keeping the tab selected -

ok, heres problem: i can create dropdown list, when try , set last used tab selected runs through while query , selects bottom option. heres code: <?php $sql="select id, description sites"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $thing=$row["description"]; $thing2 = $_post['thing']; $options.="<option value='if (isset($_post['thing'])){ echo $thing2; 'selected='selected''}else{ echo $id}'>".$thing; } ?> <form action="" method="post" /> <select name="thing" id="thing"> <option value=0>all <?=$options ?> </select> <input type="submit" name="submit" value="update"/> </form> how set selected tab 1 on after submit button c...

ios - Using UIControlEventTouchDragEnter to trigger a button's method... but doesn't work? -

i trying set button using uicontroleventtouchdragenter way trigger button's method. specifically, have button, , want button's method triggered if user presses finger outside of button, , drags finger bounds of button. according apple , event, uicontroleventtouchdragenter, is: event finger dragged bounds of control. however, can't button trigger. here code: - (ibaction)touchdragenter:(uibutton *)sender { _samlpe.image = [uiimage imagenamed:@"alternate_pic.png"]; } so, when touchinto button triggered, method change current image of _sample alternate image. if use touchupinside, image change alternate upon button click. does know why isn't working, or have work-arounds? thanks! the touchdragenter triggered when tap button, drag finger outside of bounds of button, , drag again bounds of button. you might want make use of touchesmoved method in view controller class , detect button entered based on location of touch: - (void)touche...

jdbc - How to get postgresql to work with sequel and jruby -

require 'sequel' require 'jdbc/postgres' db = sequel.connect("jdbc:postgresql://user:pass@domain/database") db.tables returns: ....(bla bla bla stack trace bla bla bla).... sequel::databaseconnectionerror: java::orgpostgresqlutil::psqlexception: connection attempt failed. ........... i have tried jdbc:postgresql://domain/database?user=name&pass=word and got error well, different one('password requested not provided') ruby 1.9.3 - jruby 1.7.3 i have looked , looked, tried many code samples, unable sequel working so, how sequel interface postgres while using jruby? sequel passes jdbc connection string directly jdbc, there nothing sequel-specific it. want jdbc:postgresql://domain/database?user=name&password=secret

java - Graphics will not cover entire canvas -

Image
know: canvas displayed properly, due yellow. however, graphics not cover canvas completely, nor law class recognized past end of black area... so causing happen? , how draw on undrawable section of canvas(yellow part), or should implement graphics way? edit: ui class creates canvas , buffer, graphics class takes on , starts drawing on them, reason cannot in yellow section, nor law class handles collision red cube , walls of app, regogize yellow area valid place go. through same variables dimensions, used everywhere. main class package app; public class main { static final int x = 1024; static final int y = 680; static final int sanic = 10; int fps = 0; int frames = 0; long totaltime = 0; long curtime = system.currenttimemillis(); long lasttime = curtime; static int[] pos; graphics graphics; law physics; static int status; boolean holdstate; public main() { pos = new int[5]; pos[1] = x; pos[2...

c# - What is the overhead of an "synchronized" async method? -

here benchmark methods return task, run synchronizely under hood. class mainclass { public static async task<int> usingasyncmodifier() { return 10; } public static task<int> usingtaskcompletionsource() { taskcompletionsource<int> tcs = new taskcompletionsource<int>(); tcs.setresult(10); return tcs.task; } public static task<int> usingtaskfromresult() { return task.fromresult(10); } public static void main(string[] args) { datetime t = datetime.now; const int repeat = 10000; // results volatile while repeat grows. console.writeline("repeat {0} times.", repeat); int j = 0; (int = 0; < repeat; i++) { j += usingasyncmodifier().result; } console.writeline("usingasyncmodifier: {0}", datetime.now - t); t = datetime.now; (int = 0; < repeat; i++) {...

loops - I'm trying to create a paging system.This is not the complete code. Getting "path doesn't exist " when running the code -

i'm new powershell, idea on why i'm getting error? yesterday_date = (get-date).adddays(-1).tostring("yyymmdd") $jsb={ $file = 'c:\users\d1\documents\batch\path\$yesterday_date1\page.log' get-content $file -wait | foreach-object -begin { $counter = 1 $lines = @(get-content $file).count } -process { if ($counter++ -gt $lines) { write-host $_ } } } start-job $jsb -name dum do{ receive-job -name dum | out-file c:\users\path\pager.txt -append }while(1) some syntax errors. 1st: missing $ variable yesterday_date. in addition, referring later variable $yesterday_date1 , not $yesterday_date . use set-psdebug -strict catch such errors. correct form is $yesterday_date = (get-date).adddays(-1).tostring("yyymmdd") 2nd: single quote doesn't evaluate variables in strings. double quotes do. consider: $file = 'c:\users\d1\documents\batch\path\$yesterday_date\page.log' $file # output c:\user...

Summary in group header in crystal report 2010 -

i have report (in crystal report visual studio 2010) , need few count summaries in group header. also, summaries have conditions. example: have column named "student_id", need count in group header every class group. have date in group='class'. but, summary shown before every data. i tried many different ways far, realized group header printed before section details , that's why didn't work. want show these summaries before starting every page. the report looks follows: class count_student 5 14 6 20 class 5 studentid stu name father-s name 1 2 3 4 5 ... class 6 studentid stu name father-s name ... right click on field want sum. insert -> summary . copy summary field in group header.thus problem solved.

android - Why Custom InfoWindow of google map v2 ,Not load url Image? -

Image
i developing app using google map v2,in app,there custom info window,which not loading image url (loading image loader) please see attached image more clearance. code here- public class customwindowadapter implements infowindowadapter { private activity objactivity; private list<groupdealmodle> maplist; public customwindowadapter(activity objactivity, list<groupdealmodle> maplist) { this.objactivity = objactivity; this.maplist = maplist; } @override public view getinfocontents(marker objmarker) { return null; } @override public view getinfowindow(marker objmarker) { view objview = render(objmarker); return objview; } private view render(marker objmarker) { imageloader objloader = new imageloader(objactivity); view view = null; if (!objmarker.gettitle().equals("")) { int pos = integer.parseint(objmarker.gettitle()); log.e("==check position==", "" + pos); if (...

python - How to use Redis to manage connections for tornado websocket -

i have tornado server tornadio2 handling websocket , tornadoredis publish realtime messages clients (code merged several examples). redis_client = tornadoredis.client(config.get('cache', 'host'), int(config.get('cache', 'port'))) redis_client.connect() class realtimehandler(tornadio2.conn.socketconnection): def __init__(self, *args, **kwargs): super(realtimehandler, self).__init__(*args, **kwargs) self.listen() @tornado.gen.engine def listen(self): self.client = tornadoredis.client(config.get('cache', 'host'), int(config.get('cache', 'port'))) self.client.connect() yield tornado.gen.task(self.client.subscribe, 'invalidation') self.client.listen(self.on_message) def on_event(self, name, *args, **kwargs): if name == 'invalidation': redis_client.publish('invalidation', kwargs['args']) def on_messag...

php - Need to find product details with minimum price -

tbl_product: +------+------+------------+-------+ | id | code | name |brand|origin| +------+------+------------+-------+ | 1 | 1001 | apple | x | | | 2 | 1002 | mango | v | b | | 3 | 1003 | banana| z | | +------+------+------------+-------+ tbl_product_price: +------+------+------+ | id | code | price| +------+------+------+ | 1 | 1001 | 250 | | 2 | 1001 | 220 | | 3 | 1002 | 175 | | 4 | 1002 | 180 | | 5 | 1003 | 170 | | 6 | 1003 | 190 | +------+------+------+ i have search box , if select pro select a.id, a.pro_code, a.pro_unit, min(b.pro_price) tab_product inner join tab_product_price b pro_code like('" .$search . "%') order pro_code limit 5" no pro_code display in search box. please code ok!! first thing join 2 tables since price of product belong tbl_product_price . after joining, need use aggregate function min() , group by lowest price in ever...

New-TimeSpan cmdlet in powershell -

how can use new-timespan cmdlet calculate total time taken script execution.i tried sample this. $val=get-date $start=new-timespan -start $val $val2=get-date $end=new-timespan -end $val2 $diff=new-timespan -start $start -end $end but ended following error: new-timespan : cannot bind parameter 'start'. cannot convert "00:00:08.7110000" value of type "system.timespan" type "system.datetime". you don't need use new-timespan subtract datetime objects: $script_start = get-date start-sleep -seconds 5 $script_end = get-date $script_end - $script_start this create timespan object.

cloudstack api url is generated but the xml is showing error -

i'm using flex builder 4 requesting cloudstack apis , getting response. when execute program url generated. webpage showing error like <?xml version="1.0" encoding="utf-8"?> -<listzonesresponse cloud-stack-version="4.0.1.20130201075054"><errorcode>401</errorcode> <errortext>unable verify user credentials and/or request signature </errortext></listzonesresponse> can tell error? the url api call isn't signed properly. for guidance see introduction cloudstack api , skip slide #9 .

javascript - grunt-contrib-concat: how to use option "process" -

i writing build system using grunt javascript library (widget) concatenate, minify , package files distribution. in concatenation step wanted insert current date 1 of js files process option of grunt-contrib-concat , stated: type: boolean object default: false process source files templates before concatenating. false - no processing occur. true - process source files using grunt.template.process defaults. options object - process source files using grunt.template.process, using specified options. function(src, filepath) - process source files using given function, called once each file. returned value used source code. (default processing options explained in grunt.template.process documentation) concat part gruntfile.js: concat: { options: { stripbanners: { block: true }, process: true, separator: '\n /* ----- */ \n', banner: '<%...

css - Preventing horizontal scrolling in mobile devices -

i have long line @ top: #top-line { background: #00a1e0; border-bottom: 1px solid #fff; height: 4px; position: absolute; top: 0; left: 0; width: 10000px; } so i'm using overflow-x: hidden prevent horizontal scrolling: html { overflow-x: hidden; height: 100%; } body { background: #ededed; font-size: 12px; font-family: arial, sans-serif; color: #666; height: 100%; overflow-x: hidden; } it works ok, in mobile phones still can scroll indefinitely right. is there workaround this? you should define width:100% or max-width:100% prevent horizontal scrolling because define width of area mobile device can occupy , nature occupying more width of mobile width define 100% restrict mobile width.

Upload only changes to published website in ASP.NET -

recently have published website , uploaded godaddy server. after have made changes in .aspx in .aspx.cs files. uploaded files server throws error. having idea how upload changes published asp.net website. thanks in advance! here do: i keep copy of older version locally. then run diff tool( folderpatch ) compare new version generate patch(zip file) upload patch patch online version make same new version using tool ensure don't miss updated files. having upload 1 file lot faster uploads. using patch tool on server, ensures files uploaded correct locations. p.s: wrote folderpatch make life easier. free , open source, feel free use helps you.

c# - How to remove redundant codes? -

Image
am not sure i'm asking in right place. using open xml productivity tool 2.0 , after generating codes, have redundant code like: bold bold1 = new bold(); bold bold2 = new bold(); text1 = new text("a"); text2 = new text("a"); ...etc. it consumes thousands of lines , difficult me navigate through. i tried resharper: but can see threat handing me (now changed 18 hours , not sure able solve it). is there program out there can perform type of refactoring fast? thanks.

php regex or string check to make sure a variable contains specific characters -

i need make sure variable holds product id contains specific characters. for integer-only variables i'm using is_numeric check. but product id, variable can contain following characters: many numbers [0-9] the characters - (dash) and/or _ (underscore) it can contain letters "s" or "c" (but not together) for example, valid: c23_2308724208_9873208 , valid: 12-c53_09872807342 , valid: s23_208320720 . not valid: 12-2352'; select * administrators; . i go format of variable don't think need long make sure variables consists of above. want put check protect sql injections. don't think need care format, i? want make sure given characters s,c,[0-9],[-,_] can found in variable, , nothing outside of range of valid characters. edit based on someone's comment format strictly followed, exact format follows: optional prefix of numbers , dash (eg. 132-) necessary letter (either s or c) followed numbers, underscore, more numbers (eg. ...

caching - ZF2 Doctrine2 Entity Cache -

does know how cache doctrine2 entities in zf2 project. cant find tutorial or website explained. cant find information start defining entity filecache. somebody of got working links or examples. thanks you have 2 options use doctrine's native caching, e.g. using memcache (in memcache block can use kind of doctrine supported cache, full list of cache drivers available). use doctrine's adapter zend/cache/storage use cache you're using elsewhere; adapter described in doctrinemodule docs. as example of version two, have following configuration in module (actually spread across various config files, can't guarantee copy-pasting verbatim work). 'services' => array( 'factories' => array( // wraps zf2 cache storage in doctrine compatible way 'doctrine.cache.zend.static.local' => function ($services) { return new zendstoragecache($services->get('cache.static.local')); }, ), 'caches...

java - JUnit exluding base class from tests in Spring context -

all unit tests have same header spring annotations: @runwith(springjunit4classrunner.class) @contextconfiguration(locations = { "classpath:spring/spring-master.xml"}) @transactionconfiguration(transactionmanager = "transactionmanager", defaultrollback = false) @transactional() i moved them base class , tests extend it: @runwith(springjunit4classrunner.class) @contextconfiguration(locations = { "classpath:spring/spring-master.xml"}) @transactionconfiguration(transactionmanager = "transactionmanager", defaultrollback = false) @transactional() public class domainobjectbasetest { ... public class sometest extends domainobjectbasetest { now when i'm running tests i'm getting domainobjectbasetest: java.lang.exception: no runnable methods my question how can avoid it? can remove @runwith , in case, i'll have apply annotation other tests. many code,don't it. probably, alternative, can somehow in spring group annotations,...

geolocation - Best node.js module for finding location? -

i had found couple of node.js modules finding information client location , network using ip address. requirements: location - country, city, state, latitude, longitude etc. network - internet service provider, internet connection type , internet speed etc. data accuracy - maximum possibility. note: looking server side solution. the above mentioned modules uses maxmind data . , had read maxmind data accuracy well. i little confused choose above node.js modules , know there better node.js frameworks available finding information met requirement or other language plugins can portable node.js. any idea greatful. using ip-based geolocation possible, not accurate. suggest think going hybrid approach, trying users location via html5 geolocation api inside browser , fallback serverside if necessary. i took @ 2 used geoip/-location modules available node.js , both use datasets provided maxmind. afaik have keep these databases up-2-date manually, clear downer. ...

ios - Random EXC_BAD_ACCESS when adding subview with ARC -

my app working on simulator when test app on device random exc_bad_access , app crashes. after few days of testing think have found code causing error. @ point need add subviews controller's main view, user interacts app , subviews removed superview , new subviews added. if don't ever remove subviews app not crash if remove them, app gets exc_bad_access , crashes. it seems subviews removed release msg when released or that... first app i'm using arc i'm missing something... here's code involved: #define kwordxxx 101 #define kwordyyy 102 ... // called after user interaction, removes // old subviews (if exist) , add new ones - (void)updatewords { [self removewords]; if (self.game.move.wordxxx) { wordview *wordxxx = [self wordviewfortypexxx]; wordxxx.tag = kwordxxx; // self.wordsview view subviews added [self.wordsview addsubview:wordxxx]; } if (self.game.move.wordyyy) { wordview *wordyyy = [s...

javascript - Moongose 3.6.11, key "options" in a model -

i migrate mongoose 3.6.11 1 of model have key named "options" in it's schema, have problem it so how can rename without loss data (i have plenty of row modify) ? thanks yeah, answer myself, here operator $rename of mongodb mongodb $rename

How to organize mongodb structure in order to avoid the need for joins? -

think of standard city builder game. have cities, each cities have units, each units have gear(equipped) , city has more gear(unequipped, in box somewhere, heh). a) first off, thought of making 3 collections. cities: {_id, name, locationx, locationy} units: {_id, name, city_id, unittype} items: {_id, name, itemtype, unitequipped} unitequipped optional( item belonged city). b) turned into: cities: {_id, name, locationx, locationy} units: {_id, units:[ {name, city_id, unittye}, {name, city_id, unittye}... ]} items: {_id, items: [ {name, itemtype, unitequipped}, {name, itemtype, unitequipped}... ]} c) , finally, 1 collection: cities: { _id, name, locationx, locationy, units: [ {name, unittye}, {name, unittye}... ], items: [ {name, itemtype, unitequipped}, {name, itemtype, unitequipped}... ] } notice how units no longer have city_id in them there no need to. can tell me pros , cons of these 3 styles? last 1 think has least redundant data if want locationx, have deal other...

multithreading - why doesn't a simple python producer/consumer multi-threading program speed up by adding the number of workers? -

the code below identical python official queue example @ http://docs.python.org/2/library/queue.html from queue import queue threading import thread time import time import sys num_worker_threads = int(sys.argv[1]) source = xrange(10000) def do_work(item): in xrange(100000): pass def worker(): while true: item = q.get() do_work(item) q.task_done() q = queue() item in source: q.put(item) start = time() in range(num_worker_threads): t = thread(target=worker) t.daemon = true t.start() q.join() end = time() print(end - start) these results on xeon 12-core processor: $ ./speed.py 1 12.0873839855 $ ./speed.py 2 15.9101941586 $ ./speed.py 4 27.5713479519 i expected increasing number of workers reduce response time instead, increasing. did experiment again , again result didn't change. am missing obvious? or python queue/threading doesn't work well? python rather poor @ multi-threading. due globa...

how to add Home menu in magento home page -

how add home menu in magento home page. add code in location magento\app\design\frontend\default\grayscale\template\catalog\navigation <li> <a href="<?php echo $this->geturl('') ?>"> <?php echo $this->__('home'); ?> </a> </li> but home menu not displayed on home page of magento you have keep categories want display in menu under root directory. there may more cases possible on why menu not appearing. please consider following these guides : http://www.magentocommerce.com/wiki/3_-_store_setup_and_management/catalog/enable_top_menu_navigation http://www.atwix.com/magento/how-to-add-a-new-item-to-the-navigation-menu/ http://www.youtube.com/watch?v=w4z1ryyfhhu

Salesforce Professional Edition API doesn't support all fields of SalesForce contact -

https://eu1.salesforce.com/services/data/v20.0/sobjects/contact/ {contactid}.xml?fields=id, name, firstname, lastname, salutation, title, email, homephone, mobilephone, otherphone". when use above api fetch contact salesforce works fine in salesforce development edition, throws exception when use same url fetch contact in professional edition. error follows, error code: invalid_field error message: lastname, salutation, title, email, homephone, mobilephone, otherphone ^ error @ row:1:column:65 no such column 'homephone' on entity 'contact'. if attempting use custom field, sure append '__c' after custom field name. please reference wsdl or describe call appropriate names. i want url fetch contact in edition of salesforce. what correct way fetch details of contact in editions of salesforce? there controls admin can use fields available , aren't (for ee , up, field level security, pe, page ...

Linking between buttons in Android via drag and drop? -

im new @ android studio, , android @ ;-) - played , googled bit ;-) is android studio simple xcode , storyborads? can link between activities/views drag drop in xcode ? or linking code? activities in android work strictly through code. there no easy linking there in xcode. have found if googled said ;) http://developer.android.com/guide/components/activities.html

python - statsmodels: specifying non-linear regression models using patsy -

i trying calculate non-linear regression models using statsmodles. in particular have problems learning patsy syntax. is there tutorial or example how formulate non-linear models using patsy syntax? in particular, how non-linear model on example ( http://statsmodels.sourceforge.net/devel/examples/generated/example_ols.html ) specified using patsy? thank in advance andy patsy isn't useful fitting general non-linear models, models on page link special sort of non-linear model -- they're using linear model fitting method (ols), , applying non-linear transformations of basic variables. standard , useful trick combine multiple non-linear transformations of same variable in order fit more general curves. this, patsy useful. what want know how express variable transformations in patsy. pretty easy. way patsy works, given formula string "x1 + x2:x3" , scans through , interprets special patsy operators + , : , , stuff that's left on ( x1 , x2 , x3...

c# - List model razor view -

i have application asp.net mvc . in controller have this: public actionresult index() { upload.models.clientmodels model1 = new models.clientmodels(); arraylist client = model1.client_list(); upload.models.akeomodels model2 = new models.akeomodels(); arraylist akeo = model2.akeo_list(); arraylist model = new arraylist(); model.add(client); model.add(akeo); return view(model); } i passed 2 concatenated list view index model: @{ viewbag.title = "bienvenue"; int = 0; } <hgroup class="title"> <h1 style="color:darkcyan">liste des clients</h1> </hgroup> <section > <form> <table style="margin-top: 50px;"> <tr ><td ></td> <td ><center><b>login</b></center></td> <td><center><b>em...

css selectors - is there a way to select a child element of an element using css -

example below should comprehend question. <div id="bmw" class="car"> <div class="seats">4</div> <div class="fuel">petrol</div> </div> <div id="merc" class="car"> <div class="seats">2</div> <div class="fuel">petrol</div> </div> using css can select seats element of bmw element. don wanna add class tag child elements of bmw and how select seats of car class elements <div id="bmw" class="car"> <div class="seats">4</div> <div class="fuel">petrol</div> </div> <div id="merc" class="car"> <div class="seats">2</div> <div class="fuel">petrol</div> </div> <div id="mazda" class="truck"> <div class="seats">2</div> <...

html - Compatibility View and its importance -

i have finished layout website, , working fine in browsers (opera, safari, chrome, ie 7, 8, 9, 10 (both), , several others) - time around, compatibility view button in address bar of ie 10 appearing. has not happened long time , it's annoying me. i don't want compatibility view button display @ all. sends bad message viewers/visitors. in case, have tested whole site on different computers running different browsers , different versions of browsers , have not noticed single problem. why compatibility view button appearing if there no issues? here's problem, , said, works fine - except when turn on compatibility view in ie 10. when turn on, things in entire website can see logo, , little image in top right corner of page (but they're positioned wanted them). gives? there's nothing wrong code - seriously. i've had validated several times, ajax stuff works charm, , tried hard find problem , intentionally tried mess it's working well. positioning of ...

javascript - Ember-Data objectAt() to get first result does not work -

i'm populating 2 templates data: first template has detailed information model (called slider), , second template has list of last 5 sliders. the problem when use objectat(0) on result, model not applied template correctly. other template list does populated. mean this: app.indexroute = ember.route.extend({ setupcontroller: function() { var sliders = app.slider.find({ limit: 5 }); this.controllerfor('indexslider').set('model', sliders.objectat(0)); this.controllerfor('indexsliders').set('model', sliders); // works fine , loads data template } }); that code not work. however, work when replace indexslider model this: app.indexroute = ember.route.extend({ setupcontroller: function() { var sliders = app.slider.find({ limit: 5 }); this.controllerfor('indexslider').set('model', app.slider.find(52)); this.controllerfor('indexsliders').set('model', sliders); } }); ...where 52 i...

javascript - variable change not notified to `$scope.$watch` -

i handling jqrangeslider through angular directive + controller. within controller, assigning new values scope variables there change not notified controller scope (i using isolated scope '=' in directive) though correctly updated. // jqrangeslider event handler var valueschanged = function(e, data) { if (data.values.min && data.values.max) { console.log('values changed', data.values); // printed $scope.minselectedtime = data.values.min; // not triggering $scope.$watch $scope.maxselectedtime = data.values.max; $scope.$broadcast('minchanged', $scope.minselectedtime); // instantly triggering $scope.$on('minchanged',...) console.log('scope', $scope); } }; $scope.$watch('minselectedtime', function(newvalue, oldvalue) { if (newvalue === oldvalue) { return; } console.log('minselectedtime -->', newvalue); }, true); $scope.$on('minchanged...

ruby on rails - "Where" method with "not nil" checking -

how can check if variable not nil when use "where" method ? i tried these on product model has borrower_id field, didn't worked : > product.where("borrower_id.nil?") > product.where("borrower_id != nil") > product.where("borrower_id == !nil") the way found 1 : > product.where("borrower_id > 0") but doesn't seem clean... try product.where('borrower_id not null')

eclipse - how to inflate layout as drawable in map android? -

i want show layout marker on google map can not inflate on map. can me solve this. , use polaris library. code written below: final view altmarker = ((layoutinflater) getsystemservice(context.layout_inflater_service)) .inflate(r.layout.map_view, null); altmarker.setdrawingcacheenabled(true); altmarker.builddrawingcache(); @suppresswarnings("deprecation") drawable drawable = new bitmapdrawable(altmarker.getdrawingcache()); final arraylist<annotation> annotations = new arraylist<annotation>(); (annotation[] region : sregions) { (annotation annotation : region) { if (region == sfrance || region == sindia) { annotation.setmarker(drawable); } annotations.add(annotation); } } try this: bitmap bitmap = bitmap.createbitmap(altmarker.getwidth(), altmarker.getheight(), bitmap.config.argb_4444); canvas...

html5 - Box2D collision causes huge FPS drop -

i'm playing box2dweb , html5 canvas, , experiencing odd behaviour. have 1 dynamic body , 1 static body, in world. can control dynamic 1 keyboard. but these 2 collide, dip 60 fps 17, , cannot move dynamic body more (due lag, bearly moves). i have try profiling using firebug, , can see result here: http://i.imgur.com/sne6oxg.png as can see, it's box2d taking time here; own rendering/clearing/processing functions aren't listed until 0.1% in table. if want sample-code, tell me! have found other people same problem here , here , didn't answer. i'm giving try! i found problem! related ppm (pixels per meter). it turns out setting pretty low (32), , when increased 192, runs smoothly again! thank god. hope can other people!

c - Comparing nan (greater and greater equal) -

i know if(nan != nan) -> true , quite logical (sqrt(-1) has unequal 0/0 ). the following line of code logical: if(nan > 90.0f) -> false ...nan not number, cannot greater or smaller number. however, not understand why if(nan >= 90.0f) -> true ?!?! i'm using tasking c166 compiler. this appear compiler bug[1]. should report tasking. [1] can see ( http://www.tasking.com/products/c166/ ), tasking not claim conformance ieee-754, behavior may not contrary published documentation. is, however, contrary common sense , taste.

php - formatter:'actions', onEdit: setColProp -

sorry english. questions jqgrid js library i have formatter:'actions', and there is onedit: function (rowid) { var cellvalue = $(this).getcell(rowid,'network_id'); // here valus needs parameter below var link = '<?php echo $base_url.'index.php/hosts/getlistofhosts/';?>'+cellvalue+''; $(this).setcolprop('parent_host', { editoptions:{ dataurl: link } }); //setcolprop ends } //onedit end i try describe in awful english - when click on edit button, getting list ( index.php/hosts/getlistofhosts -> doing list parameter cellvalue contained in hidden column network_id) and @ first click list not appear @ parent_host column (in setcolprop) at second click on line list shows in parent_host column valid cell value (from hidden column network_id) and clicking further below grid lines on edit buttons, parent_host having each lists , ok but when i've got line cell value (from hidden column network_id...

javascript - Why is location.hostname not consistent? -

i have asp.net mvc project, , in 1 of javascripts, calling location.hostname when host application on mvc, on windows 7 & 8 pcs, able print out localhost/myapp however, when hosted on windows server 2008 r2 pc, printed out localhost without virtual directory name why that? , how can display full url? you might want use: window.location.href or window.document.documenturi

c# - MVC Hover Over Item in View to render View -

i have fiddle here. demonstrates hover on , box appearing info in it. what i'm trying achieve is, when "view details" hovered over, triggers mvc action details(guid id) , result of action rendered in box. i'm not entirely sure how this. assume ajax form submitted on hover, need done js (i don't know how ajax js). div displayed newly rendered @html.action("detail", "stuff", new { id = @item.model.id }) am close? the view this <table> <thead> <tr> <td>name</td> <td>e-mail</td> </tr> </thead> <tbody> @foreach (var item in model.itemlist) { <tr> <td>@html.displayfor(model => item.name)</td> <td>@html.displayfor(model => item.email)</td> <td>@using(ajax.beginform(ajaxopts)) { <span>hover details</span> ...

Mysql SUM 0 when not in another table -

i have 2 tables: users: id | name | club_id | 1 bob 4 2 jane 5 3 alex 4 4 paul 4 5 tom 4 points: user_id | club_id | amount(can vary) 1 4 10 1 2 10 2 5 10 3 4 10 3 4 10 4 4 10 3 2 10 3 4 10 need (where users.club_id = 4 , points.club_id = 4): user_id | name | sum(amount) 3 alex 30 1 bob 10 4 paul 10 5 tom 0 notice tom present in users doesn't have entries in points, sum should 0. throws me off in conjuction grabbing list users. also efficient possible (hence added club_id = 4 both in users , points) try this: select u.id, u.name, coalesce(sum(p....

bash - why $BASH_SUBSHELL doesn't increase in pipe -

i know pipe create subshell. i test $bash_subshell , $bashpid , , find $bash_subshell doesn't increase in pipe echo $bash_subshell # 0 echo $bashpid # 8347 echo $bash_subshell | cat # 0 echo $bashpid | cat # 9727 (echo $bash_subshell) # 1 (echo $bashpid) # 9778 when bash merely forks, sets command , execves it, doesn't count subshell. for kind of control structure, command groups, if statements , while loops, shell has involved beyond setup, does. this apparent bash source, execute_command_internal in execute_cmd.c .

regex - Javascript Date Format Convertion -

my objective date in day month year format textbox , convert mm/dd/yyyy format can compare dates var userdate = document.getelementbyid("dateofjourney").value; //eg 21/05/2013 var formatteduserdate = new date( userdate.replace( /(\d{2})\/(\d{2})\/(\d{4})/, "$2/$1/$3")); alert(formatteduserdate); i'm trying escape 'forward slash' i'm getting invalid date output eg. 05/21/2013 you have done like. var userdate = "21/5/2013".split("/"); var newdate = userdate[1]+"/"+userdate[0]+"/"+userdate[2]; var formatteduserdate = new date(newdate); alert(formatteduserdate); instead of using regex. here working sample.

android - Set contentDescription for a custom dialog -

how can set contentdescription read accessibility service when dialog opened? i'm using dialog custom layout display blocking laoding screen , spoken contentdescription "alert", not appropriate in circumstance. thanks ;) you can create subclass dialog , override dispatchpopulateaccessibilityevent provide own accessibility text. here's example: @override public boolean dispatchpopulateaccessibilityevent(accessibilityevent event) { if (event.geteventtype() == accessibilityevent.type_window_state_changed) { event.gettext().add("your message goes here"); return true; } return super.dispatchpopulateaccessibilityevent(event); }

r - different 'apply' methods in RHive API -

rhive api contains 5 'apply' functions: rhive.napply rhive.sapply rhive.mrapply rhive.mapapply rhive.reduceapply unfortunately, rhive manual not provide description what difference between them? please, ... i found partial answer in brilliant manual: http://www.slideshare.net/miloveme/r-hive-introduction • napply : r apply function numeric type • sapply : r apply function string type also, went rhive source code here: https://github.com/nexr/rhive/blob/master/rhive/r/rhive.r#l76 i found, rhive.mapapply , rhive.reduceapply call rhive.mrapply inside. rhive.mrapply generic function map-reduce applying, , rhive.mapapply/reduceapply "syntactic sugar" examples of rhive.mapapply usage here: https://github.com/nexr/rhive/blob/master/rhive/inst/unittests/runit-rhive.script.r

.net - ReactiveUI ObservableAsPropertyHelper / Reactive Extensions Memory Leak? -

i noticed in .net 3.5 application, uses reactiveui, have significant memory leak seems originate in observableaspropertyhelper. created test project demonstrate here . it seems every change notification triggered simple observableaspropertyhelper calculated property leaks memory. leak seems originate in reactive extensions, not directly in reactiveui, use of oaph simple wonder if has encountered or may have proposed fix. the severity of memory leak varies between .net 3.5 (rxui 2.4, rx 1.1) , .net 4.0 (rxui 4.2, rx 2.0.3). closer linear every update of property in .net 3.5. however, leak still there in .net 4.0. i have uploaded test project , profiler images .net 3.5 , .net 4.0 test session test application, here . you can see in images object graphs different, may talking 2 different leaks entirely. in 4.0 session (40_retentiongraph.png) can see allocated objects ints (the type of oaph property) , concurrentqueue. there seems kind of circular reference issue going on there...

database - How to migrate data from MySQL 5 to Sybase ASE 15.5? -

i've passed database schema mysql sybase ase using powerdesigner. is there tool migrating data itself? sybase has old whitepaper in recommend using ems data export extract data mysql, , sybase bcp utility imports. here other recommended tools the recommended tools migration are: • powertransfer tool stream data mysql ase • infomaker™ data pipeline feature move data mysql directly ase • ms dts move data mysql directly ase • bcp moving data. • cis (sybase component integration services) , enterprise connect data access (ecda) extract data mysql , insert directly ase afaik powertransfer old tool included powerdesigner, no longer available. the whitepaper bit dated, but can found here . a second option migrating data sqlanywhere first, using ase component integration services move data ase instance. mysql sqlanywhere instructions can found here .

api key - Android - youtube api r52 - "access not configured" -

i building simple test android app, trying data particular video. have taken sha1 fingerprint of debug keystore , created google api key (and package name). have activated youtube api service it. this code: youtube youtube = new youtube.builder(new nethttptransport(), new gsonfactory(), new httprequestinitializer() { public void initialize(httprequest request) throws ioexception {} }).setapplicationname("myapp").build(); try { youtube.videos.list listvideosrequest = youtube.videos().list("snippet,contentdetails"); listvideosrequest.setid("a3pdxmyof5u"); listvideosrequest.setkey(googleapikey.debug_google_api_key); videolistresponse youtuberesponse = listvideosrequest.execute(); list<video> youtubevideos = youtuberesponse.getitems(); return youtubevideos; } catch (ioexception e) { log.e("myapp", e.getlocalizedmessage()); return null; } so, exception: 403, access not configured. i running out...