Tuesday, 15 February 2011

c - incompatible types in assignment of ‘int’ to ‘int [(((sizetype)(((ssizetype)m) -1)) 1)]’ -



c - incompatible types in assignment of ‘int’ to ‘int [(((sizetype)(((ssizetype)m) -1)) 1)]’ -

the next c code gives error:

incompatible types in assignment of ‘int’ ‘int [(((sizetype)(((ssizetype)m) -1)) 1)]’

on lines phone call recursive functions:

int mergesort(int arr[], int n) { if (n > 1) { int m = (int)(n / 2); int a1[m]; // array 1 --> 1 m int a2[n-m]; // array 2 --> m + 1 n int temp = m+1; (int = 0; < n; i++) { if (i == m) break; a1[i] = arr[i]; a2[i] = arr[temp++]; } a1 = mergesort(a1, m); //error happens here, assigning //integer integer array. a2 = mergesort(a2, n - m); arr = merge(a1, a2); } homecoming arr; }

what error mean?

there several errors:

c++ doesn't back upwards variable length arrays (a1[m]) - utilize std::vector instead. even if did, arrays can't reassigned, a1 =... illegal even if could, couldn't assign single int them. mergesort returns int (why that?)

c sorting

c++ - Using a function as the second argument of a 'for' loop -



c++ - Using a function as the second argument of a 'for' loop -

this question has reply here:

should iterate vector iterator or access operator? 4 answers

let's assume have next code:

for(std::vector<int>::iterator = vect.begin(); != vect.end(); ++i) { //do smth here }

is vect.end() going re-called each iteration? if yes, how should iterate vector then?

having function called within logical look (second argument of loop) bad practice?

yes, will. however, if compiler can determine value returned vect.end() never change, of course of study optimize out. however, if want avoid doing sure, alter code to:

for(std::vector<int>::iterator = vect.begin(), end = vect.end(); != end; ++i) { //do smth here }

you should, of course, create sure code doesn't rely on end() beingness checked on every iteration. example, if doing vect.erase(i) on elements in vector, need create sure got new end() iterator every time (and create sure assign result of erase i).

c++

Perl hash of arrays column name as keys -



Perl hash of arrays column name as keys -

i trying create hash of arrays using result of sql query: eg.

column1:

1 2 3 4

column2:

a b c d

desired result:

my %by_col = ( 'column1'=>['1','2','3','4'], 'column2'=>['a','b','c','d'], );

i able result array of hashes using:

while ($hash_ref = $sth->fetchrow_hashref()) { force @$hash_array_ref, { %$hash_ref }; }

but can't figure out other way round.

thanks!

while (my $row = $sth->fetchrow_hashref()) { $col_name (keys(%$row)) { force @{ $by_col{$col_name} }, $row->{$col_name}; } }

arrays perl hash

using google map API or usual API for compiling android project in V2? -



using google map API or usual API for compiling android project in V2? -

in google map android v1 project, should compiled google maps api not ordinary api. wonder if same story google map android v2 also?

no, maps v2 has no dependency on original maps sdk add-on. welcome set plain android build target on project , skip <uses-library> element. maps v2 has own set of dependencies, notably on opengl es 2.0+ , existence of play services framework.

android google-maps

sql server - ms sql smo:how to script foreign key WITHOUT "Alter table MyTable check constraint MyForeignKey" -



sql server - ms sql smo:how to script foreign key WITHOUT "Alter table MyTable check constraint MyForeignKey" -

i see server 2008 generated script:

alter table [mytable] check add together constraint [fk_mytable_id] foreign key([id]) references [mytable2] ([id]) on update cascade on delete cascade go alter table mytable check constraint [fk_mytable_id]

last statement redundant, script works fine without it. generate scripts of foreign keys using smo , want avoid lastly string. can it?

the check constraint section ensures constraint enabled. shouldn't necessary should enabled initial statement.

this question looks similar on stackoverflow: t-sql foreign key check constraint

sql-server foreign-keys smo

First Image in Wordpress Post Will Not Center -



First Image in Wordpress Post Will Not Center -

in of posts (not of them), first image keeps floating right event though have set in <center></center> tags. can help me figure out why happening. illustration here: http://renegadechicks.com/twelve-inspiring-centerpieces-3

below css:

/* theme name: styleweekly theme uri: http://cloverthemes.com/ author: http://cloverthemes.com/ author uri: http://cloverthemes.com/ description: style weekly version: 1.2 tags: magazine, beauty, style, fashion */ /* =reset default browser css. based on work eric meyer: http://meyerweb.com/eric/tools/css/reset/index.html -------------------------------webs------------------------------- */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pbackgre, a, abbr, acronym, address, big, cite, code, del, dfn, font, ins, kbd, q, s, samp, small, strike, sub, sup, tt, var, dl, dt, dd, ol, ul, li,article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section,fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, br { border: 0; font-family: inherit; font-size: 100%; font-style: inherit; font-weight: inherit; margin: 0; outline: 0; padding: 0; vertical-align: baseline; } :focus { /* remember define focus styles! */ outline: 0; } body { line-height: 1; } ol, ul { list-style: none; } table { /* tables still need 'cellspacing="0"' in markup */ border-collapse: separate; border-spacing: 0; } caption, th, td { font-weight: normal; text-align: left; } blockquote:before, blockquote:after, q:before, q:after { content: ""; } blockquote, q { quotes: "" ""; } img { border:5px solid #fbdddf; } img.centered, .aligncenter, div.aligncenter { display: block; margin-left: auto; margin-right: auto; } img.alignright { padding: 4px; margin: 0 0 2px 7px; display: inline; } img.alignleft { padding: 4px;im margin: 0 7px 2px 0; display: inline; } .alignright { float: right; } .alignleft { float: left; } .box img { display: block; margin: auto; } img { display: block; width: auto; margin: auto; } little {font-size:11px;} /* floating ---------------------------------------------------------------- */ .alignleft { float: left; margin: 0 10px 10px 0; } .alignright { float: right; margin: 0 0 0 10px; } .aligncenter { display: block; margin: 0 auto 10px; } .left{float:left;} .right{float:right;} /* clear floats ---------------------------------------------------------------- */ .clearfix:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; } * html .clearfix { zoom: 1; } /* ie6 */ *:first-child+html .clearfix { zoom: 1; } /* ie7 */ /* global -------------------------------------------------------------- */ body { color: #444; font-family: "segoe ui","helvetica","arial",sans-serif; font-size: 16px; line-height: 1.5em; background: #000 url("images/graphicbg.jpg") no-repeat top center; } #inner { background-color: #fff; border: 3px solid #f10c6a; padding: 20px} #logos { display:none; } #linkwithin_logo_0 { display: none; padding-below: 5px; } #post-131 .st_facebook_large, #post-131 .st_twitter_large, #post-131 .st_pinterest_large, #post-131 .st_linkedin_large, #post-131 .st_email_large, #post-131 .st_sharethis_large, #post-131 .st_fblike_large {display: none;} .stmainservices st-facebook-counter { padding-bottom:15px; } .c-1 { float: left; padding-top: 20px;width:650px} .c-1 .bd { background: none} h1,h2,h3,h4,h5,h6 {color:#cc0066; font-weight: normal;font-family:georgia,"times new roman",times,serif; padding-bottom: 10px; } h1 { font-size: 40px; } h2 { font-size: 30px; } h3 { font-size: 30px; padding-top: 5px; } h4 { font-size: 30px; } h5,h6 { font-size: 30px; } pre,code,kbd,samp,tt {mos font: 16px/1.385 "courier new", monospace, serif; } /* hyperlinks ------------------------------------------------------------ */ a, a:visited { } a:hover { text-decoration: underline; } img { border: 5px solid #fbdddf; } .imagelogo { border:none; } h1 a,h2 a,h3 a,h4 a, h5 a, h6 { text-decoration: none; color: # } h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover { text-decoration: underline; color: #0ac6f5; } /* input form & textarea ---------------------------------------------------------------- */ input, textarea { border-color: #ccc #efefef #efefef #ccc; border-width: 1px; border-style: solid; color: #777; padding: 6px; } input:focus { background: #ffffff; } /* color -------------------------------------------------------------- */ a, a:visited, #logo .site-title { color: #cc0066;border:none !important; } #nav, #nav li li a, #nav li li a:link, #nav li li a:visited{ text-transform:uppercase; } .home-columns h3, .home-columns h4, a:hover {color: #0ac6f5;} .home-columns {text-decoration:none;} #nav li {color:#000000;} #nav li a:hover { color:#0ac6f5; } #nav li li a:hover, #nav li li a:active{background:rgba(0, 0, 0, 0.50);text-transform: uppercase;} #nav li li a, #nav li li a:link, #nav li li a:visited { } #nav { } #nav ul li{ } #nav ul li { color: #fff} #nav ul li ul li,#nav ul li ul li { border: none; } /* padding ---------------------------------------------------------------- */ .pl20{padding-left:20px;} .pl10{padding-left:10px;} .pb10{padding-bottom:10px;} .pb20{padding-bottom:20px;} .pr20{padding-right:20px;} .bd{background: url("images/dot.png") repeat-x scroll left bottom transparent;} /* header ---------------------------------------------------------------- */ #header { } #header .wrap { /*background: url("images/topbanner.png") no-repeat scroll 350px 43px transparent;*/ margin: 0 auto; overflow: hidden; width:1012px; padding: 40px 0 20px 0px; border-bottom: 1px solid #fff; } #logo h1, h1{ font-size: 35px; line-height: 40px; } #logo { float:left; } #logo .site-title , .site-title a{ color: #009999; font-weight: normal; font-family: "georgia"; display: block; float: left; font-size: 48px; line-height: 50px; margin: 0; padding: 10px 0 0; text-decoration: none; width: 380px; } #logo .site-title a:hover { text-decoration:none; } #description { color: #ffffff; font-size: 12px; font-style: italic; font-weight: normal; margin: 0; padding: 0 0 0 10px; display: block; height: 0; overflow: hidden; width: 0; } #header-right{ padding: 0px 0 0; float:right; width:270px; } /* nav ---------------------------------------------------------------- */ #nav{border-bottom-style: inherit;height: 36px; text-transform: uppercase; width:1012px; } .menu-main-container, .menu{margin:0 auto; } #nav li .sf-sub-indicator{ width: 11px; height: 32px; top: 18px; right: 0px; text-indent: -9999px; overflow: hidden; position: absolute; } #nav li a:hover .sf-sub-indicator{ } #nav li li .sf-sub-indicator { top: 12px; } #nav ul { float: left; list-style: none; margin: 0; } #nav .sub-menu { } #nav .sub-menu .sub-menu{ background: transparent !important; } #nav li { float: left; list-style: none; padding: 0; } #nav li { display: block; font-family: helvetica,sans-serif; text-transform: uppercase; font-size: 14px; font-weight: 400; line-height: 20px; margin: 0; padding: 11px 19px; position: relative; text-decoration: none; } #nav .current-menu-item { } #nav li a:hover, #nav li a:active { } #nav li li a, #nav li li a:link, #nav li li a:visited { font-size:12px; line-height: 20px; width: 132px; margin: 0; padding:7px 21px 7px 13px; text-transform:uppercase; position: relative; } #nav li li a:hover, #nav li li a:active {color:#fff; } #nav li ul { z-index: 9999; position: absolute; left: -999em; height: auto; width: 166px; margin: 0; padding: 0; background:#c06; text-transform:uppercase; } #nav li ul ul { margin: -35px 0 0 166px; } #nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul { left: -999em; } #nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul { left: auto; } #nav li:hover, #nav li.sfhover { position: static; } #nav li span { color:#999; display: block; font-size: 10px; line-height: 14px; } /* main ---------------------------------------------------------------- */ #wrapper{margin:0 auto; width:1012px; padding:0px;}h2 #home-third-left{width:660px;} #home-sidebar{width:300px; float:right;} #content-sidebar{width:980px;} #content{width:660px; float:left; min-height:600px;} /* homepage elements ---------------------------------------------------------------- */ #home-top .a-left ul{margin-left:-3px;} #home-top .a-left li{float:left; padding-left:4px;} #home-second h3{font-size:32px;} #home-top .entry-excerpt p{font-size:13px; font-family:georgia,"times new roman",times,serif; line-height:22px;width:205px;float:left} #home-top {padding-bottom: 36px;} .a-left h3 {padding:10px 0px 10px 0px;font-family: 'cookie', cursive;} .a-left h3 a{color:#000000; font-size:45px;} .a-left{padding-bottom: 5px;} .a-left{width:660px;} .a-right p{padding:0 40px 10px 10px;} .a-right{width:300px; } .home-post{padding-bottom:15px;margin-bottom:20px; min-height: 135px !important;font-size: 13px;line-height: 22px;} .home-category { float:left; width:635px; } .home-category h2{font-size:40px;padding-bottom:20px;} .small{font-size:10px; color:#999;} .b-1{width:638px; float:left; padding-right: 4px;padding-top: 25px;} .b-2{width:400px; float:left;} .firstpost{padding-bottom:10px;margin-bottom:5px;} .firstpost .entry-excerpt {font-size: 13px;line-height: 22px} .b-3{width:445px;float:right; /*font-size:11px; line-height:18px;*/} .b-1 h3 {line-height:28px;} .c-1-post {width:200px; margin-left: 20px;margin-bottom:5px} .c-1 h3{font-size:13px !important;padding-top:5px !important;line-height:20px;padding-bottom: 0px !important;} .c-2-1{width:260px;} .c-2-1 h3, .c-2-2 h3, .c-3 h3, .d-1 h3{font-size:26px; padding-bottom:10px;} .c-2-2{width:380px; } .c-2-2-post{margin-bottom: 15px;min-height: 100px !important;padding-bottom: 15px;} .c-2-2 p{line-height:22px;font-size:13px} .c-3-left, .c-3-right{width:320px;} .featured-left{float:left; width:320px;} .block-small-item{ height: 90px; margin-bottom: 13px; overflow: hidden; padding-bottom: 13px; width:320px} .block-meta { color: #888888; display: block; font-size: 11px; margin-bottom: 4px; } .block-meta { color: #888888 !important; } .block-meta a:hover { color: #333333 !important; text-decoration: none; } /* post page style ---------------------------------------------------------------- */ .breadcrumbs {background: none repeat scroll 0 0 #f6f6f6;color: #666666;font-size: 11px;margin: 0 0 10px;padding: 3px 15px; display:none;} .entry-content p{color: #464646;font-family: georgia,sans-serif; margin: 0 0 16px; line-height:24px; font-size: 13px;} .entry-title{margin-bottom:13px;margin-top: 3px;background: url("images/dot.png") repeat-x scroll left bottom transparent;} .entry-title h1 { color: #000000!important; } .entry-content h2, .entry-content h3{ font-size: 32px;} .entry-content ol, .entry-content ul {margin: 0;padding: 0 0 20px;} .entry-content ol {margin: 0;} .entry-content ul li {list-style-type: square;margin: 0 0 0 10px;} .entry-content ol li {list-style: decimal outside none;margin: 0 0 0 25px;} .entry-content ol ol, .entry-content ul ul {padding: 0;} .entry-content li{padding:0 0 5px 0;} .entry-content .wp-caption-text{color: #666666;font-size: 11px;font-style: italic;line-height: 16px;margin: 0;text-align: center;} .post-meta { background-color: #f6f6f6; border-radius: 5px 5px 5px 5px; clear: both; color: #666666; font-size: 11px; padding: 7px 10px 5px; margin-bottom: 15px; display: none; } .entry-content clearfix { padding-top: 10px; } .post-info { font-size: 12px; margin-bottom: 10px; display: inline; float: left; padding-bottom: 15px; font-family: verdana; color: black; } .linkwithin_posts { background: none !important; border: none !important; padding-right: 5px !important; } .linkwithin_hook { background: none repeat scroll 0 0 transparent; color: #; font-weight: bold; letter-spacing: -0.25px; line-height: 45px; margin-bottom: 10px; } .linkwithin_text { color: #cc0066; font-size: 38px; padding-left: 10px; } .linkwithin_title { color: #464646!important; font-family: verdana, sans-serif !important; font-size: 12px !important; line-height: 14px !important; text-decoration: none; } .linkwithin_title:hover { color: #c06!important; text-decoration: underline !important; } .post-info .post-author { background: url("images/post-author.png") no-repeat scroll left center transparent; padding: 5px 16px 3px 61px; font-size: 12px; font-style: italic; } .post-info .time { font-style:italic; }en .post-comments { background: url("images/post-comments.png") no-repeat scroll left center transparent; padding: 6px 20px 6px 40px; } #disqus_thread { padding-top: 50px; } .cat{ background: url("images/icon-categories.png") no-repeat scroll left top transparent; padding: 3px 0 3px 22px; display: none; } .tags{ background: url("images/icon-tags.png") no-repeat scroll left top transparent; margin: 0 0 0 10px; padding: 3px 0 3px 20px; display: none; } blockquote {background: url(images/q.png) no-repeat;border: none;margin: 5px 15px;padding: 15px 20px 10px 40px;} blockquote p {color: #666;font-style: italic;} .page-template-page-fullwidth-php #content{width:980px;} #social{width:660px; padding:10px 0 5px; display:none;} /* pre- next ---------------------------------------------------------------- */ #nav-below {padding-bottom:20px;} .nav-previous a, .nav-next {background: none repeat scroll 0 0 #0197b2;color: #ffffff;float: left;width: 100px; font-weight: bold;display: block;font-size:12px;line-height:26px;font-family:arial,verdana,sans-serif; height: 25px;text-align: center;width: 80px;overflow: hidden;} .nav-previous a:hover, .nav-next a:hover{background:#009999;} #nav-below .nav-previous a, #nav-below .nav-next { padding: 0 10px; width: 45%; } .nav-previous { float: right; } .nav-next { float: left; } .nav-next a:hover, .nav-previous a:hover { text-decoration: none; } /* related posts ---------------------------------------------------------------- */ .related-posts{ font-size:12px; line-height:18px;} .relateimage img {border: 1px solid #eeeeee; height: 150px; width: 150px;} .listing {float: left; padding-left: 20px; width: 150px; } .related-posts-title { color: #0091a8; margin:20px 0 10px 22px; padding-bottom: 15px;} /* sidebar ---------------------------------------------------------------- */ #sidebar{ display: inline; float: right; line-height: 20px; width: 300px; } #sidebar h4, #latest-posts h4 { /*background-color: #0ac6f5;*/ background: url("images/banner.jpg") no-repeat top center; color: #fff; font-size: 36px; text-align:center; line-height: 38px; padding: 7px 0px 0px 3px; margin: 0 0 5px; } #sidebar p{margin-bottom:10px;} .widget-wrap { margin: 0 0 10px; } .widget{ margin: 0 0 30px; } .widget-area ul li { border-bottom: 1px dotted #cccccc; list-style-type: none; padding: 0 0 5px 5px; word-wrap: break-word; font-size: 13px; } .widget-area li li, .widget-area li li li{ border-bottom: 0 none; list-style: square outside none; margin: 0 0 0 20px; padding: 5px 0 0 0; } #sidebar .flickr-photos li{ float: left; background:none; list-style-type: none; padding:8px; } #sidebar .twitter h4{ background: url("images/tt.png") no-repeat scroll left center transparent; line-height: 30px; padding: 0 0 0 40px; } #sidebar_left{ float: left; width:160px; #sidebar_left { text-decoration:none !important;} } a:-webkit-any-link { text-decoration:none !important;} } #header-right a:-webkit-any-link { padding-right: 15px; } #sidebar_right{ float: right; width:120px; } .twitter h4 { background: url("images/tt.png") no-repeat scroll left center transparent; padding: 0 0 6px 35px;} /* archive ---------------------------------------------------------------- */ .archive .post img, .search .post img {width:150px; height:auto;} #archive-title {padding-bottom:15px; font-size:22px; display:none;} /* search ---------------------------------------------------------------- */ input[type="button"], input[type="submit"] { border: none;color: #ffffff;cursor: pointer;font-size: 13px;font-weight: normal;text-decoration: none; } input[type="button"]:hover, input[type="submit"]:hover {background-color: #565656; } input, select, textarea,.sticky, .taxonomy-description {border: 1px solid #dddddd;} #search {width: 265px; padding-left: 18px; padding-top: 5px; padding-bottom: 10px;} #search .s { background: #c06; border: medium none; color: #fff; font-size: 12px; padding: 5px 8px; width: 157px;float: left; } #search .search-submit{background: url("images/s.png") no-repeat scroll center center transparent; border: medium none; cursor: pointer; float: right; height: 28px; margin: 0; right: 0; top: 0; width: 39px;} #search div { background: #c06; height: 27px; position: relative; border: 2px solid #0ac6f5; } /* pagination ---------------------------------------------------------------- */ .ct-paginate {padding: 10px 0 20px 0; overflow:hidden; clear:both; font-family: arial;} .ct-paginate {border:1px solid #eee; margin-right:5px; padding:4px 8px; text-align:center; text-decoration:none;} .ct-paginate .ct-title {color:#555; margin-right:4px;} .ct-paginate .ct-gap {color:#999; margin-right:4px;} .ct-paginate a:hover, .ct-paginate a:active, .ct-paginate .ct-current {color:#fff; background: url("images/navbg.png") repeat scroll 0 0 #333333;border:1px solid #ddd; margin-right:5px;padding:4px 8px;} /* footer ---------------------------------------------------------------- */ .footer-info {padding:30px 0;} .footer-info .right{width:1012px;text-align:center;} /* =comments ------------------------------------------------------------------ */ #comments {padding:20px 0 0 0;} #comments h3,#respond h4{color: #0091a8; } #comments a{ text-decoration:none; } #comments a:hover{ text-decoration:underline; } #comments input:hover, #commentstextarea:hover{ background: #f5f5f5; } #commentform { margin: 5px 10px 0px 0px; } #commentform textarea { width: 90%; padding: 5px; font-size:13px } #respond:after { content: "."; display: block; height: 0px; clear: both; visibility: hidden; } #commentform p { margin: 20px 0; } #commentform #submit, .wpcf7-submit{ -moz-box-shadow:inset 0px 1px 0px 0px #fbafe3; -webkit-box-shadow:inset 0px 1px 0px 0px #fbafe3; box-shadow:inset 0px 1px 0px 0px #fbafe3; background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #f03c96), color-stop(1, #cc0066) ); background:-moz-linear-gradient( center top, #f03c96 5%, #cc0066 100% ); filter:progid:dximagetransform.microsoft.gradient(startcolorstr='#f03c96', endcolorstr='#cc0066'); background-color:#f03c96; -moz-border-radius:17px; -webkit-border-radius:17px; border-radius:17px; border:1px solid #ee1eb5; display:inline-block; color:#ffffff; font-family:arial; font-size:13px; padding:6px 24px; text-decoration:none; text-shadow:1px 1px 0px #ff0080; } #commentform #submit:hover, .wpcf7-submit:hover { background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ef027d), color-stop(1, #ff5bb0) ); background:-moz-linear-gradient( center top, #ef027d 5%, #ff5bb0 100% ); filter:progid:dximagetransform.microsoft.gradient(startcolorstr='#ef027d', endcolorstr='#ff5bb0'); background-color:#ef027d; } #commentform #submit:active { position:relative; top:1px; } .commentlist { margin: 0px; padding: 0px; } .commentlist ol { margin: 0px; padding: 10px; } .commentlist li { margin: 15px 0; padding:15px; list-style: none; } .commentlist li ul li { margin: 10px; } .commentlist p { margin: 10px 5px 10px 0px; padding: 0px; } .commentlist li ul li { font-size: 12px; } .commentlist li .avatar { background-color: #ffffff; border: 1px solid #eeeeee; box-shadow: 0 0 2px rgba(0, 0, 0, 0.1); float: left; margin: 0 10px 0 0; padding: 3px; } .commentlist cite, .commentlist cite { font-style: normal; font-size: 14px; } .commentlist p { } .commentmetadata { font-weight: normal; padding:5px 0 0 0; } .alt { margin: 0px; padding: 10px; } .children { margin: 0px; padding: 0px; } .nocomments { text-align: center; margin: 0px; padding: 0px; } .commentmetadata { font-size: 11px; margin: 0px; display: block; } .navigation { display: block; text-align: center; margin-top: 10px; margin-bottom: 40px; } .thread-alt { background: #ffffff; margin: 0px; padding: 0px; } .thread-even { background: #ffffff; margin: 0px; padding: 0px; } .depth-1 { border: 1px solid #bbbbbb; margin: 0px; padding: 0px; } .even, .alt { border:1px solid #eeeeee; border-radius: 5px 5px 5px 5px; } em.date, .comment strong { font-weight:normal; color:#9e825f; line-height:24px; display:block; font-style: normal; } /* socialmedia ---------------------------------------------------------------- */ /* additional ---------------------------------------------------------------- */ /* styling posts ---------------------------------------------------------------- */ .one_half, .one_third, .two_third, .three_fourth, .one_fourth { float: left; line-height: 21px; margin-bottom: 20px; margin-right: 4%; } .one_half { width: 48%; } .one_third { width: 30.6%; } .two_third { width: 65.3%; } .one_fourth { width: 22%; } .three_fourth { width: 74%; } .last { clear: right; margin-right: 0 !important; } .dropcap { color: #383838; float: left; font-size: 40px; margin-right: 6px; padding-top: 7px; position: relative; text-transform: uppercase; top: 5px; } .highlight1 { background: none repeat scroll 0 0 #f6f67a; } .highlight2 { background: none repeat scroll 0 0 #000000; color: #cccccc; } .mosaic-block { float:left; position:relative; overflow:hidden; width:210px; height:120px; /*background:#111 url(images/progress.gif) no-repeat center center; -webkit-box-shadow:0 1px 3px rgba(0,0,0,0.5);*/ border-radius: 15px; } .mosaic-backdrop { display:none; position:absolute; top:0; height:100%; width:100%; /*background:#111;*/ } .mosaic-overlay { display:none; z-index:5; position:absolute; width:100%; height:100%; background:#111; } .bar .mosaic-overlay { bottom:-100px; height:40px; background:url(images/bg-black.png); } .details{ margin:3px 10px; color:#eee; font-size:11px;} .footer-links-copyright, .footer-links-copyright a{ color:#0ac6f5; font-size:11px;padding-right:10px;} .attachment1{ text-align:center;} #content .gallery img, #gallery-listing img{background: none repeat scroll 0 0 #dddddd;border: 5px solid #ffffff; box-shadow: 0 1px 2px #cccccc;margin: 5px; padding: 1px; max-width:160px; height:auto;} #content .cb_pin_images { margin-left: auto !important; margin-right: auto !important; } .entry-content img {max-width:100%; height:auto; border: 5px solid #fbdddf;} .first-thumb img { box-shadow:5px 5px 1px #888;} .hfeed img.thumbnail { float: left; height: 160px; } .archive .hfeed article { margin-left: 20px; float:left; width: 470px;} }

i changed html first image

<center><a href="http://renegadechicks.com/wp-content/uploads/2013/02/centerpiece15.jpg <img class="size-full wp-image-10673 aligncenter" alt="centerpiece15" src="http://renegadechicks.com/wp-content/uploads/2013/02/centerpiece15.jpg" width="361" height="559"> </a></center>

to in chrome:

<p style="clear: both;"> <a href="http://renegadechicks.com/wp-content/uploads/2013/02/centerpiece15.jpg"> <img class="size-full wp-image-10673 aligncenter" alt="centerpiece15" src="http://renegadechicks.com/wp-content/uploads/2013/02/centerpiece15.jpg" width="361" height="559"> </a> </p>

and seemed center fine. reason had toggle text-decoration on tag off on work...

basically, replaced < center > tags < p> tags , made sure clear floats set before hand.

wordpress image css-float centering

sql server - Substring - T-SQL -



sql server - Substring - T-SQL -

i have string get's inserted table. size , content of string varies.

i want characters between 2 known words (_ part1id = , _ part2id =).

i want in between these 2 strings whole string.

i have tried this approach getting before _ part2id =.

anyone know how create work in given conditions?

thank you

try:

with (select 'abc_ part1id =efg_ part2id =jkl' a) select a, substring(a, charindex('_ part1id =',a)+len('_ part1id ='), charindex('_ part2id =',a)-charindex('_ part1id =',a)-len('_ part1id ='))

sql sql-server sql-server-2008 tsql

android - How to store sparsearray in bundle -



android - How to store sparsearray in bundle -

i have sparsearray<myobject> , want store in bundle in onsaveinstancestate method in activity , restore in oncreate. found putsparseparcelablearray method set sparsearray in bundle , did in onsaveinstancestate method:

bundle.putsparseparcelablearray("mysparsearray", mysparsearray);

but eclips shows error:

the method putsparseparcelablearray(string, sparsearray<? extends parcelable>) in type bundle not applicable arguments (string, sparsearray<myobject>)

and quick prepare casting argument mysparsarray sparsearray<? extends parcelable>, if , in oncreate method:

mysparsearray = (sparsearray<myobject>) savedinstancestate.getsparseparcelablearray("mysparsearray");

it gets error:

cannot cast sparsearray<parcelable> sparsearray<myobject>

if way wrong, solution set mysparsearray in bundle? help much appreciated.

your class should implement parcelable , should have static final fellow member variable called creator of type parcelable.creator<myobject>.

android android-activity bundle sparse-array

javascript - Holder.js -- Get back DOM element? -



javascript - Holder.js -- Get back DOM element? -

holder.js

i want dynamically add together placeholder image page.

inserting doesn't work:

$('<li>',{class:'file-item'}) .append($('<img>',{'data-src':'holder.js/150x150'})) .append($('<span>',{class:'file-name'}).text(file.name)) .appendto('#file-list');

because holder script has ran , isn't searching new elements.

we can, however, run 1 time again manually:

holder.run()

but scan elements added.

so...is there way can holder.js create , give me dom element can add together manually without re-running whole thing?

pass node images property holder.run , you'll able run holder on individual image. holder doesn't create dom element, changes src value.

code:

var image = $("<img>").attr({ "data-src": "holder.js/300x200" }) holder.run({ images: image[0] }); image.appendto("body");

live illustration here: http://jsfiddle.net/imsky/p3dma/

javascript holder.js

ruby on rails - Why is .each only going through the first element? -



ruby on rails - Why is .each only going through the first element? -

i wrote method:

def create_demo_organizations sample_organizations = [ '37 signals', 'fog creek'] sample_organizations.each { |item| organization.first_or_create( name: item, time_zone: 'central' ) } end

i hoping create 2 organizations names in array me, when opened in ui admin tool can see first row '37 signals' , not sec row. did write wrong?

my goal iterate through members of array , insert them in database.

first seek isolate active record code loop code. start with:

sample_organizations.each |item| puts item end

if you're getting both items printed, add together simpler ar call:

sample_organizations.each |item| organization.create(name: item) end

then finally:

sample_organizations.each |item| organization.find_or_create(name: item) end

edit:

i don't think you're calling first_or_create correctly. want this:

organization.where(name: item).where(time_zone: 'central').first_or_create

ruby-on-rails ruby

svg - raphael: show HTML entity within a tag -



svg - raphael: show HTML entity within a tag -

i want add together html entity raphael tag, see text deg , not grade sign -

this.tags.push( // create tag (x, y, text, degree, radius) r.tag(this.x, this.y[i], this.values[i]+ "&deg;c", 20, 4).insertbefore(this) ...

how can escape it?

i not sure language displays text, html, javascript or svg ...

you can pass fromcharcode raphael node.

r.text(100, 100, string.fromcharcode(176));

would render ° entity in text node.

svg raphael html-entities graphael

Inserting e-mail link (a href mailto:) in html editor does not show on website. But clicking on its (empty space) opens an e-mail to that address -



Inserting e-mail link (a href mailto:) in html editor does not show on website. But clicking on its (empty space) opens an e-mail to that address -

inserting e-mail link (a href mailto:) in html editor not show on website. clicking on (empty space) on website opens e-mail address.

i tried inserting working e-mail link page remains invisible on web page creating.

thanks.

arnold

html

java - Application server use for non-web applications -



java - Application server use for non-web applications -

i interested in understanding "best practice" utilize of application server (for illustration glassfish). have medium size application consists of various components consume , source web services. these components hosted in glassfish environment.

i have requirement simple scheduled function copies info 1 database another. is, requires no web type functionality. built simple application (say around quartz) , deployed in same glassfish server other components. understand simple question, "reasonable" approach or should stand lone application running independently application server? guess more general question "what appropriate uses application server , not?"

it shell script called cron...

seriously, not utilize of app server unless you're going sort of monitoring or load distribution out of it. sounds batch job in case should easy thing , write script or simple app main method either phone call cron (or similar) or run command line sort of embedded timer (or sleeping thread).

java java-ee

iphone - Disable taking images in any orientation other than Portrait AVFoundation -



iphone - Disable taking images in any orientation other than Portrait AVFoundation -

i using avfoundation show camera.

i prevent photographic camera rotate viewer see photographic camera in portrait , images taken in portrait mode.

i defined supported interface orientation back upwards portrait , view beingness displayed in portrait mode, not photographic camera - beingness rotated device orientation

how can forcefulness avfoundation photographic camera displayed , capture images in portrait uiviewcontroller?

my code set camera:

avcapturevideopreviewlayer* lay = [[avcapturevideopreviewlayer alloc] initwithsession:self.sess]; uiview *view = [self videopreviewview]; calayer *viewlayer = [view layer]; [viewlayer setmaskstobounds:yes]; cgrect bounds = [view bounds]; [lay setframe:bounds]; if ([lay respondstoselector:@selector(connection)]) { if ([lay.connection isvideoorientationsupported]) { [lay.connection setvideoorientation:avcapturevideoorientationportrait]; } } [lay setvideogravity:avlayervideogravityresizeaspectfill]; [viewlayer insertsublayer:lay below:[[viewlayer sublayers] objectatindex:0]]; self.previewlayer = lay;

here partial reply based on understanding of question (which differs other answers have had).

you have app locked portrait orientation. status bar @ portrait top of phone regardless of phone's orientation. locks interface, including avcapture interface. want lock raw image feed photographic camera image horizon parallel status bar.

this ideally need done continuously - if have photographic camera @ 45degree angle image counter-rotated 45 degrees. otherwise, of time, image not aligned correctly (the alternative is out of line until 90degree orientation switch updates, swivel image 90 degrees).

to need utilize core motion , accelerometer. want angle of phone's y-axis true vertical , rotate image accordingly. see here geometry details:

iphone orientation -- how figure out way up?

using core motion, trigger method viewdidload

- (void)startaccelerometerupdates { self.coremotionmanager = [[cmmotionmanager alloc] init]; if ([self.coremotionmanager isaccelerometeravailable] == yes) { cgfloat updateinterval = 0.1; // assign update interval motion manager [self.coremotionmanager setaccelerometerupdateinterval:updateinterval]; [self.coremotionmanager startaccelerometerupdatestoqueue:[nsoperationqueue mainqueue] withhandler: ^(cmaccelerometerdata *accelerometerdata, nserror *error) { cgfloat angle = -atan2( accelerometerdata.acceleration.x, accelerometerdata.acceleration.y) + m_pi ; catransform3d rotate = catransform3dmakerotation(angle, 0, 0, 1); self.previewlayer.transform = rotate; }]; } }

a b c

phone held (a) portrait; (b) rotated ~30deg; (c) landscape .

you may find little jumpy, , there bit of lag between device motion , view. can play updateinterval, , in deeper other core motion trickery dampen movement. (i have not treated case of phone beingness upside down, , if hold photographic camera face downwards or face up, result undefined fixed updated code/ utilize of atan2).

now orientation reasonably correct, image not fit view. there not lot can format of raw photographic camera feed fixed physical dimensions of it's sensor array. workaround zoom image have plenty excess image info @ angles enable crop image fit portrait format want.

either in interface builder:

set previewlayer's view square centered on it's superview, width , height equal diagonal of visible image area (sqrt (width2+height2)

or in code:

- (void)resizecameraview { cgsize size = self. videopreviewview.bounds.size; cgfloat diagonal = sqrt(pow(size.width,2)+pow(size.height,2)); diagonal = 2*ceil(diagonal/2); //rounding self.videopreviewview.bounds = (cgrect){0,0,diagonal,diagonal}; }

if in code, resizecameraview should work if phone call viewdidload. create sure self.videopreviewview iboutlet reference right view.

now when take photo, capture whole of 'raw' image info camera's array, in landscape format. saved orientation flag display rotation. may want save photo seen onscreen. means have rotate , crop photo match onscreen view before saving it, , remove it's orientation metadata. that's work out (the other part of 'partial answer'): suspect might decide whole approach doesn't want (i think you'd photographic camera sensor hardware-rotates against rotation of device maintain horizon stable).

update changed startaccelerometerupdates angle atan2 instead of acos, smoother , takes business relationship of directions without fiddling

update 2 comments, seems rotated preview layer getting stuck? cannot replicate error, must other place in code or settings.

so can check clean code, have added solution apple's avcam project, can check against that. here do:

add core motion framework avcam.

in avcamviewcontroller.m

#import <coremotion/coremotion.h> add startaccelerometerupdates method add resizecameraview method (stick both of these methods near top of class file or may confused, there more 1 @implementations in file) add line: [self resizecameraview]; viewdidload (it can first line of method) add property @property (strong, nonatomic) cmmotionmanager* coremotionmanager @interface (it doesn't need property, method assumes exists, if don't add together have modify method instead).

in startaccelerometerupdates alter line:

self.previewlayer.transform = rotate;

to:

self.capturevideopreviewlayer.transform = rotate;

also, in objects list in avcamviewcontroller.xib, move videopreview view above toolbar (otherwise when enlarge cover controls)

be sure disable rotations - ios<6.0, true, 6.0+ need select portrait in supported orientations in target summary.

i think complete list of changes made avcam, , rotation/orientation working well. suggest seek doing same. if can work smoothly, know there other glitch in code somewhere. if still find rotations stick, curious know more hardware , software environment such devices testing on.

i compiling on xcode 4.6/osx10.8.2, , testing on:

- iphone4s / ios5.1 - iphone3g / ios6.1 - ipad mini / ios6.1

all results smooth , accurate.

iphone objective-c xcode avfoundation uideviceorientation

django - How to represent unique together in Tastypie -



django - How to represent unique together in Tastypie -

i have model construction keeps track of next , followers of user.

class connections(models.model): next = models.foreignkey( user, related_name='following' ) followers = models.foreignkey( user, related_name='followers' ) class meta: unique_together = (('following', 'followers'), ) post models class post(models.model): body = models.textfield() user = models.foreignkey(user) #media = models.foreignkey(postmedia) post_image = models.imagefield(upload_to=get_postimage_path) type_of_post = models.charfield(max_length=20) def __unicode__(self): homecoming u'%s, %s' % (self.user.username, self.body) class sharedpost(models.model): post = models.foreignkey(post, unique=true) date = models.datetimefield(auto_now_add=true) favors = models.integerfield(default=1) users_favored = models.manytomanyfield(user, related_name='users_favored') notify_users = models.manytomanyfield(user, related_name='notify_users') def __unicode__(self): homecoming u'%s, %s, %s' % (self.post.user.username, self.post.body, self.pk)

now if have fetch next user in views

following = [connections.followers connections in user.following.all()]

now trying design api web application using tasypie, not sure how represent relationship in modelresources.

i want generate list of followers , next in it, , utilize filter extract posts made people user following.

curl http://localhost:8000/api/v1/sharedpost/?post__user__username=abc

this using filter out posts made specific user, want filter next users.

i can use

def get_object_list(self, request): homecoming super(sharedpostresource, self).get_object_list(request).filter(post__user=request.user)

and then

def get_object_list(self, request): user=request.user next = [connections.followers connections in user.following.all()] homecoming super(sharedpostresource,self).get_object_list(request).filter(post__user__in=following).order_by('-date')

but wont have create different resources of then? there improve way that? in maybe can create 1 resource more versatile?

django tastypie

php - Function inside a loop -



php - Function inside a loop -

i have loop table row , table data. want add together class name on every table info of course of study not same class name.

but problem output of function placing outside table. check quotes or something, still placing outside. can explain me why?

function alphacount(){ ($i=65; $i<=90; $i++) { echo char($i); } for($i=1;$i<=10;$i++) { echo '<td class="char-'.$i.'-'.$this->alphacount.'"> </td>'; }

to honest, don't much of code according problem described, guess problem following.

you have function generates identifier, echoes instead of returning it, this:

function getid() { // echo $id; }

and when generating entry, having next code:

echo "<tr class='" . getid() . "'>...</tr>";

like getid() method echoes identifier before <tr> tag rendered. can resolve either changing echo statement in getid homecoming statement, or can rewrite entry generator in next way:

echo "<tr class='" getid(); echo "'>...</tr>";

i hope had problem with.

php html loops

javascript - How do I scroll a webpage automatically? -



javascript - How do I scroll a webpage automatically? -

when website loads want gif displayed , after animation ends want page automatically scroll without clicking button , reveal main site. want gif load automatically every time, not first time.

any help appreciated.

time gif. set timeout when x time passed scrolls. maybe nicer thought time , hide instead of scroll.

though impossible time because bound loading time of gif

javascript jquery html css animation

xcode - How to make an iOS app, that perform function in the background with some interval? -



xcode - How to make an iOS app, that perform function in the background with some interval? -

i want create ios app, can every 5 minutes perform specific function. how it? function simple,

batter = 95; // calculated.. every time differ [uiapplication sharedapplication].applicationiconbadgenumber = batter;

i need create timer it, in background

you can't in background unless app fall in 1 of categories: voip, sound playback or location update. if places timers become invalids when application goes background.

ios xcode timer

web - Images not showing up online after FTP upload -



web - Images not showing up online after FTP upload -

i've been testing website locally in macosx no problems. however, after uploading files server, despite having exact same file configuration, crucial images aren't showing up! site in question www.tedxbozeman.com, in 'speakers' section.

thank you!

there problem in css file, illustration amber-jean have in css:

speaker1 { background-image: url('@root/amber-jean1.jpg');

it should url('/amber-jean1.jpg');

web upload website ftp

.net - only first 50 rows are getting copied to clipboard from datagridview in winforms -



.net - only first 50 rows are getting copied to clipboard from datagridview in winforms -

i have datagridview mydgv info filled database.

i doing ctrl+a (select all) , copying ( ctrl + c ) when paste copied info excel, first 50 rows of info getting copied. rest of rows comes blank.

here code in keydown event

if e.control andalso e.keycode = keys.c dim d dataobject = mydgv.getclipboardcontent() clipboard.setdataobject(d) e.handled = true end if

when scroll downwards grid till end (last row) , ctrl+c , paste in excel, rows getting pasted.

how proceed solve issue?

use datagridview.selectall method select rows on using ctrl + a.

and utilize next event key pressed:

void datagridview1_keydown(object sender, keyeventargs e) { if (e.control && e.keycode == keys.c) { //call datagridview.selectall method } }

.net vb.net winforms datagridview copy-paste

algorithm - solution to standard puzzle -



algorithm - solution to standard puzzle -

there board in there m*m boxes each assigned non 0 integer except 1 box marked 0 , treated vacant .only vertical , horizontal neighbors of vacant box can move towards leaving place vacant.to solve puzzle have arrange boxes in increasing order of value vacant box(box marked 0 ) coming @ end(lower right corner of board).but other engineers lazy , wants solve in minimum number of steps.

so approach should follow except backtracking.

m of order 500.. ie 500x500 board.

you can find goal state sorting array. allow goal state g simple inefficient algorithm solve puzzle be:

void solve() { if(current_state == g) return; foreach(choice c in shifting_choices) { // shift neighbour apply choice; solve(); undo choice; } }

in above algorithm choices moving blocks surrounded zeroth block.

to improve algorithm can utilize a* (best first). in order find best selection can utilize manhattan distance. steps required reach 1 block within puzzle. consider below:

6 2 1 5 0 3 4 7 8

in above situation, move 2, 5, 3, 7 find best move consider goal state:

8 7 6 5 4 3 2 1 0

when move block zeroth block changing position of 2 blocks. calculate sum of manhattan distance of these 2 blocks position within goal state. selection within to the lowest degree sum preferable:

moving 2: 2 + 3 = 5 moving 3: 1 + 1 = 2 moving 7: 1 + 1 = 2 moving 5: 1 + 2 = 3

you can break tie between 3 , 7 checking previous positions, 3 @ right place hence 7 makes locally optimal choice.

algorithm puzzle

Wilcard matching substring in Python -



Wilcard matching substring in Python -

i new python , don't know how sub-string matches wildcard status string. trying timestamp next string:

sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671.data

i want "1360922654.97671" part out of string. please help.

if dots , dashes have specific function within string, can utilize this:

>>> s = "sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671.data" >>> s.rsplit('.', 1)[0].split('-')[-1] '1360922654.97671'

step step:

>>> s.rsplit('.', 1) ['sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671', 'data'] >>> s.rsplit('.', 1)[0] 'sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671' >>> s.rsplit('.', 1)[0].split('-') ['sdc4', '251504', '7f5', 'f59c349f0e516894fc89d2686a0d57f5', '1360922654.97671'] >>> s.rsplit('.', 1)[0].split('-')[-1] '1360922654.97671'

this work strings in form:

anything-whatyouwant.stringwithoutdots

python

mapreduce - ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Call to localhost/127.0.0.1:54310 failed on local exception -



mapreduce - ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Call to localhost/127.0.0.1:54310 failed on local exception -

i getting error in starting info node while initiating single node cluster set on machine

************************************************************/ 2013-02-18 20:21:32,300 info org.apache.hadoop.hdfs.server.datanode.datanode: startup_msg: /************************************************************ startup_msg: starting datanode startup_msg: host = somnath-laptop/127.0.1.1 startup_msg: args = [] startup_msg: version = 1.0.4 startup_msg: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1393290; compiled 'hortonfo' on wed oct 3 05:13:58 utc 2012 ************************************************************/ 2013-02-18 20:21:32,593 info org.apache.hadoop.metrics2.impl.metricsconfig: loaded properties hadoop-metrics2.properties 2013-02-18 20:21:32,618 info org.apache.hadoop.metrics2.impl.metricssourceadapter: mbean source metricssystem,sub=stats registered. 2013-02-18 20:21:32,620 info org.apache.hadoop.metrics2.impl.metricssystemimpl: scheduled snapshot period @ 10 second(s). 2013-02-18 20:21:32,620 info org.apache.hadoop.metrics2.impl.metricssystemimpl: datanode metrics scheme started 2013-02-18 20:21:33,052 info org.apache.hadoop.metrics2.impl.metricssourceadapter: mbean source ugi registered. 2013-02-18 20:21:33,056 warn org.apache.hadoop.metrics2.impl.metricssystemimpl: source name ugi exists! 2013-02-18 20:21:37,890 error org.apache.hadoop.hdfs.server.datanode.datanode: java.io.ioexception: phone call localhost/127.0.0.1:54310 failed on local exception: java.io.ioexception: connection reset peer @ org.apache.hadoop.ipc.client.wrapexception(client.java:1107) @ org.apache.hadoop.ipc.client.call(client.java:1075) @ org.apache.hadoop.ipc.rpc$invoker.invoke(rpc.java:225) @ sun.proxy.$proxy5.getprotocolversion(unknown source) @ org.apache.hadoop.ipc.rpc.getproxy(rpc.java:396) @ org.apache.hadoop.ipc.rpc.getproxy(rpc.java:370) @ org.apache.hadoop.ipc.rpc.getproxy(rpc.java:429) @ org.apache.hadoop.ipc.rpc.waitforproxy(rpc.java:331) @ org.apache.hadoop.ipc.rpc.waitforproxy(rpc.java:296) @ org.apache.hadoop.hdfs.server.datanode.datanode.startdatanode(datanode.java:356) @ org.apache.hadoop.hdfs.server.datanode.datanode.<init>(datanode.java:299) @ org.apache.hadoop.hdfs.server.datanode.datanode.makeinstance(datanode.java:1582) @ org.apache.hadoop.hdfs.server.datanode.datanode.instantiatedatanode(datanode.java:1521) @ org.apache.hadoop.hdfs.server.datanode.datanode.createdatanode(datanode.java:1539) @ org.apache.hadoop.hdfs.server.datanode.datanode.securemain(datanode.java:1665) @ org.apache.hadoop.hdfs.server.datanode.datanode.main(datanode.java:1682) caused by: java.io.ioexception: connection reset peer @ sun.nio.ch.filedispatcher.read0(native method) @ sun.nio.ch.socketdispatcher.read(socketdispatcher.java:39) @ sun.nio.ch.ioutil.readintonativebuffer(ioutil.java:251) @ sun.nio.ch.ioutil.read(ioutil.java:224)

any thought how resolve error?

ok got problem solved.

since using single-node cluster through network proxy, had added next property line $hadoop_home/conf/mapred-site.xml by-pass proxy server while communicating across hadoop daemons.

however, time trying out on direct net connection, had comment out property added in mapred-site.xml.

below property mapred-site.xml commented out:

<!-- <property> <name>hadoop.rpc.socket.factory.class.default</name> <value>org.apache.hadoop.net.standardsocketfactory</value> <final>true</final> <description> prevent proxy settings set clients in job configs affecting our connectivity. </description> </property> -->

hadoop mapreduce hadoop-streaming

java - Memoization:Rememo -



java - Memoization:Rememo -

the array memo[][] returning cloth is in memo[x][y]. have tested class , seems stores first cloth fits in memo[x][y], want homecoming valuable cloth fits in memo[x][y]. how can this?

class clothcutter { static arraylist <pattern> patterns; //array of patterns seek static cloth maxcloth; //the maximum cloth static cloth memo[][]; // memo maximum cloth (x,y), memo[x][y] int width; int height; //constructor public clothcutter(int w, int h,arraylist<pattern> p) { width = w; height = h; patterns = p; maxcloth = new cloth(w,h); memo = new cloth [w+1][h+1]; (int = 0; i<patterns.size();i++) { pattern z = patterns.get(i); system.out.println(z.name); cloth m = new cloth(z.width,z.height); m.add(z); memo[z.width][z.height]=m; system.out.println(memo[z.width][z.height].value); } } public cloth optimize() { homecoming optimize(maxcloth); } public cloth optimize(cloth c){ cloth temp1 = new cloth(); cloth temp2 = new cloth(); cloth max = new cloth(c.width,c.height);//temporary max if (memo[c.width][c.height]!=null) // homecoming memo if there 1 homecoming memo[c.width][c.height]; if (c.width==0||c.height==0) //if (x||y ==0) memo[c.width][c.height]=max; homecoming max; } (int i=0;i<patterns.size();i++) { //for each pattern pattern p = patterns.get(i); if (p.width<=c.width && p.height<=c.height) { if (p.width<c.width) { //if pattern's width less cloth's width cloth = new cloth(c.width-p.width,c.height);//cut vertically a.pattern = p; cloth b = new cloth(p.width,c.height);//remainder after vertical cutting b.pattern = p; temp2=optimize(b);//recurse temp1=optimize(a);//recurse } if (c.width==p.width) { //if cloth's width equal patterns start cutting horizontally cloth = new cloth(c.width,c.height-p.height);//horizontal cutting a.pattern=p; cloth b = new cloth(c.width,p.height);//remainder after horizontal cutting b.pattern = p; temp2=optimize(b);//recurse temp1=optimize(a);//recurse } if (temp1.value+temp2.value>max.value) { //if value of optimal cloths greater value of max max.add(temp1,temp2);//add 2 cloths max max.pattern = p; if (max.width == maxcloth.width && max.height == maxcloth.height && maxcloth.value < max.value) // if max dimentions equal maxcloth dimetions , value of maxcloth less max maxcloth=max;//set maxcloth max } } } if (memo[max.width][max.height]==null) //if memo equal null memo[max.width][max.height]=max;// create memo homecoming max; }

your code little confusing me figure out problem wrote psuedocode friend , got right optimal value when ran mine. perhaps can compare!

optimize() { rectangle memo[width][height] optimize(0,0,totalwidth, totalheight, memo) } optimize(x, y, width, height, memo) { if memo[width][height] != null homecoming memo[width][height] rect = new rectangle(width, height, value = 0) each pattern { //find vertical cutting solution leftverticalrect = optimize (x, y + pattern.height, pattern.width, height-pattern.height,memo) rightverticalrect = optimize(x + pattern.width, y, width-pattern.width, height) verticalcut = new cut(x + pattern.width, y, x + pattern.width, y + height) //find horizontal cutting solution tophorizontalrect = optimize ( --parameters-- ) bottomhortizonalrect = optimize( --parameters--) horizontalcut = new cut( --parameters--) //see solution more optimal if (leftverticalrect.val + rightverticalrect.val > tophorizontalrect.val + bottomhorizontalrect.val) subprobsolution = vertical cutting solution else subprobsolution = horizontal cutting solution //see if solution found greater previous solutions subproblem if (subprobsolution.value + pattern.value > rect.value) { rect.subrect1 = subprobsolutionrect1 rect.subrect2 = subprobsolutionrect2 rect.pattern = pattern rect.cut = subprobsolutioncut rect.value = rect.subrect1.value + rect.subrect2.value + rect.pattern.value } } memo[width][height] = rect homecoming rect }

java optimization memoization knapsack-problem

Prepared statements in PHP for MySQL, what am I doing wrong? -



Prepared statements in PHP for MySQL, what am I doing wrong? -

previously in soon-to-be-deprecated normal mysql functions, had:

// on first connect database, create user hold info users not logged in if (mysql_num_rows(mysql_query("select id users id=1")) === 0) { mysql_query("insert users(id,username,email,password) values(1,'anonymous','anonymous','" . password_hash("noidentity", password_bcrypt) . "')"); }

this have now, trying accomplish same thing:

// on first connect database, create user hold info users not logged in $stmt = $db->prepare("select id users id = ?"); $stmt->execute(1); $stmt->store_result(); if ($stmt->num_rows == 0) { $stmt = $db->prepare("insert users (id, username, email, password) values (?, ?, ?, ?)"); $stmt->execute(1, 'anonymous', 'anonymous', password_hash("noidentity", password_bcrypt)); }

i maintain getting error "warning: mysqli_stmt::execute() expects 0 parameters, 1 given" seemingly expects 1, have 1 question mark, i'm doing wrong.

am doing right next ones?

$stmt = $db->prepare("update users set wins = wins + 1 id = ?"); $stmt->execute($_session["id"]);

should have ? wins = part? if so, how fill in value later if depends on current 1 in there?

what about:

$stmt = $db->prepare("select id, username, password users email = ?"); $stmt->execute($email); $row = $stmt->fetch(); if (password_verify($password, $row["password"])) {

am doing right there?

i'm trying grasp these prepared statements security purposes , finding little difficult.

use code, have utilize bind_param set data.

$stmt = $db->prepare("select id users id = ?"); $stmt->bind_param('i', 1); $stmt->execute();

php

wordpress - redeclare a php-function -



wordpress - redeclare a php-function -

a normal installation of wordpress cms consists of hundreds of scripts, plugins , themes. concept allows replace scripts creating re-create of , set altered version in right directory. however, copied script not updated when new version of script or plugin installed. within script there hundreds of functions. cost of changing 1 function other functions no longer updated. in many cases wordpress hooks , filters sufficient add together or suppress specific functionality, not always.

i'm looking way redeclare or overload function original script may replaced cms whenever update installed. tried this:

rename_function( 'wp_function' , 'old_wp_funtion ) function wp_function(){ // things before function $a = $b; // phone call old function $result = old_wp_function(); // things afterwards $b = $c; homecoming $result; }

but doesn't work. also, wordpress never know kind of , how many arguments aspect. overloaded function has deal too.

my question is: how go create work in cases, number , type of arguments. , without having alter original function/script because may (and must) overwritten wordpress updates.

php not standard back upwards redefining of functions 1 time they're declared. there number of ways forcefulness it, in general it's considered very poor programming practice, , discouraged.

if want overload code in php, much improve off writing code in classes rather plain functions, because class can extended, , methods overloaded. by far best alternative you. may require bit of reworking of code, it's practice write code in classes anyway, consider chance improve code quality.

another alternative utilize namespaces. php 5.3 , later supports namespaces, means can declare same function name multiple times, in different namespaces. if code isn't using namespaces involve important amount of work implement, may help allow want. suspect class alternative mentioned improve bet.

with specific reference rename_function() function you're trying utilize here: part of a non-standard debugger extension called adp; it's developer's debugger, shouldn't used in production system.

if you're determined way want to, other options seek include runkit extension, explicitly designed allow kind of think you're asking about. again, it's intended developer utilize only, , discouraged production use.

another alternative patchwork library, pure php code (ie doesn't require php extension installed). makes much more appealing solution. again, author explicitly recommends against using other development environment.

so there have it: several options exist you. if must proceed downwards route you've described, suggest using patchwork library.

but 1 time again you're asking not thought -- big clue should no-one else doing way, , doing similar things saying @ every chance shouldn't used in production.

the case it's considered useful tool writing test scripts, have dependencies can't avoided. redefining dependencies mocks or stubs can create possible write unit tests otherwise untestable code.

but aside that, consistent message php world is: don't redefine functions.

php wordpress overloading redeclare

c - Get IP address from socket descriptor? -



c - Get IP address from socket descriptor? -

i've opened tcp socket server (i've omitted few stuff, taken here

sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol))

is possible ip address of server sockfd? if not should look?

edit: want know address of server (this before client connects).

if want know who's @ other end of socket can utilize getpeername in linux. getsockname tell are. decide address want server sit down on though, @ bind time.

you may find question useful: bind socket network interface

and book "unix network programming, vol 1", w. richard stevens.

c sockets network-programming ip

android - trouble in deletion from the database -



android - trouble in deletion from the database -

getting contacts phone , displaying in list view, , marking contacts , adding list view, there marked list view adding , unmarked list view deleteing.

the code used is..

@override public view getview(int position, view convertview, viewgroup parent) { view view = null; if (convertview == null) { x= position; layoutinflater inflator = context.getlayoutinflater(); view = inflator.inflate(r.layout.contactliststyle, null); final viewholder viewholder = new viewholder(); viewholder.txtname = (textview) view.findviewbyid(r.id.txtview_name); viewholder.txtnumber = (textview)view.findviewbyid(r.id.txtview_number); viewholder.selection = (checkbox)view.findviewbyid(r.id.checkbtn_selectcontact); viewholder.selection .setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { contactmodel element = (contactmodel)viewholder.selection .gettag(); element.setselected(buttonview.ischecked()); if(buttonview.ischecked()) { string selectedname=element.getname(); string selectednumber=element.getnumber(); system.out.println("etrtrt"+element.getname()); databasehandler db = new databasehandler(context); log.d("insert: ", "inserting .."); db.addcontact(new contact(selectedname, selectednumber)); } else { string selectedname=element.getname(); string selectednumber=element.getnumber(); system.out.println("number"+selectednumber); system.out.println("name"+selectedname); databasehandler db = new databasehandler(context); db.deletecontact(new contact(selectedname,selectednumber)); } } });

the code in openhelper class deleting contact is

// deleting single contact public void deletecontact(contact contact) { sqlitedatabase db = this.getwritabledatabase(); db.delete(table_contacts, key_id + " = ?", new string[] { string.valueof(contact.getid()) }); system.out.println("deleted"); db.close(); }

the contact adding database not deleting database...

try

using getwritabledatabase().delete(table_name, table_row_id + "="+rowid,null)

android

Javascript ... Displaying Values -



Javascript ... Displaying Values -

i'm creating blackjack card game in javascript. appreciate comments far. i'm looking feedback why can seem phone call cardface function 1 time within carddealer function. @ nowadays cardface(0) gives me value whereas cardface(1) or other number not unless cardface(x) beingness called within carddealer function. ideas appreciated.

code below not finish believe plenty discern plenty info from.

function card(name, suit, face, value) { this.name = name; this.suit = suit; this.face = face; this.value = value; } aceofhearts = new card("aceofhearts","hearts", "ace", 11); kingofhearts = new card("kingofhearts","hearts", "king", 10); queenofhearts = new card("queenofhearts","hearts", "queen", 10); jackofhearts = new card("jackofhearts","hearts", "jack", 10); tenofhearts = new card("tenofhearts","hearts", "ten", 10); nineofhearts = new card("nineofhearts","hearts", "nine", 9); eightofhearts = new card("eightofhearts","hearts", "eight", 8); sevenofhearts = new card("sevenofhearts","hearts", "seven", 7); sixofhearts = new card("sixofhearts","hearts", "six", 6); var deck; deck = []; deck.push(aceofhearts); deck.push(aceofdiamonds); deck.push(aceofclubs); deck.push(aceofspades); deck.push(kingofclubs); deck.push(kingofdiamonds); deck.push(kingofhearts); deck.push(kingofspades); deck.push(queenofclubs); deck.push(queenofdiamonds); deck.push(queenofhearts); deck.push(queenofspades); deck.push(jackofclubs); deck.push(jackofdiamonds); deck.push(jackofhearts); deck.push(jackofspades); deck.push(tenofclubs); deck.push(tenofdiamonds); deck.push(tenofhearts); deck.push(tenofspades); var carddealer = function() { fisheryates(deck); document.getelementbyid("yourfirstcard").textcontent = "your first card " + cardface(0) ; document.getelementbyid("yoursecondcard").textcontent = "your sec card " + cardface(1) ; }; var cardface = function(x) { cardface = deck[x].face; homecoming cardface; }; var cardsuit = function(x) { cardsuit = deck[x].suit; homecoming cardsuit; }; <body> <div>black jack 1.1</div> <br/> <button type="button" onclick="carddealer()">deal</button> <div id="yourfirstcard"></div> <div id="yoursecondcard"></div> <div id="yourthirdcard"></div> <div id="yourfourthcard"></div> <div id="yourfifthcard"></div> <div id="playertotal"></div></div> <div id="playersit"></div> <div id="playermessage"></div> <div id="sitter"><button type="button" onclick="sit()">sit</button></div> <div id="hitter"><button type="button" onclick="hitme()">hit</button></div> <br/> <br/> <div id="dealersfirstcard"></div></div> <div id="dealerssecondcard"></div></div> <div id="dealersthirdcard"></div></div> <div id="dealersfourthcard"></div></div> <div id="dealersfifthcard"></div></div> <div id="dealertotal"></div></div> <div id="dealersit"></div></div> <div id="dealermessage"></div></div> </body>

here see issue:

var cardface = function(x) { cardface = deck[x].face; homecoming cardface; };

at first, declare variable called cardface , assign function. function reassigns cardface variable , returns result. that's it, function gone now, cannot refer anymore, since cardface has been reassigned.

what need alter body of function way doesn't reassign variable:

var cardface = function(x) { var cardfacevalue = deck[x].face; homecoming cardfacevalue; };

the same goes cardsuit function.

javascript

javascript - Accessing an associative array using jQuery -



javascript - Accessing an associative array using jQuery -

i have associative array here -

var dataset = { "person" : [ {"userlabels": ["name","role"]}, {"tagnames": ["lname","role"]}, {"tableclass": "width530"}, {"colwidths": ["50%","50%"]} ] }

i tried accessing 'userlabels' object using jquery using various methods failed. think doing wrong basics. want userlabels object accessed using jquery , result should array, can perform jquery.inarray() operation.

firstly, here's how can access dataset using method have.

var dataset = { "person" : [ {"userlabels": ["name","role"]}, {"tagnames": ["lname","role"]}, {"tableclass": "width530"}, {"colwidths": ["50%","50%"]} ] }; alert(dataset['person'][0]['userlabels']); //style 1 alert(dataset.person[0]['userlabels']); //style 2 alert(dataset.person[0].userlabels); //style 3 //also can utilize variables in place of specifying names i.e. var propname ='userlabels'; alert(dataset.person[0][propname]); //what follows how search if value in array 'userlabels' $.inarray('name', dataset.person[0].userlabels);

i'd inquire why you're doing in such 'interesting way'. why don't create them objects?

that's if because if think it, person object , should noted arrays objects in javascript 'length' property, though won't elaborate on here (feel free research though). i'm guessing it's because don't know how iterate on object properties. of course of study if makes more sense you, go it.

note 1 of differences between array , object object properties need defined; you'll notice gave 'name' , 'role' values of 'undefined' below.

in case, here do:

var dataset = { "person" : { "userlabels": {"name" : undefined,"role": undefined}, "tagnames": {"lname" : undefined,"role" : undefined}, "tableclass": "width530", "colwidths": ["50%","50%"] } }; (var in dataset) { //iterate on objects in dataset console.log(dataset[i]); //i prefer utilize console.log() write it's in firefox alert(dataset[i]); // works in ie. } //by using object need is: dataset.person.userlabels.hasownproperty('role'); //returns true or false

anyways, hope helps.

javascript jquery arrays associative-array

Clojure :: arity-overloaded functions calling each other -



Clojure :: arity-overloaded functions calling each other -

examples of clojure arity-overloading on functions next (taken cookbook):

(defn argcount ([] 0) ; 0 arguments ([x] 1) ; 1 argument ([ x & args] (inc (count args)))) ; list of arguments

... utilize form doesn't seem allow functions of lower arity phone call functions of higher arity default values (that's mutual idiom in java). other special form used ?

there's way express higher arity arguments in way doesn't need refer other arities using higher order functions , map / reduce. in case it's pretty simple:

(defn argcount ([] 0) ([x] 1) ([x & args] (reduce + 1 (map (constantly 1) args))))

notice general form of look is:

(reduce reducing-function arity-1-value (map mapping-function rest-of-args))

you can't way, works surprisingly big proportion of multi-argument functions. gains advnatages of laziness using map, can crazy things pass 10 1000000 arguments function little fear:

(apply argcount (take 10000000 (range))) => 10000000

try in other languages , stack toast :-)

clojure

html - table columns does not show up in resize -



html - table columns does not show up in resize -

i have 3 tables...... first table not given margin left..... next 2 tables have given margin-left move on left side.... when resize window not able see lastly column in other 2 tables.... how prepare it.... first table looks fine even after resize......

http://jsfiddle.net/x7hd9/

providing code below

<table class="table" style="margin-left: 160px; width: 1759px;"> <thead> <tr class="subbomlistheading subbomheading" style=""> <th>bom type</th> <th>product p/n</th> <th>version</th> <th>brand name</th> <th>bom description</th> <th>generation</th> <th>version</th> <th>notes</th> <th>delete</th> </tr> </thead> <tbody> <tr style="background-color: #e5dcd1;" class=" subbom"> <td>sub bom</td> <td>99-00302-00</td> <td>v.02</td> <td>creative</td> <td>hardware v1.0 system</td> <td>g1</td> <td>1</td> <td>new</td> <td><input type="radio" name="sex" value="male"></td> </tr> </tbody> </table>

try :

<table class="table" style="margin-left: 160px; width: 100%;">

also, maintain in mind <tables> not 'responsives' (has in 're-layout'), still 'extensibles'.

your table displayed @ it's minimum width, it's normal don't see lastly column, overflows viewport.

html css html5 css3 css-float

python - TypeError: input expected at most 1 arguments, got 3 -



python - TypeError: input expected at most 1 arguments, got 3 -

i'm making little guessing game in python computer guesses number chosen player.

# computer guessing game # computer tries guess number print("think of number, , seek guess it. if guess right,") print("say 'yes'.if guess high, 'lower'. , if guess is") print("too low, 'higher'.\n") reply = input("is 50? ") guess = 50 while reply != "yes": hilo = input("is higher or lower? ") if hilo == "lower": guess %= 50 reply = input("is it", guess, "?") if hilo == "higher": guess %= 150 reply = input("is it", guess, "?") print("i win!") input("press come in key exit.")

however, when running it, lines 15 , 18 of code

answer = input("is it", guess, "?")

return "typeerror: input expected @ 1 arguments, got 3" don't know how prepare this, help much appreciated.

input accepts one argument, passing 3. need utilize string formatting or concatenation create 1 argument:

answer = input("is {} ?".format(guess))

you confusing print() function, indeed take more 1 argument , concatenate values 1 string you.

python

mysql triggers to invoke jsf bean -



mysql triggers to invoke jsf bean -

i need phone call jsf bean using database trigger mysql. how can go that?

however im using entity classes. can using classes? observe new insert and phone call jsf bean?

however im using entity classes. can using classes? observe new insert and phone call jsf bean?

what want whever new record inserted in mysql dbase, values sent xhtml page parameter , managed bean called.

jsf

html - Strange behavior of scrollHeight in firefox on div with padding and overflow:auto -



html - Strange behavior of scrollHeight in firefox on div with padding and overflow:auto -

here is, http://jsfiddle.net/ynkws/

<div id="div1" style="padding: 2px; overflow: auto;"> <div style="height:30px;">lalala</div> <div style="height:30px;">lalala</div> </div> var d = $("#div1"); (var = 0; < 5; i++) { console.log(d.height(),d[0].scrollheight); d.height(d.height() - 1); }

there's div padding , overflow:auto. , in firefox there's unusual behavior of div's scrollheight value. when set div's height smaller it's original height, that's natural expect scrollbar appears , scrollheight value remains same. chrome suits theese expecatations not firefox, lastly 1 doesn't draw scrollbar, decreases bottom padding , scrollheight when deviation of original height smaller div's padding.

is bug , there prepare of 'bug'?

the firefox behavior 1 css spec requires: padding on thing overflow doesn't cause overflow on own.

html firefox scrollbar padding

Haskell and Regex - Why doesn't my function eliminateRedundantSpaces work? -



Haskell and Regex - Why doesn't my function eliminateRedundantSpaces work? -

haskell , regex - why doesn't function eliminateredundantspaces work?

import text.regex eliminateredundantspaces text = subregex (mkregex "\\s+") text " "

text.regex uses posix regular expressions, , doesn't have \s abbreviation defined (that perl extension many other implementations have adopted). instead can utilize [:space:] character group, eg:

eliminateredundantspaces text = subregex (mkregex "[[:space:]]+") text " "

regex haskell

Can I Import Excel Worksheet to Java and Sort By Cell Info -



Can I Import Excel Worksheet to Java and Sort By Cell Info -

i know if through java can compare values in columns seperate out each person's name , farther seperate out largest number in column b be.

so want find best time each runner

i understand if question possible , little bit how.

say have excel spreadsheet column has name of participants of track team. these names repeated multiple times.

column b has run times in seconds of each runner throughout season.

column c has date of time.

a b c john 20 1/26/2012 john 18 1/27/2012 john 17 1/28/2012 cindy 21 1/26/2012 cindy 20 1/27/2012 cindy 18 1/28/2012

if export excel file csv may:

load bufferedreader split each line of text array of string string.split( ";" ) convert column b integer integer.parseint() convert dates sortable yyyy/mm/dd string.split( "/" ), concat [2]+[1]+[0] make instance of person (a user defined class) name, time , date add person list sort list want user defined comparator

java excel

check if two objects are both undefined or null in javascript -



check if two objects are both undefined or null in javascript -

i have method hittest check collision detection , can homecoming point object (if collision happened) or (if there no collision) returns null or undefined (i haven't understand when homecoming null or undefined trust chrome console).

i have test collision on 2 objects. , check if 1 or 2 collisions happening. have tried code:

var result1 = hittest(player, object1); var result2 = hittest(player, object2); if( result1 || result2 ) { blabla() };

but doesn't work.

now.. know js reallly tricky language , think smart way without writing typeof 4 times. i'm thinking python short-circuit logical operators...

you can utilize &&, returns first detected false/null/undefined/0, i.e. if won't pass, if either result1 or result2 null.

javascript null undefined logical-operators

r - aggregate a column by sum and another column by mean at the same time -



r - aggregate a column by sum and another column by mean at the same time -

i want utilize aggregate function on date frame sum 1 column , take average of column.

here illustration info frame

manager category amount sqft joe rent 150 500 alice rent 250 700 joe utilities 50 500 alice utilities 75 700

i cannot below. there easy way ?

avg_cpsf=aggregate(cbind(amount,sqft)~manager,data=aaa,fun=c(sum,mean)

eventually need

manager amount sqft joe 200 500 alice 325 700

so can calculate cost per square foot doing amount/sqft

there several ways this. here (all assuming we're starting data.frame named "mydf"):

using ave , unique

unique(within(mydf, { amount <- ave(amount, manager, fun = sum) sqft <- ave(sqft, manager, fun = mean) rm(category) })) # manager amount sqft # 1 joe 200 500 # 2 alice 325 700

using data.table:

library(data.table) dt <- data.table(mydf) dt[, list(amount = sum(amount), sqft = mean(sqft)), = "manager"] # manager amount sqft # 1: joe 200 500 # 2: alice 325 700

using "sqldf":

library(sqldf) sqldf("select manager, sum(amount) `amount`, avg(sqft) `sqft` mydf grouping manager")

using aggregate , merge:

merge(aggregate(amount ~ manager, mydf, sum), aggregate(sqft ~ manager, mydf, mean))

r aggregate

iphone - Cropping an image in iOS using OpenCV face detection -



iphone - Cropping an image in iOS using OpenCV face detection -

i used below code crop face image, in face detection code. not getting proper face images , getting part of image saved , not face. what's wrong in code?

_facecascade.detectmultiscale(mat, faces, 1.1, 2, khaaroptions, cv::size(40, 40));

and within displayfaces functions cropping code:

cgrect croprect = cgrectmake(faces[i].x, faces[i].y, faces[i].width, faces[i].width); cgimageref cropped_img = cgimagecreatewithimageinrect(self.storeimage.cgimage, croprect); uiimage *img = [uiimage imagewithcgimage:cropped_img]; uiimagewritetosavedphotosalbum( img, self, nil,nil);

am getting right co-ordinates of faces[i]. problem cropping , setting roi. can 1 help me in solving it?

i tried below code also, 1 time again getting same images. (i.e., not getting actual face image)

cv :: mat image_roi; cv::rect roi(faces[i].x, faces[i].y, faces[i].width, faces[i].height); cv::mat(testmat, roi).copyto(image_roi); uiimage *img = [captureviewcontroller imagewithcvmat:image_roi ]; uiimagewritetosavedphotosalbum( img, self, nil,nil);

note: detecting face in live video stream using opencv facedetect. can greenish rectangle around face. couldn't crop face face parameters. tried setting faceroi observe eyes, fails. narrow downwards issue, problem might in setting roi image?

updated on 11/02/13:

i have done cropping below roi not set , image not cropped well:

i found issue above post ( @jameo pointing me because of rotation issue.) have rotated image below.

uiimage *rotateimage = [[uiimage alloc] initwithcgimage: image.cgimage scale: 1.0 orientation: uiimageorientationright];

and cropped image using below code:

// sub image + (uiimage*) getsubimagefrom: (uiimage*) img withrect: (cgrect) rect { uigraphicsbeginimagecontext(rect.size); cgcontextref context = uigraphicsgetcurrentcontext(); // translated rectangle drawing sub image cgrect drawrect = cgrectmake(-rect.origin.x, -rect.origin.y, img.size.width, img.size.height); // clip bounds of image context // not strictly necessary clipped anyway? cgcontextcliptorect(context, cgrectmake(0, 0, rect.size.width, rect.size.height)); // draw image [img drawinrect:drawrect]; // grab image uiimage* subimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); homecoming subimage; }

the image cropped not actual co-ordinates.

my observations: 1) cropping image facerect returned affinetransform. reason wrong co-ordinates or because of bug in code?? 2) couldnt set roi image before setting affine transform, reason, procedure set roi?

facerect = cgrectapplyaffinetransform(facerect, t);

but still cropping not done difference shown below:

full image:

cropped image

what this?

- (uiimage *) getsubimagefrom:(uiimage *)imagetocrop withrect:(cgrect)rect { cgimageref imageref = cgimagecreatewithimageinrect([imagetocrop cgimage], rect); uiimage *cropped = [uiimage imagewithcgimage:imageref]; cgimagerelease(imageref); homecoming cropped; }

iphone ios objective-c image-processing opencv

android - Custom XML attributes without custom View in Fragment -



android - Custom XML attributes without custom View in Fragment -

i'm trying add together custom xml attributes in existing view

adding them custom view not big deal don't know how access attributes in "basic" view (e.g. textview, linearlayout, imageview ...)

and more hard when there fragment , / or library project involved

so far here code

customs attributes definitions , xml (attrs.xml , layout):

<?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="starwars"> <attr name="jedi" format="string" /> <attr name="rank" format="string" /> </declare-styleable>

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sw="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="fill_parent"> <textview android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="28dp" android:gravity="center_horizontal" sw:jedi="obiwan" /> <textview android:id="@+id/rank" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="28dp" android:gravity="center_horizontal" sw:rank="master" />

since inflate on fragment (so no oncreate attrs arg !), way seek 2 sw custom attributes :

set custom layoutinflater.factory fragment layoutinflater in oncreateview

@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { super.oncreateview(inflater, container, savedinstancestate); layoutinflater layoutinflater = inflater.cloneincontext(inflater.getcontext()); layoutinflater.setfactory(new starwarslayoutfactory()); view fragmentview = layoutinflater.inflate(r.layout.jedi, container, false); ((textview) fragmentview.findviewbyid(android.r.id.jedi)).settext("yep"); homecoming fragmentview; }

trying custom attributes on custom layoutinflater.factory :

public class starwarslayoutfactory implements mill { @override public view oncreateview(string name, context context, attributeset attrs) { *** here ? *** homecoming null; } }

anyone have had kind of question ?

what i'm missing here ?

thx in advance !

i have done :)

you have create new layoutinflater.factory did on op since mill used inflated layout view, , have homecoming null on factory.oncreateview (to allow android handle inflation) must cache custom xml attibutes somewhere

so here solution :

your layout xml view must have , android:id

create class maintain custom attributes :

class="lang-java prettyprint-override"> public class attributeparser { private attributeparserfactory mfactory; private map<integer, hashmap<integer, string>> mattributelist; private class attributeparserfactory implements layoutinflater.factory{ @override public view oncreateview(string name, context context, attributeset attrs) { string id = attrs.getattributevalue("http://schemas.android.com/apk/res/android", "id"); if(id != null){ // string reference character "@", strip maintain reference id = id.replace("@", ""); typedarray librarystyledattributelist = context.obtainstyledattributes(attrs, r.styleable.newshublibrary); hashmap<integer, string> libraryviewattribute = new hashmap<integer, string>(); int = 0; for(int attribute : r.styleable.newshublibrary){ string attributevalue = librarystyledattributelist.getstring(i); if(attributevalue != null) libraryviewattribute.put(attribute, attributevalue); i++; } if(!libraryviewattribute.isempty()) mattributelist.put(integer.valueof(id), libraryviewattribute); librarystyledattributelist.recycle(); } homecoming null; } } public attributeparser(){ mattributelist = new hashmap<integer, hashmap<integer, string>>(); mfactory = new attributeparserfactory(); } public void clear() { mattributelist.clear(); } public layoutinflater getlayoutinflater(layoutinflater inflater) { clear(); layoutinflater layoutinflater = inflater.cloneincontext(inflater.getcontext()); layoutinflater.setfactory(mfactory); homecoming layoutinflater; } public void setfactory(layoutinflater inflater){ inflater.cloneincontext(inflater.getcontext()).setfactory(mfactory); } public void setviewattribute(activity activity) { for(entry<integer, hashmap<integer, string>> attribute : mattributelist.entryset()) if(activity.findviewbyid((integer) attribute.getkey()) != null) activity.findviewbyid((integer) attribute.getkey()).settag(attribute.getvalue()); } public void setviewattribute(view view) { for(entry<integer, hashmap<integer, string>> attribute : mattributelist.entryset()) if(view.findviewbyid((integer) attribute.getkey()) != null) view.findviewbyid((integer) attribute.getkey()).settag(attribute.getvalue()); } public map<integer, hashmap<integer, string>> getattributelist() { homecoming mattributelist; } public void setattributelist(map<integer, hashmap<integer, string>> attributelist) { this.mattributelist = attributelist; } } your custom attributes stored in each view tag when utilize attributeparser :

layoutinflater layoutinflater = mattributeparser.getlayoutinflater(inflater); view view = layoutinflater.inflate(r.layout.jedi, null); mattributeparser.setviewattribute(view);

android android-fragments android-view android-xml android-custom-attributes

asp.net - Control the flow of ViewEngines -



asp.net - Control the flow of ViewEngines -

having custom view engine installed on web app:

viewengines.engines.insert(0, new customviewengine1()); ...and sec default mvc view engine razor

and having definition of first view engine:

public class customviewengine1: razorviewengine { public customviewengine1(): this(null) { } public customviewengine1(iviewpageactivator viewpageactivator) { viewlocationformats = new string[] { "~/views/{1}/{0}.cshtml", "~/../framework.web/views/{1}/{0}.cshtml", "~/views/shared/{0}.cshtml", "~/../framework.web/views/shared/{0}.cshtml" }; masterlocationformats = new string[] { "~/views/{1}/{0}.cshtml", "~/../framework.web/views/{1}/{0}.cshtml", "~/views/shared/{0}.cshtml", "~/../framework.web/views/shared/{0}.cshtml" }; partialviewlocationformats = new string[] { "~/views/{1}/{0}.cshtml", "~/../framework.web/views/{1}/{0}.cshtml", "~/views/shared/{0}.cshtml", "~/../framework.web/views/shared/{0}.cshtml" }; fileextensions = new string[] { "cshtml" }; } protected override iview createpartialview (controllercontext controllercontext, string partialpath) { if (controllercontext.requestcontext.httpcontext.request.browser.ismobiledevice) { homecoming base.createpartialview(controllercontext, partialpath); } else { //...what have set here in order allow command next route engine in collection viewengines.engines } } protected override iview createview (controllercontext controllercontext, string viewpath, string masterpath) { if (controllercontext.requestcontext.httpcontext.request.browser.ismobiledevice) { homecoming base.createview(controllercontext, viewpath, masterpath); } else { //...what have set here in order allow command next route engine in collection viewengines.engines } } }

how finish code (where have comments ) in order if request has been not made mobile device, uses view engine comes next in viewengines collection? (which default mvc razor view engine).

thanks in advance.

regards.

jose

maybe blog post starting point you: a improve asp.net mvc mobile device capabilities viewengine

asp.net asp.net-mvc-3