Posts

java - Find first element by predicate -

i've started playing java 8 lambdas , i'm trying implement of things i'm used in functional languages. for example, functional languages have kind of find function operates on sequences, or lists returns first element, predicate true . way can see achieve in java 8 is: lst.stream() .filter(x -> x > 5) .findfirst() however seems inefficient me, filter scan whole list, @ least understanding (which wrong). there better way? no, filter not scan whole stream. it's intermediate operation, returns lazy stream (actually intermediate operations return lazy stream). convince you, can following test: list<integer> list = arrays.aslist(1, 10, 3, 7, 5); int = list.stream() .peek(num -> system.out.println("will filter " + num)) .filter(x -> x > 5) .findfirst() .get(); system.out.println(a); which outputs: will filter 1 filter 10 10 you see 2 first elements of stream proc...

linux - How to remove only the first occurrence of a line in a file using sed -

i have following file titi tata toto tata if execute sed -i "/tat/d" file.txt it remove lines containing tat . command returns: titi toto but want remove first line occurs in file containing tat : titi toto tata how can that? you make use of two-address form: sed '0,/tat/{/tat/d;}' inputfile this delete first occurrence of pattern. quoting info sed : line number of `0' can used in address specification `0,/regexp/' `sed' try match regexp in first input line too. in other words, `0,/regexp/' similar `1,/regexp/', except if addr2 matches first line of input `0,/regexp/' form consider end range, whereas `1,/regexp/' form match beginning of range , hence make range span _second_ occurrence of regular expression.

java - will Camera.Parameters:: setRotation rotate the image taken by samsung s2 camera? -

galaxy s2 takes portrait photos , add them oritentation_rotation_90 exif tag . thus when upload photo server presented in landscape. i'm using min api 8. i'm confused, , i'll appreciate if explain. 1) have tried: exifinterface exif; try { exif = new exifinterface(imagefilename); int orientation = exif.getattributeint(exifinterface.tag_orientation, exifinterface.orientation_normal); exif.setattribute(exifinterface.tag_orientation, string.valueof(exifinterface.orientation_rotate_270)); //also tried exifinterface.orientation_rotate_undefined) exif.saveattributes(); orientation = exif.getattributeint(exifinterface.tag_orientation, exifinterface.orientation_normal); boolean b = orientation == configuration.orientation_landscape; } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } bu...

ios - UIButton not changing anything with @selector - new Issue -

need help. trying change image of imageview using programmed button. copied of sample codes out here. sitting on highlighted button works not doing else when clicked. thanks. thanks replies. managed change photos created more problem. believe clear that new xcode. new problems: 1. new image stays on top cannot access button. 2. have image changed when button highlighted. 3. new image, created warning: "hides instance variable" on relayimages properties. again. .h file -(void)changelabel:(uibutton *)sender; -(void)addmybutton; -(void)addmyimages; -(void)addmylabel; @property (nonatomic) uibutton *playbutton; @property (nonatomic) uiimageview *relayimages; @property (nonatomic, strong) uilabel *checkstatuslabel; @synthesize relayimages; .m file - (void)viewdidload { [super viewdidload]; [self addmyimages]; [self addmybutton]; [self addmylabel]; // additional setup after loading view, typically nib. } -(void)addmybutton { uibutton *playbutton = [[uibutton a...

c# - TextBox doesn't appear in code-behind even though I regenerated the designer.cs file -

i have little problem project. added textboxes .aspx file , can't see them in .aspx.designer.cs , hence can't use them in aspx.cs . here .aspx file : register.aspx: <%@ page title="register" language="c#" masterpagefile="~/site.master" autoeventwireup="true" codebehind="register.aspx.cs" inherits="learnef.account.register" %> <asp:content id="headercontent" runat="server" contentplaceholderid="headcontent"> </asp:content> <asp:content id="bodycontent" runat="server" contentplaceholderid="maincontent"> <asp:createuserwizard id="registeruser" runat="server" enableviewstate="false" oncreateduser="registeruser_createduser"> <%-- <layouttemplate> <asp:placeholder id="wizardstepplaceholder" runat="server"></asp:place...

grails - How can I access individual values in a gsp file that are generated in a <g:each> tag? -

Image
i have following code in gsp file, used editing individual values of existing list (patientpts) <g:each var="points" in="${patientpts}"> <b>term: ${points.term} - <g:if test="${points.type.equals('c')}">calculus<br> </g:if> <g:else>perio<br> </g:else></b> <label for="${points.id}01">class 0/1:</label> <input type="text" name="class_01" value="${points.class_01}" id="${points.id}01"> <br> <label for="${points.id}2">class 2:&nbsp;&nbsp;&nbsp;</label> <input type="number" name="class_2" value="${points.class_2}" id="${points.id}2"> <br> <label for="${points.id}3"...

Call Graphs or Control-Flow-Graph for Objective-C (iOS app) -

are there call-graph and/or control-flow-graph generators objective-c ios apps? call graph - http://en.wikipedia.org/wiki/call_graph call graphs gives inter-procedural view of program. in call graph, edge between 2 nodes f , g: f --> g represents fact subroutine f calls subroutine g. control flow graph - http://en.wikipedia.org/wiki/control_flow_graph some static tool let me access graph using api/code? there way generate call graphs ios apps? or record names of methods invoked iphone application user interaction event. i'm not sure if got right, can print current call stack way: nslog(@"%@", [nsthread callstacksymbols]);