Posts

Showing posts from September, 2014

ruby - Rails 'link_to' giving an incorrect path to delete a Nested Resource -

i made simple blog application in rails , when tried giving link delete comment rails gave me incorrect link <a data-method="delete" href="/forums/27/comment.7" rel="nofollow">delete</a> this gave me error no route matches [delete] "/forums/27/comment.7" but when changed <a data-method="delete" href="/forums/27/**comments/7**" rel="nofollow">delete</a> by chrome's inspect deleted comment. how generate correct link ? controller def destroy @comment.destroy redirect_to :back end private def find_forum @forum = forum.find(params[:forum_id]) end def set_comment @comment = comment.find(params[:id]) end show.html.haml - @forum.comments.each |c| = c.user.firstname = c.comment - if user_signed_in? - if c.user == current_user = link_to "delete", [@forum, c], method: :delete routes prefix verb uri patt...

android - Customise ListView (Multiple Choices) -

i trying change text color of listview multiple choices. found many questions it, of answers propose create textview layout , allocate adapter solution. when that, checkbox disappear. adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_multiple_choice, countries); listview.setchoicemode(listview.choice_mode_multiple); listview.setadapter(adapter); main_activity.xml <listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/listview" android:scrollbarthumbvertical="@drawable/scroll" /> you can override getview method in arrayadapter , set text color this. arrayadapter<string> list = new arrayadapter<string>(this, android.r.layout.simple_list_item_multiple_choice, countries) { @override public view getview(int position, view convertview, viewgroup parent) { view v = converteview; ...

node.js - Adding www to domain in elasticbeanstalk ngnix -

i have nodejs application running on elasticbeanstalk. want redirect request basedomain.com www.basedomain.com (excluding subdomain) , add https. i have updated .config file in .ebextension folder redirect https following config file: files: "/tmp/45_nginx_https_rw.sh": owner: root group: root mode: "000644" content: | #! /bin/bash configured=`grep -c "return 301 https" /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf` if [ $configured = 0 ] sed -i '/listen 8080;/a \ if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; }\n' /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf logger -t nginx_rw "https rewrite rules added" exit 0 else logger -t nginx_rw "https rewrite rules set" exit 0 fi container_commands: 00_appdeploy_rewrite_hook: command: cp -v /tmp/45_nginx_https_rw...

xsd - Some questions about name spaces on xml? -

is namespace tag, says schema-validator element behaves "so" , behave "same" long tagged namespace ? what default namespaces ? in case belove, <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" targetnamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementformdefault="qualified"> does xmlns:xs mean http://www.w3.org/2001/xmlschema namespace presented xs , elements, not tagged xs, coming namespace http://www.w3schools.com ? is namespace tag, says schema-validator element behaves "so" , behave "same" long tagged namespace? no, xml namespace not tag @ all. namespace in programming language: largely abstract context within names exist , unique. inasmuch given name may exist , have different meanings in different namespaces, correct interpretation of unqualified name depends on knowing or guessing correct namespace (including if has no namespace). ...

python - How to create a comment on a Bitbucket pull request -

how programmatically make comment (preferrably python) on pull request hosted on bitbucket? i have buildbot server continuously running tests on branches hosted on bitbucket, , after runs tests branch, want check pending pull requests , automatically create comment noting test status (e.g. pass/fail). this , this indicate bitbucket has pretty rich api, , has methods listing comments, can't find method creating comment on pull request. according 1.0 api documentation : post new comment creates new comment on request using specified content data. caller must authenticated , have access repository create request. post https://api.bitbucket.org/1.0/repositories/ {accountname}/{repo_slug}/pullrequests/{pull_request_id}/comments --data "content=string" sample --data available in above location. also, according this answer api 2.0 supports reading of pull request comments , api 1.0 needs used manipulate them.

javascript - HtmlWebpackPlugin injects relative path files which breaks when loading non-root website paths -

i using webpack , htmlwebpackplugin inject bundled js , css html template file. new htmlwebpackplugin({ template: 'client/index.tpl.html', inject: 'body', filename: 'index.html' }), and produces following html file. <!doctype html> <html lang="en"> <head> ... <link href="main-295c5189923694ec44ac.min.css" rel="stylesheet"> </head> <body> <div id="app"></div> <script src="main-295c5189923694ec44ac.min.js"></script> </body> </html> this works fine when visiting root of app localhost:3000/ , fails when try visit app url, example, localhost:3000/items/1 because bundled files not injected absolute path. when html file loaded, js file inside non-exist /items directory because react-router hasn't loaded yet. how can htmlwebpackplugin inject files absolute path, express them @ root of /dist direct...

floating point - How does Rounding in Python work? -

i bit confused how rounding in python works. please explain why python behaves this? example: >>> round(0.05,1) # makes sense 0.1 >>> round(0.15,1) # doesn't make sense! why result not 0.2? 0.1 and same for: >>> round(0.25,1) # makes sense 0.3 >>> round(0.35,1) # in opinion, should 0.4 evaluates 0.3 0.3 edit: in general, there possibility python rounds down instead of rounding up. understand "abnormal" thing can happen python rounds down? or may rounded "abnormally" due how stored? (i haven't found case python rounded when expected round down) this design. pythons' documentation : the behavior of round() floats can surprising: example, round(2.675, 2) gives 2.67 instead of expected 2.68. this not bug : it’s result of fact decimal fractions can’t represented float.

asp.net mvc - The "GenerateResource" task failed unexpectedly null refference exception -

Image
this friend's project need, works fine here struggles start up, giving error: severity code description project file line error "generateresource" task failed unexpectedly. system.nullreferenceexception: object reference not set instance of object. @ microsoft.build.tasks.resgendependencies.getresxfileinfo(string resxfile) @ microsoft.build.tasks.generateresource.shouldrebuildresgenoutputfile(string sourcefilepath, string outputfilepath) @ microsoft.build.tasks.generateresource.getresourcestoprocess(list`1& inputstoprocess, list`1& outputstoprocess, list`1& cachedoutputfiles) @ microsoft.build.tasks.generateresource.execute() @ microsoft.build.backend.taskexecutionhost.microsoft.build.backend.itaskexecutionhost.execute() @ microsoft.build.backend.taskbuilder.<executeinstantiatedtask>d__26.movenext() recipesapp i've read many solutions: obj folder if helps any: deleted entire 'obj' folder ...

java - hibernate error: There is no primary key for referenced table -

i'm trying automatically generate table in hibernate , keep getting errors, table refers has primary key defined idk problem is. here's stack trace org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/hibernatejpaautoconfiguration.class]: invocation of init method failed; nested exception javax.persistence.persistenceexception: [persistenceunit: default] unable build hibernate sessionfactory @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1574) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:539) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:476) @ org.springframework.beans.factory.su...

android - Sherlock ActionBar and Sliding menu -

in application want use sliding menu , action bar should use sherlock action bar. i downloaded both libraries. sliding menu 1 : https://github.com/jfeinstein10/slidingmenu , sherlock action bar i able use both libraries separately. need use in application. after searching found have add actionbarsherlock dependency slidingmenu go slidingactivities plan on using make them extend sherlock__activity instead of __activity. while adding sab sliding menu dependency getting error in eclipse. found 2 versions of android-support-v4.jar in dependency list, not versions identical (check based on sha-1 @ time). versions of libraries must same @ time. versions found are: path: c:\users\kamalone\downloads\jakewharton-actionbarsherlock-4.2.0-0-g90939dc \jakewharton-actionbarsherlock-e5c2d1c\library\libs\android-support-v4.jar length: 271754 sha-1: 53307dc2bd2b69fd5533458ee11885f55807de4b path: c:\users\kamalone\downloads\slidingmenu-master\slidingmenu-master\library \li...

java - Prevent JavaFX Window from Stealing Focus -

i'm trying make overlay on screen using javafx , issue i'm having whenever overlay pops up, steals focus whichever program i'm in. issue overlay allows user simulate keyboard key presses using robot class (like on-screen keyboard) , without keeping focus in original window, typed characters have go. i've tried setting modality none, that's default option , doesn't seem doing anything. putting javafx scene in jframe work or there better way in javafx? try when focused -> compute want call stage.toback(); //the focused window prior yours gain focus

Java jdbc warning when using TYPE_SCROLL_ SENSITIVE -

this quoted oca/ocp java® se 7 programmer & ii study guide (exams 1z0-803 & 1z0-804) book : for example, suppose mistakenly set result set type type_scroll_ sensitive when creating statement object. not create exception; instead, database handle situation chaining sqlwarning connection object , resetting type type_forward_only (the default) , continue on. i don't know why setting statement of type type_scroll_ sensitive cause resetting type type_forward_only, missing anything? as per above code setting type type_forward_only connection conn = drivermanager.getconnection("jdbc:derby://localhost:1527/booksellerdb", "bookguy", "$3ller"); statement stmt = conn.createstatement(resultset.type_scroll_sensitive, resultset.concur_updatable); string query = "select * book book.format = 'hardcover'"; resultset rs = stmt.executequery(query); see here: https://docs.oracle.com/cd/a87860_01/doc/java.817/a837...

math - Calculating how "colorful" a color is -

Image
i create ratio between 0-1 of how "colorful" color is, colorful mean: black colors have ratio 0 (no light) white colors have ratio 0 (no saturation) a saturated / lighted color has ratio 1 i tried converting color hsv colorspace , calculating ratio as: ratio = (color.value / 100) * (color.saturation / 100) this works somewhat, feels curve wrong, example hsv(hue=0, saturation=80, value=80) only gives ratio of 0.64 looks close saturated / lighted color. maybe need somehow create "ease-out" on values? thought taking human perception of colors account aswell (using lab or yuv colorspaces) dont think needed here, might wrong. the definition of saturation hsv not want, because not compensate lightness of color. from the wikipedia article on colorfulness : [perceived saturation] proportion of pure chromatic color in total color sensation. where s ab saturation, l* lightness , c* ab chroma of color. this definition u...

sql - Is Order Guaranteed When Inserting Multiple Rows with Identity? -

when inserting multiple rows in table, there guarantee go in in order specify? instance, take following: declare @blah table ( id int identity(1, 1), name varchar(100) not null ); insert @blah (name) values('timmy'), ('jonny'), ('sally'); select * @blah is there guarantee sally have higher primary key timmy ? the similar question asked before. you can specify order by in insert . if that, order in identity values generated guaranteed match specified order by in insert . using example: declare @blah table ( id int identity(1, 1) not null, name varchar(100) not null ); insert @blah (name) select t.name ( values ('timmy'), ('jonny'), ('sally') ) t(name) order t.name; select t.id ,t.name @blah t order t.id; the result is: +----+-------+ | id | name | +----+-------+ | 1 | jonny | | 2 | sally | | 3 | timmy | +----+-------+ tha...

ios - Better way to hide a cell which doesn't make a condition (UITableView) -

i have uitableview hides cells aren't within radius (slider double) . im doing setting working out distance setting height of cells match if statement return 0 . throws bunch of constraint errors , don't believe best way it. so question is, there better cleaner , more elegant way achieve same, hiding cell result? current height function func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat { if usercurrentlocation != nil { let celldata = cachedata[indexpath.row] //let radius: double = radiusslidervalue if celldata.distance > radiusdata.radiusvalue { return 0 } } a better approach distance calculation before tableview loaded, , put valid data different array tableview works off, you're ever presenting rows valid. if data change once tableview has loaded , don't want reload whole table, can use insertrowsatindexpaths:with...

CORS Issue with API running on Web2Py -

i've searching lot , although found similar issues, seems haven't found answer yet , maybe can me. i have following api on web2py framework , accessing angularjs front-end app , having cors issues (i tried * in orign or specific ip , port no results). nevertheless, work ie not chrome or mozilla. @request.restful() def api(): def get(): key = main() #generate random xml , returns key response.headers['content-type'] = '*' response.headers['access-control-allow-origin'] = '*' response.headers['access-control-max-age'] = 86400 response.headers['access-control-allow-headers'] = '*' response.headers['access-control-allow-methods'] = '*' response.headers['access-control-allow-credentials'] = 'true' response.view = 'generic.xml' value = cb.get(key).value #get value stored couchbase return value r...

php - How to insert content in a header of web page from other file? -

i have problem included header in phtml file. have mvc project , view file builded this <?php require_once'header.phtml'; //some php command print stuff reuire_once 'footer.phtml'; ?> when press f12 in google chrome header content apears in body of page, : <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title></title> <style type="text/css"></style></head> <body> <title>userlist</title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <link rel="stylesheet" type="text/css" href="../css/mystyle.css"> <meta name="description" content="mvc minishop project"> <m...

database - How to store id of a record instead of text in parent table -

i have input users regarding skills. have table skills has id primary key. in other table storing user id , skill id many many relationship. problem how know skill entered user in skills table? because have put id of skill in many many relationship table. run each time select statement or there efficient solution available? thanks, how know skill entered user in skills table? in concurrent environment, there no way know that. if select, tells whether row existed @ time of select execution - doesn't tell whether row exists now . example, if select returned empty result, concurrent transaction might have inserted row within few milliseconds took receive select result. so either drastic reduction in concurrency (e.g. through table locks), or learn live it... when insert needed i'd recommend attempt insert (without select) , ignore possible primary key violation 1 . if did separate select , insert steps, you'd still have prepared pk violations, since...

android - identify items in a ListView -

i'm having troubles correct identification of items in listview . there 4 classes matter, it's lot of code @ first i'm going explain logic of classes. enter listactivity , initialize listview execute asynctask downloads json response server, parses it, populates listview objects , sets adapter while showing progressdialog the playlistitem class includes methods data single jsonobject. used parameterize arraylist objects after asynctask done list filled items , looks |button| artist( textview ) - title( textview ) update resolved 1st issue still can't figure out what's wrong buttons 2). set onclicklistener buttons in adapter's getview() method. find out if button identified correctly did nothing changed background. click on button forces background of every 11th or 12th button changed. can't figure out far. i can't proceed getting url , streaming audio until problems resolved, appreciated. classes go below, please ask if appe...

Haskell Maybe type -> type -

i running problem : couldn't match expected type ‘int’ actual type ‘maybe int’ can somehow convert ‘maybe int’ ‘int’?? if index == nothing let index = 0 putstrln(fancyprint2 $ kaasasolevlist !! index) else let index = index putstrln(fancyprint2 $ kaasasolevlist !! index) i tried this, gives me : exception: <<loop>> you have several different options around this first using if statement, small modification (avoid doing though) if index == nothing let index' = 0 putstrln $ fancyprint2 $ kaasasolevlist !! index' else let (just index') = index putstrln $ fancyprint2 $ kaasasolevlist !! index' i'm writing index' here, because haskell doesn't allow overwrite existing variables, let hide them. it's better practice label "modified" versions of variable "prime" symbol ( ' ) @ end. way can access o...

javascript - Image Split Drawer Drop Down Menu -

i love functionality of drop down menu on site: https://squareup.com/ i see it's pretty standard drawer-style drop down, question how image split that. after inspecting code i'm pretty sure don't use 2 images. advice or on appreciated! the image indeed appear twice. if run selector you'll find them. $('.home-page .hero .image, .home-page .banner .image') the second part of image starts first image cut off dropdown, giving illusion image split two. media="screen" @media (min-width: 718px) .hero-image-split .hero .image { background-position: 50% -73px !important; } for couldn't find split, occurs when click on "business types" or "products" on navbar.

haskell - How does ap fromMaybe compose? -

there was, writing function takes value input, calls function on input, , if result of just x , should return x ; otherwise, should return original input. in other words, function (that didn't know call): foo :: (a -> maybe a) -> -> foo f x = frommaybe x (f x) since seems general-purpose function, wondered if wasn't defined, i asked on twitter , , chris allen replied it's ap frommaybe . that sounded promising, fired ghci , started experimenting: prelude control.monad data.maybe> :type ap ap :: monad m => m (a -> b) -> m -> m b prelude control.monad data.maybe> :type frommaybe frommaybe :: -> maybe -> prelude control.monad data.maybe> :type ap frommaybe ap frommaybe :: (b -> maybe b) -> b -> b the type of ap frommaybe looks correct, , couple of experiments seem indicate has desired behaviour well. but how work? the frommaybe function seems clear me, , in isolation, think understand ap - @ least in context o...

ios - When do adjustsFontSizeToFitWidth or boundingRectWithSize change the context.actualScaleFactor? -

when actualscalefactor of nsstringdrawingcontext change? the documentation says: "if specified custom value in minimumscalefactor property, when drawing complete, property contains actual scale factor value used draw string." my code: mybutton.titlelabel!.font = uifont(name: "americantypewriter-bold", size: 40) mybutton.titlelabel?.adjustsfontsizetofitwidth = true mybutton.settitle("\(textstring)", forstate: .normal) let attributes = [nsfontattributename : mybutton.titlelabel!.font] let attributedstring = nsmutableattributedstring(string:textstring, attributes:attributes) let context = nsstringdrawingcontext() context.minimumscalefactor = mybutton.titlelabel!.minimumscalefactor print("context: \(context.actualscalefactor)") let resultingrect = attributedstring.boundingrectwithsize(mybutton.titlelabel!.bounds.size, options: .useslinefragmentorigin, context: context) print("actual context after drawing: \(context.actualscalefa...

I am not able to stop the Android Timer -

i using following code run timer in android app. i want stop timer when time reaches 1 minute 2 minute 3 minute and on. not able understand how it. appreciated. import android.app.activity; import android.os.bundle; import android.os.handler; import android.view.view; import android.widget.button; import android.widget.textview; public class mainactivity extends activity { textview timertextview; long starttime = 0; //runs without timer reposting handler @ end of runnable handler timerhandler = new handler(); runnable timerrunnable = new runnable() { @override public void run() { long millis = system.currenttimemillis() - starttime; int seconds = (int) (millis / 1000); int minutes = seconds / 60; seconds = seconds % 60; timertextview.settext(string.format("%d:%02d", minutes, seconds)); timerhandler.postdelayed(this, 500); } }; @o...

c# - Code First issue with seeding data in cyrilic -

i using seed method populate database. of objects have properties in cyrillic. example: context.wines.addorupdate(new wine() { id = 1, name = "Шардоне", etc........................................ the objects created in database, when check database in ms sql management studio instead of wine's name being "Шардоне", displayed "Øàðäîíå". strangely, when create wine in startup class this: var db = new winesystemdbcontext(); var shardonewine = new wine { name = "Шардоне}; db.wines.add(shardonewine); everything displayed in cyrillic in database. do have idea may cause this? you can specify charset of connectin in connection string . add part connection: charset=utf8; if no results can try change char-set of configuration.cs file. there 2 ways that. close configuration.cs in visual studio editor, right-click on file in solution explorer , select "open with..." -> ...

javascript - How can I add the fisheye lens effect to my hierarchical edge bundling graph? -

i've made hierarchical edge bundling graph similar example provided mike bostock (which i've linked on jsfiddle). problem graph larger makes unable displayed in viewing window without having multitude of nodes overlapping each other because there many (around 1500). made actual circle larger no nodes overlap means you're able view portion of graph , must scroll view rest. eventually tried zooming out of enlarged circle made wholly visible on page, names of nodes small discern. therefore, want implement fisheye lens effect on graph has magnifying effect on small text whenever user hovers on nodes , can therefore read text under "magnifying glass". this code fisheye lens example has no effect when added edge bundling graph. can see desired effect here: http://bost.ocks.org/mike/fisheye/ what must change achieve effect on graph? var fisheye = d3.fisheye.circular() .focus([360, 90]) .radius(100); d3.select(".container").on("mousemove...

How to convert FileInputStream into string in java? -

in java project, i'm passing fileinputstream function, need convert (typecast fileinputstream string), how it.?? public static void checkfor(fileinputstream fis) { string a=new string; a=fis //how convert fileinputstream string print string here } you can't directly convert string. should implement add code method //commented out because not efficient way achieve //stringbuilder builder = new stringbuilder(); //int ch; //while((ch = fis.read()) != -1){ // builder.append((char)ch); //} // //system.out.println(builder.tostring()); use aubin's solution: public static string getfilecontent( fileinputstream fis, string encoding ) throws ioexception { try( bufferedreader br = new bufferedreader( new inputstreamreader(fis, encoding ))) { stringbuilder sb = new stringbuilder(); string line; while(( line = br.readline()) != null ) { sb.append( ...

java - Spring MVC - delete row in SQL with JSP table -

i got issue place "delete" buttons in cart (sql table) want in order when cursor on delete button in example row id 36 link in button suitable row's id, 36. this code: <form action="/onlineshop/cart/selecteditem=${cart.getid()}" method="post"> <div style="padding-right: 40px"> <table border="1"> <tr> <td>id</td> <td>product</td> <td>name</td> <td>company</td> <td>type</td> <td>price</td> <td>action</td> </tr> <c:foreach var="cart" items="${carts}"> <tr> <td>${cart.getid()}</td> <td><img src="${cart.getproduct()}" /></td> <td>${cart.getname()}</td> ...

android - Google Cloud Messaging Push message limit -

is there limit size quantity of push notification cand send devices monthly? i have been reading documentation can't find information clearly. this important me because want developed application client allow them send push notification user using app. just in case useful: app hybrid app built ionic. i have been searching in here: https://developers.google.com/cloud-messaging/ maybe searching wrong. the information found limit of message stored (100 per devices) rest lost !

c++ - Should we include a macro(#define) in both .h & .cpp files -

if use them in both files. going term "macro" in c++ it's replacement mechanism(doesn't know c++ structure) happens in pre-compilation stage. is reason should define macro(#define) in both files or doesn't need or missing anything.? defining macro in .h file , including .h file in .cpp file enough.

ruby - Capistrano: create tasks with roles did not work -

i try create tasks different roles : namespace :foo task :mytasks, :roles => [:a, :b,] task_a task_b end task :task_a, :roles => :a run 'echo a' end task :task_b, :roles => :b run 'echo b' end end when execute 'mytasks' here result : $ cap -n roles=b foo:mytasks * 2013-03-01 16:59:14 executing `foo:mytasks' * executing "echo a" * executing "echo b" all tasks executed, why ? capistrano roles intended associate given server (or multiple servers) particular function, such saying "machine-a" web server while "machine-b" database server, useful because tasks need performed on machines. so roles not intended way conditionally select machine(s) run tasks on @ time when running capistrano, select tasks should run on machines. there is, however, capistrano feature called multistage may you're looking for. allows specify different sets of servers (and as...

java - IllegalMonitorStateException when attempting to wait() a thread -

this question has answer here: illegalmonitorstateexception on wait() call 8 answers i have done research problem , still unable fix issue @ hand. threading new me im having trouble comprehending. in program, starting thread transferring files on timed period. swt being used gui in program. in main ui code have pause , play button. play button , related code: playbutton.addselectionlistener(new selectionadapter() { @override public void widgetselected(selectionevent e) { if(isrunning){ // todo implies runningthread waiting, notify }else{ playbutton.setenabled(false); pausebutton.setenabled(true); try { play(); } catch (ioexception e1) { e1.printstacktrace(); } } } ...

python 3.x - Cleaning up the Garbage Output File -

i pretty new python , tried read jpg file , write simple practice. file not huge, 142 kbytes when used buffer chunks of 50000 bytes read , write new.jpg file, gave limited space error , ate of remaining 4gb of space in c:\ drive on desktop , never released memory. how can see , free memory used python. here code: def main(): buffersize = 50000 infile = open('olives.jpg', 'rb') outfile = open('new.jpg', 'wb') buffer = infile.read(buffersize) while(len(buffer)): outfile.write(buffer) print('.', end = '') infile.read(buffersize) print() print('done') if __name__ == "__main__": main() please let me know how can free memory c:\ drive short in memory. thank you! in loop, never change buffer . need assign read result, or keep writing same original buffer contents on , over, loop never ends. change final line of while loop: while(l...