Posts

Showing posts from February, 2012

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]);

asp.net - High CPU Usage by IIS even after I stop all the websites -

i have asp.net mvc 5.1 website on vps , until few days ago went without problems. has 4 gb of ram, quad core cpu (3 ghz) , ssd windows drive (currently 10 gb free space) don't think it's hardware issue. problem started after installed wordpress using web platform installer might coincidence. when restart vps smooth. after couple of hours cpu usage of w3wp.exe goes 100% , never comes down. stopped websites running , waited few minutes , it's still @ 100% i'm sure it's not of websites. there way me troubleshoot problem coming from? can guess should start? update: i restarted defaultapplicationpool in server related 1 of websites running on server , dropped cpu usage of iis 3. started again , it's going on 3% cpu , website functional. think it'll go 100% though! i followed tutorial mentioned @ andrei , confirmed it's iis that's taking high cpu , it's main site that's taking cpu. confirmed creating new application pool , cha...

c# - How do I select text in RichTextBox while keeping keyboard focus in another TextBox -

i'm working on chat window in wpf hosts forms.richtextbox. <windowsformshost x:name="wfh"> <wf:richtextbox x:name="txtmain" hideselection="false" readonly="true" multiline="true"/> </windowsformshost> below richtextbox regular wpf textbox . <textbox x:name="txtsend" textwrapping="wrap" acceptsreturn="true"/> i'd keyboard focus stay on textbox , yet still allow user select text in wfh's richtextbox , scroll. i've tried changing keyboard focus on mouseup in txtmain , cannot scroll, , it's not possible copy using ctrl+c. any ideas? you might want take @ sample . if want multiple focus have use focusscope . sample code link static void ongotkeyboardfocus(object sender, keyboardfocuschangedeventargs e) { iinputelement focusedelement = e.newfocus; (dependencyobject d = focusedelement dependencyobject; d != null; d = vi...

winforms - c# changing window size automatically -

i student working on windows forms application. in application have form pop window shows label. want change window's size according label's size. example if label has 3 lines, should show of lines automatically. right shows 1 line. how can fix problem? you need calculate size of text using font settings of label in pop-up form. here's example of pop-up form's load event: private void popup_load(object sender, eventargs e) { messagelabel.text = texttoshow; graphics gfx = this.creategraphics(); sizef textsize = gfx.measurestring(messagelabel.text, messagelabel.font); size borders = this.size - this.clientsize; this.size = new size((int)textsize.width, (int)textsize.height) + borders; } this code presumes have property called texttoshow pass message displayed form: public string texttoshow { get; set; } you can open pop-up form this: popup popup = new popup(); ...

javascript - URL Encoding issues - with decimals -

http://jsfiddle.net/3u4hn/1/ i have added comments in code each function trying achieve here. using escape match value in url (where encoded.) able handle values except values decimals. example if have: var s = "9%252e5|red|blue"; var itemtoremove = escape("9.5"); //escape match value in 's'. as '.' can not encoded/escaped not able match 1 url, ideas on how deal kind of issue.

exit android application programmatically -

i have 2 activities, first splash activity. know how exit application second activity homepage. i've used method works takes launcher. public void appexit() { this.finish(); intent intent = new intent(intent.action_main); intent.addcategory(intent.category_home); intent.setflags(intent.flag_activity_new_task); startactivity(intent); } whenever wish exit open activities, should press button loads first activity runs when application starts clear other activities, have last remaining activity finish. apply following code in ur project intent intent = new intent(getapplicationcontext(), firstactivity.class); intent.setflags(intent.flag_activity_clear_top); intent.putextra("exit", true); startactivity(intent); the above code finishes activities except firstactivity. need finish firstactivity's enter below code in firstactivity's oncreate if (getintent().getextras() != null && getintent().getextras().getboolean(...

android: Does device admin apps get deleted after factory reset? -

i have application device admin , wondering if while application still has device admin privileges, if factory reset preformed app deleted, thank help. yes, think so. apps deleted data won't make sure.

Grails: Read Oracle Database User Roles -

i'm working on groovy/grails project display roles user assigned in oracle database. possible query information oracle server via groovy/grails? if is, pointers on how appreciated. there lot of oracle metadata views available. first of there prefix dba_, all_, user_ describes how data see (depending on permissions). list dba_ prefix, replace more restrictive prefix. you interested in views: dba_roles dba_role_privs role_tab_privs dba_tab_privs dba_users session_privs session_roles table_privileges

c - Poll utilisation for blocking -

how block poll gets activated when press keyboard button. because continues alone without event. i have read manual that. while(i<5){ struct pollfd fds[2]; int timeout_msecs = 500; int ret; fds[0].fd=stdin_fileno; fds[0].events=pollin | pollwrband | pollhup; ret = poll(fds, 2, -1); snprintf(buffer, 12,"%d",ret); //write_raw(7,i,"z",1); if(ret > 0) { // write_raw(3,i,"a",1); if (fds[0].revents & pollin) { // write_raw(4,i,"b",1); // write_raw(3,1,buffer,1); posx=posx-1; write_raw(posy,posx,"_|_",3); sleep(5); fds[0].events = pollhup; } if(fds[0].revents & pollhup){ write_raw(4,i,"a",1); } } fds[0].events=null; i++; } ...

php - Add a string after each item in Wordpress menu -

i trying add special character display » alongside each menu item in wordpress. so example about » contact » , on... here's code <li><?php echo $children; echo '»'; ?></li> i expected job, puts » below list. here's full code <?php if($post->post_parent) { $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); $titlenamer = get_the_title($post->post_parent); } else { $children = wp_list_pages("title_li=&child_of=".$post->id."&echo=0"); $titlenamer = get_the_title($post->id); } if ($children) { ?> <h2 class="left_title"> <?php echo $titlenamer ?> </h2> <ul class="left_body"> <li><?php echo $children; echo '»'; ?></li> </ul> if $children variable ...

ios - getting adjustsFontSizeToFitWidth to work with constraints for snug content -

Image
this little view control i've written test out issue i'm having constraints , adjustsfontsizetofitwidth. little thing add's , remove's words label see how various content sizes in label_title effect layout. desired layout snug around label_title (with label_count taking rest of room). unfortunately not quite snug yet. here 3 view states i've screen captured illustrate lack of snugness on blue title i'm trying fix. following full source of view controller run view. #import "mainviewcontroller.h" @interface mainviewcontroller () // stuff test our problem @property(nonatomic,strong) uibutton * addbutton; @property(nonatomic,strong) uibutton * removebutton; // our problem @property(nonatomic,strong) uiview * view_labels; @property(nonatomic,strong) uilabel * label_title; @property(nonatomic,strong) uilabel * label_count; @end @implementation mainviewcontroller // synthesize views constraint mapping @synthesize label_title; @synthesize...

memory - What is an Efficient way to load apk icons in Android? -

i working on small file manager helping me learn android development , ran few issues loading apk icons apk files. trying load icon assoicated apk. planning on loading in adapter. here method using: public bitmap getapkbitmap(file f) { packageinfo packageinfo = getcontext().getpackagemanager().getpackagearchiveinfo(f.getabsolutepath(), packagemanager.get_activities); applicationinfo appinfo = packageinfo.applicationinfo; if (build.version.sdk_int >= 8) { appinfo.sourcedir = f.getabsolutepath(); appinfo.publicsourcedir = f.getabsolutepath(); } drawable icon = appinfo.loadicon(getcontext().getpackagemanager()); bitmap bmpicon = ((bitmapdrawable) icon).getbitmap(); return bmpicon; } problem: it works ok, problem whenever have lot of apks, or scroll little fast, app crashes , run few memories. plus whenever scrolling, laggy , isn't smooth @ all. you need implement lazylist sho...

linux device driver - How to call compat_ioctl or unlocked_ioctl? -

i'm trying implement driver rtc (real time clock). used ioctl function in kernel 2.6.32 . worked fine. when run same driver in kernel 3.13.0, gave error ‘struct file_operations’ has no member named ‘ioctl’ when changed ioctl unlocked_ioctl , compat_ioctl , compiled , moduled inserted. but calling ioctl in user application not invoking ioctl function in module. function have use in user application invoke compat_ioctl or unlocked_ioctl ? check arguments in driver define structure file operation definition like static struct file_operations query_fops = { .owner = this_module, .open = my_open, .release = my_close, #if (linux_version_code < kernel_version(2,6,35)) .ioctl = my_ioctl #else .unlocked_ioctl = my_ioctl #endif }; define ioctl #if (linux_version_code < kernel_version(2,6,35)) static int my_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg) #else static long my_ioctl(struct file *f, unsigned i...

ios - UIPopoverController presentPopoverFromBarButtonItem allows to press navigation button twice -

i using code below presenting uipopovercontroller view: [popover presentpopoverfrombarbuttonitem:sender permittedarrowdirections:uipopoverarrowdirectionup animated:yes]; so works good, still able press uibarbuttonitem sender in code above. so need disable button when popover shown self or there solution? use method instead, toolbar view containing sender: [popover presentpopoverfromrect:sender.frame inview:toolbar permittedarrowdirections:uipopoverarrowdirectionany animated:yes];

asp.net mvc 5.1 - mvc 5 browse icon missing on window phone 8 -

Image
i created blank mvc 5 app - changed nothing. after publishing everthy works fine - except no "navigation icon" on wp8 device. (small font) full navigation bar on wp7 device. icon on galaxy tab. but on wp8 device (tested mobile desktop setting in ie) nothing. if switch landscape see "about" , "contact" links not "register / login". when turn portrait - "about" , "contact" visible till refresh page. gone again. the device tested lumia 1020 wp8 (8.0.10517.150) german (768 x 1280). got screenshots results: as can see - no "menu box" on right. checked lumia 920 (wp8) - same results. i found working solution. after finding link http://timkadlec.com/2013/01/windows-phone-8-and-device-width/ checked other (there linked)article @ http://mattstow.com/responsive-design-in-ie10-on-windows-phone-8.html adding (found @ "update: january 15 2013) script (function() { if ("-ms-user-select" in...

excel - Procedure does not paste value in the destination sheet -

ok wrote small sub : sub dingo() dim apriori dim e integer dim n integer dim rr integer dim yolk integer dim timy integer 'timy = yeah.count rr = activeworkbook.worksheets.count yolk = rr e = 1 each apriori in yeah 'we need loop on copying mechanism!!!-re-test dim rng range if trim(apriori) <> "" sheets(yolk).range("1:1") set rng = .find(apriori, .cells(.cells.count), xlvalues, xlwhole, xlbyrows, _ xlnext, false) yolk = yolk - 1 'e = 1 if not rng nothing application.goto rng, true activecell.offset(26, 0).copy worksheets("extractions").range("b2").offset(, e).paste e = e + 1 else msgbox "nothing found" end if end end if next apriori end sub it supposed find value...

html - Bootstrap li a padding 0 not working -

i'm trying set padding 0 px hyperlink inside li tag not working. if set in inline specific hyperlink working fine. html <div class="container"> <div class="row"> <div class="col-xs-2"> <ul class="nav nav-pills nav-stacked "> <li class="active"><a href="nokia-phones-1.php">nokia</a></li> <li><a href="samsung-phones-9.php">samsung</a></li> <li><a href="motorola-phones-4.php">motorola</a></li> <li><a href="sony-phones-7.php">sony</a></li> </ul> </div> <div class="col-xs-10"> <h2>most viewed</h2> </div> </div> </div> css @import url("http://netdna.bootstrapcdn.com/bootswatch/...

android - How to set offset of ListView's scrollbar from the right -

please read before answering may not question think is here listview <listview android:id="@+id/ist" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@color/ca” android:dividerheight="@dimen/h1” android:gravity="center" /> everything working fine, except scrollbar apparently has paddingright or layout_marginright didn't set. scrollbar -- not row items populate adapter. seeing scrollbar showing 10dp right edge while content of rows fill screen's width. want scrollbar show entirely right of contents not visual superposition along z-axis. try playing scrollbarstyle . i've found android:scrollbarstyle="outsideoverlay" works/looks best. controls scrollbar style , position. http://developer.android.com/reference/android/view/view.html#setscrollbarstyle(int) public void setscrollbarstyle (int style...

c# - Shortest Path from city 0 to N (by road/ by Air mixed cost) -

okay, need nudge in right direction. have array of costs of travelling city 0 n , array of costs of travelling city 0 n flight. have limit k on number of flights can take when travelling. example n = 3 // there 3 cities visited 0->1 ->2 ->3 in consecutive order roadtime = { 1, 2, 3}; flighttime = { 2, 1, 6}; k = 2; //take maximum of 2 flights i allowed travel road or use road , @ k flights , find minimum cost of travelling 0 3 in example. what tried: started out hand trying find possible solution , came binary tree couldn't represent tree structure in code (c#) without pulling hair out - i'm new graphs think applying them. in process of working out stumbled on idea and, thinking had nailed it, realized find permutations of trip 0 n mix of road cost , flight cost minimum cost: public int mintime(int n, int[] roadtime, int[] flighttime, int k) { int n = 0; int min = roadtime.sum(); while (k > 0) { char[] s ...

How to map Java overloaded constructors to Frege functions -

java (unfortunately) supports constructors , methods overload. example, hashmap has 4 constructors. in frege can't do: data map = native java.util.map data hashmap = native java.util.hashmap native new :: () -> stmutable s hashmap native new :: int -> stmutable s hashmap native new :: int -> float -> stmutable s hashmap native new :: mutable s map -> stmutable s hashmap this doesn't compile because can't bind 4 times "new". possible have 4 "java constructors" in frege datatype? overloaded constructors , methods can defined using | : data hashmap k v = native java.util.hashmap native new :: mutable s (map k v) -> stmutable s (hashmap k v) | () -> stmutable s (hashmap k v) | int -> stmutable s (hashmap k v) | int -> float -> stmutable s (hashmap k v) you can use https://github.com/frege/native-gen starting point generate frege code java class....

c++ - converting QImage to cv::Mat by using raw data -

i want convert svg graphic opencv mat object. therefore svg graphic loaded qsvgrenderer object , afterwards converted qimage object use raw data create final mat object: void scalesvg(const cv::mat &in, qsvgrenderer &svg, cv::mat &out) { if (!svg.isvalid()) { return; } qimage image(in.cols, in.rows, qimage::format_argb32); // qpainter paints image qpainter painter(&image); svg.render(&painter); std::cout << "image byte count: " << image.bytecount() << std::endl; std::cout << "image bits: " << (int*)image.constbits() << std::endl; std::cout << "image depth: " << image.depth() << std::endl; uchar *data = new uchar[image.bytecount()]; memcpy(data, image.constbits(), image.bytecount()); out = cv::mat(image.height(), image.width(), cv_8uc4, data, cv_autostep); std::cout << "new byte cou...

c++ - QSplitter - changing the size of QTabWidget -

i have qtabwidget , layout. want tabs of qtabwidget occupy width of qtabwidget have this. following method expands 2 tabs in qtabwidget same size qtabwidget void contacts::adjusttabs( int pos, int index ) { std::string orig_sheet = ui.tabwidget->stylesheet().tostdstring(); qstring new_style = qstring("qtabbar::tab { width: %1px; } ").arg((ui.tabwidget->size().width() /ui.tabwidget->count())); std::string t = new_style.tostdstring(); orig_sheet = orig_sheet + t; ui.tabwidget->setstylesheet(orig_sheet.c_str()); } the above method works fine. problem starts when qtabwidget set in qsplitter layout along other layout.at startup construction above method not seem work instance have this someclass::someconstructor() { ui.setupui(this); ......... qobject::connect(ui.splitter,signal(splittermoved(int,int)),this,slot(adjusttabs(int,int))); adjusttabs(0,0); } now when form appears horizontal size of tabs remain unchanged (...

How to create a macro that generates another macro in SISC / Scheme? -

in guile or using srfi-46 possible shown in specifying custom ellipsis identifier . possible in sisc or "pure scheme" r5rs? i know possible without using ellipsis, if need use inner ellipsis example bellow? (define-syntax define-quotation-macros (syntax-rules () ((_ (macro-name head-symbol) ...) (begin (define-syntax macro-name (syntax-rules ::: () ((_ x :::) (quote (head-symbol x :::))))) ...)))) (define-quotation-macros (quote-a a) (quote-b b) (quote-c c)) (quote-a 1 2 3) ⇒ (a 1 2 3) the macro expander used in sisc, psyntax, supports different way inner ellipses, using ... macro. can write applying ... macro each inner ellipses want use: (define-syntax define-quotation-macros (syntax-rules () ((_ (macro-name head-symbol) ...) (begin (define-syntax macro-name (syntax-rules () ((_ x (... ...)) '(head-symbol x (... ...))))) ...

arrays - Perl while loop won't exit when blank line is entered -

i trying print sum, maximum, , minimum values of list of numbers struggling working. when press enter loop should exit program keeps running use strict; use warnings; @items; ( $sum, $max, $min ); while ( chomp( $num = <stdin> ) ) { last if ( $num eq '\n' ); $max ||= $num; $min ||= $num; $sum += $num; $max = $num if ( $num > $max ); $min = $num if ( $num < $min ); push( @items, $num ); } printf( "entered numbers are: %s \n", join( ', ', @items ) ); print( "sum of numbers : ", $sum ); print "\n"; print( "minimum number : ", $min ); print "\n"; print( "maximum number : ", $max ) you can't use chomp inside while condition this while (chomp(my $num = <stdin>)) { ... } because while loop needs terminate when <> returns undef @ end of file. must put chomp first statement of loop the simplest way exit loop check whether input co...

Windows PhoneToolkit ListPicker: implementing a countries list as in the settings? -

Image
i have list of countries want display in list similar in phone settings app i tried using toolkit's listpicker had poor performance in loading list size large, seems known issue listpicker. is there alternatives implementing such list ? i know old question, here's solution worked me: implement new page listbox. in new page, when item selected, save selected item/index in phoneapplicationservice.current.state then navigate backwards , retrieve saved item/index page state.

python regex invalid syntax -

i testing code current 2600 magazine wordlist generator based off bunch of searches in google. invalid syntax line: results.extend(re.findall("<a href="/%201d([^/%201d]*)/%201d">class=(?:1|s)",data.read())) i new regex did research on basics of re , seemed easy still didn't understand /%201d. did search on , found thats it's hex of char code. still stuck on making work. here rest of code. line i'm having problem line 36. this function: import re, sys, os, urllib ### custom useragent ### class appurlopener(urllib.fancyurlopener): version = "mozilla/5.0(compatable;msie 9.0; windows nt 6.1; trident/5.0)" urllib._urlopener = appurlopener() uopen = urllib.urlopen uencode = urllib.urlencode def google(query, numget=10, verbose=0): numget = int(numget) start = 0 results = [] if verbose == 2: print("[+]getting " + str(numget) + " results") while len(resu...

java - "NullPointerException: null" in play framework -

i new play framework , have project java in play framework connected mongodb via morphiaplay. problem cannot add data. of code public class sign extends controller{ static form<group> groupform = form(group.class); public static result index() throws exception { // redirect "group result return redirect(routes.sign.group()); } public static result group() { return ok(views.html.sign.render(group.all(), groupform)); } public static result newgroup() { form<group> filledform = groupform.bindfromrequest(); if(filledform.haserrors()) { return badrequest(views.html.sign.render(group.all(), filledform)); } else { group.create(filledform.get()); return redirect(routes.sign.group()); } } } @entity public class group { @id public objectid id; @required public string name; public string email; public string username; public string passwo...

Project on Google go, imports of libraries -

everyone. i new go language , trying understand basics of building go applications. met following problem. for example, using other libraries in project. have them locally, on computer, project works fine. i loading code on github , programmer download it. understand, code won't work, because programmer doesn't have libraries used. so question is: best way share project libraries has? should upload these libraries in separate repositories? use project, people need inside code detect libraries using download them 1 one? for example, in java there such thing maven or ant, downloads required dependencies. there tools go? let's call main file of project main.go , using own library: mathutil.go what best way make project run on other computers? go's dependencies work using maven or ivy transitive dependencies. when "go get" of package, depend on automatically download. for example, in source: import "github.com/foo/bar" g...

c++ - How to implement the extraction operator in a class? -

i have class reads parts of binary file variables of different types. class foo { public: size_t getsizet(); float getfloat(); std::string getstring(); private: std::ifstream stream; }; now i'd implement stream extraction operator described in answer . class foo { public: foo &operator>>(foo &foo, size_t &value); foo &operator>>(foo &foo, float &value); foo &operator>>(foo &foo, std::string &value); private: std::ifstream stream; }; the code fails compile error message: error c2804: binary 'operator >>' has many parameters . how override stream extraction operator? should distinguish between types , chainable. as free function, operator signature should be: foo& operator >>(foo& foo, size_t& value); as member function (your case), should be: foo& operator >>(size_t& value);

Linux: Raw Sockets Sent Packets Not Received Locally Under KVM -

i've been trying send udp packets using raw socket, however, sent packets not received locally. same packets received if sent remote destination. test performed under kvm. same test seems working under parallels. the socket set with: raw_socket = socket (af_packet, sock_raw, htons (eth_p_all)); there's receive filter attached , set promiscuous. packets received correctly. sent packets received in wireshark , analysed correctly. however, local program (e.g. nc -l -u -p ...) not receive packet. if send same packet remote destination, packet received correctly. fact wireshark receives packet suggests not dropped iptables rules (i've checked drop rules counters , there no dropped packets). it seems if packet routed not reprocessed network stack, if makes sense. it's supposed example code in network course, , currently, i'm losing face in front of students. hope none of them on list ;-). would appreciate help, yuval. a few comments code. brevity, ...

ruby - Jquery-fileupload-rails not working with multiple-part form -

i'm trying crazy jquery-fileupload functionality work carrierwave: http://railscasts.com/episodes/381-jquery-file-upload?autoplay=true and causing me kinds of problems. have 3 models - projects, versions , layers. within project, i'm trying create both version , several associated layers within same form (from new.html.erb file in views/versions). i'm following ryan bates railscast #381 , can't seem files upload automatically when selected directly in new view. (on new version page, if select several layer files click 'create version' button, associated layer files upload successfully. in tutorial upload right away when selected via jquery without having click 'create' button. main difference between & i'm trying is uploading files 'paintings' index page...where trying display uploaded files directly on 'new.html.erb' form page...& when user clicks 'create version' form creating both new version , new ass...

javascript - ajax request xml from php -

i have google map, gets markers loaded based on date variable, in php. default date current date. want date changeable, through form. on page map is, have form, users can select date, , want map reload markers based on date selected. have onchange event call mytest(); function, re-load map. can't work, when date changed, nothing happens. here code. javascript function mytest() { var map = '' function mymap(){ var im = 'http://www.robotwoods.com/dev/misc/bluecircle.png'; var custommarker = 'http://findmyyard.com/images/markericon.png'; if(navigator.geolocation){ navigator.geolocation.getcurrentposition(locate); } else { alert('please enable "location sharing"') } function locate(position){ var mylatlng = new google.maps.latlng(position.coords.latitude, position.coords.longitude); var mapoptions = { zoom: 12, center: mylatlng, maptypeid:...

python - How to append a list with a single string to a list? -

i wondering how able append list list? x = [] x.append(list(('h4','h3'))) print x # [['h4', 'h3']] x.append(list('h4')) print x # [['h4', 'h3'], ['h','4']] i wondering how [['h4', 'h3'], ['h4']] instead of [['h4', 'h3'], ['h','4']] . scoured web , saw x.extend isn't wanted :\ you can use [] instead of list : x.append(['h4']) the list function (which constructs new list) takes iterable in parameter , adds every element of iterable in list. but, strings iterable in python, each element (characters here) added elements in list. using [] shortcut avoid that. from documentation : list([iterable]) return list items same , in same order iterable‘s items. iterable may either sequence, container supports iteration, or iterator object. if iterable list, copy made , returned, similar iterable[:]. for instance, list(...

java - ClassFormatError when defining class in OSGI environment -

i'm having problems little project i'm working on. in project i'm trying dynamically create classes configuration string , load jvm. when in "normal" environment (unit tests) works fine. when try create classes in osgi environment (apache karaf) receive classformaterror message "illegal class name "ljava/lang/string;" in class ...". after short research found out problem occurs classes in java/lang when not loaded system class loader i'm else expert when comes class loading in java , osgi. i think way i'm getting access defineclass method of interest problem here is: protection_domain = (protectiondomain) accesscontroller.doprivileged(new privilegedaction() { public object run() { return restendpoint.class.getprotectiondomain(); } }); accesscontroller.doprivileged(new privilegedaction() { public object run() { try { class loader = class.forname...