Posts

Showing posts from February, 2014

php - Yii folder structure and global configuration for n applications -

Image
i'm building folder structure , global configuration allow me create applications on yii framework applications share common codes, extensions or modules. the idea is, each application have business level application, but, can shared between applications, want use common repository (models, extensions, widgets, etc) for example, want share auth extension control system permission, want 'install' auth under common folder instead under each application. below, architecture build: i found yiiboilerplate similar, don'y configure yii in such way want to. the folder structure desire is: common/ css/ images/ protected/ commands/ components/ config/ controllers/ extensions/ models/ views/ application1/ css/ images/ protected/ commands/ components/ config/ controllers/ extensions/ models/ views/ so, let's ...

c# - Split string with height and width on textblock - Silverlight Window phone -

i have long string , want binding textblock limit width , height. caculator height textblock as: textresult.text = reader.readtoend(); double h = textresult.actualheight; if height textblock > height limit, want spit string @ line in textblock have height = height limit , binding rest other textblock. can me?

c# - Baffling IndexOutOfBoundsArray Exception -

can 1 of fine folks tell me possibly causing c# method throw indexoutofbounds exception? appreciated. public bool populatestudents(string path) //decided return bool if successful reading file. { thestudentlist = new list<student>(); //create instance.. string text = null; fileinfo source = new fileinfo(@path); bool success = true; try { streamreader r = source.opentext(); text = r.readline(); string[] splittext = new string[23]; student currentstudent = new student(); while (text != null) { splittext = text.split(','); currentstudent = new student(splittext[0], splittext[1], splittext[2]); (int = 0; < 20; += 2) { currentstudent.entergrade(int.parse(splittext[i + 3]), int.parse(splittext[i + 4])); } currentstudent.calgrad...

java - How to share my android code? -

i've been working on android app company , have pass off software engineer. how pass on via email? there can export in eclipse can continue left off? i'm assuming you're not using version control system. go 1 now. run - don't walk. get company invest couple of bucks in private github account or similar. code version control system, , send replacement credentials log version control system.

Why does a binary of one OS (Windows) does not run in other ( Linux) for same underlying architecture? -

it may trivial question have hard time explain little brother windows binary not run in different os linux when both os running in same machine. if binaries (opcodes) have same execute in same underlying architecture ( intel 32-bit), differences between binaries of windows , linux ( or ubuntu , radhat linux)? there runtime modification of binaries @ instruction level before execution processor? how explain in lay man /simple terms can understand. the different operating systems have different abis require different loaders use. if loader other os available (via, say, wine ) possible load executable, @ point api becomes important.

android - AutoCompleteTextView don't show dropdown when I come back to this activity after go to another activity -

i use adapter fill autocompletetextview. @ first,everything goes fine.the autocompletetextview works fine.then want go activity work.but when come back,the autocompletetextview not show dropdown if adapter has right data. how can fix it? arrayadapter adapterstart; autocompletetextview businfo_start; autocompletetextview businfo_start; list<autocotent> auto_list;// before code below,these variable have initialized adapterstart = new autotipadapter(view.getcontext(),r.layout.auto_tip_item, auto_list); businfo_start.clearlistselection(); businfo_start.clearcomposingtext(); businfo_start.setfocusable(true); businfo_start.setadapter(adapterstart); adapterstart.notifydatasetchanged();

gcc - stack smashing detected with perl DBD::mysql -

i bugged stack smashing detected error of perl dbd::mysql in suse. the full error log here https://gist.github.com/tsechingho/5617282 . could give me ideas how resolve problem? thanks. versions: gcc-4.7.2 perl-5.16.3 dbi-1.627 dbd::mysql-4.023

oop - Why my extend() method in Javascript don't work for 3 and more objects? -

i have 3 object. netbuilder numbering numberingmethoddefault and have extend method. extend: function (child, parent) { var f = function () {}; f.prototype = parent.prototype; child.prototype = new f(); child.prototype.constructor = child; child.superclass = parent.prototype; this.mixin(child, parent); }, /** * @param {type} dst * @param {type} src * @returns {undefined} */ mixin: function (dst, src) { var tobj = {}; (var x in src) { if ((typeof tobj[x] == "undefined") || (tobj[x] != src[x])) { dst[x] = src[x]; } } if (document.all && !document.isopera) { var p = src.tostring; if (typeof p == "function" && p != dst.tostring && p != tobj.tostring && p != "\nfunction tostring() {\n [native code]\n}\n") { dst.tostring = src.tostring; } } } than try numbering extends netbuilder , numberingmethoddefault extends numbering. ooputility.extend(numbering...

rendering - Whether current character rendered width depends from previous character in Android -

i have question 1 android text rendering detail: whether current character rendered width depends previos character in android text renderer (for example in textview)? for example if char 'x' have width equals x_w , 'y' - y_w , string "xy" have equals x_w + y_w ? some more details: point should measure strings quiсk possible. want measure once each letter (character) text using paint.gettextwidths(...) , jsut use work characters width. depends on font. it's not assume, if want width of string, measure full string. if absolutely need that, use monospace font.

python - Pick optimize minimum number of elements to span a region -

Image
i have optimization problem. have never learned algorithms, taught myself python, not sure if hard or easy problem solve. non-abstract application of problem determining cheapest way sequence dna using available reagents. problem... there circular region, 0-10, 10 loops 0. there elements of length 1, each spans part of region , ultimate goal minimize number of elements while covering every position. have number of elements of length 1, these elements not cover whole region. therefore, need add additional elements, @ cost. so final cost (number of elements) + 2(number of elements purchased) , goal minimize cost. easy problem solve, or require significant effort solve it? so in example, pick add value @ 2 , 5.75, , remove values @ 2.5. i don't know python, can pseudo-code. might not perfectly optimal constraints, can tweak around if needed. let's assume elements have 2 properties, begin , end , define x-coordinate respectively, well, begin , end! (even t...

java - Get android GPS location in my web appliaction -

i have web application developed using java spring technology. want extend android devices requires me current location of android devices. can guide me on how go forward on this? as per understanding web application have send notification android , android client have send message web application lat , long information. but how send notification android client here? you may use android cloud device messaging framework send request server android phone. check this link well. also, answers following questions may helpful you: two way communication between android , server , android: how periodically send location server .

After appending a select option and selecting the appended option alert shows undefined + Jquery -

i newbie jquery , trying append select option. works , when select newly added option in select. getting undefined in alert. var selects = $(this).closest('div').find('.accselectandlookup') ; //check if accid present in selectoptions , if not add if (!selects.find('option[value="' + accid + '"]').length) { alert(accid); // throws correct value selects.append('<option value="' + accid + '">attach existing : ' + accname + '</option>'); } what doing wrong ? thanks in advance selects.change(function(){ alert('selected value ' + selects.filter(":selected").val()); // throws undefined }) simply use $(this).val( ) selected option value of current select . selects might not available when change event fired due variable scope. selects.change(function(){ alert('selected value ' + $(this).val()); // throws undefined });

objective c - Why does respondsToSelector: exist? -

why have manually check every time try send message object might not respond message/selector? why can't language check every time message sent, or every time performselector: or variants of message gets called. eliminate crashes due sending invalid messages. is inefficient this? there few reasons why every method call doesn't have built-in check. first, pretty inefficient. more importantly, in cases should calling known methods there no need check. but there various reasons why want check @ runtime. protocols optional methods prime case. working different versions of api common reason. new methods added or removed on time. we need able tell difference between mistake , knowing calling method may or may not exist. when mistake, want failure , exception. when method optional, need runtime check call can skipped if doesn't exist.

.net - VB.net and Webservices Exception -

i calling webservice through vb.net. have done addwebreference create bindings. when ws call throws exception, able catch generic exception object catch ex exception . however, not able figure out how catch exception type thrown. from wsdl <wsdl:message name="fexception"> <wsdl:part name="fault" type="tns2:fexception"/> </wsdl:message> <wsdl:message name="myexception"> <wsdl:part name="fault" type="impl:myexception"/> </wsdl:message> <complextype name="fexception"> <sequence> <element name="errcode" type="xsd:int"/> <element name="errmessage" nillable="true" type="soapenc:string"/> </sequence> </complextype> <complextype name="myexception"> <complexcontent> <extension base="tns2:fexception"><sequence...

angularjs - Angular element remove does not work ? -

i have service responsible show loading bar on screen. add loading bar dynamically coremodule.provider('$loading', function () { this.$get = ['$document', function ($document) { var element = angular.element('<div id="loading" class="loading">' + '<img src="../styling/img/loading.gif" alt="loading .... ">' + '</div>'); return { inprogress:function (message) { $document.find('body').append(element); }, finish:function () { // $document.find('body').remove(element); <- not work // $document.find('body').remove('#loading'); <- neither 1 !! } } }]; }); however finish function work @ all. remove element body. ideas ? you can use element.remove() - see http://docs.angularjs.org/api/angular.element availab...

python - Can a unique list accept lower and uppercase entries -

my script logs information unique file types in directory , subdirectory. in process of creating unique list of file extensions current code considers jpg, jpg , jpg same includes 1 of them in list. how can include 3 or more variances? for root, dirs, files in os.walk(sourcedir, topdown=false): fl in files: currentfile=os.path.join(root, fl) ext=fl[fl.rfind('.')+1:] if ext!='': if dirlimiter in currentfile: list.append(currentfile) directory1=os.path.basename(os.path.normpath(currentfile[:currentfile.rfind(dirlimiter)])) directory2=(currentfile[len(sourcedir):currentfile.rfind('\\'+directory1+dirlimiter)]) directory=directory2+'\\'+directory1 if directory not in dirlist: dircount+=1 dirlist.append(directory) if ext not in extlist: extlist.append(ext) the full script in ...

What is the Python syntax for adding the reduce part of a map/reduce pair in the ViewDefinition method of couchdb? -

i add permanent view couchdb database using viewdefinition class in python rather use futon define view. i have added map part of map/reduce pair so: postbyid = viewdefinition(‘application’,‘postbyid’, ‘function(doc) {if (doc.type==”posts”) {emit(doc.id, doc)};}’) postbyid.sync(database) but cannot work out syntax adding reduce part of map/reduce pair. for instance, if intended view looks (copied futon): "views": { "postbyid": { "map": "function(doc) {\n\tif (doc.type==\"post\") {\n emit(doc.id, doc)};\n}", "reduce": "_count" how code reduce part of map/reduce pair in viewdefinition class? alternatively, on right track or there better way of doing this? the reduce function entered fourth parameter. found looking through couchdb library code documentation , examples little sparse. postbyid = viewdefinition(‘application’,‘postbyid’, ‘function(doc) {if (doc.type==”posts”)...

angularjs - ng-show directive not working properly -

i using ng-show directive show/hide alert box in ui: <alert ng-show="{{showalert()}}">{{showalert()}}</alert> my controller code is: $scope.showalert = function () { return userform.$invalid || false; }; though getting correct value content of alert , able see booelan values in ui alert still keeps on showing. any idea? ng-show accepts expression. userform lives in $scope . template: <span ng-show="showalert()">form invalid!!</span> controller: $scope.showalert = function() { return $scope.userform.$invalid || false; }; or, simply: <span ng-show="userform.$invalid">form invalid!!!</span> and link working example: http://plnkr.co/edit/nlc1dbtk8vazbbgjnlb0

vb.net - Condition is never met when no queryString is presented -

either none of these presented or 1 presented. when none presented condition never hit private _page string = httputility.urlencode(httpcontext.current.request.querystring("page")) private _pge string = httputility.urlencode(page.routedata.values("page")) private function getpage() string dim ret string = "" if string.isnullorempty(_page) = true andalso string.isnullorempty(_pge) = true ret = 1 elseif string.isnullorempty(_page) = false andalso string.isnullorempty(_pge) = true ret = _page elseif string.isnullorempty(_page) = true andalso string.isnullorempty(_pge) = false ret = _pge end if return ret end function might cozed . return _page try .. private function getpage() string if string.isnullorempty(_page) = true andalso string.isnullorempty(_pge) = true _page = 1 return _page elseif string.isn...

Make checkstyle require the Java 7 Diamond operator -

is possible make checkstyle require java 7 formatting of diamond operator? want ensure codebase consistently uses new java 7 style, i.e.: list<string> items = new linkedlist<>(); instead of older: list<string> items = new linkedlist<string>(); take @ this . one of users complaining bug in diamond operator grammar: list list = new arraylist<>(); throws error:unexpected token: > this bug report closed patch adds support java 7. according page, 1 of features added was: 4) diamond generics: in presence of diamond, ast looks like: +--type_arguments | +--generic_start +--generic_end download link patch.

C# winform, how to set DataGridView VirtualMode in one or more DataGridView -

i'm working on windows form project. in form have 2 datagridviews. i'd set 2 datagridviews datagridview.virtualmode. is there efficient way task except creating twice code following? seeking advice, in advance. datagridview dgv1 = new datagridview(); datagridview dgv2 = new datagridview(); arraylist expense_summary_codes1 = new arraylist(); expense_summary_code expense_summary_codeinedit1; int rowinedit1 = -1; bool rowscopecommit1 = false; arraylist expense_summary_codes2 = new arraylist(); expense_summary_code expense_summary_codeinedit2; int rowinedit2 = -1; bool rowscopecommit2 = false; ... ellipsis private void dgv_cellvalueneeded(object sender, datagridviewcellvalueeventargs e) { datagridview dgv = (datagridview)sender; switch(dgv.name) { case "dgv1": if (e.rowindex == dgv.rowcount - 1) return; expense_summary_code expense_summary_codet...

php - Square thumbnail advance -

Image
i have php thumbnail function. how works can check below: public static function makethumb($source, $destination, $thumb_width){ $size = getimagesize($source); $width = $size[0]; $height = $size[1]; $x = 0; $y = 0; $status = false; if ($width > $height) { $x = ceil(($width - $height) / 2); $width = $height; } else if ($height > $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_image = imagecreatetruecolor($thumb_width,$thumb_width) or die ('cannot initialize new gd image stream'); $extension = self::get_file_extension($source); if ($extension == 'jpg' || $extension == 'jpeg') $image = imagecreatefromjpeg($source); if ($extension == 'gif') $image = imagecreatefromgif($source); if ($extension == 'png') ...

C Segfaults when trying to free memory that no longer needs to be used -

i working on circular buffer program in c. buffer has able expand , shrink depending on conditions checked each time buffer updated new quote (the buffer contains stock quotes). however, when try expand buffer , free old (smaller) buffer, "invalid next size" errors gilbc. my expand function follows: cbuf* expandbuffer(cbuf *cb_ptr){ int newsize; newsize = (cb_ptr->maxsize * 2) -1; cbuf *tempbuffer = malloc(sizeof(cbuf) + newsize * sizeof(quote)); tempbuffer ->maxsize = cb_ptr->maxsize * 2; tempbuffer ->start = cb_ptr->start; tempbuffer ->end = cb_ptr->end; tempbuffer ->freeslots = tempbuffer->maxsize - cb_ptr->maxsize; int x; int counter; counter = 0; for(x = cb_ptr->end; x < cb_ptr->maxsize; x ++){ tempbuffer->quotebuffer[counter].time = cb_ptr->quotebuffer[x].time; tempbuffer->quotebuffer[counter].rate = cb_ptr->quotebuffer[x].rate; counter ++;...

android - Preference Menu on 10 inch tablet -

i trying figure out why layout of preference menu displayed in false way on 10' tablets when using in landscape mode. looks lines right of checkboxes left of them. can see here http://imageshack.us/photo/my-images/109/schnappschuss2013052109.png/ on 7' tablets, works expected do. my menu looks that: <?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" > <preferencecategory android:title="@string/pref_message" android:key="pref_key_message_settings"> <checkboxpreference android:key="pref_key_add_timestamp" android:summary="@string/pref_summary_addtimestamp" android:title="@string/pref_addtimestamp" android:defaultvalue="true"/> <listpreference android:dependency="pref_key_add_timestamp" ...

asp.net - How to create a message dialog or popup using devexpress xaf -

how create or there built in functionality in xaf display message box in xaf web application? there 2 approaches. you can use confirmationmessage property of action. for more advanced scenarios, there sample project attached this support centre ticket demonstrates how display dialog via popupwindowshowaction .

Zend search integration in native PHP project -

i integrate zend search native php project. getting kinds of include errors. i have done research , seems there lot old articles written before zf2. zf1 used straight forward. include lucene.php , it. however since release of zf2 search component no longer part of zf2's skeleton , down-loadable separately. when included lucene.php, script stars complaining missing classes. (include problem) should include files or should use kind of autoloader? you can use composer install individual zf2 packages, , take care of autoloading , dependencies you. https://github.com/zendframework/zendsearch you can see needs zendframework/zend-stdlib download repository , install composer, dependencies you, , setup autoloading. php composer.phar install

Inserting current href with javascript -

i'm editing wordpress plugin need track outbound clicks google analytics' event tracking javascript code. challenge is, can edit 1 php file produces multiple links. in code below need replace part "this.getattribute('href')" href of link. how can done? have tried this.getattribute('href') code doesn't execute. <a href="http://lifeplace.com.au/" onclick="trackoutboundlink(this, 'outbound links', this.getattribute('href')); return false;" title=""><img class="soliloquy-item-image" src="http://www.96five.com/wp-content/uploads/2013/03/image.jpg" alt="" title="lifeplace"></a> you set href dynamically anytime, value: var anchor=document.getelementsbytagname("a")[0]; // sake of example anchor.href="www.google.de"; http://jsfiddle.net/lp5dc/

objective c - NSRegularExpression find pattern with optional part -

here thing : i have file storing datas, following pattern : item1:value1 item2:value2 item3:value3 // \n item1:value1 item2:value2 item1:value1 item2:value2 // , on... // item3:value3 optional then store datas of file in nsstring , deal them. i want match value2 thing pesence of item3:value3 optional in each line. so tried use ? regular expression operator i'm not sure way use it. so typically tried match following pattern (which doesn't work, ofc): @"item1:.* item2:(.*) (item3:.*)?\n" better explained, want regroup 2 conditions in 1 : @"item1:.* item2:(.*) item3:.*\n" // case 1 : item3:.* present in line @"item1:.* item2:(.*)\n" // case 2 : item3 not present note made personnal function returns matches in nsmutablearray . i hope clear enough :/ thanks , ideas. ok, looks there couple of errors in regular expression: i'll run through them now. firstly, trying match end of line "\n". wo...

How is `exact` lookup different from `equal` lookup in Django -

how exact lookup diffferent equal lookup in django i have 2 queries blog.objects.get(title=title) blog.objects.get(title__exact=title) what difference between these two? there no difference, first 1 same second one. look @ documentation : blog.objects.get(id__exact=14) # explicit form blog.objects.get(id=14) # __exact implied

playframework - play anorm, create a model from json without passing anorm PK value in the json -

object users { implicit object userreads extends reads[user] { def reads(json: jsvalue) = jssuccess(user( id((json \ "id").as[string].tolong), (json \ "name").as[string], (json \ "email").as[string] } implicit object userwrites extends writes[user] { def writes(user: user) = jsobject(seq( "id" -> jsnumber(user.id.get), "name" -> jsstring(user.name), "email" -> json.tojson(user.email) } def view(id: long) = action { implicit request => ok(json.tojson(user.find(id))) } def all() = action { implicit request => ok(json.tojson(user.findall())) } def save = action(parse.json) { request => val userjson = request.body val user = userjson.as[user] try { user.create(user) ok("saved") } catch { case e: illegalargumentexception => badrequest("error") } } } case class user( id: ...

css - <select> drop arrow doesn't want to go out the container -

i'm trying find workaround (without using js) firefox bug doesn't allow style firefox dropdown arrow in select elements. people done putting select element in container , setting container's width smaller select's. somehow doesn't work me, when set select element's width 100000px (the arrow still there on max. right position). http://jsfiddle.net/qq829/ here jsfiddle css: #nav { background: url("http://cdn.bavotasan.com/wp-content/uploads/2011/05/down_arrow_select.jpg") no-repeat scroll right center #dddddd; border: 1px solid #cccccc; height: 34px; overflow: hidden; max-width: 800px; border-radius: 12px; -moz-border-radius: 12px; -webkit-border-radius: 12px; border: 1px solid #1c2149; background: #a7cfdf; /* old browsers */ background: -moz-linear-gradient(top, #a7cfdf 0%, #1a80b6 100%); /* ff3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a7cfdf), color-s...

c++ - how to browse classes after instantiation? -

i'm developing program in c++ using many templates. i'd read definitions of template classes after instantiation. for example main.cc: #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pb; typedef trie<int, null_type> trie_t; ext/pb_ds/detail/container_base_dispatch.hpp: /// specialization patricia trie map. template<typename key, typename mapped, typename _alloc, typename policy_tl> struct container_base_dispatch<key, mapped, _alloc, pat_trie_tag, policy_tl> ext/pb_ds/assoc_container.hpp: #define pb_ds_branch_base \ detail::container_base_dispatch<key, mapped, _alloc, tag, policy_tl>::type template<typename key, typename mapped, typename tag, typename node_update, typename policy_tl, typename _alloc> class basic_branch : public pb_ds_branch_base ... #define pb_ds_trie_base \ basic_branch<key,mapped,tag, \ typename pb_ds_trie_node_and...

How to search a list and return the specific strings and data associated with it using Java -

i have list of names account numbers associated them. how create method when type name keyboard search list , return account numbers associated using java? example if pass name "lisheen" method return account numbers associated along other account name , numbers starts "lisheen". name account number a-wear 78090231 john 76581234 pstn 76811467 arni harald 78062351 barry moore 77002345 chill industries 79205416 espion 78348903 michael 78583451 kathleen o'hara 78505421 liam home 76314321 lisheen mine 78074315 lisheen mine 78085413 lisheen mine 78083413 lisheen mine 78083413 lisheen mine 78084315 lisheen ...

C++: better to keep reference or pointer? -

this might regarded style question. have class keeps reference instance of class: class { }; class b { a& ref; public: explicit b(a& ref) : a(ref) { } }; i decided use references instead of pointers, because ref never null pointer. also, code looks nicer. but, user has no idea whether copy or not right? in case, don't copy, if destroyed while instance of b still existing, problems happen. if use pointers, of course same can happen, feel user aware, writes code, no copying being done. opinions this? best c++ way deal problem? ps.: 1 solution thought of make things pointer kept, if object points destroyed, copy made first. not difficult implement, point is: trouble worth , overhead justify it? sort of self-made reference counter people really? if b must ever use single instance of a , instance never change, reference makes sense. thus, b cannot constructed without instance of a - introduce tight coupling. however, if can have instance of b ...

java - Is it possible to call an EAR with a script ?(an deployed EAR on jboss 7) -

i write svn pre commit hook script able call ear deployed on jboss 7. mean when script executed open web navigator , call ear via (localhost:8080/nameoftheear). important in project appreciated. edit : thx answer. details : ear contains application (in war module of course) action precommit hook same opening web browser, writing "localhost:8080/nameoftheear" , clicking on enter. possible ?? in few words, when script executed => application (in ear) pops in web browser because limitations of precommit hook can based on language in write hook, can in precommit hook. languages allow system call open web page. wouldn't imagine prevent commit occurring. there's little reason precommit hook. however, precommit hook runs on machine hosting subversion repository. hook kind of functionality work if working copy committing changes on same physical box hosting repository. if have remote clients sending changes repository via svnserve or http, attempting ...

types - Found scala.Unit, required Unit -

i have simple container trait so: trait handler { def apply[in, out](in: in): out } when try implement it: new handler { def apply[any, unit](in: any) = println(in) } i error: [error] found : scala.unit [error] required: unit(in method apply) [error] def apply[any, unit](in: any) = println(in) why this? can fix compiler error? there same question correct answer . you use trait type parameter, not method type parameter: trait handler[out] { def apply[in](in: in): out } new handler[unit] { def apply[in](in: in) = println(in) }

c++ - force encoding to SQLGetData function in odbc -

please know way force encoding(example utf-8) retrieve data using sqlgetdata function in odbc? although question not specific, following might you: encoding not performed sqlgetdata. you have know source encoding scheme (for later data manipulation) check http://msdn.microsoft.com/en-us/library/windows/desktop/ms715441(v=vs.85).aspx

mysql - fetch values from three tables and compare all three value with single table -

i facing problem in creating mysql query.it bit complicated try make clear. have 4 tables like: 1)farmer_details 2)disrtrictlist 3)blocks 4)village. i have 3 known values disrict(id),block(id),village(id) table disrtrictlist blocks village firstly want fetch these 3 field these 3 tables want find these 3 values contain in farmer_details tables.if understand , have suggestion please provide help. i write these query doesn't work me:- select farmer_name, father_name, district, centre, land, farmer_details.village, mobile farmer_details ,disrtrictlist ,blocks ,village disrtrictlist.name_id '6' , ( blocks.id '53' , village.id '2')

python - Django GET and POST handling methods -

i want way automatically route , post requests subsequent methods in centralized way. want create handler in following way. class myhandler(basehandler): def get(self): #handle requests def post(self): #handle post requests this webapp2 , style, possible in django? want view in class-method style. kind of basehandler , router should write. hint: use django generic views. this supported in django class based views . can extend generic class view , add methods get() , post() , put() etc. e.g. - from django.http import httpresponse django.views.generic import view class myview(view): def get(self, request, *args, **kwargs): return httpresponse('this request') def post(self, request, *args, **kwargs): return httpresponse('this post request') the dispatch() method view class handles this- dispatch(request, *args, **kwargs) the view part of view – method accepts request argument plus ar...

What is needed to design on windows a driver for bluetooth mouse? -

what needed design on windows driver bluetooth mouse? do need use .net framework that? , need create own code scratch there existing windows-based api designers you need windows driver kit provide necessary apis. , .net won't come in handy there, working pure c, maybe c++. additionally need know bt-stack, proprietary. creating drivers no piece of cake, definitely. maybe user-space bt-library.

c# - how to show the following output in wpf datagrid depending on a condition -

Image
i displaying processing time data in datagrid follows using following statement var duration_query = this.db.events .where(p => id.contains(p.serverid) && p.type == "complete" && // fromdp , todp name of datapicker control (p.date >= fromdp.selecteddate.value && p.date <= todp.selecteddate.value)) .groupby(p => p.duration) .select(g => new { duration = g.key, serverid = g.count() }) .orderby(x => x.duration).tolist(); dgprocessingtime.itemssource = duration_query.tolist(); xaml i have used layout transform rotate datagrid header. <datagrid x:name="dgprocessingtime" itemssource="{binding}" autogeneratecolumns="...

excel - ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row returns wrong row -

i'm using small macro add , delete rows in protected worksheet. each line has "delete" button. when new line added, last existing line copied (including "delete" button) , content cleared. for deleting rows hand on parameters including "delete" button's (and item's) row. use: rowtodelete = activesheet.shapes(application.caller).topleftcell.row this code works fine existing lines, fail lines added since workbook last opened (except last one). other delete next line added instead of "real" one. i guess cache problem, "application.caller" contains right string, returns row of copied shape no longer carries name. is there way clear relevant cache or force shapes() not use cache? thanks lot help. i've found workaround i'm not happy has trick now. i'm using random shapenames avoid wrong return values. seems if shape name did not exist before lookup works. shp.name = "shape" & fo...

security - How to have an USB drive readable by all but writable only by me? -

i have files (document word or pdf) written on usb drive given second person cannot control. need him not able in way modify or delete files drive, needs able read files or print them. person able delete or modify must me. imagine have use type of password system... how supposed do? as far know can done @ either application level (for example using adobe acrobat or microsoft office security features) or file-system level (file permissions). the problem application level security limits number of file types can share, in case you've specified pdf , ms word, both of have protection features, depending on versions you're using. the problem using file-system level permissions none of file-systems permission support in general use (ntfs, hfs+, ext3/4) compatible across platforms. in case i'd convert them pdf , use pdf protection features. edit: don't think you'll able prevent user deleting files @ all.

django obtain related manager with unknown name -

trying make app reusable , compatible custom user models, i've encountered following issue: let's user model following: class member(abstractuser): pass # builtin user name as result of code django.contrib.auth.models : class permissionsmixin(models.model): """ mixin class adds fields , methods necessary support django's group , permission model using modelbackend. """ is_superuser = models.booleanfield(_('superuser status'), default=false, help_text=_('designates user has permissions without ' 'explicitly assigning them.')) groups = models.manytomanyfield(group, verbose_name=_('groups'), blank=true, help_text=_('the groups user belongs to. user ' 'get permissions granted each of ' 'his/her group.')) user_permissions = models.manytomanyfield(perm...

python - Process very large (>20GB) text file line by line -

i have number of large text files need process, largest being 60gb. each line has 54 characters in 7 fields , want remove last 3 characters each of first 3 fields - should reduce file size 20%. i brand new python , have code want @ 3.4 gb per hour, worthwhile exercise need getting @ least 10 gb/hr - there way speed up? code doesn't come close challenging processor, making uneducated guess limited read , write speed internal hard drive? processlargetextfile(): r = open("filepath", "r") w = open("filepath", "w") l = r.readline() while l: x = l.split(' ')[0] y = l.split(' ')[1] z = l.split(' ')[2] w.write(l.replace(x,x[:-3]).replace(y,y[:-3]).replace(z,z[:-3])) l = r.readline() r.close() w.close() any appreciated. using idle python gui on windows 7 , have 16gb of memory - perhaps different os more efficient?. edit: here extract of file processed. 707...

parallel processing - Get current job number in makefile -

is there way current job number use in makefile rule? let me give little context. using tool runs on multiple files. naturally use parallel jobs speed things up. real issue here tool spawns multiple threads , them run in single core - since way faster. did tests , runs faster way. i need job numer set process affinity cpu core. there no way "job number" because make doesn't track job number. instances of make in single build share list of identical tokens. when make wants start job obtains token. when make finished job adds token list. if tries token , 1 not available sleep until 1 becomes available. there's no distinguishing characteristic tokens there's no way have "job number". to learn more how gnu make handles parallel builds, can read http://make.mad-scientist.net/jobserver.html i'm not quite sure how helps anyway. make doesn't know threads, starts processes. if single process consists of multiple threads, make s...

node.js - express app listen if mongodb is up and re-establish connection -

i have code opens connection mongodb: db_connect_mongo = init: (callback) -> self = mongo_options = db: safe: true mongoose.connect db_url, mongo_options db = self.db_mongo = mongoose.connection db.on "error", (error) -> logger.error "error connecting to: " + db_url, logcategory callback error, null db.on "connected", -> logger.info "successfully connected to: " + db_url, logcategory callback true, db db.on "disconnected", -> logger.info "disconnected database: " + db_url, logcategory # check , connect redis exports = module.exports = db_connect_mongo i call in app.coffee like: #connect database dbconnection = require "./utils/dbconnect" dbconnection.init (result) -> logger.info "database initialized: " + result, logcategory when shut down mongo db, info: [database connection] disconnected database: mongodb://127.0.0.1:27017/zmgc-mong...

jquery mobile - Background image fix doesn't work Css/jquerymobile -

the main page of app has content scrollable , need make image background fixed. that' s code of css: ui-overlay-e { border: 1px solid #f7c942 /*{e-body-border}*/; color: #222 /*{e-body-color}*/; text-shadow: 0 /*{e-body-shadow-x}*/ 1px /*{e-body-shadow-y}*/ 0 /*{e-body-shadow-radius}*/ #fff /*{e-body-shadow-color}*/; background-image:url("../img/biografia_bg.png"); background-repeat:no-repeat; background-attachment:fixed; } but doesn't work, background scroll. don't understand why. thanks

python - Celery beat queue includes obsolete tasks -

i'm using periodic celery tasks django. used have following task in app/tasks.py file: @periodic_task(run_every=timedelta(minutes=2)) def stuff(): ... but task has been removed app/tasks.py file. however, keep seeing call task in celery logs: [2013-05-21 07:08:37,963: error/mainprocess] received unregistered task of type u'app.tasks.stuff'. it seems celery beat scheduler use not update queue. how scheduler defined in project/settings.py file: celerybeat_scheduler = "djcelery.schedulers.databasescheduler" restarting celery worker not help. fyi, use redis broker. how can either clear or update celery beat queue older tasks not sent celery worker? install django-celery . as cited, project not needed use celery yet need enable admin interface @ /admin/djcelery/ managing periodic tasks. there won't no registered or periodic tasks. restart beat , check table periodic tasks again. beat have added existing scheduled tasks table inter...

c# - How to access the current HttpRequestMessage object globally? -

i have method creates httpresponsemessage containing error object returned based on current request media type formatter. currently, have hardcoded xmlmediatypeformatter i'd able find current request mediatypeformatter @ runtime don't have access current request object since below code exists on separate class library. private httpresponsemessage create(httpstatuscode statuscode, string errorcode, string errormessage) { var result = new httpresponsemessage(statuscode) { content = new objectcontent<error>(new error() { code = errorcode, message = errormessage }, new xmlmediatypeformatter()) }; return result; } how access current httprequestmessage object globally? httpcontext.current.request if impossible, how implement above method knows formatter should using current request? it's not impossible have found out. it's added items property of current http...

java - Send parameters from JSP to Servlet using POST -

i building simple web app , attempting create login page. page consists of jsp form loads servlet. i have got form working using method: jsp looks this: <form method="get" action="login"> email:<input name="email"/> password:<input name="password"/> <input type="submit" value="log in"/> and in servlet: @webservlet(name = "login", urlpatterns = {"/login"}) public class login extends httpservlet { /** * processes requests both http * <code>get</code> , * <code>post</code> methods. * * @param request servlet request * @param response servlet response * @throws servletexception if servlet-specific error occurs * @throws ioexception if i/o error occurs */ protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html;charset=utf-8"); //assign...

jquery - SyntaxError: invalid label parsing json response -

im getting response jquery ws request. { "skywinresponse": { "statuscode": 0, "message": "ok\n ", "rowsaffected": 1, "results": { "result": { "@xsi.type": "member", "accountcreditlimit": 0, "accountno": 1000001, "address1": "annavägen 10", "addresschangedate": "2013-04-12", "balance": 2068, "balancecurrency": "kr", "certificatetext": "pk", "climatecompensate": 2, "club": "ufk", "contactname": "last, andreas", "contactphone": "090-123456", "countrycode": ...

jquery - Click then mouseout, incorrectly unbinding -

i have news list type display, appearing in series of list items, have made content of news item intentionally larger <li> , set overflow hidden. want when click on <li> item, scrolls content upwards (so see hidden content) if mouse leaves <li> item, wait few seconds before returning original state. have managed pretty this, have not unbound mouseout action properly, if run mouse on <li> item again, run delay counter again here current jsfiddle example you can see doing wrong clicking on item, mouse out , wait drop, running mouse , forth on 1 again, , clicking on it, should delay long time. any appreciated. html <ul> <li> <img src="http://dummyimage.com/150x150/000/fff.png" width="150" height="150" /> <div class="header">lorem ipsum</div> <div class="body">suspendisse et gravida quam. suspendisse potenti. suspendisse ornare congue ...