Posts

Showing posts from July, 2012

How to judge whether the Android device is phone or pad? -

how judge whether android device phone or pad,i can not find method of android api.now judge based on device dimensions, if(size > 6) -->pad else ---> phone,does have solution i know not want hear, don't distinguish between phone or tablet. you need ask yourself, why? - there 7inch + devices phone functionality. - there 5inch - devices without phone functionality. - sensors vary between devices, large , small. - there phablets may fall either category. so, if definition of "phone" is, "can make phone calls?" ... telephonymanager manager = (telephonymanager)context.getsystemservice(context.telephony_service); if(manager.getphonetype() == telephonymanager.phone_type_none) { // has no phone }

opencyc - Exception for the log settings while starting CYC instance -

i have been trying logging working on cyc server side interaction clients(api/cyckb browser)....havn't been successful yet.. here exception get...not sure wrong json file (log4j2.json) http://pastebin.com/2cjjebdb (log contents) here contents of log4j2.json file http://pastebin.com/mkza0r3d can point our mistake here? from error seems log4j thinks file contains xml, because there comma in name.

java - Event Handler when a Row is deleted from Table View -

i need know how catch event happens when row deleted tableview , index of row. @ moment when row deleted table view tableview.getselectionmodel().clearselection() method called. want select last index available in table view. tableview.getselectionmodel().clearandselect() not option, because row deleted automatically. regards for table type, example, person : import javafx.collections.listchangelistener.change ; // .... tableview<person> table = ... ; table.getitems().addlistener((change<? extends person> c) -> { while(c.next()) { if (c.wasremoved()) { int numremoved = c.getremoved().size(); int index = c.getfrom(); system.out.println(numremoved + " items removed table @ index "+index); } } }); the listchangelistener.change documentation describes values returned c.getfrom() , c.getto() , c.wasremoved() , c.getadded() , etc. under various scenarios.

javascript - Proper way of invoking a function to validate data before submitting a form -

in understanting, have 2 options this: a) on html form, assign function on "onsubmit" attribute, , use function return false if goes wrong. submitting form, submit-type button can used. b) have non-submit button, triggers javascript function on-click; then, function, "form.submit();" call , force submition. is there practical difference between these 2 methods / prefered method of doing this? pro - cons, etc? now, see them being matter of taste,but if there's functional difference might come handy knowing it! thanks lot you may use "onchange" event listener not allowing enter invalid data in form

java - Unable to install Jboss server on Eclipse Luna -

i trying install jboss on eclipse luna. have installed jboss tool, when try define server jboss option not present. after clicking downloadable server adapter selected jboss wildfly & eap server tools. unable download adapter following error: cannot complete install because of conflicting dependency. software being installed: jboss as, wildfly & eap server tools 3.1.1.final-v20160409-0826-b118 (org.jboss.ide.eclipse.as.feature.feature.group 3.1.1.final-v20160409-0826-b118) software installed: eclipse ide java ee developers 4.4.1.20150109-0740 (epp.package.jee 4.4.1.20150109-0740) 1 of following can installed @ once: console 3.6.100.v20150822-1912 (org.eclipse.ui.console 3.6.100.v20150822-1912) console 3.5.300.v20140424-1437 (org.eclipse.ui.console 3.5.300.v20140424-1437) cannot satisfy dependency: from: eclipse ide java ee developers 4.4.1.20150109-0740 (epp.package.jee 4.4.1.20150109-0740) to: org.eclipse.epp.package.jee.feature.feature.group [4...

jquery - Javascript replace utf characters in string -

i want after type title of post automatically take value , create slug. code works fine english latin characters problem when type characters 'čćšđž'. code replace first type of characters in string if character repeated problem. so, testing purpose title 'šžđčćžđš čćšđžčćšđž čćšđžčć ćčšđžšžčćšđ ćčšžčć' converted slug 'szdcc'. this jquery code: $('input[name=title]').on('blur', function() { var slugelement = $('input[name=slug]'); if(slugelement.val()) { return; } slugelement.val(this.value.tolowercase().replace('ž', 'z').replace('č','c').replace('š', 's').replace('ć', 'c').replace('đ', 'd').replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '')); }); how solve problems? possible few characters put in same replace() function? replace() replaces first occurrence unless regex used global modifier. need c...

sql - Sorting Results in Mysql -

i have table looks this, name person's name, , votes how many people have rated person, , rating_percent rating percent 5.0 highest. question is, best way sort them depending on number of votes , rating_percent. , can give me sample code. | id | name | votes | rating_percent | | 1 | george | 12 | 4.5 | | 2 | pamela | 1 | 5.0 | | 3 | britney | 22 | 3.2 | | 4 | lucas | 43 | 1.2 | | 5 | bobby | 54 | 2.4 | th query be select * table_name order votes desc, rating_percent desc

Can't use old c functions in opencv 3.1 -

opencv3.1 build cmake latest stable. trying cpp example project works fine. i tried hello-world example from: http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html test.c //////////////////////////////////////////////////////////////////////// // // hello-world // // simple, introductory opencv program. program reads // image file, inverts it, , displays result. // //////////////////////////////////////////////////////////////////////// #include <stdlib.h> #include <stdio.h> #include <math.h> #include <cv.h> #include <highgui.h> int main(int argc, char *argv[]) { iplimage* img = 0; int height,width,step,channels; uchar *data; int i,j,k; if(argc<2){ printf("usage: main <image-file-name>\n\7"); exit(0); } // load image img=cvloadimage(argv[1]); if(!img){ printf("could not load image file: %s\n",argv[1]); exit(0); } // image data height = img-...

javascript - Bootstrap drop down with check box(s) allowing for multiple check boxes instead of just one -

i have bootstrap drop down menu allows user add check box next item in drop down list. however, user able add multiple check boxes - desired behavior user should able select 1 check box. if user has selected 1 check box other check box should removed. $("document").ready(function() { $('.dropdown-menu').on('click', function(e) { if($('.checkbox').count() > 1){ if($(this).hasclass('dropdown-menu-form')) { e.stoppropagation(); } } }); }); .dropdown-menu-form { padding: 5px 10px 0; max-height: 100px; overflow-y: scroll; } <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <div class="dropdown"> <a class="dropdown-toggle btn" data-toggle="dropdown" href="#"> toggle dropdown <b class="caret"></b> <...

java ee - Which protocols can a soap web service use? -

i new soap web services , able write soap web service , test it. i understood soap uses http/https communicate. when browsing through websphere admin console saw called soap connector , port number 8880. mean? answer : soap ;-) , under, transport layer : http or https. soap_connector_address default value 8880 specific port opened on appserver web service dialog (not serving web pages example). ibm websphere doc ports kenavo! (in bzh), yoann

ios - `UIRefreshControl endRefreshing` not working -

Image
i've got pull-to-refresh feature in app is, far can tell, set "normal way": uirefreshcontrol *refreshcontrol = [[uirefreshcontrol alloc] init]; refreshcontrol.attributedtitle = [[nsattributedstring alloc] initwithstring:@"pull refresh"]; [refreshcontrol addtarget:self action:@selector(refreshpage) forcontrolevents:uicontroleventvaluechanged]; self.refreshcontrol = refreshcontrol; the refreshing part works fine. after done refreshing call [self.refreshcontrol endrefreshing] at point, appears ignore call , continues show pull-to-refresh "gap", without spinner: (i have breakpoint @ line verify endrefreshing is being called) if jiggle page thumb (pull down without pulling far enough trigger pull-to-refresh), fix , spring place. why doesn't spring when call [self.refreshcontrol endrefreshing] ? there way can programmatically force spring back? i've tried placing endrefreshing call in delay: [self.refreshcontrol performse...

Using Python and Selenium, how do I find an extjs combobox with xpath? -

the html follows: <input id="combobox-3829-inputel" class="x-form-field x-form-text" type="text" style="width: 100%; text-transform: uppercase; -moz-user-select: text;" name="combobox-3829-inputel" autocomplete="off" aria-invalid="false" data-errorqtip=""/> i know need along these lines: //input[starts-with(@id, "combobox-")] but don't know after part. combo box can have text input in it, have part done. i'm trying convert absolute xpath shorter version. i've figured out buttons , finding text on fine, first run in combo box. i've searched many examples can find, haven't found recent 1 made clear me. also, know xpath have defined above can find combo box, issue page has 2 combo boxes identical in every way except generated id number. how can index them? thank in advance help. if using static id's try //*[@id='combobox-3829-inputel...

asp.net - Nested Repeaters in C# -

hi have display hierarchical information (which has 4 levels) within repeater. decided use nested repeater control. found article on msdn, http://support.microsoft.com/kb/306154 shows how use nested repeaters 2 levels of information. can please me extend 4 levels? sample code appriciated. thank you. html code : <asp:repeater id="repeater1" runat="server" onitemdatabound="repeater1_itemdatabound"> <itemtemplate> <h1> repeater 1</h1> <asp:repeater id="repeater2" runat="server" onitemdatabound="repeater2_itemdatabound"> <itemtemplate> <h1> repeater 2 </h1> <asp:repeater id="repeater3" runat="server" onitemdatabound="repeater3_itemdatabound"> <itemtem...

sql - Remove all rows Except condition -

i remove rows table except when firstname ben , isadmin true here sql delete table1 (firstname <> 'ben' , isadmin = 1); however, issue when isadmin false... should remove row doesn't remove it. issue here? the correct sql should be delete table1 (firstname <> 'ben' or isadmin = 0);

java - How to animate dashed line Javafx -

Image
i want move (animate) dashes in line: line l=new line(); l.getstrokedasharray().addall(25d, 20d, 5d, 20d); animate stokedashoffsetproperty of line value of 0 until total length of items in stroke dash array. run timeline in reverse if want animate in opposite direction. import javafx.animation.*; import javafx.application.application; import javafx.scene.*; import javafx.scene.shape.line; import javafx.stage.stage; import javafx.util.duration; public class linestrokeanimator extends application { @override public void start(stage stage) { line line = new line(20, 100, 80, 20); line.getstrokedasharray().setall(25d, 20d, 5d, 20d); line.setstrokewidth(2); final double maxoffset = line.getstrokedasharray().stream() .reduce( 0d, (a, b) -> + b ); timeline timeline = new timeline( ...

javascript - Refreshing $scope from inside a $scope.function() -

first of all, i'm sorry if post long. also, in case somehow interferes answers may give me, i'm not defining controller in usual way. instead, follow http://www.technofattie.com/2014/03/21/five-guidelines-for-avoiding-scope-soup-in-angular.html , , do: var game_1 = function($scope){ var _this = this; //some code $scope.somefunction = function() { _this.somefunction() ; } ; } ; game1.prototype.somefunction = function() { //some code } ; game_1.$inject = ['$scope'] ; app.controller('game_1', game_1) ; in html, have object attribute ng-show="checkrare" . now, have set of functions work kind of matryoshka doll: defined inside controller: this.promptelement = function(message) { var input = prompt(message) ; if ( input === null ) { this.resetcell(this.cellij) ; return false ; } else if ( input === '' ) { this.resetcell(this.cellij) ; return '' ; } else { return...

android - How do I access a text file from GCP Storage and parse it? -

i have app want make android. have decided store information display in text file , parse it, rather database since data simple. the info 2 lines of text, word , short description of word. want app each pair (word, description) text file , display on card in app. i stored .txt file in google cloud platform storage , need writing code access file(s) , parse them use in cards ui. i can find no helpful examples of how file parse in app in smooth way. you can use client library open file , read it. example, python client library @ https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/functions and code this: import cloudstorage try: gcs_file = cloudstorage.open(filename, 'r', content_type='text/plain') # process normal ... except cloudstorage.notfounderror: pass sample java client code @ https://cloud.google.com/storage/docs/xml-api-java-samples

android - How to get Background color for a Button -

i have imagebutton , background color android:src="@color/c105" how can color programmatically ? i want color not drawable getresources().getcolor(r.color.c105); should it you set color on image button having reference in code this: (imageview) findviewbyid(r.id.your_image_view).setbackgroundcolor(getresources().getcolor(r.color.c105);

java - JavaFx Popup Window With MouseClick -

Image
this question exact duplicate of: javafx image appear in popup window is there way make popup window appear using onmouseclick , if how go doing this? need add code make new window appear when click on building in map. if seems vague might ask , ill try explain further. cheers! package application; import java.net.url; import java.util.collection; import java.util.resourcebundle; import javafx.beans.invalidationlistener; import javafx.beans.observable; import javafx.beans.property.doubleproperty; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.fxml.fxml; import javafx.fxml.initializable; import javafx.scene.node; import javafx.scene.control.scrollbar; import javafx.scene.control.slider; import javafx.scene.image.imageview; import javafx.scene.input.mouseevent; import javafx.stage.popup; import javafx.stage.stage; public class mapcontroller implements initializable { //t&l protecte...

Very simple BigQuery SQL script won't return "0" for Count rows with no results -

i trying make simple sql script work: select date(sec_to_timestamp(created_utc)) date_submission, count(*) num_apples_oranges_submissions [fh-bigquery:reddit_comments.2008] (lower(body) contains ('apples') , lower(body) contains ('oranges')) group date_submission order date_submission the results this: 1 2008-01-07 3 2 2008-01-08 1 3 2008-01-09 2 4 2008-01-10 3 5 2008-01-11 2 6 2008-01-13 2 7 2008-01-15 2 8 2008-01-16 3 as can see, days there no submissions containing both "apples" , "oranges", instead of value of 0 being returned, entire row missing (such on 12th , 14th). how can fix this? i'm @ wits end. thank you. try below, return submissions days select date(sec_to_timestamp(created_utc)) date_submission, sum((lower(body) contains ('apples') , lower(body) contains ('oranges'))) num_apples_oranges_submissions [fh-bigquery:redd...

ubuntu - Performance of 32 bit application on 64 bit platform -

we have 32 bit application. running on 32 vm. if run application on 64 bit os(virtual machine) supports intel virtualization technology run faster? not have 32 bit os(virtual machine) supports intel virtualization technology. there not not enough material find. please share knowledge. the answer no. we running on instance had no hardware virtualization support. tested on new virtualized system intel virtualization technology . application here 32 bit system , new system 64 bit os - ubuntu. run using gcc-multilib support ubuntu. there not huge performance improvement observed.

parsing - How can I parse this date in Golang? -

i having trouble in parsing date ( "apr 19, 3:15p et" ), can please me in regard? this code have written. d, err := time.parse("jan 02, 3:04p et", date) thanks in advance. the 3 letter month constant jan date := "apr 19, 3:15p et" d, err := time.parse("jan 02, 3:04p et", date) http://play.golang.org/p/lkeqotc1hd

bash - Trigger event on AWS EC2 instance stop/terminate -

is there way trigger event (e.g. running script push logs s3) when ec2 instance stopped/terminated? i have looked triggering script using service in /usr/lib/systemd/system haven't had luck yet. have heard networking capabilities on instance can shutdown before service triggered , if true, why script not executing correctly. you can trigger events, such pushing logs s3 on specific events, cloudwatch... learn more here: https://aws.amazon.com/cloudwatch/

c++ - Initializing a static POSIX semaphore inside a class -

class semaphore { private: static sem_t sem_id; } in cpp: sem_init(&semaphore::sem_id, 0, 0); obviously , compiler won't let me run code outside of function. it's not type can initialized value. how do it? you wrap sem_id in own class performs sem_init on default-construction (and sem_destroy on destruction; don't forget that!). sadly, sem_t not class can't inherit , must instead compose it: #include <semaphore.h> class scoped_sem_t { public: scoped_sem_t() { sem_init(&sem, 0, 0); } ~scoped_sem_t() { sem_destroy(&sem); } sem_t& get() { return sem; } private: sem_t sem; }; class semaphore { private: static scoped_sem_t impl; // use semaphore::impl.get() }; scoped_sem_t semaphore::impl; // (don't forget this!) (n.b. untested guess should work…) (also, not best example of class design, gives gist.) otherwise, sadly, there no ways neatly. write sem_init @ start of main instead, c...

python - How can I stop a long-running function when it is called multiple times? -

below have example program. when button pressed, takes second before can calculate value show. if user presses button in rapid succession end waiting long time see last answer, answer care about. in code, can see _datacruncher function needs know self._count , self._count not depend on output of _datacruncher . my question, therefore, how can interrupt normal execution of _datacruncher on subsequent calls in order keep gui free other stuff, , not waste processing time when not needed? realize need use thread run _datacruncher , sort of queue appropriate val display, not understand how put together. from pyqt4 import qtgui, qtcore import sys import time import random import random class mainwindow(qtgui.qmainwindow): def __init__(self): self.app = qtgui.qapplication(sys.argv) super(mainwindow, self).__init__() self.count = 0 self.initui() def initui(self): # layouts central = qtgui.qwidget() layout = qtgui.qv...

r - How to use rowwise with do function with if else of ifelse? -

i have data frame contain column, list. data frame contain json reponse column, , second column list converted json using following code. vectorize_fromjson <- vectorize(fromjson, use.names=false) z <- vectorize_fromjson(data_df$json_response) i using rowwise function extract information list. however, not able use if it. working code t <- data_df %>% rowwise %>% do( test = class(.$json_list$cbas$dslscc) ) i want follows: t <- data_df %>% rowwise %>% do( test = ifelse(class(.$json_list$cbas$dslscc)=="list", true, .$json_list$cbas$dslscc) ) following error: error in .$json_list$clear_bank_attributes$days_since_last_successful_check_cashed$nil : $ operator invalid atomic vectors

c# - DataBinding exception that says system.data.datarow does not contain a property with the name -

lacking asp.net experience, have been trying resolve issue last 3 days without success. databinding:system.data.datarowview not contain name 'reci_seq' exception getting when changed code display gridview. i had below code working fine: <asp:tablecell width="57%"> <asp:linkbutton id="lnkdname" runat="server" onclick="lnkdname_click"></asp:linkbutton> <asp:label runat="server" id="lbldtag"></asp:label></asp:tablecell>.................... but when changed below codes start getting exception: <asp:gridview id="grddevicedown" runat="server" width="100%" cellpadding="0" cellspacing="1" autogeneratecolumns="false" onrowdatabound="grddevicedown_rowdatabound" onrowdeleting="grddevicedown_rowdeleting" onrowcommand="grddevicedown_rowcommand" gridlines=...

gradle - Android DataBinding build error -

i have problem data binding library android. have freshly installed android studio v2.0 , newly created project. problem when try add databinding { enabled = true } to build.gradle, error while trying build project: :app:databindingprocesslayoutsdebug failed error:execution failed task ':app:databindingprocesslayoutsdebug'. could not initialize class android.databinding.parser.xmllexer the build.gradle files this: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0' // note: not place application dependencies here; belong // in individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: delete) { delete rootproject.builddir } and apply plugin: 'com.android.application' android { compilesdkversion 23 buildtoolsversion '23.0.3' defaultconfig { applicationid "com.silgrid...

yelp - Using Google My Business API to post reviews -

i'm trying automatically post review google business (also tripadvisor, yelp or similar valid option). far, no luck apis, don't seem support this. does have experience this, or knows workaround it? suffice "pre-fill" text boxes on review sites, or have widget (as https://www.tripadvisor.com/widgets-g60763-d6727310-the_ludlow_new_york_city-new_york_city_new_york.html#w-cdswritereviewlg , tripadvisor though - no luck google business). thank you! google business api gives capabilities of managing business user's transactions i.e reading / replying reviews on business fyi https://developers.google.com/my-business/reference/rest/v3/accounts.locations.reviews/reply not give option post reviews onto businesses. yelp , tripadvisor have no apis post reviews @ moment.

Issue while installing mysql.connector in Python 2-7 after migrating from 2.6 -

mysql.connector used work expected in python 2.6 wanted use argparse, installed 2.7 version. facing below errors while installing connector version. not sure how resolve them. **error while importing connector:** [/usr/local/bin ] # python python 2.7.6 (default, apr 19 2016, 19:36:47) [gcc 4.4.7 20120313 (red hat 4.4.7-11)] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import mysql.connector traceback (most recent call last): file "<stdin>", line 1, in <module> importerror: no module named mysql.connector >>> **paths located** [~ ] # python2.6 /usr/bin/python2.6 [~ ] # python2.7 /usr/local/bin/python2.7 [~ ] # python /usr/local/bin/python [~ ] # ls -l /usr/local/bin/py* -rwxr-xr-x 1 root root 84 apr 19 18:10 /usr/local/bin/pydoc lrwxrwxrwx 1 root root 18 apr 19 21:57 /usr/local/bin/python -> /usr/bin/python2.6 lrwxrwxrwx 1 root roo...

c - Why is one seg faulting and the other not? -

hi have program needs compare string array predefined string when use variable args[0] works in function strcmp below int gash_execute(char **args){ int i; if(args[0] == null){ return 1; } for(i = 0; < gash_command_num(); i++){ if(strcmp(args[0], functions[i]) == 0){ return(*function_address[i])(args); } } return gash_launch(args); } however when trying strcmp args[i] such below seg fault. can me find solution problem? int gash_execute(char **args){ int i; if(args[0] == null){ return 1; } for(i = 0; < gash_command_num(); i++){ if(strcmp(args[i], functions[i]) == 0){ return(*function_address[i])(args); } } return gash_launch(args); } args[] array of strings separated spaces, program custom shell, pretend in shell command line input "cat echo ls" args[0] "cat" , on. need implement i/o redirection. need check every el...

javascript - How can I use the React media synthetic event listener on an audio element? -

facebook/react lists "media events" on page: https://facebook.github.io/react/docs/events.html i trying execute function on pause/play , i'm trying: <audio id="globalaudio" onplay={this._onplay} onpause={this._onpause}> </audio> but functions aren't firing. i'm aware can add event listener like: let ga = document.getelementbyid("globalaudio"); ga.addeventlistener("play", this._onplay); ga.addeventlistener("pause", this._onpause); but i'm wondering how use syntheticevent talk in above link, or if there other convention followed react listening events these. i needed upgrade react. still using version had listed in todo list tutorial.

batch file - Install fails for dBASE III Administrator, "goto was unexpected" -

i novice programmer/it guy @ family owned real estate finance business. long story short, created dbase iii based application system track customer accounts 25-30 years ago. cost change modern system astronomical , since can code reasonable efficiency keep it. right, using single user version on separate workstations. want install dbase administrator , change things on networked environment. figured going little out of depth able work through it. running on windows xp system, no internet connection, land together. i got install disk image vetusware. mounted image via virtual floppy. in command prompt navigate disk , follow instructions manual: insert system disk #1 in drive a. change default drive typing a:[return] so far good...i have prompt. then type: a> install c: dba i type "install c: dba", launched "install.bat" found on disk, reports "goto unexpected @ time." , returns me prompt. i post batch file text below. u...

python - Project is not white listed when using google cloud message - GCM Service for android -

when using gcm error: the project 3425345631 not whitelisted . i'm trying use gcm - have created andorid key , server key. i'm following tutorial getting started gcm . problem comes when i'm trying run python code ccs server. error the project 3425345631 not whitelisted . have put project number username in python code, , password used generated api key server apps in google api, , registration_id has value registered device (android phone) want send messages to. can 1 please describe entire process of setting ccs server google cloud messaging? there special sign-up form ccs , user notifications, in supply google api project it. can't use new apis without google accepting registration on form.

C++: Pointer not initialized but pointing to a variable -

int main() { int b = 10; int* bpointer; *bpointer = b; cout << *bpointer << endl; cout << bpointer; } first cout prints 10, second prints 0. how can pointer pointing 0 store value? as other comments , answers have noted, using uninitialized pointer yields undefined behavior—so shouldn't that. however, seem understand that, you're still curious why see behavior you're observing... since bpointer not declared volatile , compiler can assume *bpointer cannot change during function scope. basically, compiler sees assignment *bpointer = b; and optimizes line cout << *bpointer << endl; into this cout << 10 << endl; which can assume equivalent. the compiler might able deduce program ends @ point, , skips assignment *bpointer altogether; however, seems bit more farfetched me. all of platform , compiler combinations tried yielded error, wasn't able confirm explanation—but if you...

java - comparing a input string to string in a database -

i'm studying android studio , started databases week. little app. simple. user enters string , presses button in first activity. string sent second activity compared values in database , display ones similar: public class drinkcategoryactivity extends listactivity { public static final string extra_message = "message"; private sqlitedatabase db; private cursor cursor; private cursor newcursor; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); intent intent = getintent(); string messagetext = intent.getstringextra(extra_message); //setcontentview(r.layout.activity_drink_category); listview listdrinks = getlistview(); try{ sqliteopenhelper starbucksdatabasehelper = new starbucksdatabasehelper(this); db = starbucksdatabasehelper.getreadabledatabase(); /* select _id, name drinks; */ cursor = db.query("drink", new st...

html - Overflow:auto inside a flexbox behaves differently for children with display:block and display:flex -

Image
children in flexbox if has display:flex , don't behave overflow . example provided in codepen should self explanatory: http://codepen.io/sanjay1909/pen/vgrjpg i not sure understood flexbox correctly flex values. <div class="hbox"> <div class="vbox resizingdiv"> <div class="flexbox-item" style="flex-direction:column;overflow:auto"> <div class="flexbox-inner">1</div> <div class="flexbox-inner">2</div> <div class="flexbox-inner">3</div> <div class="flexbox-inner">4</div> <div class="flexbox-inner">5</div> <div class="flexbox-inner">6</div> <div class="flexbox-inner">7</div> <div class="flexbox-inner">8</div> <div class="flexbox-inner">9</div> </div> <div class="flexbox-item ...

ruby on rails 3 - Anyway to stub local variables in an rspec test? -

i have code looks in method trying test: service = if user_activator? someservice.new(subscription.user, cookies: cookies) elsif sub_activator? someotherservice.build(subscription: subscription, cookies: cookies) end i trying stub service instance of someservice , try see if receives method code looks this: expect(some_service_instance).to receive(:activate).with(hash_including( app_context: app_context, cookies: cookies, subscription: subscription )) but there way stub local variable instance of useractivationservice?? here ways think may work? first, should extract conditional local variable set method (this feels fishy): def service if some_service_activator? someservice.new(subscription.user, cookies: cookies) elsif sub_activator? someotherservice.build(subscription: subscription, cookies: cookies) end end then can do: let(:some_service_i...

compiler errors - C++: Filescope constants with same name are breaking one definition rule? -

i have 2 constants in 2 different .cpp files, both named const char const * texture_filename = "..."; one in a.cpp , other in b.cpp , @ file scope, , neither file includes other or should see 1 another, vs2010 generates linker error: a.obj : error lnk2005: "char const * const texture_filename" (?texture_filename@@3pbdb) defined in b.obj what doing wrong here, , how might fix without needing rename either constant? what doing wrong here, , how might fix without needing rename either constant? you defining 2 objects named texture_filename . that's problem. there more 1 ways fix problem. simplest fix make them static in file scope. static const char * texture_filename = "..."; update, in response op's comment texture_filename not const object. happens point c style string const . can modify texture_filename elsewhere in file using: texture_filename = <some other c style string>; to make texture_filen...

java - AsyncTask do not cancel on cancelling -

i have asynctasks. in oncreate view of dialog fragment creating object of asynctask below (sample code) @override public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) { cashinvalidatorlistner = new cashinvalidatorlistner(msessionmanager.getcustomerid(),msessionmanager.getposid(), this); } now in onclick executing async taks @override public void onclick(view v) { if(v==ok) { if(mhomeactivity.mprogressdialog!=null && !mhomeactivity.mprogressdialog.isshowing()){ mhomeactivity.mprogressdialog.show(); } cashinvalidatorlistner.execute(); } } i have added oncancellistner progressbar @override public void oncancel(dialoginterface dialog) { if(dialog==mprogressdialog) { mdialogextraoptions.cashinvalidatorlistner.cancel(true); toast.maketext(getbasecontext(), "task cancled", toast.length_short).show(); } }...

java - REST client sample to update thumbnail Photo using Azure AD Graph api? -

i looking sample rest client can update user thumbnailphoto using azure ad graph api? rest client there , works https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#getuserthumbnailphoto i tried sample java rest client received 405 - method not allowed: public void updateuserphotograph(modelmap model) throws ioexception { //https://graph.windows.net/{tenant}/users/{user}/thumbnailphoto?api-version=1.6 uricomponents uricomponents = getphotouri(); string bearertoken = getbearertoken(); try { httpclient httpclient = httpclients.createdefault(); byte[] bytesencoded = base64.encode(extractbytes()); uribuilder builder = new uribuilder(uricomponents.tostring()); uri uri = builder.build(); httppost request = new httppost(uri); request.setheader(httpheaders.authorization, "bearer " + bearertoken); request.setheader(httpheaders.conte...

c# - How to find employee by id with textbox and button -

my question how can find employee id example if type in textbox 17432 , when click on search button should give me employee id fullname lastname , salary information . using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace project_employee { public partial class form1 : form { employee[] employee = new employee[10]; public form1() { initializecomponent(); employee[0] = new employee(17432, "john", "adverd", 800.00); employee[1] = new employee(17433, "adrian", "smith", 800.00); employee[2] = new employee(17434, "stephen", "rad", 9000.00); employee[3] = new employee(17435, "jesse", "harris", 800.00); employee[4] = new employee(17436, ...