Posts

Showing posts from July, 2013

java - Cannot inherit from final class error -

what error mean .. runs fine in eclipse not in intellij idea exception in thread "main" java.lang.verifyerror: cannot inherit final class @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclasscond(classloader.java:631) @ java.lang.classloader.defineclass(classloader.java:615) @ java.security.secureclassloader.defineclass(secureclassloader.java:141) @ java.net.urlclassloader.defineclass(urlclassloader.java:283) @ java.net.urlclassloader.access$000(urlclassloader.java:58) @ java.net.urlclassloader$1.run(urlclassloader.java:197) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:190) @ java.lang.classloader.loadclass(classloader.java:306) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:301) @ java.lang.classloader.loadclass(classloader.java:247) @ com.couchbase.client.viewconnection.createconnections(viewconnection.java:120) @ com.couchbase.client.viewconnection.&l

c# - Binding Style to a TextBox -

i have textbox following: <textbox name="txtbackuppath" grid.column="0" grid.row="0" height="auto" textwrapping="wrap" style="{binding path=backuppathstyle}" foreground="{binding path=foregroundcolor}" text="{binding path=backuppath, mode=twoway}" verticalalignment="stretch" acceptsreturn="true" margin="3,3" verticalscrollbarvisibility="disabled" /> in code can set foregroundcolor following without errors: brush _red = brushes.red; backupdirectory.foregroundcolor = _red; backupdirectory datasource tied ui. trying use mvvm pattern set ui elements through properties in code. when try use style like: style style = new style(typeof(textbox)); style.setters.add(new setter(control.foregroundproperty, brushes.goldenrod)); style.setters.add(new setter(control.backgroundproperty, brushes.aqua)); backupdirectory.backuppathstyle = style;

java - Button is not Clickable or not getting any response -

html code button submit in jsp: <button type="button" class="btninactive" name="save" id="savegrid" onclick="savelist()"> <img src="<c:url value="/images/save.png" />" alt="save" title="save" class="vmiddle padright5"> <spring:message code="label.save"/></button> html code mouseover button: <button onclick="savelist()" id="savegrid" name="save" class="btninactive" type="button" disabled="disabled"> <img class="vmiddle padright5" title="save" alt="save" src="/web/images/save.png"> save </button> i tried this: driver.findelement(by.xpath(".//*[@id='savegrid']/img")).click(); webdriverwait wait = new webdriverwait(driver, 15); wait.until(expectedconditions.elementtobeclickable(by.csss

jquery - How do I close the modal from the backdrop? -

so have modal, , once open i'm able close via close button or x. however, able close clicking on backdrop. here code have far close modal. function close_modal() { jquery('#details-modal').modal('hide'); settimeout(function() { jquery('#details-modal').remove(); jquery('.modal-backdrop').remove(); },500); } i think give idea of how work function myfunction() { var modal = document.getelementbyid('mymodal'); var span = document.getelementsbyclassname("close")[0]; span.onclick = function() { modal.style.display = "none"; } // when user clicks anywhere outside of modal, close window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } }

How to use FirebaseUI for Google authentication on iOS in Swift? -

i'm following https://firebase.google.com/docs/auth/ , want use firebaseui ( https://github.com/firebase/firebaseui-ios/tree/master/firebaseui ) authentication. the ui shows , i'm able click "sign in google" , complete web sign in flow. app re-opens auth url, authui function never fires. what's wrong? func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { // override point customization after application launch. firapp.configure() let authui = firauthui.authui()!; nslog("setting delegate"); authui.delegate = self; let googleauthui = firgoogleauthui.init(clientid:firapp.defaultapp()!.options.clientid); authui.signinproviders = [googleauthui!]; msplitviewcontroller = self.window!.rootviewcontroller as! uisplitviewcontroller self.window!.rootviewcontroller = authui.authviewcontroller(); return true } func authui(authui: f

Run html file in browser -

i have html file approx. 5000 lines of css , 2000 of js. how can render file in browser? file can't downloaded computer, can't use traditional file:/// run locally. don't want host online. there way? if open splitting file, suggest using split -l 200 filename command filename name of main file , 200 number of lines want in each file.

Problems transitioning between panels (C# WinForms) -

Image
i'm writing "multi-screened" application in c#. "screens" represent different areas of program i.e. settings, restricted access, administration, etc. the problem i'm having when i'm transitioning between 1 panel , another. during transition process, whole form momentarily glitches , outlines of of controls can seen. text on panels appears block background of other panel , other weird things occur. here's screenshots of i'm trying explain... here's panel i'm transitioning should like: and here's happens in transitioning process: i have function use transition between panels. code follows: delegate void dtranspanel(object pan1, object pan2); private void transpanel(object hide, object show) { if (invokerequired) invoke(new dtranspanel(transpanel), new object[] { hide, show }); else { panel h = (panel)hide; panel s = (panel)show; h.hide();

Git, a reset commit is still in local history -

i check dev branch server , made commit , reset '--hard' because should not modify @ branch, not push server. search changes 'git log', see commit still in it. delete dev branch local dev pull again. sure commit not in dev of server side, did exist in history of local dev. --updated-- sure code not in local dev or remote dev, can see log/commit 'git log' in local dev. why reset commit still in history of local history? make sense?

android - dynamically hide or show TextView in ListView's rows corresponding to title's first character -

Image
i need hide or show label of listview's row if first character of title matched first time in list. attach picture can understand clearly. i tried when create arraylist of contacts : public arraylist<contactitem> getdisplaycontacts(context context) { arraylist<contactitem> contactslist = null; databasehandler db = new databasehandler(context.getapplicationcontext()); try { dao<contactitem,integer> daosubject = db.getcontactdao(); contactslist = (arraylist<contactitem>) daosubject.queryforall(); } catch(exception e) {e.printstacktrace();} collections.sort(contactslist, new comparator<contactitem>() { @override public int compare(contactitem lhs, contactitem rhs) { return lhs.getname().compareto(rhs.getname()); } }); (int =0; i< contactslist.size()-1;i++)

javascript - Using void(0) when function doesn't return anything -

why isn't practice put void(0) when function doesn't return explicitly? function somefunc(a) { // stuffs return void(0); } this when debugging stuffs. thanks. since void(0) resolves undefined , question "why isn't idea return undefined function?". using void(0) alternative undefined bad idea, relatively speaking, because it's more complex undefined , , less explicit. our goal programmers make simple, readable code others read , make sense of. it's bad idea explicitly return undefined function same reason, introduces unnecessary complexity. typeof undefined evaluates undefined . makes writing tests more difficult , gives less insight purpose of function does, say, returning false .

java - Android: Cannot execute method with TextView -

this question has answer here: android.content.res.resources$notfoundexception: string resource id #0x0 3 answers i following beginner's android development course on udacity , have seemed come across simple error, though cannot life of me figure out or how search it. there number increment , decrement button on sides change it. problem comes either when call displayquantity method or when tries set text of quantitytextview. value of quantity change, app closes before changes on screen. public void increment (view view){ quantity = quantity + 1; displayquantity(quantity); } public void decrement (view view){ quantity = quantity - 1; displayquantity(quantity); } private void displayquantity(int quantity) { textview quantitytextview = (textview) findviewbyid(r.id.quantity_text_view); quantitytextview.settext(quanti

javascript - Node.js: "Can't set headers after they are sent" error -

here code: github.repos.getcontent({ user: "user", repo: "repo", path: "path" }, function(err, res) { var content = err; console.log(err, res); }); response.json({ message: 'got content! ' + content}); }); that github command outputs content of file, , manipulate content. however, either says "can't set headers after sent" if put inside function(err,res) part, or says var content hasn't been made yet if outside. how use output , manipulate it?

Numeric Regex Expression for Detection Using Javascript -

i new regex hence long question. know regex expression codes detect different types of numbers in html paragraph tag. integer number (eg: 0 , 1,000 , 1000 , 028, -1 , etc) floating number (eg: 2.3 , 2.13 , 0.18 , .18 , -1.2 , etc) or regex can combine both 1. & 2. -- integer , float number good! tried solution in stackoverflow results undefined/null, else not detectable already ratio (eg: 1:3:4 detect whole if possible) fractional number (eg: 0/485 , 1/1006 , 2b/3 , etc) percentage number (eg: 15.5% , (15.5%) , 15% , 0.9%, .9%) also, know if regex can detect symbols , numbers together in whole (15.5% , 1:3:4), or must split different parts before detection of number can performed (eg: 15.5 + % , 1 + : + 3 + : + 4 ) ? these different expressions meant written javascript code different exceptions of cases later on. expressions planned used regex detects basic integer in attached javascript snippet below: var paragraphtext

ios - objective c Project setup on xcode missing frameworks -

Image
i trying setup objective-c project in xcode. project copied , sent in zip file. trying build code has errors , there missing frameworks. tried running pod install , installed dependencies. in xcode still highlighted red. how fix problem ? thanks i've run pod install , installed dependencies. please see attached image below. and happened in workspace. the podfile became ruby script not sure if has effect. changed default. first time coding in ios have no idea how fix this. me start project. response. you have add missing framework xcode library . to first click on .xproj file , goto general , scroll down , click on linked framework , library . , press + sign add framwork . you can add framework available in xcode library. and other 3rd party framework not available in xcode library have download internet or update pod file add pod related framework.

Separating text in one TextView by a line in Android -

i have textview display stuff database. since don't know how generate number of textview s according database, wonder if there way set visible line after 1 item string. example, list of items book1 love total of 3 book2 love total of 2 as can see, if display in 1 textview , hard determine separate books, wondering if there can separate them. if put books name database in arraylist this public arraylist<string> getallbooks(){ arraylist<string> alarraylist = new arraylist<string>(); database db = getwritabledatabase(); cursor cursor = db.query("books", null, null, null, null, null, null ); if (cursor!=null && cursor.movetofirst()) { do{ string book = cursor.getstring(cursor.getcolumnindex("book_name")); alarraylist.add(book); }while(cursor.movetonext()); db.close(); } return alarraylist; } then can use arraylist create desire output public void

Where did this random git branch come from? -

Image
when run git branch command there branch listed (1) appended it, never created branch name , can't delete using git branch -d command. it, , how delete it? :) edit using accepted answer: its invalid have space part of branch name, not clear how got created, if real branch. you can go low level delete branches directly manipulating .git dir. verify it's under .git/refs/heads , remove file .git/refs/heads/gps-feature-branch* under there. perhaps how branch name manipulated in first place (although git wouldn't recognize space in branch name, can add parens here).

pyvmomi: How to get the sms.StorageManager instance? -

i try sms.storagemanager instance in pyvmomi, , register storage provider later. cannot find way sms.storagemanager. objects retrievecontent() method "sessionmanager", "scheduledtaskmanager", no sms.storagemanager. there way sms.storagemanager? right sms api isnt supported pyvmomi, there wrapper created 3rd party supports it. here link pyvmomi wrapper supports it. example provide using wrapper: from infi.pyvmomi_wrapper import client infi.pyvmomi_wrapper.sms import smsclient # first open "regular" client client = client("vcenter-server", username="myuser", password="pass") sms_client = smsclient(client) storage_manager = sms_client.service_instance.querystoragemanager() storage_providers = storage_manager.queryprovider()

Visual Source Safe 6.0 compatibility with Visual Studio 2015 -

i'm involved in technology upgrade project in company, , know if vss6.0 compatible latest visual studio 2015? thank you. vss not included since vs 2010 due performance issues. according can use visual source safe visual studio 2013? and visual studio 2015 professional , visual sourcesafe (vss) you can choose "microsoft visual sourcesafe" plugin tools -> options -> source control. i suggest use tfs/cvs/git/svn rather vss better version control of application.

ios - Dynamic Height for UICollectionView Cell -

Image
first attempt @ creating collectionview programmatically. used couple tutorials facebook/linkedin-esque layout textview , imageview. great when there image have no idea how make cell dynamically smaller in height when there no image. know have fixed height of 500 being first attempt, not sure how set dynamically adjust. i've seen lot of obj-c examples nothing (that can understand) swift know how implement. func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize { if let textcontent = datasource.posts[indexpath.item].textcontent { let rect = nsstring(string: textcontent).boundingrectwithsize(cgsizemake(view.frame.width, 1000), options: nsstringdrawingoptions.usesfontleading.union(nsstringdrawingoptions.useslinefragmentorigin), attributes: [nsfontattributename:uifont.systemfontofsize(14)], context: nil) return cgsizemake(view.frame.

cmd - Autohotkey script to open command prompt -

i've collected script autohotkey forum lets me open command prompt @ location i'm open in windows explorer. if current window not explorer window prompt opens @ location script present. change behavior , make open c:\ if current window not explorer window. i've tried edit script not working desired. #ifwinactive, ahk_class cabinetwclass controlgettext, address , edit1, ahk_class cabinetwclass if (address <> "") { run, cmd.exe, %address% } else { run, cmd.exe, "c:" } exitapp #ifwinactive the command run cmd.exe in c:\ path is run, cmd.exe, c:\ a full script run cmd window every time this settitlematchmode, 2 ifwinactive, ahk_class cabinetwclass controlgettext, address , edit1, ahk_class cabinetwclass else address = ; exclude specific windows ifwinactive, computer address = ifwinactive, documents address = if (address <> "") run, cmd.exe, %address% else run, cmd.exe, c:\ exitapp

mysql - Filter Rows with time difference -

i have "readings" table columns timestamp datetime channel_id integer value decimal test_id integer now want filter rows test_id can do. in result number of rows much. suppose if use channel number 2,3 , 5 test_id 17 , if log data every second there 10k rows. when plot graph there many data graph lines not visible clearly, make them visible need filter out rows. i need in filtering of rows time difference between 2 records should few seconds lets 10 seconds. in data not consecutive. any appreciated. the sample data follows: 24-05-2016 08:00:55 | 2 | 10.23 | 17 24-05-2016 08:00:55 | 3 | 100.23 | 17 24-05-2016 08:00:55 | 5 | 12.23 | 17 24-05-2016 08:00:56 | 2 | 09.23 | 17 24-05-2016 08:00:56 | 3 | 12.23 | 17 24-05-2016 08:00:56 | 5 | 11.23 | 17 24-05-2016 08:00:57 | 2 | 09.23 | 17 24-05-2016 08:00:57 | 3 | 01.23 | 17 24-05-2016 08:00:57 | 5 | 11.23 | 17 24-05-2016 08:00:58 | 2 | 09.23 | 17 24-05-2016 08:00:58 | 3 | 01.23 | 17

cordova - How to set an image as wallpaper in an ionic app? -

i have image gallery application build using ionic, need user able set current image home screen wallpaper or lock screen wallpaper or both. how achieve using ionic ? there ng-cordova plugin available set wallpaper? any appreciated. thanks your problem seems phonegap setting wallpaper www assets? android there has plugin android set wallpaper, seems long time no maintain it. https://github.com/purplemadcanada/wallpaper-phonegap-plugin ios can't this, because sandbox mechanism programmatically update background wallpaper of ios 7?

can any one help me how to connect database in oracle and the connection string in c# -

protected void page_load(object sender, eventargs e) { oracleconnection con = new oracleconnection(); con.connectionstring = "user id =test;password=test1;datasource=oracle"; myconnection.open(); } above code using. called on page_load. string oradb = "user id =test;password=test1;datasource=oracle"; oracleconnection conn = new oracleconnection(oradb); conn.open(); using (oracledataadapter = new oracledataadapter( "select id emp1", conn)) { datatable t = new datatable(); a.fill(t); // render data onto screen datagridview1.datasource = t; } conn.dispose();

php - accessing uploaded files from hosted website temp folder -

i learning "penetration testing of web server / websites". testing web server security following steps: test 1: through inspect element tools added new form element test 2: filled form elements exists , browse php file through injected input file tag, when submit form, submitted , uploaded file (sure uploaded file pitched in temp folder of website temp folder) test 3: hanged here, because don't know how access php file uploaded step 2? any idea appreciated. cooperation. for uploaded file run directly browser imply temporary folder inside web root major security flaw not find frequently. hopefully few people stupid enough change default configuration option put temporary files in web root.

php - How to extend session time out in code igniter? -

in config.php , session related config in config file follows; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 1800; //30 minutes $config['sess_expire_on_close'] = false; $config['sess_encrypt_cookie'] = false; $config['sess_use_database'] = true; $config['sess_table_name'] = 'rd_sessions'; $config['sess_match_ip'] = false; $config['sess_match_useragent'] = true; $config['sess_time_to_update'] = 300; for normal usage of site session expires after half hour of login. have feature in website user can play timer based tasks. example when user clicks button, timer started, task after times, when done clicks stop button , timer stopped , time saved in database. the problem here task might lats more 30 minutes, session gets expire when user playing timer. can't change sess expiration time in config because other users (who not playing timer

Reading pattern from file and create a bmp image of that in C -

Image
i want read text file using c language.here's file:- you see there pattern in text content on file. 0 means nothing. 9 means black. there coloring scheme 0 9. i have create bitmap image of , color according values in pattern. have adjust 0-256 color scheme. , final output shown below now see pattern in content of text file opposite final output bitmap file (not necessary). darkness of colors in bitmap image according values in pattern of text content. anyone tell me how achieve in c language. i able create bmp file not according pattern in text file. #include <stdio.h> #include <stdlib.h> int main() { char bitmap[1900]; // -- file header -- // // bitmap signature bitmap[0] = 0x42; bitmap[1] = 0x4d; // file size bitmap[2] = 58; // 40 + 14 + 12 bitmap[3] = 0; bitmap[4] = 0; bitmap[5] = 0; int i=0; // reserved field (in hex. 00 00 00 00) for(i = 6; < 10; i++) bitmap[i] = 0; // offset o

ruby on rails 3 - Passing parameters with links -

routes.rb resources :carts resources :cart_items end rake routes: cart_cart_items post /carts/:cart_id/cart_items(.:format) cart_items#create when click on link, should create new item in cart_items: link_to 'add cart', '#' i need link. how pass :cart_id through link.i'm newbie rails. in advance. assuming have @cart , doing link_to 'add cart', cart_path(@cart) suffice.

Exporting results from stationary tests (urca package) from R to excel -

i have conducted adf, pp , kpss tests using urca package. want transfer results r excel. tried using 'xlsx' package, it's library isn't loading tried using write.csv command doesn't export results directly . adf test x=ur.df(bse,type="none", selectlags="aic") x summary(x) please me export results excel .

android - Before save image open popup where u save image internal or external memory -

actually requirement when click on camera , save image on custom directory before create custom directory have open option menu save image internal memory or external memory , picture had save on particular location have choose have sample code please need in android try using : directory chooser this allow choose directories internal/external storage. you can open separate activity or dialog/popup . more details library + sample provided in given link. refer , let me know if helped. i think want. for using in eclipse need download these jar files. have provided links below: com.github.frankiesardo:auto-parcel:0.3.1.jar . com.gu:option:1.3.jar . com.google.auto.value:auto-value:1.1.jar download jar . put them in libs folder. clear , build project. errors gone.

Accessing a Bitnami install on VM from outside devices -

i have apache/php/mysql bitnami install running in vm on windows box. can enter ip of vm host machines browser , site-in-progress comes fine. however, need view site in progress device/computer (mobile testing). how can done? a bit late answer think adds value... most vm software has commonly called 'bridged' mode (it's called 'bridged networking' in virtualbox - don't recall it's called in vmware). in essence allows vm it's own independent ip on lan (just 'real' pc). the downside it's not secure (because vm totally exposed network), upside it's quicker , easier set because don't need muck around port forwarding , there no risk of posts conflicting host or other vms. for full details of networking options in virtualbox see page: http://www.turnkeylinux.org/docs/virtual-networking-explained

android - Modifying Toolbar to add new row -

Image
i'm in process of learning how create toolbar. have searched many areas couldn't find how modify toolbar i'll have 2 rows. 1st row navigation , title. 2nd row search bar example: i did it. removed searchview menu , put main layout. layout xml looks this: <linearlayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical"> <include android:id="@+id/tool_bar" layout="@layout/toolbar_home" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colortoolbar" android:paddingbottom="16dp" android:elevation="4dp"> <android.support.v7.widget.searchview android:layout_width="match_parent" android:layout_height=&qu

android - Chromcast Remoteplayer seek to resume at seek 0 position when using nanohttpd -

chromcast remote player seek resume @ seek position 0 when using nanohttpd server. main issue getting when seek video player in device working fine on tv seek-bar set @ 0 position , music stat @ beginning. when call mremotemediaplayer.seek() in onseekchanged() getting result success on tv seek-bar set @ 0 position , music stat @ beginning. public class webserver extends nanohttpd { fileinputstream fileinputstream; public webserver(){ super(8080); } @override public response serve(string uri, method method, map<string, string> header,map<string, string> parameters, map<string, string> files) { string mediasend=" "; long size=0; fileinputstream fis = null; try { fis = new fileinputstream(path); //byte[] buffer = new byte[(int) fis.getchannel().size()]; size=fis.getchannel().size(); } catch (exc

php - The information from the form is not sending to the database -

it echoing other page not sending database. there php page connect database.so took off connection database in php page got alot of errors. this code: <?php require 'login.php'; $path = 'img/'; if (isset($_post['submit'])) { // grab image post array $fn = isset($_post['fname']) ? $_post['fname'] : ''; $ln = isset($_post['lname']) ? $_post['lname'] : ''; $sex = isset($_post['sex']) ? $_post['sex'] : ''; $city = isset($_post['city']) ? $_post['city'] : ''; $em = isset($_post['email']) ? $_post['email'] : ''; $pass = isset($_post['pword']) ? $_post['pword'] : ''; $confirm = isset($_post['cword']) ? $_post['cword'] : ''; //$gend = $_post['gender']; not using $pic = $_files['pic&

angular - Receiving multiple instances of data from Behavior Subject every time component is initialised -

i have simple router calling service , receiving data behavior subject...when navigate route , comeback receiving multiple values subject...how can destroy observers of subject , create new subject whenever need...? here plunker demo http://plnkr.co/edit/okiljcekskho1zjf5may?p=preview planning destroy observers of subject in ngondestroy... ngondestroy(){ this.srvc.destroysubject(); } can please tell me how destroy observers of behaviorsubject? the behavior expected. export class sample1 { constructor(public srvc:heroservice) { this.srvc.data.subscribe(data=> { console.log(data); }); this.srvc.getdata(); } } in constructor subscribe srvc.data , because data behaviorsubject returns recent emitted value. initialize data null , therefore @ first there no data. then in constructor call this.srvc.getdata() causes event emitted , received subscription (the lines before). if navigate away , back, sample1 initialized again , co

javascript - IE change event on file input -

i trying fire custom function when gets changed. i'm triggering input through button(which has custom styling). when input triggered button, change event doesn't fire, if click "browse" button of input event fires properly. is there way can fix this? note: using delegate since input gets added dynamically. here's setup: $("#parent") .delegate(".browse","click",function(){ $(this).siblings("input[type='file']").trigger("click"); }) .delegate("input[type='file']","change",function(e){ alert("changed"); }) here's fiddle: http://jsfiddle.net/np88n/1/ $("#parent") .delegate(".browse","click",function(){ $(this).siblings("input[type='file']").trigger("click"); }) change in $("#parent") .delegate(".browse","click",function(){ $(this).

multithreading - How to execute dependent tasks in Java 8 without any blocking -

not long ago answered question: executing dependent tasks in parallel in java using future.get() blocking current thread, , there possibility thread pool runs out of threads if many gets() called @ 1 time. how 1 compose futures futures in java? i thought answer question myself, 1 can use completablefutures in java instead of futures. completablefutures allow composition via thencombine method, similiar scalas flatmap. there no blocking happening , 3 threads needed achieve fastest time. import java.util.concurrent.completablefuture; import java.util.concurrent.executorservice; import java.util.concurrent.executors; import java.util.function.bifunction; import java.util.function.supplier; public class barrista { // number of threads used in executor static final int nothreads = 3; // time of each task static final int heatwater = 1000; static final int grindbeans = 1000; static final int frothmilk = 1000; static final int brewing = 1000;

python - Hadoop streaming how to multiply matrix by vector when they're stored in many files -

i have matrix like: 1,1,2 2,3,4 6,4,6 1,2,4 3,6,3 4,6,2 4,5,8 3,4,4 and vector 1,3 4,5 5,4 6,2 they're stored in 2 different files. need multiply them column. matrix of body m(i,j,v), row number, j column number , v value. vector of body v(j,v). i wrote mapper #!/usr/bin/env python import sys # class store matrix records class matrixrecord(object): def __init__( self ): self.i= none self.j= none self.v= none # class store vector records class vectorrecord(object): def __init__( self ): self.j= none self.v= none # lists store objects listofmatrixrecords = [] listofvectorrecords = [] # input comes stdin (standard input) line in sys.stdin: # remove leading , trailing whitespace , split splittedline = line.strip().split(",") # if it's matrix element - body looks # 1,3,6 if(len(splittedline) == 3): x = matrixrecord(); x.i = splittedline[0] x.j = splittedline[

spring - Error in line <context:component-scan="com.gontuseries.hellocontroller" /> -

<?xml version="1.0" encoding="utf-8"?> <!doctype xml> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan="com.gontuseries.hellocontroller" /> <bean id="viewresolver" class= "org.springframework.web.servelet.view.internalresourceviewresolver"> <property name = "prefix"> <value>"/web-inf/"</value> </property> <property name = "suffix"> <value>"".jsp"</value> </pr

ios - Download image directly to a photo album -

currently i'm using alamofire network requests. how can download image directly photo album exists using phphotolibrary photos.framework ? p.s.: don't mind have solution using nsurlsession itself. considerations: file can't stored in disk temporarily. want data in memory , save once disk using photos.framework . i figure out myself. implemented datataskwithrequest nsurlsession . initially thought using nsdata(contentsofurl:) contentsofurl method not return until entire file transferred. should used local files , not remote ones because if you're loading large content , device has slow connection ui blocked. // avoid this! let originalphotodata = nsdata(contentsofurl: nsurl(string: "http://photo.jpg")!) so, possible load content nsdata data task. 1 solution can like: let request = nsmutableurlrequest(url: nsurl(string: urlstring.urlstring)!) request.allhttpheaderfields = [ "content-type": "image/jpeg" ] le

android - marker is not stick to given position on map while spinning the map -

Image
i observed strange behavior of marker on map while spinning/rotating map 1 direction other. in code have moved map center point upward marker location display current ongoing cursor @ bottom of map per suggestion nikunj in post . seems working fine while in zoomed view , when polylinie drown vertically. when polyline drown towards left or right marker displayed in opposite direction expectation of marker draw on polyline. for placing marker is: getting nearest latlng of polyline current location , assigning marker , animating parking polyline's point. following snapshots of issue. 1) when polyline vertically straight : 2) when polyline in right side : 3) when polyline in left side : if has faced same issue please suggest me solve issue. you need set anchor of image on marker. example: markeroptions markeroptions = new markeroptions() // set options marker .anchor(0.5, 0.5);

java - numetriclabz / numandroidchart how to space out the bars in a stacked bar chart / stacked percentage column chart -

i trying create 100% stacked bar chart in android using numetriclabz / numandroidchart library. i have been able draw chart want format things make better since right looking cluttered, tried find solution no avail. i have few questions , great if guys can me out : how can seperate out bars in stacked bar chart / stacked percentage column chart ? how can change colors of bars? how can draw trendline in stacked bar chart ? how put label inside bar? how can remove description @ bottom if want to? is there other chart library should use myself in this, have used mpandroidchart library dont know if has trendline required in project. here code of mainactivity.java : package com.example.android.testingbarchart; import android.app.activity; import android.os.bundle; import com.numetriclabz.numandroidcharts.chartdata; import com.numetriclabz.numandroidcharts.stackedbarchart; import java.util.arraylist; import java.util.list; public class mainactivity extends activity

umbraco - How to create an instance of a model that inherits RenderModel inside UmbracoApiController? -

Image
i'm using umbraco cms. have following model: public class loyaltypromo : rendermodel { public loyaltypromo(ipublishedcontent content) : base(content) { } //properties removed brevity } i want use model inside umbracoapicontroller . this: public class promoservicecontroller : umbracoapicontroller { public async task<object> getall() { var umbracohelper = new umbracohelper(umbracocontext.current); ipublishedcontent content = umbracohelper.typedcontent(1050); var list = new list<loyaltypromo>(); list.add(new loyaltypromo(content)); return list; } } unfortunately doesn't work, nullreferenceexception : error has occurred. object reference not set instance of object. system.nullreferenceexception @ umbraco.web.models.rendermodel..ctor(ipublishedcontent

java - Convert Image to Base64 using Apache Commons -

i'm using base64encoder of sun micro systems convert image base64 string. problem i'm getting warnings during build don't want java code .. public static string encodetostring(bufferedimage image, string type) { string base64string = null; bytearrayoutputstream bos = new bytearrayoutputstream(); try { imageio.write(image, type, bos); byte[] imagebytes = bos.tobytearray(); base64encoder encoder = new base64encoder(); base64string = encoder.encode(imagebytes); bos.close(); } catch (ioexception e) { e.printstacktrace(); } return base64string; } warnings : [javac] /users/lucy/dev/workspace/flsv2/src/util/bufferimage.java:53: warning: base64encoder internal proprietary api , may removed in future release [javac] base64encoder encoder = new base64encoder(); [javac] ^ [javac] /users/lucy/dev/workspace/flsv2/src/util/bufferimage.java:53: warning: base64encoder internal proprietary api , may removed in f

java - Why StatefulSessionComponent cause a memory leak? -

Image
because of java heap space error did heap dump of java ee 7 program running on wildfly 9 server. used eclipse memory analyser analyse dump. eclipse memory analyser reveals 2 following problems same: one instance of "org.jboss.as.ejb3.component.stateful.statefulsessioncomponent" loaded "org.jboss.modules.moduleclassloader @ 0xe0130378" occupies 168 975 304 (36,60%) bytes. memory accumulated in 1 instance of "java.util.concurrent.concurrenthashmap$node[]" loaded "". one instance of "org.jboss.as.ejb3.component.stateful.statefulsessioncomponent" loaded "org.jboss.modules.moduleclassloader @ 0xe0130378" occupies 155 775 312 (33,74%) bytes. memory accumulated in 1 instance of "java.util.concurrent.concurrenthashmap$node[]" loaded "". i have few stateful ejbs on program. mean ejbs never garbage collected ? idea how solve problem ? edit here capture of dominator tree: seems class java.

functional programming - Optimal way of defining constants in a python function -

this might more theoretic question practical one, not make significant difference in runtime of program. @ least not in case. i have received python code imports different ("homemade") functions. 1 function (call func ) called 5 times main script (call main ). in func lot of constants defined in beginning of function. example: import numpy np def func(x,y,z): c0 = np.array([1,2,3]) c1 = np.array([1,2,3]) c2 = np.array([1,2,3]) c3 = np.array([1,2,3]) #do stuff variables x,y,z #return stuff i wondering: when calling function, constants c0,...,c3 defined each time function called, or "fixed" when compiled bytecode when running main script, defined once? yes, defined each time function called. the dynamic nature of python means value of np.array may have changed in time between function's definition , call (and betweeen calls), compiler has no opportunity evaluate them "in advanc