Posts

Showing posts from September, 2012

android - draw from current location to marker google map api v2 -

i create project same this: http://wptrafficanalyzer.in/blog/showing-nearby-places-using-google-places-api-and-google-map-android-api-v2/ when click find button show many place. wanna click marker , draw route location marker. how can me?

php - Using $_get on URL that is linked to id in database row -

i'm trying $_get part of url in href. want happen when click link redirected specific link. if makes sense. i have 2 functions: first function, list of links: function showposts() { $sql = ("select * blog"); $query = mysql_query($sql); while ($row = mysql_fetch_array($query)) { $listid = $row["blog_id"]; $showtitle = $row["title"]; $showcontent = $row["content"]; $showtimestamp = $row["timestamp"]; echo' <div> <a href="index.php?option=blog&task=view&id='$listid'"><h3>'.$showtitle.'</h3></a> <div>'.$showcontent.'</div> <p>'.$showtimestamp.'</p> </div> '; } } second function, redirect link: function viewpost() { if(empty($_get['id']) ) { $listid = '

python - Reduce "for loops for big data" and make improvement -

i trying make code (that made) faster possible. first, code follows #lemmas list consisting of 20,000 words. #that is, lemmas = ['apple', 'dog', ... ] #new_sents list consisting of 12,000 lists representing sentence. #that is, new_sents = [ ['hello', 'i', 'am', 'a', 'boy'], ['hello', 'i', 'am', 'a', 'girl'], ... ] x in lemmas: y in lemmas: # prevent 0 denominator x_count = 0.00001 y_count = 0.00001 xy_count = 0 ## dice denominator in new_sents: x_count += i.count(x) y_count += i.count(y) if(x in , y in i): xy_count += 1 sim_score = float(xy_count) / (x_count + y_count) as can see, there many iterations.. 20,000 * 20,000 * 12,000, big numbers. sim_score dice coeffient of 2 words. is, xy_count means number of wo

web - Java get single element from webpage -

hi after searching still not found answer single element of webpage string variable. know how in c know in java eg: document.nav(the webpage) string value = document.getelementbyid(theid) thanks so eg: some webpage has <body> <p id=element1>the value want</p> </body> and need value webpage string variable you can use jsoup that: string url = "http://www.example.com"; // or whatever goes here document document = jsoup.connect(url).followredirects(false).timeout(60000/*wait 60 sec response*/).get(); string value = document.body().select("#element1" /*css selector*/).get(0).text(); if need input format please refer the cookbook it's not necessary specify timeout ect. connection. use document document = jsoup.connect(url).get(); i included timeout if webpage takes long load. may want follow redirects.

javascript - PHP/MySQL Query Issues -

i attempting set basic log in system website having major issues getting query operate correctly. far have tried figure out going on has failed. far can tell query not failing not returning data either. using query in phpmyadmin results in proper query information being returned. here php code: <?php //empty error variables $sqlerror; if(empty($_post['uname'])) { $data = "false,username field empty"; echo json_encode($data); return false; } if (empty($_post['pword'])) { $data = "false,password field empty"; echo json_encode($data); return false; } $username = $_post['uname']; $password = $_post['pword']; echo $username."<br/>"; echo $password."<br/>"; if(!checkdb()) { $data = "false,".$sqlerror; echo json_encode($data); return false; } else { checkdbl(); } function checkdb() { echo "made checkdb! <br/>"; $co

html - Configuration of Twig via FTP with Autoloader.php -

i try twig work in application. so, i've unpacked , uploaded twig files on ftp in twig folder. i've created in twig_templates folder template base.twig looking this: <!doctype html> <html lang="pl"> <head> <title>{{title}}</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div id="content-container"> <{{type}} id="content"> {% block content %} {% endblock %} </{{type}}> </div> </body> </html> and i've tried use template in base.php file (deployed in project root folder): <?php require_once '/twig/lib/twig/autoloader.php'; twig_autoloader::register(); $loader = new twig_loader_filesystem('/twig_tem

jqXHR vs. jQuery AJAX-requests in Rails -

i don't understand why jquery.ajax-request .csv-file fails display highchart chart in rails: var jquery = $.get('foo.csv', function(data) {} whereas 1 displays fine: var jqxhr = $.get('foo.csv', function(data) {} can please explain? jquery name of main function in jquery library ( $ synonym it). shouldn't reuse in own code. although if local variable, don't think should affect library, uses global variable window.jquery . it's still bad idea use variable name, confusing.

ios - CGRectContainsPoint doesn't return YES but on simulator the point is in the image -

in viewdidload making imageview called deepfryingbasket. can move basket finger left , right not or down. second image have 1 french frie falling down screen. if frie , basket collide, frie should disappear looks falls in basket. thats why have nstimer fires every 0.01 sec collisiondetection method. the problem when catch french frie basket frie doesn't disappear. sure collisiondetection method called compiler never gets in if-statement , don't know why. appreciated! - (void)viewdidload { [super viewdidload]; deepfryingbasket =[[uiimageview alloc] initwithframe:cgrectmake(110,468,100,80)]; deepfryingbasket.image = [uiimage imagenamed:@"deepfryingbasket"]; [self.view addsubview:deepfryingbasket]; collisiondetection = [nstimer scheduledtimerwithtimeinterval:0.01 target:self selector:@selector(collisiondetection) userinfo:nil repeats:yes]; [collisiondetection fire]; } -(void)collisiondetection{ if (cgrectcontainspoint (frenchfrie.fram

android - How do you create a layout that is as shown in the image? -

Image
i off creating travel app had such design in pic above. central dot denotes intermediate stops between 2 locations. first source, second destination. i know best way acheive layout described in image travel app. thanks in advance. code tried below here: (sample) <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="224dp" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:layout_marginleft="30dp" android:layout_margintop=&

javascript - Google Maps Error - Invalid latitude / longitude? -

i have following code: <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <div class="row"> <div class="col-md-6" id="googlemap" style="height:500px;"></div> </div> <script> function initialize() { var mapprop = { center: new google.maps.latlng(44.6656, -83.5753), zoom: 10, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("googlemap") ,mapprop); var marker = new google.maps.marker({ position: mapprop, }); marker.setmap(map); } google.maps.event.adddomlistener(window, 'load', initialize); </script> the map displays fine can't add marker. following error: setposition: not latlng or latlngliteral: in property lat: not number i don't see how latitude , long

Returning a DOM element with Webdriver in Javascript -

how return dom element webdriver in javascript? i using wd.js javascript bindings: require("wd") .remote("promisechain") .init() .get("http://www.google.com") .elementbyid("mngb") .then(function(element) { console.log(element); }); i getting weird object not standard dom element (for example cannot html code out of it): { value: '0', browser: { domain: null, _events: {}, _maxlisteners: 10, configurl: { protocol: 'http:', slashes: true, auth: null, host: '127.0.0.1:4444', port: '4444', hostname: '127.0.0.1', hash: null, search: '', query: {}, pathname: '/wd/hub', path: '/wd/hub', href: 'http://127.0.0.1:4444/wd/hub' }, saucerestroot: 'https://saucelabs.com/rest/v1', noauthconfigurl: { protocol: 'http:', slashes: true, host: '127.0.0.1:4444', port: '

PHP's hash() in Java -

i trying java generate same hash string php's hash algorithm does. i have come close enough: hash('sha512', 'password'); outputs: b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86 java code: public static void main(string[] args) { hash("password"); } private static string hash(string salted) { byte[] digest; try { messagedigest mda = messagedigest.getinstance("sha-512"); digest = mda.digest(salted.getbytes("utf-8")); } catch (exception e) { digest = new byte[]{}; } string str = ""; (byte adigest : digest) { str += string.format("%02x", 0xff & adigest); } return str; } this outputs same. my problem when use third argument within php's hash function. on php's site it's described following: raw_output when set true, outputs raw

c++ - Boolean value returned on a function call to null object -

what boolean value returned when fucntion call made on null object in c++? classdummy* dummy = null; if (!dummy->dummy_function(1,2,3)) { // } shouldn't return error according c++11 standards? unless dummy has been declared @ namespace scope, uninitialized , value unspecified, i.e. may or may not null. invoking member function on nullptr , or on pointer pointing invalid memory, undefined behavior . you might get away correct result if member function invoke doesn't access other data members of class; in other words, if doesn't dereference this pointer. however, regardless of whether obtain expected result or not, still undefined behavior. compilers not required detect such invalid function calls. if obvious, initialize object pointer nullptr , invoke member function on it, may see diagnostic compiler, not guaranteed.

mongodb - how to use mongodbexport in python or shell script -

i want create json output mongodb mongodbexport it act correctly in terminal command : sudo mongoexport --db mydb --collection url_db --query '{"state": "processed"}' --out /mongodb_json/name.json but how can use in shell script or in python subprocess.call i use code in python : call(["mongoexport", "--db","mydb","--collection","url_db","--query","'{\"state\": \"processed\"}'","--out ",outfile],shell=true) but create error: "no collection specified!" ,"export mongodb data csv, tsv or json files." thank if passing arguments in via list , need remove shell = true argument, otherwise first element of list used construct subprocess call (in case mongoexport called) call(["mongoexport", "--db","mydb","--collection","url_db","--query","'{\

asp.net - how to add text inside imagebutton while creating it dynamically -

Image
how add text or label inside image button while creating dynamically. have tried imagebutton imbtn = new imagebutton(); imbtn.id = sname; imbtn.alternatetext = sname; imbtn.lable=sname; imbtn.attributes.add("src", "./image/" + strtext); imbtn.alternatetext = sname; imbtn.style.add("height", "50px"); imbtn.style.add("width", "90px"); imbtn.style.add("left", ileft + "px"); panel4.controls.add(imbtn); this line 4 not working. the imagebutton control not have attribute 'lable' guess want use tooltip label control imbtn.tooltip = sname having normal button control image // css class .image-btn-add { background-image: url("images/add.png") ; background-repeat: no-repeat; background-position: left; background-size: 20px !

gwt + jetty + spring + log4j ERROR: "DOMConfigurator object is not assignable to a Configurator" -

this problem mentioned in several sources around web unable solve solutions provided there. problem: following error thrown log4j when issuing mvn gwt:run : [error] log4j:error "org.apache.log4j.xml.domconfigurator" object not assignable "org.apache.log4j.spi.configurator" variable. [error] log4j:error class "org.apache.log4j.spi.configurator" loaded [error] log4j:error [sun.misc.launcher$appclassloader@23137792] whereas object of type [error] log4j:error "org.apache.log4j.xml.domconfigurator" loaded [webappclassloader=demo@3d1665ac]. [error] log4j:error not instantiate configurator [org.apache.log4j.xml.domconfigurator]. description of project: use default jetty server provided gwt , run on exploded war. <gwt.version>2.6.1</gwt.version> <spring.version>3.2.6.release</spring.version> <log4j.version>1.2.17</log4j.version> <slf4j.version>1.7.5</slf4j.version> <dependency> <gr

MapKit in iOS 8 and Swift -

i'm trying use mapkit on ios 8 , keep getting error: trying start mapkit location updates without prompting location authorization. must call -[cllocationmanager requestwheninuseauthorization] or -[cllocationmanager requestalwaysauthorization] first. looking here, found had implement nslocationwheninusagedescription in plist , make call locationmanager.requestwheninuseauthorization() nothing happens , still error in console. doing wrong? in application delegate made optional var locationmanager outside class , set locmanager = cllocationmanager() locmanager!.requestwheninuseauthorization() this causes alert view pop nslocationwheninuseusagedescription or nslocationalwaysusagedescription if change appropriately. then in view controller file made var outside class hold local cllocationmanager. set if locmanager { locman = locmanager! locman!.delegate = self } then can use delegate method func locationmanager(_manager: cllocation

jquery - Grails: Trying to use tablesorter -

this dumb question trying use table sorter grails project , have jquery.tablesorter.js file copied 'js' directory of grails project , have columns sortable on clicking wondering other stuff comes table sorter widgets , css themes. in order keep following same pattern of adding files project i.e. keep adding grails project's 'js' , 'css' directory? worried directory paths need preserved theme , widget functionality. advice appreciated. wasn't able find specific installation instructions themes ad widgets anywhere. basically, i'd maximum functionality out of plugin not know place of additional css , images files noticed 'images' directory withing 'css' directory , have 'images' directory in project. thanks. i able locate information on using tablesorter might helpful. if add page header should functionality of tablesort widgets , themes. <!-- ui theme stylesheet - contents shown below --> <link rel=&quo

ios - How to call CGRectDivide in Swift? -

i'm trying call cgrectdivide , can't figure out syntax in swift. language guide doesn't seem help. here's template: cgrectdivide(rect: cgrect, slice: cmutablepointer<cgrect>, remainder: cmutablepointer<cgrect>, amount: cgfloat, edge: cgrectedge) my code: var r = uiscreen.mainscreen().bounds var myslice: cgrect var myremainder: cgrect cgrectdivide(rect: cgrect, slice: myslice<cgrect>, remainder: myremainder<cgrect>, amount: 44.0, edge: cgrectedge.maxyedge) that gives me error: "cannot specialize non-generic definition" i'm stumped. swift being readable language. try this: cgrectdivide(r, &myslice, &myremainder, 44.0, cgrectedge.maxyedge)

ruby on rails 4 - How to filter query result? -

how filter out experiments hasn't associated circuit? my experiment model: has_many :circuits my query: @experiments = experiment.where(:public=>true).where( 'updated_at >= :one_month_ago, :one_month_ago => time.now - 30.days ) so, need avoid experiment circuits associated equal zero. idea? i need avoid experiment circuits associated equal zero one way setting validation on foreign_key(experiment_id) if have it. class circuit < activerecord::base belongs_to :experiment validates :experiment_id, :presence=>true end so,by setting above validation,you can make sure every circuit associated expeiment .

php - Delete double rows in MySQL table when columns have identical entries -

this question has answer here: remove duplicates using mysql query? 7 answers i have database table (test_table) auto-increment column (id) , want delete double (or more) entries when 3 specific columns (a, b, c) have identical entries. id column_a column_b column_c ------------------------------------------------ 1 ooo aaa uuu 2 ooo aaa uuu 3 ttt ppp uuu 4 ooo aaa uuu 5 iii kkk ccc in example, rows id 2 , 4 should deleted after executing delete query. regards. delete tbl `id` not in ( select * ( select min(`id`) tbl group `column_a` , `column_b`

hibernate - IN clause with a composite primary key in JPA criteria -

i have table named group_table in mysql 2 columns user_group_id , group_id (both of them of type varchar ). both of these columns form composite primary key. i need execute statement using sub-select in() select rows based on list of values passed query. @override @suppresswarnings("unchecked") public list<grouptable> getlist(list<grouptable> list) { criteriabuilder criteriabuilder=entitymanager.getcriteriabuilder(); criteriaquery<grouptable> criteriaquery=criteriabuilder.createquery(grouptable.class); root<grouptable> root = criteriaquery.from(entitymanager.getmetamodel().entity(grouptable.class)); criteriaquery.where(root.in(list)); return entitymanager.createquery(criteriaquery).getresultlist(); } the implementation produces following query. select group_id, user_group_id projectdb.group_table ((?, ?) in ((?, ?), (?, ?))) /*binding parameters.*/ bind => [null, null, role_aaa, aaa, role_bbb, aaa]

PHP Validation String Does Not Contain List Of Values -

for example might: $exclude_values = ['/','.']; $check_string = 'asdf/'; $return = 'valid'; foreach($exclude_values $value) { if(strpos($value,$check_string) != false) { $return = 'invalid'; } } return $return; is there better way this? i've seen examples of single checks on stack not multiple values i can't recommend string searching function outside multibyte or pcre lib, because not utf-8 compatible, , you'll have strange errors sooner or later. in case regex better solution: return !preg_match('%[/\.]%usd', $check_string);

lisp - loop keyword immediately after finally -

when had asked how get numbers lottery given hint create function shuffles list. tried so, , got working. my current implementation looks this: (defun shuffle (list) (let ((len (length list))) (loop repeat len (rotatef (nth (random len) list) (nth (random len) list)) return list))) good news works: (shuffle '(1 2 3 4 5 6)) ;; => (3 1 4 2 6 5) bad news error message: warning: loop: loop keyword after finally: permitted cltl2, forbidden ansi cl. unfortunately don't understand it. why tell me loop appears after finally ? and, what's wrong code causes this? is there better way formulate this? warning: loop: loop keyword after finally: permitted cltl2, forbidden ansi cl. this means return loop keyword , not allowed after finally , according ansi cl standard. if want return loop , need use return macro: (loop ... (return list)) it's common mistake. finally return &l

jquery - How to auto-fill images from a directory in html for Flexslider2? -

i have been searching day , pretty stumped. i've tried searched have had no success. this problem.. <div id="slider" class="flexslider"> <ul class="slides"> <li><img src="photos/mini-01.jpg"/> <li><img src="photos/mini-02.jpg"/> <li><img src="photos/mini-03.jpg"/> <li><img src="photos/mini-04.jpg"/> </ul> </div> <div id="carousel" class="flexslider"> <ul class="slides"> <li><img src="photos/mini-01.jpg"/> <li><img src="photos/mini-02.jpg"/> <li><img src="photos/mini-03.jpg"/> <li><img src="photos/mini-04.jpg"/> </ul> </div> what want have auto create lines images based on what's in "photos" folder. using temp

c# - Exposing items in a ListBox through an Interface in MVP -

in mvp application presenter wants access / update data in list box on view . , presenter talking view through interface iview . i'm planing expose items in list box through property follows. have problem in using single property in case. interface iview { list<string> permission; } class form : iview { public list<string> permission { { return lstgivenpermissions; } // casting error set { lstgivenpermissions.datasource = value; } } } so presenter should able access , update data in list follows class presenter { updatemodelfromview() { model.permission = view.permission; } updateviewfrommodel() { view.permission = model.permission; } } my model this class model { ipublic list<string> permission = new list<string>(); // } i know above code not compiled due mismatches in datatypes. (casting errors). could please let me know how can achieve this? i l

eclipse - Why does CDT have different repository for Kepler/Juno/Indigo? -

the cdt repositories different kepler/juno/indigo. kepler: http://download.eclipse.org/tools/cdt/releases/kepler juno: http://download.eclipse.org/tools/cdt/releases/juno indigo: http://download.eclipse.org/tools/cdt/releases/indigo also, noticed cdt version kepler latest, juno , indigo have relatively older cdt versions. wanted have latest cdt version in juno. cause harm if upgrade cdt in juno using kepler repository? recent releases of eclipse have had synchronized releases of of different components (platform, jdt, pde, cdt, ....). these components have been tested work each other should not have problems installation or missing apis. you may able use newer versions of component (such cdt) older release. may find install fails because component requires newer versions of core plugins. if install using combination has had less testing.

debian - Access mysql without password, running as OS root -

is there way user root access mysql , privileges, without knowing password? i more used, without being expert, postgresql, , know default debian install of latter can type: # su - postgres $ psql i have root access server working on, administrator has not created mysql account me, , not reachable. considering tamper mysql files, suppose there must way me log in, haven't found yet. there mysql user, seems doesn't work postgres user: # su - mysql # whoami root # mysql error 1045 (28000): access denied user 'root'@'localhost' (using password: no) it has been pointed out not practice, have found way. mysqld has command-line switch named --init-file refers file containing sql commands executed when server starts. so able create user myself commands: # echo create user 'scozy'@'localhost' identified '****'; > /root/init.sql # /etc/init.d/mysql stop # mysqld --init-file=/root/init.sql # /etc/init.d/mysql resta

html - jQuery Effects - JQuery show and hide div on mouse click -

i have 1 script (show , hide div #id on click )and work fine need know how can change font color (click here) on click mean if hide (div class="menu") click here text color black / if show (div class="menu") click here text color color red image more clarify http://s18.postimg.org/5f9in18u1/image.jpg div id="showmenu">click here</div> <div class="menu" style="display: none;"><ul><li>button1</li><li>button2</li><li>button3</li></ul></div> script below $(document).ready(function() { $('#showmenu').click(function() { $('.menu').slidetoggle("fast"); }); }); demo / http://jsfiddle.net/apa2s/1/ all need toggleclass function. take @ fiddle $(document).ready(function() { $('#showmenu').click(function() { $('.menu').slidetoggle( 'fast' ); $('#showmenu'

javascript - $_REQUEST Variable Not Working Online -

i have suggestion search box has following code: html <input style="margin-right: 10px;height: 21px;" type="text" placeholder="persons first name" name="individual_name" id="individual_name" onfocus="clearfield(this, this.placeholder)" onkeyup="filter_individual_results()"/> javascript <script> $(function() { $( "#individual_name" ).autocomplete({ source: "<?php echo base_url(); ?>frontend_individual/suggest_names", minlength : 3, select: function( event, ui ) { //$('#ui-id'+i).click(filter_individual_results()); update_input_box('individual_name',ui.item.value,'2'); //alert('id :'+ui.item.value) ; //document.location.href = base_url+"controller_name/search?keyword="+ui.item.value; or r

javascript - Sorting json object by value -

i have json object below, how sort using date? json = {"date_hash":{"second_bleed":"2014-09-08","sixth_boost":"2014-10-28","first_boost":"2014-06-24","first_bleed":"2014-08-08","fifth_boost":"2014-09-30","fourth_bleed":"2014-11-03","second_boost":"2014-07-15","fourth_boost":"2014-09-02","third_bleed":"2014-10-06","primary_injection":"2014-06-02","third_boost":"2014-08-05"}} i tried doing json['date_hash'].sort(function(a, b){ }); sort not function json? the date_hash object json object doesn't have order (not sortable). you should try use array: {"date_hash": [ {"name": "second_bleed", "date": "2014-09-08"}, .... {"name": "sixth_boost", "d

javascript - angularjs infinite request loop for $resource -

for reason when hit route in angular crash browser , node server freaks out making tons of requests: get /bower_components/bootstrap/dist/js/bootstrap.js?_=1402331354670 200 3ms - 53.96kb /js/app.js?_=1402331354671 200 1ms - 1.56kb /js/controllers/main.js?_=1402331354672 200 2ms - 140b /js/controllers/login.js?_=1402331354673 200 3ms - 735b /js/controllers/userlist.js?_=1402331354674 200 2ms - 120b /js/controllers/signup.js?_=1402331354675 200 1ms - 465b /js/controllers/profile.js?_=1402331354676 200 1ms - 665b /js/controllers/courselist.js?_=1402331354677 200 1ms - 369b /js/controllers/coursedetails.js?_=1402331354678 200 4ms - 281b /js/filters/titleize.js?_=1402331354685 200 1ms - 381b /bower_components/jquery/dist/jquery.min.js?_=1402331354686 200 2ms - 82.3kb /bower_components/angular/angular.min.js?_=1402331354687 200 1ms - 102kb /bower_components/angular-route/angular-route.min.js?_=1402331354689 200 2ms - 3.86kb ...again , again forever the route click: a(ng-href='

linux - File found by Django server but not by Apache/mod_wsgi -

i've got django app when run "manage.py runserver 0.0.0.0:80" works fine, when run apache2 server tells me "no such file or directory" i reckon it's telling apache path in, i've done obvious: wsgiscriptalias / /home/mywebsite/myproject/wsgi.py wsgipythonpath /home/mywebsite <directory /home/mywebsite/myapp> <files wsgi.py> order deny,allow require granted </files> </directory> <directory /home/mywebsite> //i thought might give access root folder order deny,allow require granted </directory> note file in root of project, next manage.py. app able display front page, ajax fired 1 of buttons fails due above mentioned file error. i must missing how specify file path . the code access file this: with open('demo.txt') fp: etc... to reiterate, works fine when run django server. apache runs main page fine, falls on when looking file. what need change? one way set p

jquery - Getting a specific field by name? -

i have form number of fields, each same name: <input type="text" name="title[]" placeholder="title" value="a"> how can specific field? i have tried: console.log($('input[name=title[]]').val()); but no luck. as @adrift mentions , need wrap name attributes in quotes because has special character's. once done can use eq() enter index value of element specific input element- console.log( $('input[name="title[]"]').eq(3).val() );

How to add menu to Android List item via long click -

i'm attempting add menu list view. when user long click's on list item want have menu populate (really i'm showing list of items user wants buy, , menu display "remove")... how i'm displaying list, how add the listenener long click? public static class checkoutfragment extends listfragment { /** * * fragment argument representing section number * fragment. */ private static final string arg_section_number = "section_number"; public list<entry> cart; jsonobject json; jsonparser jparser = new jsonparser(); jsonarray directory; /** * returns new instance of fragment given section number. */ public static fragment newinstance(int sectionnumber) { checkoutfragment fragment = new checkoutfragment(); bundle args = new bundle(); args.putint(arg_section_number, sectionnumber); fragment.setarguments(args); return fragment; } public che

asp.net mvc - Warning on Razor when <img width="@someVar"> -

having following .cshtml : @{ int somevar = 300; } <img width="@somevar"> visual studio (2012) gives me warning : warning 1 '@width' not valid value of attribute 'width'. it work ok, i'm wondering if there's way pass variable width attribute without having warning. thanks! just wrap value in parentheses, so: @{ int somevar = 300; } <img width="@(somevar)"> the warning should disappear.

Making my own buttons in a pixelated engine in java -

i have been working on own 2d game using java. game made scratch , not using built-in java libraries create default button. stuck on problem can not figure out. in game using pixelated look, gui. have created following button class: package com.theshaft.client.gui; import java.awt.event.mouseevent; import com.theshaft.client.gfx.screen; public abstract class button { protected int x; protected int y; protected int width; protected int height; protected boolean ispressed; protected boolean ishovered; protected boolean isactivated; protected buttonmanager bm; public button(buttonmanager bm, int x, int y, int w, int h) { this.bm = bm; this.x = x; this.y = y; this.width = w; this.height = h; } public void onactivate() { this.isactivated = true; } public abstract void tick(); public abstract void render(screen s); public void onpress(mouseevent e) { if(e.getx() >= x && e.getx() <= x + width && e.gety() >= y &a

python - Is there a way to suppress printing that is done within a unit test? -

this question has answer here: silence stdout of function in python without trashing sys.stdout , restoring each function call 7 answers edit: please notice i'm using python 2.6 (as tagged) say have following: class foo: def bar(self): print 'bar' return 7 and have following unit test: import unittest class ut_foo(unittest.testcase): def test_bar(self): obj = foo() res = obj.bar() self.assertequal(res, 7) so if run: unittest.main() i get: bar # <-- don't want this, *do* want rest . ---------------------------------------------------------------------- ran 1 test in 0.002s ok exit code: false my question is: there way suppress output of object being tested while still getting output of unittest framework? call unittest option "-b" - buffer stdout , stderr foo.p

asp.net mvc - Can't get to property in razor foreach -

i'm still new mvc , razor , i'm hoping can me out something. able use following code print line (using @reply.getproperty("propertyname") when try assign variable (test) code fails. why , how can around it? need able assign , use further in other code. @foreach (var reply in currentpage.children) { @reply.getproperty("propertyname") @{ string test = reply.getproperty("propertyname"); } } in view @{ string test = string.empty; } @foreach (var reply in currentpage.children) { @reply.getproperty("propertyname") test = reply.getproperty("propertyname"); }

jquery - Is dynamic content reloaded on a resize event triggered? -

Image
i want load different picture depending on window width. i've built empty divide in body of document , i'm going set content (the image source) means of jquery script. now want changing orientation of device new query triggered, i've put code in resize method. what happens if resize event triggered , picture has loaded same previous 1 (suppose screen size changes 799px 800px)? loaded anyway wasting bandwidth or isn't loaded again? generally, no. however, behavior depends on caching definition set server , compatibility of client used (there shouldn't issues standard browsers). as suggested above, can use developer tools (network tab) to check whether resource has been reloaded. need check whether got standard 200 response, 200 (from cache) response or 304 (not modified). major difference between 200 (from cache) , 304 response, 304 request issued server , server respond 304, means cached item valid (a request issued content not re-downloaded), w

php - ACF Map not showing up -

i developing first wordpress template acf's map, div code coming out empty. could bring me light, please? know possibly stupid have missed out, new php , working hard learn :) this index code, had remove loop giving me error. i got code acf's website <?php get_header(); ?> <div class="map"> <?php if( have_rows('address') ): ?> <div class="acf-map"> <?php while ( have_rows('address') ) : the_row(); $location = get_sub_field('address'); ?> <div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"> <h4><?php the_sub_field('room_type'); ?></h4> <p class="address"><?php echo $location['address']; ?></p> <p><?php the_sub

python - threading.Condition.wait(timeout) ignores threading.Condition.notify() -

i have application uses 2 threads. want able shut down both threads waiting condition variable exitcondition . using python 3.3 unlike python 2.7 makes threading.condition.wait() return true when condition notified , false when timeout occured. #!/usr/bin/python import threading time import sleep exitcondition = threading.condition() def inputactivity(): while true: exitcondition.acquire() exitconditionreached = exitcondition.wait(.1) #<-critical print(exitconditionreached) exitcondition.release() if exitconditionreached: #exitcondition reached -> shutdown return else: #exitcondition not reached -> work sleep(.1) inthread = threading.thread(target = inputactivity) inthread.start() sleep(.2) #<-critical exitcondition.acquire() exitcondition.notify() print("exitcondition notified") exitcondition.release() inthread.join() there 2 lines #<-critical comment in line 10 , 21.

reporting services - SSRS ignore a field result -

i guys i'm having slight problem report im writing. so when run report gives me list of outcomes data source. 1 of results 'closed' want exclude outcome in report. cant exclude in sql code doesn't bring null values. ( when no outcome has been given task yet i.e no 1 has had time yet have set in expression 'no outcome'.) so want know if can edit expression not bring value of 'closed' =iif(isnothing(fields!outcomedescription.value),"no outcome",fields!outcomedescription.value) any on great sorry if iv not explained well. rusty to this, you'll want add filter either dataset or table object - whichever appropriate needs. for dataset filter, merely open dataset properties, , filters tab. table, you'll need go tablix properties. setting filter there simple. filtering @ dataset level drop of filtered records before controls on report access them. filtering @ object level drop filtered records control, still avail

arrays - Matlab: Remove loop from code -

flow 4d double matrix fourth dimension 2 . want implement loop without using loops. essentially , each index in third dimension,, want divide flow1 square blocks of size block-size , calculate mean of values in fourth dimension of each block, assign values respective fourth dimension elements in block . typical values [height width n block_size] = [ 480 640 100 8] . guaranteed block_size factor of both height , width [height,width,n,~] = size(flow1); reduced_flow = zeros(size(flow1)); ii = 1:block_size:height jj = 1:block_size:width k = 1:n reduced_flow(ii:ii+block_size-1,jj:jj+block_size-1,k,1) = mean(mean(flow1(ii:ii+block_size-1,jj:jj+block_size-1,k,1),1),2); reduced_flow(ii:ii+block_size-1,jj:jj+block_size-1,k,2) = mean(mean(flow1(ii:ii+block_size-1,jj:jj+block_size-1,k,2),1),2); end end end example flow1 = round(10*rand(4,4,2,2)); block_size = 2; [flow1 reduced_flow] ans(:,:,1,1) = 6.0000 4.0000