Posts

Showing posts from June, 2013

sql - Joining tables in a database using differently formated data (MAC addresses) -

i have 2 tables i'd join via mac address field, each table stores mac addresses different: table 1 data: 0:1e:8:c5:9e:fe table 2 data: 00:1e:08:c5:9e:fe the first 1 removes starting 0's of 6 groups of colon-separated fields. is there way can join on these in sql without having modify data? i'm guessing have convert both values xx:xx:xx:xx:xx:xx, compare them...i'm not quite sure how that. you can remove leading zeroes replace , stuff functions: select * table1 inner join table2 on table1.shortmac = stuff(replace(':' + table2.longmac, ':0', ':'), 1, 1, '')

javascript - flexslider and flexcarousel on one page -

when try use "basic flexlisder" ( http://flexslider.woothemes.com/index.html ) , "basic carousel" ( http://flexslider.woothemes.com/basic-carousel.html ) on 1 page, carousel not display properly. guessed it's fault of clashing class names (since both in <div class="flexslider"> ). however, after analyzing source code on flexslider page, found put carousel in <div class="flexslider carousel"> , unlike written in example, still did not help. carousel still behaves slider. i tried copying styles new class, called flexcarousel, didn't work (even after making changes in jquery call well). has simple example of slider , carousel working on simple page? my javascript: <script type="text/javascript"> //slideshow $(window).load(function() { $('.flexslider').flexslider({ animation : "slide",

jquery - If .next() element is the .last() element? -

i know it's quite simple, .next() , .last() kind of confuse me. i'm kind of mixed up. what trying add class when next element last of kind in list. fiddle in current code adds class after last element displayed, when goes first. jquery: im sure has .length $("#next-button").on('click', function () { var nextitem = $('.active').removeclass('active').next(), breaditem = $('.clickable').next(); if (!nextitem.length) { nextitem = $('.item').first(); //here try add class ".last" last ".item" element $('.item').last().addclass('last'); } nextitem.addclass('active'); breaditem.addclass('clickable'); }); this adds class when click on last element going towards first. also bonus question, confused why when add class .clickable breadcrumbs first 1 takes me right data-id check fiddle i appreciate community

multithreading - NetworkOnMainThreadException Error in Android -

i'm trying use jsoup html parsing library html document using document doc = jsoup.parse(u, 1000); and i'm getting error "android.os.networkonmainthreadexception" i understand because need have download occurring somewhere other main thread don't understand how fix this. if use threading need able return doc can parse through when download finished. can me fix this? the class using follows: public class datasorter{ private document doc; datasorter(){ downloaddata(); } private void downloaddata() throws ioexception{ string url = "www.google.com"; url u = new url(url); system.out.println("downloading...."); doc = jsoup.parse(u, 5000); //time out 5000ms system.out.println("download successful"); } document getdoc(){ return doc; } } you doing network related operation on main ui thread. use thread or asynctask http://developer.android.

php - Joomla com_user extending similar to com_categories and com_content -

Image
ok feel should ask not find reference in kind of documentation, , reading through actual code figure out best way accomplish take far longer hope spend. when enter article manager have navigation link category manager , vice versa. similar component , default user manager. i have profile plugin extend users suit needs, configuration of seamless adjusting com_user component integrate better component looking for. so question com_content , com_categories use "extension" parameter. possible add similar functionality without full core override of com_users? if full override there chance of extensions not working due reliance on users. i willing clarify if not make sense, question more see extent can "extend" joomla without overrides. update: i have found cool technique, not quite answer though. can override list controller/model/view in component, , if based off of current com_users component can make direct integration. edits need making sure routes use

java - how to compare an string array? -

i have code example. want compare strings contains paths. problem @ else part...in example have / , usr together..and want compare length after point different..thank help string path1 = "/usr/libexec/warmd"; string path2 = "/usr/lib/libopen/xy"; string[] test1 = path1.split("/"); string[] test2 = path2.split("/"); arraylist<string[]> path1array = new arraylist<string[]>(); arraylist<string[]> path2array = new arraylist<string[]>(); path1array.add(test1); path2array.add(test2); int len1 = test1.length; int len2 = test2.length; int len; if (len1 <= len2) { len = len1; } else len = len2; (int = 0; < len; i++) { if ((test1[i]).equals(test2[i])) { continue; } else break; } you can find common prefix substring follows : int minlen = math.min(test1.length, test2.length); string commonprefix = ""; (int = 0; < minlen; i++) { if (test1[i].compareto(test2[i

javascript - Create new function in contentScriptFile in Firefox extension -

i'm developing firefox extension in i've these functions in contentscriptfile of mypanel: ... function myfun(param){ console.log("myfun "+param) } self.port.on('mytrigger',function(value){ $("#myfavdiv").append("<a onclick='myfun(\'"+value+"\')'> click me!</a>") }); ... i'm including script file (in main.js ): mypanel = panel.panel({ width: 400, height: 200, contenturl: self.data.url("panel.html"), contentscriptfile: [self.data.url("jquery-1.10.2.min.js") , self.data.url("mscript.js")] }); everything working fine, problem onclick method dynamically added anchor tag in div#myfavdiv error thrown when click anchor: timestamp: 8/10/2013 1:24:48 error: referenceerror: myfun not defined i tried write myfun function in main.js still same error there. any idea(s)/solution(s)? i think content script being sandboxed html, when anch

java - Spring Hibernate MySQL- 50k insert taking 20minutes -

i have been working on project using latest appfuse base.. have extended lot of models particularly user accommodate of things doing, 1 of them adding few lists user have larger lists attached them, here example: user -> leadlists (maybe 100 or of these) -> leads (upwards of 50k) , problems start. have process working user uploads csv parse lead objects , add them list user save user , let cascade save work. once save fires takes 20 minutes or more finish , permgen memory error... problem #2 once in db have not been able display them @ without getting permgen out of memory error. can please offer insight may doing wrong? have enabled hibernate batch size , set 50, else can ridiculous insert time down? did write code using hibernate batch processing best pratice? if not, check link . if yes , trying write single user+leadlists(100)+leads(50k) in single shot (are 50k items!!! that's no peanuts!) have choices: move flat jdbc (orm not best choice batch progra

html - Can't seem to get rid of giant footer -

i have page here: http://www.cooperstandardperformance.com/content/test-blank-page and can't seem rid of giant footer - there's no footer div or styling can see firebug indicate giant footer. i want page white down bottom - going wrong? thing can see might cause this: background: none repeat scroll 0 0 #2b296a; is right? should change #fff; , done it? or there else not noticing. remove background style body tag.

email - Xor Encryption PHP for Activationlink E-Mail -

i have problem xor encryption activiationlink. xor encryption activiationlink code works, encryption last id user. if im testing mail, produced curious encryption "30303030" example id: 3445 if encryption have 54515c50 but if click on activationlink in e-mail have "30303030" , not 54515c50. i don't know how creat encryption "30303030". testing id , have again "30303030" encryption i don't have idea solve this. here code: <?php // xor "encryption" function x0rcrypt($text, $key) { if (strlen($schluessel) == 0) { return; } $result = ''; $i = 0; while ($i < strlen($text)) { ($j=0; $j < strlen($key); $j++) { if ($i >= strlen($text)) { break; } // text xor key $result .= $text{$i} ^ $key{$j}; $i++; } } return($result); } // hex bin function hex2bin($string) { retu

ruby on rails - How can I add a variable to an "it" statement in an rspec? -

if have let(:analysis_file_1) { "./spec/test_files/analysis1.json" } ... "should have message x" i'd print out value of analysis_file_1 in "it" statement. but doesn't work: it "#{analysis_file_1} should have message x" it errors out in `block in <top (required)>': undefined local variable or method `analysis_file_1' #<class:0x007f865a219c00> (nameerror) is there way use let defined variable in message? you can define constant this: analysis_file_1 = "./spec/test_files/analysis1.json" "#{analysis_file_1} should have message x" or in case have multiple analysis files can put them in array: ["./spec/test_files/analysis1.json", "./spec/test_files/analysis2.json", "./spec/test_files/analysis3.json"].each |analysis_file| "#{analysis_file} should have message x" # spec here end end

r - Improper p-value for Kruskal Wallis test; possibly related to NA values? -

i trying perform kruskal-wallis test between 2 columns in dataframe when saw that, if compare column itself, not p-value of 1: controlvcontrol<- kruskal.test(neurite.5rgd[,1], neurite.5rgd[,1], na.rm=true) controlvcontrol$p.value [1] 7.967453e-99 same thing happens if compare 2 different columns hold identical data: (1:length(neurite.5rgd[,1]))[which((neurite.5rgd[,1]-neurite.5rgd[,3])!=0)] integer(0) > controlvbdnf<- kruskal.test(neurite.5rgd[,1], neurite.5rgd[,3], na.rm=t) > controlvbdnf$p.value [1] 7.967453e-99 i figured due na values in columns, tried simple example: > x <- c(1, 2, 3, 4,5, na, na) > y <- c(1, 2, 3, 4,5, na, na) > krus <- kruskal.test(x,y, na.rm = true) > krus$p.value [1] 0.4060058 > ttest <- t.test(x,y, na.rm=t) > ttest$p.value [1] 1 can tell me i'm doing wrong?

Using a function in jquery contextMenu selector -

below example https://github.com/medialize/jquery-contextmenu . what need put function in "selector:" use bunch of logic make decision on element candidacy. any suggestions? $(function(){ $.contextmenu({ selector: '.context-menu-one', callback: function(key, options) { var m = "clicked: " + key; window.console && console.log(m) || alert(m); }, items: { "edit": {name: "edit", icon: "edit"}, "cut": {name: "cut", icon: "cut"}, "copy": {name: "copy", icon: "copy"}, "paste": {name: "paste", icon: "paste"}, "delete": {name: "delete", icon: "delete"}, "sep1": "---------", "quit": {name: "quit", icon: "quit"

Android - AttributeSet -

i have code this: public class cannonview extends surfaceviewimplements surfaceholder.callback{ activity activity; and constructor: public cannonview(context context, attributeset attrs){ super(context,attrs) activity = (activity) context; but apparently attributeset doing nothing, dont know why there, questions are: 1.-what attributeset? 2.-why need provide attributeset attrs second argument? way rest of code painting using canvas. thanks. http://developer.android.com/training/custom-views/create-view.html - explanation. shortly, attributeset needed gui editor. attributeset set of parameters layout_width , layour_height , on. need new custom attributes, need extend expand attributset class

uiviewcontroller - View unusable after dismissViewControllerAnimated:completion: -

i'm migrating older code used nibs use manual view creation ( loadview ) , auto layout . root view controller container vc (with 2 children) uses auto layout , modally presents view controller has layout specified in nib , not yet use auto layout. fine after presentviewcontroller:animated:completion: , when modal view closed dismissviewcontrolleranimated:completion: via delegate call, presenting view left in strange, unusable state content weirdly shifted , not react touch. i have tried create minimal test case reproduce problem, i've failed reproduce issue. what causing this? i setting translatesautoresizingmaskintoconstraints = no; on root uiview . appears "outermost" uiview — superview @ root of view hierarchy must use default translatesautoresizingmaskintoconstraints = yes . once i've removed this, worked expected.

Java generics enforce same type for keys and values of map -

what looking for: i'm looking construct enforces type on both keys , values of map: kind of map<key<x>, value<x>> . however, additionally enforce types match within each key/value entry, between entries, no type must should enforced. for example, within same map, these key/value pairs should considered valid: key<integer> maps value<integer> key<string> maps value<string> key<double> maps value<double> however, invalid: key<integer> mapping value<string> key<double> mapping value<boolean> how can accomplish using java generics? what i'm not looking for: i understand can implement set<pair> , pair accepts key/value of same type. however, looking key no longer constant time operation. i understand map<key<?>, value<?>> , assert key , value same type @ runtime. however, wondering if possible strictly using generics. you can this,

c++ - Using my own sort to sort 2D vertices clockwise -

so have vector of vertices i'm trying sort , i'm new using predicates. current sort vertices. void triangulate::ordervertices() { std::sort(mvertices.begin(), mvertices.end(), triangulate::clockwise()); } and sorting predicate bool triangulate::clockwise::operator()(const cvertex2& pointa, const cvertex2& pointb) { if(pointa.mpoint.x >= 0 && pointb.mpoint.x < 0) { return true; } if(pointa.mpoint.x == 0 && pointb.mpoint.x == 0) { return true; } // gets center of current viewport cvertex2 centercoordinate(cclipper::instance()->getmidx(), cclipper::instance()->getmidy()); // compute cross product of vectors int det = (int)((pointa.mpoint.x - centercoordinate.mpoint.x) * (pointb.mpoint.y - centercoordinate.mpoint.y) - (pointb.mpoint.x - centercoordinate.mpoint.x) * (pointa.mpoint.y - centercoordinate.mpoint

docusignapi - Manipulate the document name through Connect -

is possible manipulate document name when sent using docusign connect? we have multiple envelopes single document in each envelope name of pdf document getting sent docusign has same name it's overwriting saved document. use connect method receive xml file document pdf's , other information. i'm trying use name of document in envelope. you cannot rename document through docusign connect, have complete control on document name when adding envelope. if you're adding through docusign console can rename file on disk before uploading. if you're adding through api, control document name through name property of documents section of request body: "documents": [ { "name": "documentnamehere.pdf", "documentid": "1", "order": "1" } ] when adding through api can programmatically set name whatever want - instance can prompt use

Importing data and variable names from a text file in Python -

i have text file containing simulation data (60 columns, 100k rows): a b c 1 11 111 2 22 222 3 33 333 4 44 444 ... in first row variable names, , beneath (in columns) corresponding data (float type). i need use these variables data in python further calculations. example, when insert: print(b) i need receive values second column. i know how import data: data=np.genfromtxt("1.txt", unpack=true, skiprows = 1) assign variables "manually": a,b,c=np.genfromtxt("1.txt", unpack=true, skiprows = 1) but i'm having trouble getting variable names: reader = csv.reader(open("1.txt", "rt")) row in reader: list.append(row) variables=(list[0]) how can change code variable names first row , assign them imported arrays ? instead of trying assign names, might think using associative array , known in python dict , store variables , values. code (borrowing liberally csv docs ): import csv open('

java - Mockito: How do I mock an instance creation? -

consider need mock following line employee.addoffer(employee, new offer(details)); now need mock new offer(details) nothing the way try is donothing().when(employee).addoffer(any(employee.class), any(offer.class)); this fails nullpointerexception because tries execute new offer(details) , details nothing how can mock new offer(details) return other mock? you should mock offer : offer mockoffer = mock(offer.class); employee.addoffer(employee, mockoffer);

php - Remove entire image if image source is within a specific directory -

i trying strip out html code of images content if image path within specific directory. take example block of content: donec iaculis <img src="http://www.domain.tld/smilies/butterfly.gif" alt="butterfly.gif" /> arcu pretium elementum et posuere felis. <img alt="mrgreen.gif" src="http://www.domain.tld/smilies/mrgreen.gif" /> duis sit amet erat vitae tellus eleifend varius. <img src="http://www.domain.tld/avatars/somedude.jpg" /> pellentesque ac ligula what after is: donec iaculis arcu pretium elementum et posuere felis. duis sit amet erat vitae tellus eleifend varius. <img src="http://www.domain.tld/avatars/somedude.jpg" /> pellentesque ac ligula in example need have 2 images's removed contain /smilies/ , leave 1 img exists within /avatars/ path. note alt="" in 2 different locations on 2 images matches. <?php $html = 'donec iaculis magna eget <img src=&q

mysql - Display pdf from database using php -

there pdf file stored in database [blob - 143.3 kib]. it's got userid of 12. trying call page when click on button, pdf populates webpage. if (isset($_post["work"]) && !empty($_post["work"])) { $result = mysql_query("select file ce userid=12", $c) or die("six"); $document1=mysql_result($result, 0, 'file'); echo $document1; } echo ' <form action="yourcase.php" method="post"> <input type="hidden" name="work" value="1"> <input type="image" id="work" src="images/papers.png"> </form>'; currently, echos out page of this: ‰Œa Â@e÷9Å_ê&&Ói[Ž€°£ zqŠôúÆŽ@ïåÿ&ŠÆÑ,¢y[«*Æx%Ó@/rˆoÝçÇ¡. using post, able call pdf file desktop, can't figure out how database. $file = 'sample.pdf'; $filename = 'sample.pdf'; header('content-type: ap

java - Erratic auto-scrolling in JList -

i'm trying create jlist allows re-order items in list dragging them. working ok, except auto-scrolling behavior jerky , erratic. when grab item in list , drag bottom of list, expect scroll smoothly , continuously, scrolls few pixels , stops. if jiggle mouse cursor around edge of jlist, continues scrolling few pixels @ time, not acceptable behavior. does have suggestions on how fix this? in case matters, i'm running java 6 on mac os x 10.8.3. import javax.swing.*; import java.awt.*; import java.awt.datatransfer.stringselection; import java.awt.datatransfer.transferable; public class draggablejlist { public static void main(string[] args) { eventqueue.invokelater( new runnable() { public void run() { int count=200; string[] elements = new string[count]; for(int n=0; n<count; n++ ) { elements[n] = string.valueof( n ); } jlist list = new jlist(

c# - Is it OK to subclass solely to provide default state/configuration? -

say have gui framework supports nesting gui components inside 1 another. let's call base class gui component can contain other gui components container. is ok subclass container soley provide default configuration, or should subclassing provide addition/override/implemented behavior? example, wanted make buttonbar container filled 100% of screen width, 50 pixel in height, , laid out components horizontally. configure container that, either of following 2 examples: container container = new container(); container.percentwidth = 100; container.height = 50; container.layout = layout.horizontal; // use container or, (and question), ok this: public class buttonbar : container { public buttonbar() { percentwidth = 100; height = 50; layout = layout.horizontal; } } buttonbar buttonbar = new buttonbar(); // use buttonbar buttonbar has no additional functionality on container, , overrides no container methods. serves ease configuring co

java - Frontend Bug Reporting plugin for Website Beta Tester -

Image
i looking bug reporting solution can embed website. allow users report front end issues directly page , able capture screen clippings, ideally have kaptcha prevent basic spamming. have issue tracker, want ease reporting process encourage reports can submitted anonymously. i haven't yet managed find suits needs, tools have found far seem browser based plugins or web based issue trackers not after. usersnap solves problem. delivers visual feedback (screenshot + annotations) , integrates existing bug tracker (have @ list here: http://usersnap.com/doc/connect ). it's small widget added web page in minutes (just few lines of javascript):

css - angular js dom manipulation with directives -

i trying use angular directives dynamically replace html portion of portlet of page. the html portlet has 2 sections embedded. top part has heading obtained different backend service <div class="headerdiv"> <h3 class='headerclass'> <a href="">object heading</a> </h3> </div> the content loaded in different section <div id="objectdiv" ng-controller="objectctrl"> <div ng-show="object.title" mydirective><b>{{object.title}} </b></div> <div element-trigger><b>{{object.name}} </b></div> <div element-trigger><b>{{object.description}} </b></div> </div> the controller loads details successfully the new directive added app.directive('mydirective', function(){ return function(scope, elem, attrs){ //obtain old header var oldheader = angular.element( '.headerdi

Why doesn't grep give the matching line? -

i've noticed that grep -rni 'a2}' * does not give all documents have string a2} matching line. why case? i've tried create minimal example, when create new file , paste content, fails. i've uploaded file git repository . perhaps it's encoding problem. the content of file is: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{kv-diagramme} \label{chap:a2} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pstexabbildungohnecaption{figures/a2-1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% local variables: %%% mode: latex %%% tex-master: "skript" %%% end: the result of grep -rni 'a2}' * is moose@pc08 ~/downloads/algorithms/grep $ grep -rni "a2}" * %%% end:master: "skript"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% but expected moose@pc08 ~/downloads/algorithms/grep $ grep

javascript - In HTML5, please explain the meaning of '?' in the statement -

in html5, meaning of '?' in statement? what's meaning of content after '?'? <script type='text/javascript' src='http://mobile.smashingmagazine.com/wp-includes/js/thickbox/thickbox.js?ver=3.1-20121105'> </script> in html 5, nothing. part of url. in case, indicates start of query string , process on server may give special attention to. it might give no special meaning whatsoever, there url different avoid older, cached versions of same file being reused after changes made it.

c# - How to Parsing XML? -

how parse xml.here, want take name , picture url.. i trying code.. facebookclient client = new facebookclient(); var friendlistdata = client.get("https://graph.facebook.com/?ids=100005000000000&fields=name,picture"); jobject friendlistjson = jobject.parse(friendlistdata.tostring()); string json = convert.tostring(friendlistjson); xmldocument doc = (xmldocument)jsonconvert.deserializexmlnode(json, "root"); string xml = doc.innerxml; xdocument myxdoc = xdocument.load(new stringreader(xml)); var list = loc in myxdoc.descendants("root").elements("100005000000000") select new { //id = loc.element("id").value, name = loc.element("name").value, url=loc.element("url").value, }; but, getting error "name cannot begin '1' character, hexadecimal value 0x31." please correct it. <root

Implementing android's default Gallery like view -

in gallery app, first shows albums in thumbnail. on click of each albums shows images in gridview . on click of gridview images opens full screen. what have done: initially, i'm loading images(http images) in galleryview (horizontal scroll) , on click of galleryview items opens images in gridview .then on click of gridview items, open in fullscreen. working :) what i'm looking for: in galleryview want show albums. on click of galleryview items has open images of particular album in gridview . i'm using android universal image loader.

how to apply many rotate translate,scale animation to imageview in android -

hi doing 1 application here when activity starts time need rotate image first need move image top center there have scale image after time have in visable imageview,i tried using below code first applied rotate animation applied translate animation.after 2 seconds applied scale animation image not scaling in center taking imagview original postion(top) there scaling need scale imageview after move animation there @ postion need scale image view...any 1 suggest how apply different animations single imageview. public class extends activity{ translateanimation movelefttoright1; animation logomoveanimation; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.game); final imageview myimage = (imageview)findviewbyid(r.id.imageview1); //rotate animation final animation myrotation = animationutils.loadanimation(getapplicationcontext(), r.anim.rotator); myimage.startanimation(myrotatio

security - How safe are PHP session variables? -

i have login script verifies username/password against data in 'user' table. furthermore, have 'roles' table specifies access level of given user. assuming using safe login scripts, there security holes in performing additional query, upon successful login, against 'roles' table discover user's authorization level , storing session variable? idea on page mixed authority, query session variable discover logged in user's authorization level. thanks. sessions safer than, say, cookies. still possible steal session , hacker have total access whatever in session. ways avoid ip checking (which works pretty well, low fi , not reliable on own), , using nonce. typically nonce, have per-page "token" each page checks last page's nonce matches has stored. in either security check, there loss of usability. if ip checking , user behind intranet firewall (or other situation causes this) doesn't hold steady ip user, have re-authenti

c++ - Walking an object on a terrain (made using heightmap) in OpenGL -

to walk object on terrain, i'm keeping camera , object fixed, , moving terrain according keyboard button pressed (using gltranslatef). i'm able move along x , z axis easily, when i'm moving along y axis, i'm having lot of trouble. here essential parts of code: i've made class called terrain uses bmp file height @ different points. essential code is: float terrain::getheight(int x, int z) { return hs[z][x]; } terrain* loadterrain(const char* filename, float height) { image* image = loadbmp(filename); terrain* t = new terrain(image->width, image->height); (int y = 0; y < image->height; y++) { (int x = 0; x < image->width; x++) { unsigned char color = (unsigned char) image->pixels[3 * (y * image->width + x)]; float h = height * ((color / 255.0f) - 0.5f); t->setheight(x, y, h); } } delete image; t->computenormals(); return t; }

c# - set minimum number of rows in visual studio report viewer -

i showing total of values in column on every page placing textbox in footer , setting expression of column sum(reportitems!sales.value). wan't set number of rows in page fixed value of 36. if number of rows in page less 36 want show empty rows rows. know possible set number of rows in page using group expression , using page break group. want show empty rows if number of rows less fixed row. please help. thanks in advance

android - Get position of ListView -

i using customized listview edittext , checkbox. displayed both editext , checkbox in public view getview(final int position, view convertview, viewgroup parent) and list view have number of counts presents. position getview shows number of counts appear in screen, when scrolled down, again position started zero. tried list view onitemclick listener, there noting response. there way position of listview. public view getview(final int position, view convertview, viewgroup parent) { system.out.println("index:"+position); ......... } `

ios - dynamically set navigation controller title -

i'm working core data, , part of app very similar default contacts app. there edit screen after contact in core data, , make title: [insert contact name here] s information". know can set title core data entity attribute doing: self.navigationcontroller.title = _athletesfullname; (property attribute under entity "athlete"). there way can self.navigationcontroller.title = @"%@'s information",_athletesfullname; ? try code: self.navigationcontroller.navigationitem.title=[nsstring stringwithformat:@"%@ 's information",_athletesfullname];

spring - Is it possible to get a List of all active Sessions? -

when being in grails action can access httpsession session . is possible list of active sessions? you can use getsessionsinfo() method of scopesinfoservice service of application info plugin. first install plugin(in buildconfig) compile ":app-info:1.0.2"{ excludes 'jquery' } then make entry in config grails.plugins.appinfo.usecontextlistener = true finally inject service , use getsessionsinfo() method def scopesinfoservice ... scopesinfoservice.getsessionsinfo() to list of active sessions.

c++ - Printf and cout only printing first character of args cpp -

i may missing point here have following method print out args in cpp program in visual studio: int _tmain(int argc, char* argv[]) { char* fu = "bar"; std::cout << "test, " << argc << ", " << argv[0] << ", " << argv[1] << ", " << fu << endl; printf("%s, %s, %s", argv[0], argv[1], fu); return 0; } the problem having seems print first character of args , not whole string. from can tell, argv[0] dereferences argv array char*, , passing cout/printf functions. should print characters \0 character. i created test char* fu see if problem passing in char* functions, 'bar' printed. the thing can think because size of fu known @ compile time , size of argv isn't funny going on way compiled. i know can print out contents looping through characters seems defeat point, example if want work strings comparison or something. can please expl

how to delete .svn hidden files from terminal in ubuntu 11.10 -

i have problem in using svn repository. when try update project in svn m getting following error oomsys@oomsysmob-6:~/brundelre3$ svn st svn: warning: '.' not working copy oomsys@oomsysmob-6:~/brundelre3$ svn skipped '.' i tried things explained these error these links: removing .svn files directories find , remove hidden folders svn ubuntu linux command line how remove svn folders recursively but nothing solves problem. want remove hidden files project. .svn directory in root of working directory. need delete root folder unversion files. can checkout again @ same location , svn version files without downloading if there no new updates.

java - How do I check if a environment variable exists in my pom.xml? -

if runs pom.xml nasty error because environment variable not defined. trap , show more straightforward error problem can fixed defined environment variable. know not idea have environment variable in pom, time need to. clues? the variable java_6_home, path jdk6 since default 1 jdk7 maven-enforcer-plugin can it: <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-enforcer-plugin</artifactid> <version>1.3.1</version> <executions> <execution> <id>enforce-property</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireenvironmentvariable> <variablename>java_6_home</variablename> &l

PHP Convert string into array -

how convert string $string = 'array(array("a"=>"content"))'; (<-- string) array this: array(1) { [0]=> array(1) { ["a"]=> string(7) "content" } } i going build function run serialize online: input: $string = 'array(array(1))'; echo serialize($string); result: a:1:{i:0;a:1:{i:0;i:1;}} not s:16:"array(array(1)))"; you call: $returnvalue = serialize('array(array(1))'); you /could/ use eval() : $string = 'array(array("a"=>"content"))'; eval("\$array = $string;"); print_r($array); output: array ( [0] => array ( [a] => content ) ) but if you're accepting user inputs, should not use eval() . also, consider using json_encode() / json_decode() instead. alternatively, store arrays in strings, use serialize , unserialize .

json - Is it possible to skip or ignore a attribute while using Streaming API of Jackson -

this json source. can skip retweeted_status token , move next contributors token (not 1 inside retweeted_status token). currently following code goes retweeted_status object , parsing each 1 of them: jp = jsonf.createjsonparser(strline); if (jp.nexttoken() != jsontoken.start_object) { throw new ioexception("expected data start object"); } twitterentry result = new twitterentry(); // iterate on object fields: while (jp.nexttoken() != jsontoken.end_object) { string fieldname = jp.getcurrentname(); // let's move value jp.nexttoken(); if (fieldname.equals("id")) { result.setid(jp.getlongvalue()); } else if (fieldname.equals("text")) { result.settext(jp.gettext()); } else if (fieldname.equals("fromuserid")) { result.setfromuserid(jp.getintvalue()); } else if (fieldname.equals("touserid")) { result.s

Admob integration with pygame in android -

hello curious know solution integrating admob app written in pygame subset android. have tried below things did' t work me :( still nothing working me may there no way :( try 1: followed google https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals#android solution has no code change build.xml modification didt works me :( try 2: tried below solutio also. http://www.michenux.net/android-admob-tutorial-461.html did't work me :( try 3: tried hack pythonactivity.java. getting below related errors. have googleadmobadssdk-6.4.1.jar in \pgs4a-0.9.4\libs path still below kind of error. below code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //vrbilgi setcontentview(r_layout_main); // setcontentview(r.layout.main); // create adview // adview = new adview(this, adsize.banner, my_ad_unit_id); adview = new adview(this, adsize.banner,"a15

variables - sed replacing without untouching a string -

im trying replace lines within files contains: /var/www/webxyz/html to /home/webxyz/public_html the string: webxyz variable: web1, web232 so string before , after webxyz should replaced. tried without solution: sed -i 's/"var/www/web*/html"/"home/web*/public_html"/g' also want should check , replace files (inclusive subdirectory , files), * operator don't work. within regular expression, you’ll need escape delimiting character surround them, in case / . can use different delimiter , : sed -i 's,"var/www/web*/html","home/web*/public_html",g' but working intended, you’ll need remove " , replace b* (sed doesn’t understand globbing wildcards) this: sed -i 's,var/www/web\([^/]*\)/html,home/web\1/public_html,g' here \([^/]*\) used match after web except / . matching string referenced \1 in replacement part.

sql server - Create a dynamic table based on existing table result in sql -

this question has answer here: sql server 2008 vertical data horizontal 3 answers this actual table. month rcount cond_id cond_desc jan-13 52 -1 n/a jan-13 194 0 normal jan-13 86 2 abnormal feb-13 54 -1 n/a feb-13 158 0 normal feb-13 110 2 abnormal mar-13 14 -1 n/a mar-13 113 0 normal mar-13 90 2 abnormal apr-13 3 -1 n/a apr-13 259 0 normal apr-13 144 2 abnormal may-13 10 -1 n/a may-13 693 0 normal may-13 305 2 abnormal may-13 1 4 critical jun-13 169 0 normal jun-13 36 2 abnormal jun-13 1 4 critical i need following results. r_id cond_id cond_desc jan-13 feb-13 mar-13 apr-13 may-13 jun-13 1 -1 n/a 51 54 14 3 10 169 2 0 normal 194 158 113 259 693 36 3 2 abnormal 86 110 90 144 305 1 4 0 critical 0 0 0 0 1 0 assuming wont t

Declare an empty two-dimensional array in Javascript? -

i want create 2 dimensional array in javascript i'm going store coordinates (x,y). don't know yet how many pairs of coordinates have because dynamically generated user input. example of pre-defined 2d array: var arr=[[1,2],[3,4],[5,6]]; i guess can use push method add new record @ end of array. how declare empty 2 dimensional array when use first arr.push() added index 0, , every next record written push take next index? this easy do, i'm newbie js, , appreciate if write short working code snippet examine. thanks you can declare regular array so: var arry = []; then when have pair of values add array, need is: arry.push([value_1, value2]); and yes, first time call arry.push , pair of values placed @ index 0. from nodejs repl: > var arry = []; undefined > arry.push([1,2]); 1 > arry [ [ 1, 2 ] ] > arry.push([2,3]); 2 > arry [ [ 1, 2 ], [ 2, 3 ] ] of course, since javascript dynamically typed, there no type checker enforcing

scala - if (Option.nonEmpty) vs Option.foreach -

i want perform logic if value of option set. coming java background, used: if (opt.nonempty) { //something } going little further scala, can write as: opt.foreach(o => { //something }) which 1 better? "foreach" 1 sounds more "idiomatic" , less java, less readable - "foreach" applied single value sounds weird. your example not complete , don't use minimal syntax. compare these 2 versions: if (opt.nonempty) { val o = opt.get // ... } // vs opt foreach { o => // ... } and if (opt.nonempty) dosomething(opt.get) // vs opt foreach dosomething in both versions there more syntactic overhead in if solution, agree foreach on option can confusing if think of optional value. instead foreach describes want sort of side effects, makes lot of sense if think of option being monad , foreach method transform it. using foreach has furthermore great advantage makes refactorings easier - can change type list

Link C Flex lexer to C++ parser -

i using flex develop lexer language of mine. want create parser in c++ , using own approach it. since lexer in c (flex), want compile lexer ( gcc -c lex.yy.c -lfl ) , program ( g++ -c file1.cc file2.cc ... ) separately , link them create final executable. in particular, after creating lexer, write following code c++ program: #include <iostream> extern int yylex(); int main(int argc, char** argv); int main (int argc, char** argv) { yylex(); return 0; } but link error when link stuff like: g++ main.cc lex.yy.o -lfl but get: /tmp/ccbrhobp.o: in function `main': main.cc:(.text+0x10): undefined reference `yylex()' collect2: ld returned 1 exit status where problem? thankyou what happens here compile c code, this: int yylex() { // ... } it generates yylex symbol. compile c++ code. c++ allows 2 different functions same name exist, can't use name of function symbol name. when write int yylex(); on c++ code, gcc looks symbol: _z5yylexv .

I have an issue with animating the height of my nav with jquery - it makes me click the button twice -

i have nav height set 0px. when click on element (here, #menu_button) nav's height supposed change given height (here, 143px). toggles it. problem i'm made click button twice first time before works properly. please help. btw i'm new here. here's code: <nav> <ul> <a href="#port"><li><p>portfolio</p></li></a> <a href="#about"><li><p>about me</p></li></a> <a href="#contact"><li><p>contact me</p></li></a> </ul> </nav> <div id="container_menu_button"> <div id="menu_button"> <div id="menu_pic"></div> </div> </div> (css of nav) nav { height:0px; overflow:hidden; } (jquery) <script> $("#menu_button").click( function(event){ event.preventdefault(); if ($(t

multiple forms handled by one script php -

i try create order page on php. have created form stores data database. form number based on user , created dynamic. <?php if(isset($_post['submit_num'])) { $number=$_post['sky']; for($i=0;$i<$number;$i++) { $item = $_session['item']; echo $item; $rec_query = "select * ylika"; $rec_result= mysql_query($rec_query) or die("my eroors"); echo '<form action="user_order_form.php" method="post">'; echo '<html>'; while($row_rec = mysql_fetch_array($rec_result)) { echo '<input type="checkbox" name="yliko[]" value='.$row_rec['onoma'].'> '.$row_rec['onoma'].''; echo '<br>'; } echo '<br>'; echo '<input type="submit&

Python and Arduino Serial Communication -

i using python 3.2 trying communicate arduino through serial port. documentation, understad arduino serial.read() reads individual bytes. however, when tried implement this, serial.read() reads numbers sent. here code python , arduino for example, have value 412 send arduino. python: xcoordint = 412 xcoordconverted = "%03d" % (xcoordint) xcoord = [int(i) in str(xcoordconverted)] xsingledigit0 = chr(int(xcoord[0] + 48)) xsingledigit1 = chr(int(xcoord[1] + 48)) xsingledigit2 = chr(int(xcoord[2] + 48)) ser.write (bytes(xsingledigit0, 'utf-8')) ser.write (bytes(xsingledigit1, 'utf-8')) ser.write (bytes(xsingledigit2, 'utf-8')) arduino: char joincharx[3] ; int n_avail = serial.available(); if(n_avail>0){ (int i=0;i<3; i++){ joincharx[i] = serial.read(); } int xcoords = atoi(joincharx); serial.print(joincharx[0]); the joincharx[0] when returned 412 , not 4. wondering why , how read 1 individual byte @ time? try

java - Tomcat Server Publishing issue in eclipse -

Image
when trying start server getting below exception could not publish server.java.lang.indexoutofboundsexception technologies jsf2,primefaces3.5,tomcat7,java7,gson2.2.4 oprating system ubuntu13+ ide eclipse kepler i noticed when removing gson2.2.4.jar working fine after adding jar nothing working , server not started. i found issue when adding in pom.xml <dependency> <groupid>com.google.code.gson</groupid> <artifactid>gson</artifactid> <version>2.2.4</version> </dependency> its creating issue when run mvn install got error [error] error: error reading /home/hariom/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar; invalid loc header (bad signature) so replaced dependency one <dependency> <groupid>com.google.code.gson</groupid> <artifactid>gson</artifactid> <version>2.2.2</version> </dependency>

asp.net mvc - Best Way to reuse code inside my Controller action method -

i have code in same controller class looks same, such setting viewbags populate drop down lists, same code applies in post , create , edit action methods. have created private method @ end of controller class follow:- private void populateviewbags() { string controllername = routedata.values["controller"].tostring(); viewbag.possibledatacenters = repository.alldatacenter().orderby(a => a.name).tolist(); viewbag.possiblezones = repository.allzone().orderby(a => a.name).tolist(); list<string> s = new list<string>(); s.add(controllername.tolower()); viewbag.products = repository.getproducts(s).orderby(a => a.componentname).tolist(); viewbag.sites = repository.getsdorg().orderby(a => a.name).tolist(); viewbag.customers = repository.findaccountdefinition(null).tolist(); } and calling method inside action method. right way re-use code? thanks there 2 standard ways can this. 1st approach - override onaction