Posts

Showing posts from July, 2012

ios - set WKInterfaceButton title color - WatchKit -

is there way change color of watchkit wkinterfacebutton title programmatically? know can change in storyboard need change in code. per apple documentation doesn't whether such action allowed or not. did try looking @ available methods wkinterfacebutton , there 1 setbackgroundcolor not title color. did miss something? i haven't tried this, looks can use setattributedtitle: , 1 of attributes can nsforegroundcolorattributename color want set title too.

PHP echo tag and quotes -

i tried search solution don't know how it. on php when use (echo) tag, it's possible use other delimiter other " or ' ? example, can this? echo *hello world*; or echo |hello world|; maybe editting php.ini? thanks you. no. can't this. changing fundamentals of language. it's asking if can use : instead of ; end statements. if need use ' in echo statement use \ , escape character strings. instance: echo "pete\'s coffee" //prints: pete's coffee

string - Java only get Exception name without StackTrace -

how can exception name without getting stack trace? i using exception.tostring() convert thrown exception string, want exception name like nullpointerexception , not entire stack trace. how can solve this? exception.getclass().getsimplename(); class#getsimplename() note: not work in case if exception anonymous class (although have never seen anonymous exception in production code)

Android source base: where is partition table defined -

in android system source base, partition table specified? realize vendor/device-specific. the partition sizes defined in board configuration files. example, system partition size board_systemimage_partition_size , defined here flo , here grouper. mapping code names products separate issue. (iirc, grouper , flo nexus 7 (2012) , nexus 7 (2013), respectively.)

twitter bootstrap - Dynamically Load content and Navbar items are not working properly on ScrollSpy -

i have requirements few data content , corresponding buttons dynamically adding navbar. when content dynamically adding after scrollspy not working , behaving wearied. scrolling on content, no proper button getting active. i know has dynamic adding don't know how resolve it. jsfiddle: in below jsfiddle, if click on welcome 2 new content div , tabs getting added , after when start scrolling, functionality not working properly. http://jsfiddle.net/26e8nduc/2/ $('.navbar li a').click(function (event) { var scrollpos = $('body > .container').find($(this).attr('href')).offset().top - offsetheight; $('body,html').animate({ scrolltop: scrollpos }, 500, function () { $(".btn-navbar").click(); }); return false; }); thanks response rushi when adding elements dynamically, need refresh scrollspy after elements have been added. from latest bootstrap documentation http://getbootstrap.com/javascript/#scrollspy

javascript - Pjax loaded content is hidden -

i'm trying integrate jquery-pjax theme ( next hexo.io), , here's code using it: (function() { (function($) { return $(document).pjax('a', '#pjax', { fragment: '#pjax', timeout: 10000 }).on('pjax:send', function() { topbar.show(); $('body').velocity({paddingright: 0}); }).on('pjax:complete', function() { topbar.hide(); }); })(jquery); }).call(this); and related html layout: <div id="header" class="header"> <div class="header-inner"> {% include '_partials/header.swig' %} </div> </div> <div id="pjax"> <div id="main" class="main"> <div class="main-inner"> <div id="content" cl

internet explorer - How can I determine the type of ActiveXObject and object created in JavaScript? -

1) say have following in javascript: var xmldoc = new activexobject("msxml2.domdocument.6.0"); var xmldoc2 = new activexobject("msxml2.domdocument.3.0"); var xmldoc3 = new activexobject("microsoft.xmldom"); typeof xmldoc; // returns object typeof xmldoc2; // returns object typeof xmldoc3; // returns object how return type of activexobject of each one, i.e. msxml2.domdocument.6.0 , msxml2.domdocument.3.0 ? want observe if xmldoc's activexobject equal xmldoc2's activexobject . 2) // object xmldocument var xmlobj = document.implementation.createdocument ("", "", null); typeof xmlobj; // returns object same situation activexobject, except object defined xmldocument . how able validate xmldocument ? again, typeof returns object , not helpful here. thank much.

hadoop - EC2 cluster created by spark using old HDFS 1.0 instead of 2.5 -

i created cluster using spark-ec2 script. installs hdfs version 1.0. use cluster connect hive installed on cloudera cdh 5.3 cluster. getting following error:- org.apache.hadoop.ipc.remoteexception: server ipc version 9 cannot communicate client vers ion 4 @ org.apache.hadoop.ipc.client.call(client.java:1070) @ org.apache.hadoop.ipc.rpc$invoker.invoke(rpc.java:225) @ com.sun.proxy.$proxy10.getprotocolversion(unknown source) @ org.apache.hadoop.ipc.rpc.getproxy(rpc.java:396) @ org.apache.hadoop.ipc.rpc.getproxy(rpc.java:379) @ org.apache.hadoop.hdfs.dfsclient.createrpcnamenode(dfsclient.java:119) @ org.apache.hadoop.hdfs.dfsclient.<init>(dfsclient.java:238) @ org.apache.hadoop.hdfs.dfsclient.<init>(dfsclient.java:203) @ org.apache.hadoop.hdfs.distributedfilesystem.

c++ - operator= override not being used -

this question has answer here: why assignment operator not called in case in favor of copy constructor? 2 answers i have assignment: main.cpp polygon &q = polygonlist->top(); polygon p = q; i want use operator override deep copy. polygon.cpp polygon& polygon::operator=(const polygon &obj) { // deep copy here return *this; } polygon.hpp public: polygon& polygon::operator=(const polygon &obj); any idea why not hitting overide? edit know not because debugger isn't breaking on return of override you initializing p using copy constructor. instead of polygon p = q; , try: polygon p; p = q;

oauth 2.0 - How do I upload a file using the Box API using app credentials? -

i want user upload our server , have our server upload file specific folder in box using api. how can this? credentials should use? curl https://app.box.com/api/oauth2/token \ -d 'grant_type=client_credentials&client_id=client_id&client_secret=secret' returns {"access_token":"token","expires_in":3793,"restricted_to":[],"token_type":"bearer"} curl https://upload.box.com/api/2.0/files/content \ -h "authorization: bearer token" -x post -f \ file=@package.json -f folder_id=3306197480 returns {"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"parent","message":"invalid value 'd_3306197480'. 'parent' value 'd_3306197480' not found"}]},"help_url":"http://d

memory management - C++ vector reduce allocation size -

when c++ vector dynamically reduce allocated size in practice. i know allocated space doubles upon insert full vector, it's not clear me when allocation reduced. classical hysteresis halve allocation size upon removal 1/4-full vector. it never shrink allocated memory in absence of explicit direction so. in c++11 there shrink_to_fit call ask implementation this, may not reduce allocated memory. in prior versions have create new copy , swap away old one.

string - AutoSum and Sum return '0' when trying to add numbers imported by SQL -

Image
excel 2007 - anytime click autosum shows 0 , or anytime use formula sum still gives me 0 . this sql query imported using data-connection-sql server , saved sql query in workbook. what gives keeping me totalling? it seems me explanation trying add strings. if so, error checking activated (formulas tab) little triangles (by default green) should clear evidence. these provide easy way convert strings numbers numbers excel can add. select contiguous range starting cell requiring conversion , warning sign should appear: (not top left). click on exclamation mark , on convert number , format of cells in selection converted sum function behave like. much less (because don't see how have done) somehow have acquired leading spaces , when entering data cell formatted text. triangle warning same number stored text no conversion. formula such as: =trim(a1) should however, though depend on type of space (eg not work nbsp - though should not acquire 1 of s

Using win32com via python to scrape excel file for chart objects and convert them to images -

i trying scrape .xlsx excel file chart objects , export them images. similar stackoverflow question found this one attempts same thing. script, however, not seem work (even when correct syntax/methods). willing running in either python 2.7.9 or 3.4.0. have both versions running on computer. here code working with: import win32com.client win32 excel = win32.gencache.ensuredispatch('excel.application') wb = excel.workbooks.open(r'c:\users\emilyn\desktop\charttest.xlsx') excel.visible = true wb.sheets("sheet1").select() wbsheetone = wb.sheets(1) wb.displayalerts = false = 0 chart in wbsheetone.chartobjects(): print(chart.name) chart.copypicture() excel.activeworkbook.sheets.add(after =excel.activeworkbook.sheets(3)).name="temp_sheet" + str(i) temp_sheet = wb.activesheet cht = wb.activesheet.chartobjects().add(0,0,800,600) cht.chart.export("chart" + str(i) + ".png")

javascript - $q.reject and handling errors in AngularJS chained promises -

i'm having trouble understanding basic concept of error handling chaining promises. in order learn rules, have written simple example, guessing result be. unfortunatly doesn't behave though will. have read multiple articles subject perhaps can't details because of poor english language. anyway, here code : var promisestart = $q.when("start"); var promise1 = promisestart.then(function() { return serviceforpromise1.get(); }); var promise2 = promise1.then(function(data1) { return serviceforpromise2.get(data1); },function(error) { return $q.reject(); }); var promiseend = promise2.then(function(data2) { return data2; },function(error) { return error; }); return promiseend; well know can way better coded it's purpose. here code of serviceforpromise1 function : function serviceforpromise1() { ... return $http.

c# - Asp.net mvc5 WPF authentication -

i'm playing around asp.net / mvc5 had idea wanted create wpf login can use login wpf app asp.net info. assume have create login form onto wpf , send mvc website, server verifies them , if credentials correctly emits authentication cookie sent client. client stores cookie further authentication. so means need send post request mvc website verifies username , password, server returns cookie stored client in cookiecontainer. how ever rather stuck on how go ahead , this. as @goobering pointed out in comment above, big of question answered on stack overflow post. you're looking tutorials. more importantly, wpf app going reach out mvc webiste authentication and/or authorization, or going other data well? my suggestion make wcf authorization web service hosted on same website mvc. integrating identity wcf easy, , integrating wcf wpf apps simpler. support getting other data need mvc website. here links: http://www.codemag.com/article/0611051 https://msdn.microsoft.

geospatial - Calculating scale of an image -

i'm working on processing geo-spatial raster data, jog-a raster exact , know imagery supposed to scale of 1:250000, calculate in code not coming correct values thought ask help. here bounds of single image , other values needed calculations. (coordinates in degrees, epsg:4326) meters per degree: 111319.49079327358 image size: x: 1536 y: 1536 dpi: 90 upper left: longitude: -89.54314720812182 latitude: 33.6529242569511 upper right: longitude: -88.8578680230458 latitude: 33.6529242569511 bottom right: longitude: -88.8578680230458 latitude: 33.13518696069031 bottom left: longitude: -89.54314720812182 latitude: 33.13518696069031 i thought say: (deglata - deglatb) * meterperdeg / imagesizey * dpi / 0.0254 33.6529242569511deg - 33.13518696069031deg = 0.51773729626079deg $1 deg * 111319.49079327358m/deg = 57634.2521844373683014174969282m $2 m / 1536px = 37.52m/px $3 m/px * (90px/in * 1in/0.0254m) = 132953.03 which gives scale of 1:132953... not close

ios - Confirm email address exists and is not already taken, using Parse and email Regex -

i @ part of register process confirm if email given user exists , not taken. so far, have regex set , customized how want (i limiting user student email address). - (bool)validateemail:(nsstring *)emailstr { nsstring *emailregex = @"[a-za-z]+\\.[a-za-z]+@[ace]+\\.[tamut]+\\.[edu]"; nspredicate *emailtest = [nspredicate predicatewithformat:@"self matches %@", emailregex]; [self checkemailanddisplayalert]; return [emailtest evaluatewithobject:emailstr]; } i throw alert if email not acceptable. - (void)checkemailanddisplayalert { if(![self validateemail:[_email text]]) { [self.email becomefirstresponder]; // user entered invalid email address uialertview *alert = [[uialertview alloc] initwithtitle:@"error" message:@"enter valid email address." delegate:self cancelbuttontitle:nil otherbuttontitles:@"ok", nil]; [alert show]; } else { // user entered valid email address [self registernewuser]; }

java - Update Data Using Spring Integration JDBC Outbound Gateway -

i need on spring integration jdbc outbound gateway. playing spring integration sample jdbc. add codes update data using jdbc outbound gateway, here spring-integration-context.xml: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemalocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jd

Image path in database vs intelligent folder structure -

assuming want safe 1 profile picture each user of system. better save path image in database or rely on intelligent folder structure like /images/users/user1.png and access image directly? what if have more 1 picture per user? practice? /images/user1/pic1.png so question is, why save picture's path , waste space when know pictures without db queries? this general question apart technologies. it's better assume each user have more 1 picture, if you're absolutely sure of otherwise now.. 2 ways go it: each user have folder pictures. /path/user1/img1.jpg , /path/user1/im2.gif all pictures in same folder, username prefix of filename /path/user_pics/user1_img1.jpg , /path/user_pics/user2_img3.gif personally, prefer former. in cases, won't need store full path of picture in database.. storing image content-type (which determines extension) , filename enough. gives more freedom machine serving image itself.

How to style Android default ViewPager's bar, created from Android Studio template -

Image
i trying create tabbed activity, , i'm using viewpager (actually, android studio created template, didn't know viewpager was). want style tab-bar below (indicated red "circle"): i've tried setting styles.xml tried everything, still, nothing applies that. here code: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // set action bar. final actionbar actionbar = getsupportactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); // create adapter return fragment each of 3 // primary sections of activity. msectionspageradapter = new sectionspageradapter(getsupportfragmentmanager()); // set viewpager sections adapter. mviewpager = (viewpager) findviewbyid(r.id.pager); mviewpager.setadapter(msectionspageradapter); // when swiping between different sections, select corresponding // tab. can use actio

OpenGL / GLU : Is there a built-in function for drawing circles? -

i know there built-in functions drawing rectangles ( glrecti() instance), , thought circle pretty basic usage. is there such built-in function drawing circles? or should implement myself? gludisk() can used so : void gludisk(gluquadricobj *obj, gldouble innerradius, gldouble outerradius, glint slices, glint loops) innerradius , outerradius control size of hole , disk. set innerradius 0.0 render solid circle . slices: number of sides disk (eg. 3 equilateral triangle, 6 washer 20 circle). loops: number of concentric rings rendered eg. 1 circles 2 washers. using larger values loops improves specular lighting , effect of spotlights. official manpage .

If your app is terminated by the iOS system does it generate a crash report? -

while running on device (ios 8) think system may terminating app while suspended either memory or running background task long. suspect because when resume app has returned root view controller, shouldn't possible unless app started fresh. i never see crash report when viewing device logs however. if system terminates app generate crash report? if app killed low memory generates low memory report: when low-memory condition detected, virtual memory system in ios relies on cooperation of applications release memory. low-memory notifications sent running applications , processes request free memory, hoping reduce amount of memory in use. if memory pressure still exists, system may terminate background processes ease memory pressure. if enough memory can freed up, application continue run , no crash report generated. if not, application terminated ios because there isn't enough memory satisfy application's demands, , low memory report generated , stored o

java - Add feed4j dependency in pom.xml -

Image
i cannot add dependency in pom.xml feed4j.jar when select dependency feed4j feed4junit not feed4j. when add dependency in pom.xml <dependency> <groupid>feed4j</groupid> <artifactid>feed4j</artifactid> <version>1.0</version> </dependency> i error missing artifact feed4j:feed4j:jar:1.0 as result when try mvn clean install error package it.sauronsoftware.feed4j not exist any please. feed4j not in maven central repository. have several options: use maven repository has feed4j artifact available. can set own nexus or artifactory. include jar file in project , use maven system scope (see this question example how use it) install dependency manually in local maven repository. here short tutorial how that.

mysql - Php mysql_fetch add me the row number at the begining of each row -

this php code: $query = select * tablename; $result = mysql_query($query) or die((mysql_error())); $count = 0; if (mysql_num_rows($result) > 0){ while( $row = mysql_fetch_array($result)){ $json_output[$count]=$row; $count ++; } } $output = json_encode($json_output); $output = str_replace('[{', '{', $output); $output = str_replace('}]', '}', $output); echo $output; and part of php output: {"0":{"0":"2","gi_id":"2","1":"sample_name.jpg","gi_nome_file":"sample_name.jpg","2":"sample_name","gi_pseudonimo":"s. name","3":"sample name"," as can see, there tag "0", "1" , "2", etc represent column number ( "0" gi_id , "1" gi_nome_file etc) of sql table. why there duplicates? probally can manage output ignorin

javascript - Check if User has Role - Parse Cloud Code -

writing parse cloud function (which uses parse javascript sdk ) , having trouble checking see if current user has role "admin". i'm looking @ web view of role class , role name "admin" exists, if click "view relations" users, shows current user. doubt should matter, "admin" role , current user user role. lastly, "admin" role has acl of public read, shouldn't causing issues either. code follows: ... var queryrole = new parse.query(parse.role); queryrole.equalto('name', 'admin'); queryrole.equalto("users", parse.user.current()); queryrole.first({ success: function(result) { // role object var role = result; role ? authorized = true : console.log('shiet, user not admin'); }, error: function(error) { console.log("bruh, queryrole error"); } }) console.log('after test: auth = ' + authorized); if (!authorized) { response.error(&quo

Update Site for Earlier Version of Spring Tool Suite -

my company's legal department has approved use of spring tool suite 3.6.3 eclipse 4.3. noticed eclipse update site eclipse 4.3 has spring tool suite 3.6.4. there url earlier spring tool suite 3.6.3 version eclipse 4.3 can downloaded? yes, there is. update site sts 3.6.3 on eclipse 4.3 is: http://dist.springsource.com/release/tools/update/3.6.3.release/e4.3 the distribution builds of sts 3.6.3 here: windows (32bit): http://dist.springsource.com/release/sts/3.6.3/dist/e4.3/spring-tool-suite-3.6.3.release-e4.3.2-win32.zip windows (64bit): http://dist.springsource.com/release/sts/3.6.3/dist/e4.3/spring-tool-suite-3.6.3.release-e4.3.2-win32-x86_64.zip osx (64bit): http://dist.springsource.com/release/sts/3.6.3/dist/e4.3/spring-tool-suite-3.6.3.release-e4.3.2-macosx-cocoa-x86_64.tar.gz linux (32bit): http://dist.springsource.com/release/sts/3.6.3/dist/e4.3/spring-tool-suite-3.6.3.release-e4.3.2-linux-gtk.tar.gz linux (64bit): http://dist.springsource.com/release/

c - expected expression before 'long' -

i'm new programming, , i'm using book me write code solve ln(1+x) after user inputs "x". syntax way book has in example keep getting error: expected expression before 'long' on line 28. line 28 line reads long double y = log(1+(x)); . #include <stdio.h> #include <math.h> #define log(x) _generic((x),\ long double: log(1+(x))\ ) int main() { double x; printf("please enter number -1 +1: "); scanf("%f", &x); long double y = log(1+(x)); printf("from c math library: ln(1+x) = %f\n", y); } if new programming, , trying make example work, not use macros @ stage focus on function , data type. start double typical working type of library interfaced math.h . example shows how calculate natural ln log() function. as others have commented, scanf() needs format specifier of %lf double , printf() needs format specifier of %f double . note have tested return value scanf() function as

java - Neo4j 2.1.x ExecutionEngine number of instances -

what best practice instances of executionengine ? remember coming across post on neo4j newsgroup saying 1 instance should shared across app examples can find show suggest otherwise. overall best practice? matter? exactly one . otherwise duplicate or loose caches keeps compiled query plans. you should create somewhere statically graphdatabaseservice , or server extension have injected via @context cypherexecutor . since neo4j 2.2. don't need anymore, can run cypher queries directly via gdb.execute()

c++ - Safely Destroying a Thread Pool -

consider following implementation of trivial thread pool written in c++14. threadpool.h threadpool.cpp observe each thread sleeping until it's been notified awaken -- or spurious wake call -- , following predicate evaluates true : std::unique_lock<mutex> lock(this->instance_mutex_); this->cond_handle_task_.wait(lock, [this] { return (this->destroy_ || !this->tasks_.empty()); }); furthermore, observe threadpool object uses data member destroy_ determine if being destroyed -- destructor has been called. toggling data member true notify each worker thread it's time finish current task , of other queued tasks synchronize thread that's destroying object; in addition prohibiting enqueue member function. for convenience, implementation of destructor below: threadpool::~threadpool() { { std::lock_guard<mutex> lock(this->instance_mutex_); // line. this->destroy_ = true; } this->cond_handle_task_.notify_all();

c# - Why does the ReadLine () method NOT pause for user input? -

i began study c#, ran problem. readline() method not pause user input. started c#, , works on other people's programs, have no idea why. using xamarin on mac. here example code not work: using system; namespace learningc { public class learningsharp { public static void main (string[] args) { console.writeline (console.readline ()); } } } i found out solution. right click on project , select options . then, select general under run tab , check "pause console output" ("run on external console" must checked work.)

java - Do MySQL Connections close automatically when the program exits? -

this question has answer here: will sql connections automatically closed if close jvm? 2 answers if create mysql connection in java program, , program exits main method, happens mysql connection? public static void main(string args[]) { connection conn = getconnection(...); return; } does connection closed automatically? or connection stays alive until times out? no, that's resource leak right there. connection object cease exist because jvm terminates when main() ends, resources allocated on database server stay open while till database decides reclaim them after timeout . this bad practice because if program terminates without explicitly closing database connection , happens database operations (like insert, updates etc.) done before, undefined . some, jdbc drivers commit changes , implicit rollback . it highly recommended not

javascript - Empty oAuth Login Dialog -

Image
back in january started project of mine, left mid jan because of work load. i retake recently. when left it, got working login in facebook both using standard javascript sdk , when moved on parse test online. fast forward yesterday , i'm finding whenever try login, oauth modal dialog never loads, left blank i checked login sdk , parse fb login sdk i'm still having problem any idea? never mind, looks user scope of email no longer 'user_email'.

while loop with the if statement in python -

print ("selection of mode\n easy \n moderate \n tough") selection = int(input("please enter right choice!! > ")) while selection != '': if selection == 1: print("\ngoodluck") elif selection == 2: print('\nyou brave') elif selection == 3: print ('\nyou must kidding') selection = int(input("please enter right choice!!! > ")) i making small program, new python have bit of understanding problem, need know error when user have typed in correct selection 1 or 2 or 3 should go in loop , run if statement. once done should exit. apparently not working perfectly. print ("selection of mode\n easy \n moderate \n tough") selection = input("please enter right choice!! > ") while selection != '': if selection == '1': print("\ngoodluck") break elif selection == '2': print('\nyou brave')

sql - javax.persistence.PersistenceException: [PersistenceUnit: NG] Error while reading JPA XML file: META-INF/SQLQueries.xml -

i have tried several suggested methods resolve java persistence exception have not been successful yet. suggestions or appreciated. below details sqlqueries.xml ----------------------------- <?xml version="1.0" encoding="utf-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/orm_2_0.xsd " version="2.0"> <sql-query name="get_next_num_sp" callable="true"> <return alias = "nextnumber" class="com.utility.numbergenerator.da.numberdaoimpl"> <return-property name="nextseqnum" column="next_seq_num" /> </return> { ? = call test_proc } </sql-query> </entity-mappings> persistence.xml ----

Why this reverse string logic in java wont work in python? -

please explain why logic wont work in python. works in java? def reverse(number): reversednumber = 0; temp = 0; while(number > 0): #use modulus operator strip off last digit temp = number%10; print(temp) #4 #create reversed number reversednumber = reversednumber * 10 + temp; number = number/10; print("reversednumber", reversednumber) reverse(1234) in python 3 dividing 2 integers can return float. in languages 1/2 == 0 . in python 3 1/2 == 0.5 . integer division in python 3 use double division sign, i.e. 1//2 == 0 . note, difference between python 2 , 3. also not work because comments in python written starting # not // .