Posts

Showing posts from January, 2012

matlab - Submatrix in C++ -

i have programming issue regarding extraction of subimage (submatrix) bigger image (matrix). have 2 points (upper , lower bound of subimage want extract) , want extract subimage bigger 1 based on these points. can't find how thins c/c++. i know it's easy matlab. suppose these 2 points (x_max,y_max) , (x_min,y_min). extract subimage need code following: (matlab code)-> small_image=big_image(x_min:x_max,y_min,y_max); but in c can't use interval of indexes : matlab. here faced problem before? if doing image processing in c/c++, should use opencv . the cv::mat class can using region of interest (roi) .

dictionary - Recipe from Python Cookbook -

i'm trying implement recipe o'reilly's python cookbook (2nd ed.) , small portion of recipe doesn't work should. hoping me figure out why. the recipe "5.14: enhancing dictionary type ratings functionality." i've got of code working, error when trying change 'ranking' of key. i've left in comments author's trying have idea "unders" , "dunders" for. "_rating" aspect, believe somehow causing error. error: file "rating.py", line 119, in <module> r["john"]=20 file "rating.py", line 40, in __setitem__ del self._rating[self.rating(k)] ## attributeerror: 'ratings' object has no attribute 'rating' code: class ratings(userdict.dictmixin, dict): '''the implementation mixes inheritance , delegation achieve reasonable performance while minimizing boilerplate, and, of course, ensure semantic correctness above. mappings'

queue - How to implement double compare and swap in C/Linux? -

i reading paper "simple, fast, , practical non-blocking , blocking concurrent queue algorithms" , realized that assume computer implements following pseudo-code atomically: cas(q->tail,tail,<next.ptr,next.count+1>) where q->tail , tail pointer , instance of struct containing pointer , counter. i know gcc provides couple of build-ins single word compare , swap in c. however, possible implement non-blocking atomic double compare , swap single compare , swap in c (using linux)? right approach implement pseudo-code of referenced paper? i don't know of cas operations work on 2 distinct memory locations. however, it's possible paper using struct pointer , counter workaround treat both fields larger type, , therefore, change both atomically. assuming have struct of 2 fields, pointer , counter: pointer size of 4 bytes, counter size of 4 bytes; aligned without padding struct size of 8 bytes. assuming have cas operation handles values of 8 byte

SQL Server : if one value in a column occurs at least once or another value more than once -

i'm glad have question @ least working example time. used efficient query when had criteria result returned if had count >= 1. had additional count different code values , if occur 2 or more times. query went running in few seconds 43 seconds. i think have logic right wondering if had more efficient way this. select person.person_id person person.person_id in ( select procedure.person_id procedure procedure.performed_by = '555555' , procedure.code in ( '99201', '99202' ) , year(procedure.service_date) = year(getdate()) group procedure.person_id having count(1) >= '1' ) -- having count >= 1 occurrences or person.person_id in ( select person_id procedure procedure.performed_by = '55555' , code in ( '99304','99305' ) , year(procedu

video - Rendering Performance ffmpeg of JAVACV on Android -

i doing application creates video using set of photos saved in sd-card. problem trying fix application crashes when create videos. crashes depends of resolution of source picture files. example, can render video using 400 images resolution of 320x480 can 25-frames video using images resolution of 2500x3200. i doing rendering process in background using asynctask (for providing feedback user , maintain informed of rendering process). when rendering process crashes no warnings/errors/etc captured in logcat. using ddms examining memory usage can not view memory leak (i not recieve memory warning on logcat). reasons supose may problem related ffmpeg libraries (but have no idea). i have testet different codecs defined on avcodec.java, like: av_codec_id_mpeg1video = 1, av_codec_id_mpeg2video = 2, av_codec_id_h263 = 5, av_codec_id_mjpeg = 8, etc trying lossless video codecs seems not doing effect, , errors when try codecs. i running application on sony ericsson xp

ios - Load a .tmx (Tiled Map) in Sprite Kit? -

is there (preferably easy) way load .tmx file in ios 7's sprite kit? if not, there alternatives? check out tilemapkit sprite kit. unlike other solutions loads , renders (!) map types , variations supported tiled, including staggered iso , hex maps! tilemapkit engineered oop framework should be, , exposes data stored in tmx file. in other words it's not single class got crammed it. tile picking (point coord, coord point conversion) map types/variations built-in. more awesome features on way, review roadmap , check out class reference . tilemapkit tested fully compatible swift , mac apps, too. visit tilemapkit forum if have questions or requests. i'm posting frequent development reports can check what's coming next. disclaimer : if isn't obvious now, i'm 1 of tilemapkit developers. :)

java - Drag and move JPanels in a group of JPanels -

there group of 10 jpanels placed in gridlayout. want drag 1 jpanel(for instance panel1) , place on jpanel (for instance panel2) , move panel2 left or right , place panel1 in panel2 position. able drag jpanel using drag option, not able drop @ required position. need in moving panels in drop location. sorry, if question not clear. hope understand. in advance. you try this, said, there's better way: public jpanel getpanelcolliding(jpanel dragpanel, jpanel[] panels) { rectangle rdrag = dragpanel.getbounds(); (jpanel panel : panels){ if (panel == dragpanel) continue; rectangle r = panel.getbounds(); if (r.insersects(rdrag)) return r; } return null; } then in drag listener can call , swap panel locations if getpanelcolliding() not null. didn't test this, should work!

glassfish - Eclipse (Kepler) Ignoring Context Root -

we have multi-module maven project. context root our jax-rs specified in pom , application.xml gets generated when maven build on project. inside eclipse when clean/build project , deploy glassfish context-root gets ignored , context-root ends being name of war file. is there way override this? didn't seem issue in older version of eclipse had been using. if you're running server inside eclipse, try right-clicking project , going properties > web project settings. change context root want , click apply. in servers tab, turn off glassfish if it's running, right click glassfish server , choose clean it. try running project.

Jenkins Dedicated Dashboard Server -

i in need of setting dedicated jenkins dashboard server, houses jobs multiple server. each jobs configured on seperate build machine. can please suggest best approach ?? note: master/slave config not option since want entire build done @ build server , dashboard server managing , reporting respective projects thanks in advance

javascript - Google Maps with OMS - Marker properties in response to click event -

i'm having bit of problem overlappingmarkerspiderfier google maps api: near start of script, store of markers in array called "parentnodes". when click on marker, need able detect "id" of marker ("id" property of each marker set whenever initialising them) can run function hides of markers except 1 clicked on. i've tried adding listener each marker after initialise them, wouldn't recognise array, though it's global, giving me error "parentnodes[i] undefined" whenever clicked on marker. for(var = 0; < parentnodes.length; i++) { oms.addlistener('click', function() { console.log(parentnodes[i].id); }); } i thinking better solution have 1 listener, there way of accessing properties of marker if listener doesn't know 1 clicked on , whether or not other markers underneath it? or listener know somehow? this faq

c++ - why can't objects be created without a constructor? -

why creation of object needs constructor? if don't define constructor default constructor generated ..but why constructor necessary? why can't objects created without constructor? this more of discussion on terminology real argument behavior. mention, in cases there nothing done during construction, there should no need constructor, right? well, there concept of trivial-constructor constructor not @ all. sake of standard document, easier treat having (possibly trivial) constructor have provide cases , exceptions in places states 'constructor'. consider every use of 'constructor' have replaced 'constructor or nothing if type not have virtual functions or bases , no members require generation of constructor'. this same reason why virtual functions called overrider first 1 in hierarchy definition not override anything. form of generalization makes language easier interpret, although not many people claim section 8.5 on initializati

javascript - How to go to another html page and click a button automatically? -

i got 2 html page , b. when click link in a, want open b , pass value b. value added text input in b , button in b click automatically? how achieve function? i´m not quite sure of want i'll give try, first need javascript or js library achieve , php. first things first: create link: <a href="pageb.html">go page b</a> now can pass value using method, since want pass value need page format .php , not .html. add value link: <a href="pageb.php?data=123">go page b</a> so have value named "data" '123' in it. in page b need open php initializer this: <?php $data = $_get['data']; ?> <input type='text' value='<?=$data?>' /> <input type='submit'id="buttontobeclicked" > <script> document.getelementbyid("buttontobeclicked").click(); </script> in case need form action. stuff inside click button automatcly

excel - populating HTML template from an external source -

i've done lot of searching on it's bit tricky when you're not quite sure you're searching for. i've produced html email template designed include list of events company runs. each list item includes event title, date , short description. have list set out table. reason being html document has filled in others aren't versed in html , easiest way find them able fill in, adding new table rows etc without messing template (we used use lists , we'd end list items popping everywhere, list items not getting closed etc.) anyway long story short; there way me populate these table cells (or list items) source? 1 method thought work inputting data excel spreadsheet/database, running puts data html template , outputs new html document can use in email (ie have static , not sourcing it's info externally). i'm sure it's possible way beyond own abilities, wanted advice. sorry long post!

jbpm - Drools Error- ERR 102 Line 9:143 mismatched input '==' in rule -

Image
i trying configure decision table evaluate condition. below snippet decision table. while doing getting following error [err 102] line 8:143 mismatched input '==' in rule "rules_11". i not sure doing wrong. the problem in line 9 condition cannot have variable comparison floating there. $selectedattribute.code in line 9 doesn't mean anything, that's not conditional element.

jquery - How to trigger transition plugin on click? -

i found plugin http://jsfiddle.net/addyosmani/a89sq/show/ animates bars when page loads. want animations start individually when each bar clicked on. idea how this? thanks here code $(window).load(function () { $(function () { function updatestatus(msg) { $('.status').html(msg); } function compattest() { if (modernizr.csstransitions) { $('.compat span').html('yes'); } } compattest(); $('.alt0').animate({ width: '480px' }, 4000, function () { updatestatus('animation 1 complete'); }); $('.alt1').animate({ width: '480px' }, 5000, function () { updatestatus('animation 2 complete'); }); $('.alt2').animate({ width: '480px' }, 20000, function () { updatestatus('a

casting - Java cast: Which is better -- the imperative or programmatic way? -

i have seen there 2 ways cast object in java: list<object> l = new arraylist(); arraylist<object> first = (arraylist<object>) l; arraylist<object> second = arraylist.class.cast(l); which better , why? the better method readable. if know class type cast, use (classtoupcast) object . if don't know class but have class<classtoupcast> clazz object, use clazz.cast(object) .

hadoop - impala time in Hue UI -

i trying estimate time required queries simple complex in impala , using hue ui. possible know time needed complete query through ui. impala or hive provides general estimate of progress. hue try display end time extrapolating start time current progress. feel free follow https://issues.cloudera.org/browse/hue-1219 .

uglifyjs - Reverse Uglified Javascript Code -

i looking way (preferably , online site) reverse uglify of javascript. website: http://jsbeautifier.org/ great minifed code, not great job ugly stuff. chrome dev tools can this. point no 2 in http://www.elijahmanor.com/2011/08/7-chrome-tips-developers-designers-may.html

macvim - Location-dependent vim settings -

i work on multiple software projects have different style conventions. possible vim automatically change settings (e.g. indentation) depending on directory particular file lives in? no vim doesn't have settings appropriate what's described. but there's plugin that however, may find plugin want example vim-independence : the plugin automatic, if file .vimrc exists in git project root - load it. (full disclosure: wrote script)

Java hashmap will not allow get method to be called -

i have java program nested hashes. when call value inside inner nest, given error stating cannot call type object, when call getclass().getname(), given hashmap. here copy of traceback exception in thread "main" java.lang.error: unresolved compilation problem: method get(string) undefined type object @ epitopeanalysis.parsecolumns(epitopeanalysis.java:88) @ epitopeanalysis.<init>(epitopeanalysis.java:43) @ jobmanager.<init>(jobmanager.java:42) @ analyzer.main(analyzer.java:13) here copy of code import java.awt.list; import java.lang.reflect.type; import java.util.arraylist; import java.util.collections; import java.util.hashmap; import org.bson.types.basicbsonlist; import com.google.gson.*; import com.google.gson.reflect.typetoken; import com.mongodb.basicdblist; import com.mongodb.basicdbobject; public class epitopeanalysis { int combinations; int[] positions; string locus; arraylist<subject> subjects;

php - Jquery submit radio button without reload and -

so because experience jquery 0 have no idea how run mysql script when form submitted without reloading page? in short form radio button submit --> form sended --> query without reload my script: <form id="myform" method="get"> <div class="row"> <div class="span4 info1"> <section class="widget"> <img src="../bootstrap/img/thumb/0.jpg" width="auto" height="auto"> <?php if ($selectedbg == '0') { echo '<h2>current one</h2>'; } ?> <input type="radio" name="options[]" value="0" onclick="document.getelementbyid('myform').submit();"/> choose background </section> </div> </div> <?php $checked = $_get['o

c++ - Algorithm for maintaining a transformation matrix stack in graphics -

this question has answer here: modern opengl: vbo, glm , matrix stacks 4 answers i trying write small 2d graphics library using sdl. want implement equivalent of matrix stack in opengl , implement functions pushmatrix() , popmatrix() in opengl. can coding matrix multiplications. need algorithm storing stack , managing transformations. a stack array, or linked list, push operation creates copy of last/topmost element , appends @ end, , pop operation removes last element list/array. using/implementing arrays/linked lists basic computer science knowledge.

wpf - using custom controls instead of user controls to create complex views -

i not have enough information wpf, please correct me. seems handle different views create many usercontrols needed(each view needs 1 usercontol binds viewmodel) , , using mvvm pattern designers can create views independently. if designer tries create 2 themes different structure, has create 2 usercontrols because when using usercontrols layout specified(as mentioned here ). on other way customcontrols not specify layout, seems using customcontrols more reasonable. question: using custom controls instead of usercontrols correct, , if is, reasonable viewmodels inherit control, , views become styles viewmodels? unless need functionality provided custom controls, suggest using usercontrols or datatemplates. simpler. here's related question\answer. wpf user controls vs custom controls

angularjs - Where does the error event go in Angular when using a factory? -

i have code below working need create handler when error occurs not sure how insert that.. put in factory on in main method? msaapp.factory('msa', function ($resource) { return $resource('/api/place/:id', { id: '@id' }, { update: { method: 'put' } }); }); $scope.delete = function () { debugger; var id = this.msa.placeid; msa.delete({ id: id }, function () { $('#todo_' + id).fadeout(); }); } edit 1: $scope.delete = function () { debugger; // var id = this.msa.placeid; var config = { method: 'put', url: 'api/place/:id', data: { 'some': 'data' } } $http(config) .success(function (data, status, headers, config) { console.log(data); }) .error(function (data, status, headers, config) { console.log(data); }); //msa.delete({ id: id }, function () { // $('#todo_' + id).fadeout(); /

clojure - ClojureScript macro error: "Can't def ns-qualified name" -

what's causing error? (defmacro defn+ [name & stmts] `(defn htrhrthtrh ~@stmts)) (defn+ init [] (js/alert "hi")) -- java.lang.assertionerror: assert failed: can't def ns-qualified name (not (namespace sym)) htrhrthtrh gets namespace-qualified syntax-quote in output, result looks like (defn some.namespace/htrhrthtrh [] (js/alert "hi")) which incorrect, explained in exception message. presumably you'll want use ~name in place of htrhrthtrh include name argument defn+ in output; this, or along similar lines, fix problem. hard-wire exact name you'd have ~'htrhrthtrh .

asp.net - " " Does not exist in current context? -

Image
im making website sends information mysql server, using asp.net. code. problem im having when debug code , launch page, these error: im not sure why, have error. here code: default.aspx <%@ page title="home page" language="c#" masterpagefile="~/site.master" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default"%> <asp:content id="bodycontent" runat="server" contentplaceholderid="maincontent"> <form id="form1" runat="server"> <div> <table width="300px" > <tr> <td>first name</td> <td> <asp:textbox id="txtfirstname" runat="server"></asp:textbox> </td> </tr> <tr> <td >last name</td> <td> <asp:textbox id="txtlastname&quo

Installing rails on PPC linux (lubuntu 12.04) -

ok. have old powermac g5 , decided use staging server. i went along trying normal installing rails things, when experienced error. could not find javascript runtime. see https://github.com/sstephenson/execjs (github) list of available runtimes (execjs::runtimeunavailable). execjs , not find javascript runtime as far can tell, because there no javascript runtime execjs call. people suggested installing node-js fix problem. makes sense. turns out, node, requires v8 javascript engine, required arm or i386, doesn't run on ppc. so screwed, or there javascript runtime can use rails. , how set up? thanks. here ppc port of v8 actively developed ibm folks: https://github.com/andrewlow/v8ppc

c# - When should I use dependency injectors like Ninject -

problem i have problems understand when , in code should use dependency injectors ninject. code let's example have following code: //without ninject: imailsender mailsender = new mockmailsender(); //with ninject: imailsender mailsender = kernel.get<imailsender>(); this 1 not dependency injection make sense use ninject in scenario? another example shows how code gets messed using dependency injector: public void calculaterevenuerecognitions(icontract contract) { //with ninject var kernel = new standardkernel(new defaultmodule()); var arguments = new list<iparameter> { new constructorargument("amount",contract.revenue), new constructorargument("date", contract.whensigned) }; contract.addrevenuerecognition(kernel.get<irevenuerecognition>(arguments.toarray())); //without ninject: contract.addrevenuerecognition(new revenuerecognition

Regex Match between special character -

i have string similar this: ++ name1 description:asdfmkdfkmfkskfsaf \n ++ name2 description:asdfmkdfkmfkskfsaf \n ++ name3 description:asdfmkdfkmfkskfsaf i want extract groups like: group1: name1 description:asdfmkdfkmfkskfsaf group2: name2 description:asdfmkdfkmfkskfsaf group3: name3 description:asdfmkdfkmfkskfsaf how regex? maybe thats u like? public static void main(string[] args) throws malformedurlexception, ioexception { string text = "++ name1\n" + "description:asdfmkdfkmfkskfsaf \\n\n" + "++ name2\n" + "description:asdfmkdfkmfkskfsaf \\n\n" + "++ name3 description:asdfmkdfkmfkskfsaf\n" + "++ name4 :asdfmkdfkmfkskfsaf\n" + "++ name5 asdfmkdfkmfkskfsaf\n"; system.out.println(text); system.out.println("\n\n\nresult:"); matcher matcher = pattern.compile("\\+\\+ (.*?)\\s+(?:descriptio

java - Bulk image downloading with optimized way -

this question has answer here: a way bulk download images on http java 3 answers i'm having web site somthing.com developed in spring mvc , 1 client desktop application developed in swing java. want download bulk images server url like. somthing.com/resourse/webfiles/imgs/1.jpg somthing.com/resourse/webfiles/imgs/2.jpg somthing.com/resourse/webfiles/imgs/3.jpg ... somthing.com/resourse/webfiles/imgs/n.jpg for testing purpose installed client in several pc's , given hit server avg. takes 20 mins download 1800 imgs/pc. is there faster way this? the current code/login steps are...(sorry not giving actual code..) requesting image url. fetching response in output stream. then taking byte , looping write images in physical location. if have access server, copy files usb thumbdrive , copy them every pc. faster. actually, assume approach ban

asp classic - How can I use MAX or last in ASP using SQL -

i have follwing code in form query <% divrec = request.querystring("div") set rstest = server.createobject("adodb.recordset") rstest.locktype = adlockoptimistic sql = "select max (division_program) 'division 1' censusfacility_records " rstest.open sql, db %> but following error adodb.recordset error '800a0cc1' item cannot found in collection corresponding requested name or ordinal.

python - Twisted FTP server does not show files after login -

i'm running twistd -n ftp --root=/tmp --password-file=/tmp/pass.dat i can connect ftp ftp://localhost:2121 , run ls . if login, , try same ls following error: 550 []: no such file or directory. any ideas? thanks, miki i had same problem until found in bugtracer: http://twistedmatrix.com/trac/ticket/4494 code avatar = ftpshell(filepath.filepath("/home/" + avatarid)) means ftp login should same linux login, "/home/login" directory exist.

c# - char[] array to textfile, including non-printing control characters -

i got quite tricky question (at least me), coding small , simple encryption , decryption program works polyalphabetical substitution. this encryption function: static string encr(string plaintext, string key) { char[] chars = new char[plaintext.length]; int h = 0; (int = 0; < plaintext.length; i++) { if (h == key.length) h = 0; int j = plaintext[i] + key[h]; chars[i] = (char)j; h++; } streamwriter sw = new streamwriter(file_name, false, encoding.unicode); (int x = 0; x < plaintext.length; x++) { sw.write(chars[x]); } sw.close(); return new string(chars); } it's working fine, problem outputfile created streamwriter contains additional unwanted 00's (due unicode encoding) , 2 totally wrong beginning-values due unicode encoding http://abload.de/img/unbenannt-16ilx4.jpg (sorry can't post im

java - Oracle to Hibernate to ISO 8601 Date format -

i have entity field declared date , mapped date field in oracle. when print value field, date format 2013-04-23 09:05:03.0 . i need convert date iso 8601 format. used: system.out.println("converted date:" + asxmlgregoriancalendar(retruneddate); private static datatypefactory df = datatypefactory.newinstance(); public static xmlgregoriancalendar asxmlgregoriancalendar(java.util.date date) { if (date == null) { return null; } else { datatypefactory df = datatypefactory.newinstance(); gregoriancalendar gc = new gregoriancalendar(); gc.settimeinmillis(date.gettime()); return df.newxmlgregoriancalendar(gc); } } the following code returns: system.out.println("converted date:" + asxmlgregoriancalendar(retruneddate); // output converted date: 2013-04-23t09:05:03.000-05:00 questions: there 000 instead of actual number. not sure why? what 0 @ end hibernate 2013-04-23 09:05:03.0 ? how full date? whe

android - How do I use a 9-patch? -

Image
i have 9-patch image , want use "seperate" admob ad app. want draw light blue line ad is. this 9-patch: i added layout imageview , xml code: <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/adview" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:src="@drawable/ab_transparent_example" /> and result: but want 9-patch take size of screen, make full blue line left right of screen. i've never worked 9-patch before, doing wrong? the diagram below pretty visual explanation of 9-patch is. specific problem, should set 9-patch background image. <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above=

Why doesn't "git flow feature pull" track? -

lets i've created new feature git flow feature start featurename then published git flow feature publish featurename now colleague wants collaborate on feature me, does git flow feature pull featurename this creates new branch on local repo, based on feature branch in remote repo. not set local feature branch track remote feature branch, has track branch manually. what reasoning behind step? why not have feature pull command set track well? what's workflow difference between git flow feature pull , git flow feature track . in cases use each of those? sounds using git flow feature pull , should using git flow feature track , since create local branch tracks remote. i can't think of why i'd ever use git flow feature pull . creates local branch no tracking set on it, , don't know why useful! it's badly named, since pull should involve merge, , not.

android - Why i can't lock DrawerLayout with layout gravity -

i use drawerlayout , want change gravity of listview in drawerlayout. after change gravity of listview android:layout_gravity="start|bottom" from android:layout_gravity="start" , drawerlayout can't lock mdrawer.setdrawerlockmode(drawerlayout.lock_mode_locked_closed); setdrawerlockmode() work with; <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" > </relativelayout> <listview android:id="@+id/drawer_list" android:layout_width="320dp" android:layout_height="match_parent" android:layout_gravity="start" androi

tomcat - ${pageContext.request.contextPath} is not working on plain HTML -

i'm using tomcat 7.0. facing issue not load css , js file. trying add ${pagecontext.request.contextpath} not work, tried c:url tag, getting syntax error in eclipse. the structure of these files is: webcontent -content/css/lab3.css html , js folder under content folder well <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0"> <display-name>lab3</display-name> <welcome-file-list> <welcome-file>/content/html/lab3.html</welcome-file> </welcome-file-list> </web-app> here html head: <link rel="stylesheet" type= "text/css"

c# - Advise on abstraction -

i working on code whereby have abstract class has few core properties , run(int index) method. create new types inherit this. these new types can have multiple methods can called according index passed in. public abstract class baseclass { public abstract void run(int index); } public class class1 : baseclass { public override void run(int index) { if (index == 0) { methoda(); } else if (index == 1) { methodb(); } } private void methoda() { //do stuff } private void methodb() { //do stuff } } i'm wondering there better way this. these types , methods called ui, - menu click example. might have class1 , class2. class1 might have 3 methods call run(0) ... run(2) on it. class2 might have 1 internal method call run(0). maybe need keep collection of ints each class guess map methods. might have add string collection hold friendly name menu item

pickle saving pygame Surface (python) -

i tried save pygame.surface doesn't let me, error typeerror: can't pickle surface objects i can make save surfaces? or maybe there module can save ? explanation: a = pygame.surface( (5,5) ) file = open("hello", "w") pickle.dump(a, file) i have classes saves in them surfaces. as monkey said: don't want pickle surface. if need save surfaces' content use pygame.image.save() function. if prefer surface not actual image file (for whatever reason) use pygame.image.tostring() function lets convert surfaces' content stringbuffer.

java - ListView, ArrayAdapter in Android -

i need class i have make asynchronous call method gettodaystweets() in tweetutil retrieve data. popular list of data collected. view dialog app work while asynchronous call of tweetutil in progress. class public class mainactivity extends activity{ private listview listoftweets; private arrayadapter<string> tweetsadapter; protected void oncreate (bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); listoftweets = (listview) findviewbyid(r.id.listoftweets); tweetsadapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1); listoftweets.setadapter(tweetsadapter); //to:do list of tweets tweetutil , populate list //do asynchronus } } public class tweetutil{ public static list<string> gettodaystweets(){ list<string> tweets = new arraylist<string>(); //...getting tweets twitter.com //...adding result list<string> tweets return tweets; } } using asynctask c

maintain multiple socket connections while putting the recv through a single handler in python -

i have function returns host specific site. , using these 2 functions def connect(self, rooms): print('') = [x x in rooms] x in i: self.room_connect(x) running = true while running: self.event_data()` def room_connect(self, rooms): host = getserver(rooms) sock = socket.socket(socket.af_inet, socket.sock_stream) sock.connect((host, 443)) sock.send(self.room_auth(rooms).encode()) self.sockets = sock print(self.sockets) print('connected '+ rooms) self.postbyte = true i able connect different socket each host. problem is, need maintain connection each socket connects to. in end, last socket created in loop maintained. socket recv data socket passed in handler parse info. asking how keep connection each of sockets created in loop going while passing recv info in handler. handler event_data() , in event_data function data parse defined data = self.sockets.recv(1024). problem last socket

sdk - Android Studio 0.2.5 Does not see Galaxy S4 as device -

i've googled on place , have yet find answer. have new galaxy s4 , downloaded android studio. i'm trying run first hello world app on phone, yet android studio 0.2.5 not see device. have enabled dev mode on s4 i've read, still no go. tried restarting s4. anyone have sort of idea might issue? i have galaxy s3 , did not know when in same position are. the android page on making device recognizable via usb misleading. way out ? well, download , install samsung kies , let work. install necessary drivers make device recognizable. happy coding.

tcl - how does it know that it's not a "variable" but rather a "string"? -

this script: #!/usr/bin/expect set a1 "aaa" set a2 "bbb" set a3 "ccc" {set b 1} {$b<4} {incr b} { set c \$a$b send $c } output : $a1$a2$a3 i hoping replicate send $a1 send $a2 send $a3 the output should have been aaabbbccc and yet not. i don't have interpreter handy, , little rusty tcl, that's remember should work, want deference varoiable value it's name: set aaa "123" set bbb "aaa" # supposed echo '123': puts [set $bbb]

Does java define string as null terminated? -

this question has answer here: how string terminates in java? 3 answers as title suggests, it's theoretical question. i'd know if java defines string null terminated. i'd know if java defines string null terminated. no. string defined fixed length sequence of char values. possible char values (from 0 65535) may used in string. there no "distinguished" value means string ends. so how track string ending? using length? yes. string object has private length field (in implementations i've examined ...). if want understand more how java strings implemented, source code various versions available online. google "java.lang.string source".

javascript - sending an email through HTML Form Action -

i little confused on how send e-mail through <form action="mailto:michael@microsoft.com?subject=hi michael" method="post"> if have following text boxes input information: name subject e-mail of user message how fit information e-mail being sent? ie: when open email see: from: bob@microsoft.com subject: hey message: message. <form action="mailto:you@hotmail.com?subject=hi" method="post"> <table width="200" border="0"> <tr> <td>name </td> <td><input type="text" name="name" id="name"/></td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td>email </td> <td><input type="text" name="email" id="email"/></td> <td>

What is most efficient method to store 3 max values found in a hashmap ? (java) -

i have hash map containing objects, need write method returns 3 objects maximal value (calculated method), looking efficient data structure use. what need data structure can hold 3 sorted values, , every time add value larger of elements pushes smallest value out , puts new value in proper index. is there similar have describes or have create new object store data? seems there no such thing in standard library. but easy yourself! create array size of 4. add values it. once has 3 values , you're trying add 4th one, add fourth , sort list. time add value overwrite 4th 1 , sort again. here short example script should give idea: import java.util.arrays; public class temptest { static int[] topthree = new int[4]; static public void addvalue(int newval) { if (newval > topthree[0]) { topthree[0] = newval; arrays.sort(topthree); } } public static void main(string[] args) { (int = 0; < 10; i++)

ios - How to get public photos JSON of any user - not necessarily in your friend list - using Graph API of Facebook search at a particular Location? -

i want integrate facebook graph api location based photo search public photos post url in json file. when search, example, "photos taken in bhubaneswar, india" on facebook's home page, getting lots of public (from may or may not friends) photos. feature facebook added. my question how json file public photos array, is, should fql query json file? https://developers.facebook.com/docs/reference/api/examples/ http://developers.facebook.com/docs/reference/api/

mysql - First three Groups with Highest Marks should have specific points 5,3, 1 -

this question has answer here: first 3 groups highest marks should have specific points 3 answers my table +------+--------+---------+-------+--------+ | name | group1 | section | marks | points | +------+--------+---------+-------+--------+ | s1 | g1 | class1 | 55 | (null) | | s16 | g1 | class1 | 55 | (null) | | s17 | g1 | class1 | 55 | (null) | | s2 | (null) | class2 | 33 | (null) | | s25 | g10 | class1 | 55 | (null) | | s26 | g10 | class1 | 55 | (null) | | s4 | g88 | class2 | 65 | (null) | | s5 | g88 | class2 | 65 | (null) | | s32 | (null) | class1 | 65 | (null) | | s7 | g5 | class1 | 32 | (null) | | s18 | g5 | class1 | 32 | (null) | | s10 | (null) | class2 | 78 | (null) | | s8 | g8 | class1 | 22 | (null) | | s20 | g8 | class1 | 22 | (null) |

javascript - get the value from a particular column -

i'm trying alert message on click each column. have table in 3 row , 4 column, want alert message next column value on third column click of each table. have tried column value not particular column. problem invoke in every column click want alert mesage when third column click of each row html <table id='mytable'> <tr><td>r1c1</td><td>r1c2</td><td>r1c3</td><td>r1c4</td></tr> <tr><td>r2c1</td><td>r2c2</td><td>r2c3</td><td>r2c4</td></tr> <tr><td>r3c1</td><td>r3c2</td><td>r3c3</td><td>r3c4</td></tr> </table> js $("#mytable tr").bind("click", function () { alert($(this).children("td").eq(3).html()); }); demo here try this $('table#mytable tr td:nth-child(3)').on('click', function() { alert($(this).nex

functional programming - Match Comparison OCaml -

i have come love syntax in ocaml match mycompare x y |greater-> |less-> |equal-> however, needs 2 things, custom type, , mycompare function returns custom type. would there anyway without doing steps above? the pervasives module seems have 'compare' returns 0 if equal, pos int when greater , neg int when less. possible match those? conceptually (which not compile): match mycompare x y | (>0) -> | (0) -> | (<0) -> i know use if statements, pattern matching more elegant me. there easy (if not maybe standard) way of doing this? is there easy … way of doing this? no! the advantage of match on switch in language ocaml's match tells if have thought of covering cases (and allows match in-depth , compiled more efficiently, considered advantage of types). lose advantage of being warned if stupid, if started using arbitrary conditions instead of patterns. end construct same drawbacks switch . this said, actually, yes! y

Android Map on V1 using the API Key Registered for Maps API V2 -

i developed application using android maps api v1 long back. somehow debug.keystore got deleted , if try build app again getting below error. now, can not api key android google maps v1. question can new maps api key android maps v2 , use application uses maps api v1. please let me know if 1 of know solution problem ioexception processing: 26 java.io.ioexception: server returned: 3 @ android_maps_conflict_avoidance.com.google.googlenav.map.basetilerequest.readresponsedata(basetilerequest.java:115) @ android_maps_conflict_avoidance.com.google.googlenav.map.mapservice$maptilerequest.readresponsedata(mapservice.java:1473) @ android_maps_conflict_avoidance.com.google.googlenav.datarequest.datarequestdispatcher.processdatarequest(datarequestdispatcher.java:1117) @ android_maps_conflict_avoidance.com.google.googlenav.datarequest.datarequestdispatcher.servicerequests(datarequestdispatcher.java:994) @ android_maps_conflict_avoidance.com.g

javascript - Public property bound to button outside of class doesn't have the same value as button bound internally when object is instantiated -

overall, have object keeps track of selected checkbox ids. way pushing/slicing ids into/out of array, $grid.selectedrows . object binds 'refresh' method refresh button. have class created object from, kendogridselection . my issue button bound inside of class shows correct array values, while button bound outside of class public selectedrows property no longer updates after refresh button clicked. for testing purposes, have 2 seeselectedrowsarray buttons: seeselectedrowsarray button (bound internally) seeselectedrowsarray2 button (bound outside of class) i testing in chrome version 28.0.1500.95 m here code: js var kendogridselection = function (gridid, pagerselector) { var $grid = this; $grid.selectedrows = []; $grid.gridid = gridid; $grid.pagerselector = pagerselector; $grid.grid = $($grid.gridid).data('kendogrid'); $grid.pager = $($grid.pagerselector).data('kendopager'); $grid.gridcheckboxes = $('input[

c# - Windows Phone 8 app randomly crashes with error code -2147220717 (0x80040313) -

i developing stopwatch , timer app in c#/xaml windows phone 8. while using app on phone, found randomly closed out/crashed , @ different points of use (i.e. wasn't doing same thing each time closed out). while debugging, found app closed out following error code in output window: "the program '[1100] taskhost.exe' has exited code -2147220717 (0x80040313)." i confused why happening. tried creating entirely new solution , moving code on , i've still been getting same issue. have tried using app on multiple different devices, , same thing happens (even in emulator). app crashes after 5 minutes of use, crashes after 30 minutes of use, it's unpredictable makes hard find root of problem. app uses xna framework play audio sound , coding4fun toolkit timespanpicker control, , besides there isn't else that's particularly notable app. have tried removing playing of audio file , removing references xna framework, , problem persists. any ideas on prob