Posts

Showing posts from July, 2014

python call set property when property missing -

i have object has several properties containing values take while query. dont want values properties when create instance, when code path requires property few needed depending on code path. order when reach points int eh code not deterministic, cant set property @ fixed point in script. going create method def getvalue(self, attributename): if hasattr(self, attributename): return getattr(self, attributename) elif attributename == 'a1': v = ... code value a1 self.a1 = v return v elif attributename == 'a2': v = ... code value a2 self.a2 = v return v .... but wondering if way deal or if there smarter ways preferred. comment you can use decorator: class cached_property(object): """define property caching value on per instance basis. decorator converts method single self argument property cached on instance. """ def __init__(self, met...

c++ - Program with probability -

in event need generate probability, example bias coin 75% of tossing head , 25% tossing tail. conventionally, way: #include <cstdlib> #include <iostream> #include <ctime> using namespace std; int main() { int heads=0, tails=0; srand(time(null)); number = rand() % 100 + 1; //generate random number 1 100 if (number <= 75) //75% chance heads++; //this head else tails++; //this tail } this working code, when answered similar question on bias coin in user, of users mentioned multiple of 100. since random function generates uniform distribution, feels above code enough simulating probability event. in past posts, user bathsheba mentioned somehting multiples of 100: program simulates coin toss bias coin wanted know possible problems in code in relation that. my question is: above code acceptable code create simulation probability? or there flaws in these codes affect accuracy of simulated res...

reflection - String mapping to Java class fields -

do have idea of best practice or how can implement dynamical mechanism map string values java classes fields on runtime . this: iquote_id - should mapped current quote class - getid() method customer_name - should mapped current customer class - getname() method i have tried use reflection i'm not sure if solution since have fields coming direct classes, other superclasses , lot of if's me solve it..and want other elegant way if exists. how can build such mechanism? hint appreciated.thanks.

java - How to load dynamically a class with class.forName in JBOSS 7 -

i'm migrating web application jboss 7 , have problems class.forname method. i have 2 jars, each 1 in 1 different module: campuscomponentsjava-1.4.4.jar campusgateway-2.5.3-snapshot.jar the code campuscomponentsjava loads dynamically class campusgateway-2.5.3-snapshot.jar in following way: class.forname("edu.uoc.campusgateway.osid.authentication.authenticationmanager") i have created 2 modules in modules folder: <?xml version="1.0" encoding="utf-8"?> <module xmlns="urn:jboss:module:1.1" name="edu.uoc.oki2"> <resources> <resource-root path="campusgateway-2.5.3-snapshot.jar" /> <resource-root path="campuslauncherjava-1.1.3-snapshot-filter.jar"/> <resource-root path="okibusjava-1.2.2-config-uoc.jar"/> <resource-root path="okibusxmlschemas-1.1.1-snapshot.jar"/> <resource-root path="okiosid-2.0.jar...

module - Exporting Functions In Haskell -

i have haskell file named a.hs. have many helper functions, want export 2 of them, example foo1 , foo2. syntax corect? module (foo1,foo2) foo1 b = * b foo2 b = + b since there other helper functions in file, i'm not supposed reach them prelude after doing this, right? can reach them. i'm not sure do. how can solve problem? thanks in advance. the syntax correct. however, interpreted files, ghci makes toplevel functions available.

Invali attempt to call metadata when reader is closed c# winform -

this edited code removed try catch see getting exceptions. alse marked edited code. code getting on nerves have been googling problem , tried found. checked every connection other code there seems no problem them. each , every connection closed. querystring = "select * product prd_code = @c or prd_name=@pn "; sqlcommand command = new sqlcommand(querystring, con); command.parameters.addwithvalue("@c", convert.toint32(txtpcode.text)); command.parameters.addwithvalue("@pn", txtpname.text.tostring()); con.open(); //edited here using (sqldatareader dr = command.executereader()) { // , here if (dr != null && fr.hasrows && dr.read() == true) { if (txtpcode.text == "") { txtpcode.text = dr["prd_code"].tostring(); } else if (txtpname.text == "") { txtpname.text = dr["prd_name"].tostring(); ...

iOS Delegate not called -

for project need able send status "secondtableviewcontroller" "firsttableviewcontroller". followed tutorials on delegates don't seem work. when want call method in firsttableviewcontroller secondtableviewcontroller check see if "delegate" property empty, , every time is.. this code: secondtableviewcontroller.h @protocol sendstatusdelegate <nsobject> @required -(void)didstatuschanged; @end // eof delegate protocol @interface secondtableviewcontroller : uitableviewcontroller @property (nonatomic, assign) id<sendstatusdelegate> delegate; @end secondtableviewcontroller.m // status changed on row click - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { if (self.delegate) { // never called because delegate looks remain empty [self.delegate didstatuschanged]; } } firsttableviewcontroller.h @interface firsttableviewcontroller : uitableviewcontroller <sendstatusdeleg...

php - WordPress - Hiding dates in past with get_posts and Advanced Custom Fields -

i have page show 3 upcoming events. getting 3 posts specific parent, ordered date set using date picker advanced custom fields plugin. i have managed work, shows right posts, ordered based on date picker. see code below: <?php $posts = get_posts(array( 'post_type' => 'page', 'post_parent' => 307, 'numberposts' => 3, 'meta_key' => 'info_startdate', 'orderby' => 'meta_value_num', 'order' => 'asc' )); ?> <?php foreach($posts $post) { ?> <?php setup_postdata($post); ?> <div class="col-md-4"> <?php $info_date = get_field("info_date"); ?> <small><?php echo $info_date; ?></small> <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5> </div> <?php } ?> <?php wp_reset_pos...

How to select all items in windows phone list picker -

i have windows phone list picker control in code bind items c#.i.e, items comes services .i have keep "select all" item .so can select items @ once.i added "select all" .on checking "select all" check box .i not event execute code check boxes checked , ui reflected thanks in advance try code private void selectall(object sender, routedeventargs e) { yourlistbox.selectall(); } for more information check out documentation in msdn http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.selectall%28v=vs.110%29.aspx im not sure if right way, works list<object> arr = new list<object>((((system.collections.generic.dictionary<string, string>)(s))).values); (int k = 0; k < data.length; k++) { object selectitem = arr[k]; items.add(selectitem); } yourlistbox.selecteditems = items; this how made work in case way create lis...

php - My time slots are not booked -

Image
i want create basic time slot booking system. i've run problems. i have created calendar can see happening on speific date: it takes information database table. i'm using phpmyadmin, , i've added date manually in there. as can see in table, use start time , endtime. if click date in calendar, create add-event link this: <?php if (isset ( $_get ['v'] )) { echo "<a href='test.php . ?month=" . $month . "&day=" . $day . "&year=" . $year . "&v=true&f=true'>add event</a>"; if (isset ( $_get ['f'] )) { include ("test.php"); } $sqlevent = "select * calendar eventdate='" . $month . "/" . $day . "/" . $year . "'"; $resultevents = mysqli_query ( $mysqli1, $sqlevent ); echo "<br>"; while ( $events = mysqli_fetch_array ( $resultevents ) ) { } } ?> click...

mysql - ERROR: When running sqoop import command on master node -

i have configured hadoop multi node cluster. when trying import table mysql database hive using sqoop in master node , it's throwing following error, sqoop import --connect jdbc:mysql://master:3306/mysql --username root --password admin --table payment --hive-import -- --null-string '\\n' \ --null-non-string '\\n' warning: /usr/lib/hcatalog not exist! hcatalog jobs fail. please set $hcat_home root of hcatalog installation. warning: $hadoop_home deprecated. 14/04/14 16:17:32 warn tool.basesqooptool: setting password on command-line insecure. consider using -p instead. 14/04/14 16:17:32 info tool.basesqooptool: using hive-specific delimiters output. can override 14/04/14 16:17:32 info tool.basesqooptool: delimiters --fields-terminated-by, etc. 14/04/14 16:17:32 info manager.mysqlmanager: preparing use mysql streaming resultset. 14/04/14 16:17:32 info tool.codegentool: beginning code generation 14/04/14 16:17:33 info manager.sqlmanager: executing sql statem...

How to retrieve my location and phone number from facebook in Android? -

i newbie in android.i have integrated facebook android. have retrieved id,name , profile picture. want retrieve phone number , location fb. can't understand permissions settings , all. have done following coding. want explain me step step do. codes follows: mainactivity.class session.openforread(new session.openrequest(mainactivity.this).setcallback(statuscallback).setpermissions(permissions)); new request( session, "/me?fields=location", null, httpmethod.get, new request.callback() { public void oncompleted(response response) { // handle result // f map<string, object> responsemap = new hashmap<string, object>(); graphobject graphobject = response.getgraphobject(); responsemap = graphobject.asmap(); string location = responsemap.get(...

asp.net - EF6: Enum Types -

there option in ef6 designer convert property enum type. used add new enum type model. how bind enum dropdownlist in formview ? note: i'm using web forms asp.net model binding. enum.getvalues looking believe: public enum currency { usd = 0, euro, frank, pound } var listitems = new list<selectlistitem>(); foreach(currency c in enum.getvalues(typeof(currency))) { listitems.add(new selectlistitem() { value = (int)c, text = c.tostring() }) } and bind listitems... if deal different enums been presented via drop down controls, can implement generic method generates bindable datasource enum type based on following implementation of enumtolist method: http://extensionmethod.net/csharp/enum/generic-enum-to-list-t-converter public static list<selectlistitem> createselectlist<t>() { var listitems = new list<selectlistitem>(); foreach(var e in enumtolist<t>()) { listitems.add(new selectlistitem() ...

html - CSS - margin and padding dont work on positioning vertical -

Image
i making this: it looks like: as can see there, things bad positioned, try use padding margin fix not moving verticaly, how can fix it? my html: <div class='article-container'> <div class='article'> <div class="img-position"> <a href="#"><img src="http://funedit.com/andurit/try1/images/foto.png"/></a> </div> <span class="topic-name"><a href="#">název topicu nebo článku </a></span> <span class="date">28.8.2014 / 19:30</span> <span class="author"> od<a href="#"> dwandy </a></span> <span class="article-description"> ahoj jak se máte já se mám dobře ale nevím jak vy teda se máte? </span> <span class="article-comments"> <a href="#"> 4x reakce </a>...

javascript - Calculating hours difference between two dates in AngularJS -

this question has answer here: how subtract 2 angularjs date variables 7 answers i've got template looks this: <tr ng-repeat="task in tasks" class="thumbnail"> <td ng-model="task.id">{[{ task.id }]}</td> <td ng-model="task.time_start">{[{ task.time_start | date : 'mmm d, y hh:mm' }]}</td> <td ng-model="task.time_stop">{[{ task.time_stop | date : 'mmm d, y hh:mm' }]}</td> <td>[here want time difference]</td> <td><button ng-click="edit(task)">update</button></td> </tr> and want count hours difference between task.time_stop , task.time_start . there anyway "live" , in template? use moment library this: moment.utc(mom...

How to unhide a worksheet in excel using VBA if the workbook is protected -

i have workbook in excel , workbook password protected. have 2 sheets in 's1' , 's2'. 's1' protected , hidden. have added button in 's1' when pressed unhides 's1'. using following code: private sub commandbutton2_click() sheets("s1").visible = true end sub i using userinterfaceonly:=true but throws error "unable set visible property of worksheet class" it throws same error when try hide sheet under same circumstances how fix problem without compromising safety of workbook

Save specific fields with elasticsearch-model in Rails -

i'm using elasticsearch-model gem in rails 4 project store users in mysql , elasticsearch. in project, elasticsearch part used find people of mysql fields geo_point, birthdate, gender, etc... not every fields i've in mysql "users" table useful user's search. so, i'd store users fields in mysql , fields needed user's search in elasticsearch. to store required fields on create, i've overrided method 'as_indexed_json' , used : as_json(only: ['id', 'gender', 'location'] on create, things work great. when i'm updating user fields should saved in mysql only, adds elasticsearch anyway. for instance, user model have "id", "gender", "is_premium", "status", "created_at", "birthdate", "location". in elasticsearch i'd save "id", "gender", "birthdate", "location" how can this? help. this issue...

rss - When parsing multiple feeds with SimplePie in PHP, the $feed variable always holds the first feed, even though the URL has changed -

i want grab data website each page has own feed. therefore intend grab feeds sequentially, so: $maxpages = 5; ($i = 1; $i <= $maxpages; $i++) { // create new instance of simplepie object $feed = new simplepie(); $feed->set_feed_url('http://www.targetpage.org/forum?page=' . $i . '&foo=true'); $feed->enable_cache(false); $feed->init(); foreach($feed->get_items() $item) { $md5 = md5($item->get_id()); $title = $item->get_title(); $href = $item->get_link(); $content = $con->real_escape_string($item->get_content()); //insert gathered data database $query = "insert feed_items (md5, title, content, url) values ('$md5', '$title', '$content', '$href')"; mysqli_query($con, $query); } } so while every pass through 'for' loop url changes, stuff simplepie returns same. trying destroy $feed in end did...

javascript - jQuery expression as object key -

this question has answer here: how create object property variable value in javascript? [duplicate] 9 answers dynamically access object property using variable 10 answers i need figure out how create dynamic key string object. expression makes javascript complain. return {$(this).val(): true}; // returns object e.g. {2: true} what doing wrong? you have create object, use bracket notation dynamic key var obj = {}; var val = $(this).val(); obj[val] = true; return obj; or unnecessary one-liner return (function(o,e) {o[e.value]=true; return o;})({}, this);

mysql - PHP - Update database when submitting form -

i have created edit functions problem when press submit button refreshes form , not update database new information entered in form. i cannot seem find issue keeps edit_options.php working. insert part.... // check if form has been submitted. if has, process form , save database if (isset($_post['submit'])){ // confirm 'id' value valid integer before getting form data if (is_numeric($_post['id'])){ // form data, making sure valid $id = $_post['id']; $option_name = mysql_real_escape_string($_post['option_name']); $option_value = mysql_real_escape_string($_post['option_value']); // check prodname/color fields both filled in if ($option_name == '' || $option_value == '') { // generate error message $error = 'error: please fill in required fields!'; //error, display form renderform($id, $option_name, $optio...

sql - Postgres - Transpose Rows to Columns -

Image
i have following table, gives multiple email addresses each user. i need flatten out columns on user query. give me "newest" 3 email addresses based on creation date. user.name | user.id | email1 | email2 | email3** mary | 123 | mary@gmail.com | mary@yahoo.co.uk | mary@test.com joe | 345 | joe@gmail.com | [null] | [null] use crosstab() tablefunc module. select * crosstab( $$select user_id, user_name, rn, email_address ( select u.user_id, u.user_name, e.email_address , row_number() on (partition u.user_id order e.creation_date desc nulls last) rn usr u left join email_tbl e using (user_id) ) sub rn < 4 order user_id $$ , 'values (1),(2),(3)' ) t (user_id int, user_name text, email1 text, email2 text, email3 text); i used dollar-quoting first parameter, has no special meaning. it's ...

ios - Adjusting frame of controls programatically -

i using uibutton control through xib file. want set frame of button programatically. have tried below btn.frame=cgrectmake(0,0,200,70); it doesn't change position , stays on same x , y co-ordinates have placed in xib file. please me this. use first 2 parameter represent x,y coordinate button , other 2 represent height , width of button btn.frame = cgrectmake(80.0, 210.0, 160.0, 40.0);

android - Lifetime of anonymous object run as thread in Java -

within method have following, runnable r = new runnable() { public void run() { ... ... } }; new thread(r).start(); what lifetime of anonymous object , thread ? what lifetime of anonymous object , thread ? 1) thread keeps running until stop it. 2) object scope( r ) in method.

node.js - Socket io not working under Express project on heroku -

the contents of app.js var express =require('express'), app =express(); server=require('http').createserver(app), io =require ('socket.io').listen(server); io.configure(function () { io.set("transports", ["xhr-polling"]); io.set("polling duration", 10); }); users = {}; var port = process.env.port || 5000; server.listen(port); app.use(express.static(__dirname + '/public')); io.set('log level',1); io.sockets.on('connection', function(socket){ console.log("hey"); socket.on('new user', function(data, callback){ if (data in users){ console.log("hey"); callback(false); } else{ callback(true); console.log("hey1"); socket.nickname = data; users[socket.nickname] = socket; updatenicknames(); } ...

java - Powermock replace superclass method -

i have following code: public class classa { public object buid(){ object obj=new object(); //building object... return obj; } public class classb extends classa { public object build(){ object obj=super.build(); //some operations obj return obj; } } i want test classb#build. in order need mock super.build() invocation. possible powermock? supress working fine, didn't manage replace method membermodifier.replace.

mysql - Whats wrong with my nested subquery? -

so i'm solving interactive tutorial http://www.sqlzoo.net/wiki/select_from_nobel_tutorial bonus part doesn't have solution. here's question: in years physics prize awarded no chemistry prize. select yr nobel subject = 'physics' , yr not in (select yr nobel subject = 'literature') i got output 1943 1935 1918 1914 when tutorial said answer is 1933 1924 1919 1917 i don't understand why solution wrong edit: saw careless mistake 'literature' should 'chemistry' still seems invalid there 2 errors in query: you mistyped chemistry (your query says literature instead) you did not ask distinct results here modified query: select distinct yr nobel subject = 'physics' , yr not in (select yr nobel subject = 'chemistry') distinct important, because in 1933 physics prize has been awarded multiple winners - namely, dirac , schrödinger. these 2 rows table result in 2 entries 1933 in output, not ...

r - How do you save a ggplot_table as a jpeg? -

following sandy muspratt's answer question: "inserting image ggplot outside chart area" , how save output jpeg? helpful generating reports in r. better create grobs, arrange them using arrangegrob , use ggsave : library(png) library(grid) library(ggplot2) ## create image grob img <- readpng(system.file("img", "rlogo.png", package="png")) g <- rastergrob(img, interpolate=true) ## ggplot2 grob p = qplot(x=x,y=y,data= data.frame(x=1:10,y=1:10)) library(gridextra) ## arrange , save ggsave('test.png', arrangegrob(p,g))

c# - List for both checkedlist box and combobox -

i want add selected items of checkedlistbox , combobox list , use list in each loop in c# i tried this list<string> list=new list<string>(); if (rbtnmultiplescenario.checked == true) { foreach ( checkedlistbox str in clbscenario.selecteditems) { lstitems.add(str); } } by using string, not able add selected items of checkedlistbox. which type of list have use? list<string> list=new list<string>(); if (rbtnmultiplescenario.checked == true) { foreach ( string str in clbscenario.selecteditems) { lstitems.add(str); } } this assumes selecteditems contains collection of strings (which exception does)

backbone.js - Backbone events disappear with bootstrap tab -

i've found strange beaviour backbone views events , bootstrap tabs. in application, views attached bootstrap tabs. when click on tab, view attached tab must (re)-rendered or inserted in tab (to reflect updates on model occurred in other views). however, i've realized events attached views deleted somehow after tab clicked. i've created js fiddle demonstrating : http://jsfiddle.net/ybm4j/ any ideas ? js: window.app = { views: {} }; app.views.sessionlist = backbone.view.extend({ tagname: 'select', events: { 'change': 'selectionchanged' }, initialize: function () { _.bindall(this, 'selectionchanged'); this.render(); }, render: function () { $(this.el).append('<option value="option1">option 1</option>'); $(this.el).append('<option value="option2">option ...

IOS - Segue - detect which image was clicked -

i working on ios. using images instead of buttons.there segue between 1 controller another. depending on image has been clicked want load specific information in secondcontroller. want know possible detect image has been tapped , pass image name or title or whatever can detect controller using segue.the other way 2 have transparent buttons on images , tag value. want know if somehow can detect image clicked why go code. -(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { nsinteger tagindex = [(uibutton *)sender tag]; if (([segue.identifier isequaltostring:@"rightimagesegue"])) { secondviewcontroller *destviewcontroller = segue.destinationviewcontroller; [destviewcontroller setselectedbutton:tagindex]; } } there couple of ways this. first of all, uibuttons can have background image, set various images. if you're intent on using uiimageview , have implement touch event receiving method , handl...

matlab - Electric field integral plot -

Image
i trying plot electric field integral in matlab, e(yaxis) vs z (xaxis). function follows : i graph first integral e(z) in picture. as have analytic formula integral, need set values z , compute corresponding e(z): %% set values z z = x1:0.1:x2; % x1 , x2 bounds on x axis % discrete step set 0.1, lower/increase depending on level of detail want %% compute electric field values ez = (k*l/z) .* ( b/sqrt(z.*z + b*b) + a/sqrt(z.*z + a*a) ); %% plot values plot(z, ez);

jquery - Show/Hide options in a select -

i got problem ie. got input , select : <input type="radio" checked="" value="par" name="marche">particulier <input type="radio" value="pro" name="marche">pro/tpe <input type="radio" value="ent" name="marche">entreprise <select id="typedeproduit" name="typedeproduit"> <option class="par" value="21" style="display: block;">g9119a mrh gan habitat globale </option> <option class="par" value="22" style="display: block;">g9120a mrh gan habitat confort </option> <option class="pro" value="24" style="display: none;">g6020a - rcce </option> <option class="pro" value="25" style="display: none;">g6006a - autre rc </option> <option class="pro" value="27...

hibernate - Grails: Criteria query fail on join tables? -

we have problem working grails (2.3.7), it's related criteria queries , mappings. problem after defining criteria , trying list results, hibernate seems not adding mapping tables query, , therefore, query fails. right have 3 tables related: users, competitions + usercompetition has relationship among other 2 tables composite primary key, has reference each 2 tables foreign key. here there definition of our domains: class user { (...) static hasmany = [competitions:competition] static mapping = { table "users" (...) competitions jointable: [name: 'userscompetitions', key: 'userid', column: 'competitionid'] } class competition { (...) static hasmany = [users:user] static belongsto = user static mapping = { table "competitions" id column: 'competitionid' users jointable: [name: 'userscompetitions', key: 'competitionid', column: 'userid'] } } ...

ibm mobilefirst - How to automatically reload changes HTML/CSS after "Run on Worklight Dev Server"? -

i have hybrid worklight app , every time change html code have delete app admin console, clean eclipse, clear chrome browsing data , redeploy. how can automatically make wl reload html changes every time redeploy wl environment (no more remove console or clean eclipse)? my first response is: huh? totally not supposed this... starting worklight 6.1, after change in of application's web resources (html, js, css, images, ...), after initial deployment of app (run > run on worklight development server) no longer need re-build app. when preview app via worklight console, need refresh browser window. that's it. you should not delete app worklight console or "clean eclipse". that said, if talking previewing "common web resources" option in worklight console, may want (hopefully one-time action) to: close eclipse locate temp folder ( windows , os x ) delete wlbuildresources folder (optionally wlpreview folder well) open eclipse re...

linux - How to append string in the contents of files on the basis of search -

so far have tried below unix script append contents of files on basis of search. fine. if run same below script multiple times perl command keep on appending in files. searcharr=(test1 test2 test3) replacearr=(somestring1 somestring2 somestring3) a=`echo ${#searcharr[@]}` echo $a ((i=0;i<$a;i++)) searchvalue=`echo ${searcharr[i]}` replacevalue=`echo ${replacearr[i]}` file in `find . -name \* -print`; grep "$searchvalue" $file &> /dev/null if [ $? -ne 0 ]; echo "search string not found in $file!" else perl -p -i -e "s/$searchvalue/$replacevalue/g" $file echo $file "replace string success!" fi done done current output:- if run more 1 times keep on appending that. example if run 2 times append 2 times somestring1somestring1test1 somestring2somestring2test2 somestring3somestring3test3 needed output:- no matter how many times runs somestring1test1 somestring2test2 somestring3test3 add word bo...

java - confusion in acquiring and releasing of locks -

i have following code snippet client of android emulator: public cursor query(uri uri, string[] projection, string selection, string[] selectionargs,string sortorder) { string key = selection; string keyhash = genhash(key); log.v("provider.query","key & keyhash: "+key+" & "+keyhash); if(simpledhtutil.toforward(keyhash, currenthash, predecessorhash)){ dhtdto dto = new querytransfer(successorport, currentport, -1, key, keyhash); st.makesendrequest(dto); synchronized(biglock.lock){ simpledhtutil.cursorreset(); requiredanswers = 1; currentanswers = 0; } while(requiredanswers>currentanswers){ synchronized(biglock.lock){ try{ if(requiredanswers>currentanswers){ log.d("provider.externalquerylock","ca: "+currentanswers+"ra: "+requiredanswers+...

c++ - How to check number is available in CString - Visual MFC -

there edit control (type: cstring) in program. how check if control contains number? (ex: "abcdef4hg", "xxxyyy12"....) just try check if there digit in string or not. can use std::isdigit . #include <cctype> bool hasdigits(const cstring &str) { for(int = 0; < str.getlength(); i++) { if(std::isdigit(str[i])) return true; } return false; }

c# - Visual Studio 2013, changes not showing in debug -

Image
have upgraded visual studio 2013 pro , having teething problems. primarily if change html or css in either .aspx page web forms or .cshtml mvc, changes aren't reflected on page i'm working on when debug , don't appear not matter how times refresh or clear cache. using web essentials, should put changes straight on page have refresh page doesn't seem working either. also occasionally, not always, if stop debugging, change code behind run project again says it's running different version of code 1 being debugged , have stop it, rebuild , debug. have never had these problems on previous version of visual studio. any suggestions? go tools-options under projects , solution -> build , run select "always build" under "on run, when projects out of date"

has and belongs to many - rails prevent deletion of child unless parent is being deleted also -

in ruby on rails 4, let's parent has many children. when parent deleted, children must deleted. other that, child shall not deleted unless orphan. how that? i tried following class parent < activerecord::base has_many :children, inverse_of: :parent, dependent: :destroy end class child < activerecord::base belongs_to :parent, inverse_of: :children before_destroy :checks private def checks not parent # true if orphan end end with before_destroy check, however, nothing gets deleted. there way of telling method if reason of being called because parent deletion? is odd thing ask for? mean, preventing deletion of childs. working carp's answer rails: how disable before_destroy callback when it's being destroyed because of parent being destroyed (:dependent => :destroy) , try this: child: belongs_to :parent before_destroy :prevent_destroy attr_accessor :destroyed_by_parent ... private def prevent_destroy if !destroyed_by_parent ...

How to modify ~/.ssh folder & files in windows? -

i feel missing fundamental concept how .ssh directory works in windows. have had no issues when working in osx/linux having now. end goal move existing ssh key default ~/.ssh directory, , update config if choose (you know, normal ssh key related tasks). however, time have tried move existing ssh key on ~/.ssh directory, or open it, or create config file following error (in either gitbash, puttygen, etc...): puttygen (saving key disk): overwrite existing file c:\users\me\.ssh? or in gitbash (attempting anything, including create config file): touch: creating `/c/users/me/.ssh/config': no such file or directory cd ~/.ssh sh.exe": cd: /c/users/me/.ssh: not directory what missing/not understanding? kind regards, u353 i have created , regularly use ".ssh" directory on windows 7; mentioned in above comments, windows explorer doesn't support them, or more specifically, error-checking in windows explorer not allow give file name starts peri...

linux - How to use an older version of glibc, for Python script to work on REHL 3, using PyInstaller on CentOS6 -

i have rhel3 server python 2.2! need run scripts on machine using 2.6 python. so have centos 6 python 2.6. wrote code , used pyinstaller give me single executable. works on centos machine. however, on rehl3 error " /lib/tls/libc.so.6: version `glibc_2.4' not found /lib/tls/libc.so.6: version `glibc_2.3.4' not found " understandable, it's old vs new. i tried using pyinstaller on centos 3 there dependencies , yum doesn't work , centos 3 dead. i thought install glibc 2.4 , 2.3.4 on centos 6 in different directory. work, wouldn't know how use pyinstaller use library. then thought, chroot? what ideas on this, out of them! i search in repo. if there aren't, try compile old version. look here.

mongodb - AngularJS ngTable not updated -

i using angular routing in application ngtable . 1 of pages contains ngtable , , search form, data coming database using get method (mongodb) every time search, every time search ngtable (table) should updated, , problem table updated 1 time, after loading page first time. the contoller used partial page : app.controller('searchcontroller',function($scope,ngtableparams,$http,$filter, $sce){ $scope.searching=function(){ var str = $scope.search.tags; var tagsarry = str.split(","); $http.get('/api/getdoc',{params:{title:$scope.search.title,tags:$scope.search.tags}}) .success(function(data) { if(data.notexist!=-1){ $scope.tableparams = new ngtableparams({ page: 1, // show first page count: 10 // count per page }, { total: data.length, // length of data getdata: function($defer, pa...

How to set/remove insets in JavaFX TitledPane -

Image
i've created titledpane in javafx single child component (a button) follows: <?import java.lang.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <anchorpane id="anchorpane" prefheight="400.0" prefwidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> <titledpane animated="false" layoutx="137.0" layouty="60.0" prefheight="400.0" prefwidth="600.0" text="untitled" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="0.0"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0" > <children > <button lay...

ios - What is in BLE Advertising data? -

i trying implement bluetooth low energy in 1 of projects, using iphone , hm-0 ble module. my question: possible read service uuids (or characteristics) after scanning, without having connect peripheral? the point whether or not possible put list of service uuids , value of characteristics on advertising data. the way achieve want add available services advert report. functionality module-dependent , there many modules not allow that. had quick @ at commands of hm-10 , seems module 1 of them. please note ble can add whatever want advert report, , program iphone read data accordingly. however, if want full-fledged ble communication (i.e. reading characteristic values, etc) best option connect device. for more information, take @ these useful links: http://letsmakerobots.com/node/38009 http://letsmakerobots.com/node/39795 http://www.jnhuamao.cn/download_rom_en.asp?id=66 i hope helps.

What does SSMS use to create a linked SQL Server by name? -

we have several sql servers set in workplace linked each other , make use of 4-part db names in lot of our code. considering moving of our databases 1 server , assessing impact on our code, no 1 here seems know beyond linked server name protocol used in [server] portion of 4pt db name [server].[database].[dbo].[table] . [server] portion wins entry, dns, or sql server doing clever on it's own there? if it's dns, simple enough move db's (minimal code changes), else , may have reconsider our strategy. server symbolic name, datasrc matters. suppose have linked server created this: exec master.dbo.sp_addlinkedserver @server = n'test', @srvproduct=n'', @provider=n'sqlncli', @datasrc=n'server2008r2' and queries select test.database.schema.table . recreate linked server different @datasrc , still work, time read data different physical server (as long data there , security set right).

java - How can I add to the current value in SQLite column? -

im trying add on current number in credits column of person rowid of 0. if current value 5 , user selects number 2 in spinner , clicks button, value change 7. value gets updated 2. need add/change code achieve this? public void updateuser(int money) { string selectquery = "select " + key_credits + " " + database_table + " " + key_rowid + " = " + 0; cursor c = ourdatabase.rawquery(selectquery, null); int oldmoney = 0; if (c.movetofirst()) { oldmoney = oldmoney + integer.parseint(c.getstring(4)); } contentvalues cvupdate = new contentvalues(); cvupdate.put(key_credits, (oldmoney + money)); ourdatabase.update(database_table, cvupdate, null, null); } you missed clause in update part ourdatabase.update(database_table, cvupdate, key_rowid + "=?" ,new string[] { "1" }); i gu...

php - unset an array with a specfic condition -

basically have array $code : array ( [1] => array ( [0] => france [1] => 26422 [2] => 61748 [3] => 698477678 ) [2] => array ( [0] => united states [1] => 545 [2] => 2648 [3] => 55697455 ) [3] => array ( [0] => canada [1] => 502 [2] => 1636 [3] => 15100396 ) [4] => array ( [0] => greece [1] => 0 [2] => 45 [3] => 458 ) i want unset countries $code[$key][1] == 0 tired this: $code = array_filter($code, function (array $element) { return !preg_match('(0)i', $element[1]); }); but returns countries unless 1 has in $code[$key][1] 0, this: array ( [1] => array ( [0] => france [1] => 26422 ...

ruby - Can't get a element by id with selenium webdriver -

i have code this. require "selenium-webdriver" d = selenium::webdriver.for :firefox d.navigate.to "http://finance.yahoo.com/stock-center/" d.find_element(:id, "yfs_184_^oex") but code fails nosuchelementerror . selenium::webdriver::error::nosuchelementerror: unable locate element: {"method":"id","selector":"yfs_184_^gsptse"} i checked existence of yfs_184_^oex element inspector. why can't find element id? i assume trying find element: <span class="l84" id="yfs_l84_^oex">825.68</span> the problem locator there typo in id. "l84" - notice letter "l" not number "1" (as in attempted code). d.find_element(:id, "yfs_l84_^oex") with change, script work: require "selenium-webdriver" d = selenium::webdriver.for :firefox d.navigate.to "http://finance.yahoo.com/stock-center/" e = d.find_element(:id...

java - Insert each selected item in a list Android -

i want insert each selected item of listview in list, list going parameter method. elements in listview selected long click. i'm new @ android, appreciate. this code: listviewtodo.setonitemlongclicklistener(new onitemlongclicklistener() { @override public boolean onitemlongclick(adapterview<?> arg0, view arg1, int position, long arg3) { // todo auto-generated method stub return false; } }); listviewtodo.setonitemlongclicklistener(new onitemlongclicklistener() { @override public boolean onitemlongclick(adapterview<?> arg0, view arg1, int position, long arg3) { yourlist.add(arg0.getitem(position)); return false; } }); yourlist list of whatever items want store, whitch of same type items supplied listview adapter

java - Possible to 'look ahead' in a StreamTokenizer? -

working on parser, , if detect keyword want call function , send next token (we can assume input proper , correct). what tried below not work because cannot dereference int. what trying: boolean eof = false; do{ int = 0; int token = st.nexttoken(); switch (token){ case streamtokenizer.tt_eof: system.out.println("eof"); eof = true; break; case streamtokenizer.tt_eol: system.out.println("eol"); break; case streamtokenizer.tt_word: //system.out.println("word: " + st.sval); if (st.sval.equals("start")){ system.out.println("---start----"); system.out.println(start(st.nexttoken().sval)); // ahead } break; ...