Posts

Showing posts from September, 2015

ios - Can NSManagedObject conform to NSCoding -

i need transfer single object across device. right converting nsmanagedobject dictionary , archiving , sending nsdata. upon receiving unarchiving it. transfer nsmanagedobject archiving , unarchiving instead of creating intermediate data object. @interface test : nsmanagedobject<nscoding> @property (nonatomic, retain) nsstring * title; @end @implementation test @dynamic title; - (id)initwithcoder:(nscoder *)coder { self = [super init]; if (self) { self.title = [coder decodeobjectforkey:@"title"]; //<crash } return self; } - (void)encodewithcoder:(nscoder *)coder { [coder encodeobject:self.title forkey:@"title"]; } @end nsdata *archivedobjects = [nskeyedarchiver archiveddatawithrootobject:testobj]; nsdata *objectsdata = archivedobjects; if ([objectsdata length] > 0) { nsarray *objects = [nskeyedunarchiver unarchiveobjectwithdata:objectsdata]; } the problem above code is. crashes @ self.title in initwithcoder sa

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

i have simple page in intranet uses razor/asp fetch single record table , display it, plus few graphic, dashboard display. meaning, no user intervention other first time open ie internal url. the problem having every morning ie displays "page not found or network error" message. refresh page, , it's stuck , doesn't display anything. try different pc, open ie internal url , it's stuck... ...until following: login server hosting page run inetmgr go web sites, etc right click on page that's giving me problem , select browse at moment, error message: server error in '/' application. -------------------------------------------------------------------------------- type of page not served. description: type of page have requested not served because has been explicitly forbidden. extension '.cshtml' may incorrect. please review url below , make sure spelled correctly. requested url: /application/dashboard.cshtml ---------------

Most efficient way to access 2D Maps (Maps of Maps) in Java? -

i'm implementing weightedslopeone prediciton algorithm recommender system , @ point in code need have 2 2d maps, 1 map<integer, map<integer, integer>> , 1 map<integer, map<integer, double>> as can understand accessing these , assigning values cumbersome procedure: //the following 20 lines 1 line in python. sigh... hashmap<integer, integer> freqsforitem1 = frequencies.get(curitemid); //see if have value curitemid if (freqsforitem1 == null) { freqsforitem1 = new hashmap<integer, integer>(); freqsforitem1.put(curitemid_2, 1); frequencies.put(curitemid, freqsforitem1); } else {//see if have value curitemid+curitemid_2 integer freqforitem1item2 = freqsforitem1.get(curitemid_2); if (freqforitem1item2 == null) { //if don't have value item1+item2 put 1 freqsforitem1.put(curitemid_2, 1); } else {//we have value curitemid+curitemid_2 //so increment freqsforitem1.put(curitemid_2, freqf

java - Jmockit String final length method mocking Issue -

using jmockit 1.2 jar, trying mock string's length method getting unexpected invocation exception: failed: test java.lang.illegalstateexception: missing invocation mocked type @ point; please make sure such invocations appear after declaration of suitable mock field or parameter @ stringdemo.testa$1.<init>(testa.java:17) @ stringdemo.testa.test(testa.java:13) i using testng: @test public void test() throws exception { new expectations() { @mocked("length") string astring; { astring.length(); result = 2; } }; system.out.println(a.showa("test")); } } actual class a: public class { public static int showa(string str){ int a= str.length(); return a; } } this wrong way of recording expected results. shouldn't mock , record string's length() method, record showa() instead. here solution @suppresswarnings("unused&qu

c++ - wxwidget compiling on windows command prompt -

can please guide me on method,as how compile wxwidget using windows command prompt or msys. [i can't seem find on wxwiki/wxwidget official book/anywhere else] i have compiled wxwidget instructions have provided (using msys). from searching on internet seems 1 can (maybe?) through use of makefile (is correct?) if yes: directory & how should link wx libraries in makefile if no: way besides makefile? i know can use ide's code::block , make life simpler prefer compile using command prompt/msys. thanks in advance.

c# - Linq to SQL search for wildcard in double -

in linq sql trying search value of type double: var q = in db.gettable<hkks_medlemmer>() g in db.hkks_get_grader_kun_grad(convert.toint32(a.skif)) a.aktiv == true && (a.skif.tostring().startswith(searchvalue) || sqlmethods.like(a.navn, "%" + searchvalue + "%") || sqlmethods.like(a.mellemnavn, "%" + searchvalue + "%") || sqlmethods.like(a.efternavn, "%" + searchvalue + "%") || sqlmethods.like(a.adresse, "%" + searchvalue + "%") || sqlmethods.like(a.telefon, "%" + searchvalue + "%") || sqlmethods.like(a.mobil, "%" + searchvalue + "%") || sqlmethods.like(a.postnr, "%" + searchvalue + "%") || sqlmethods.like(a.town, "%" + searchvalue + "%") || sqlmethods

What is the difference between data design and data model(ERD) -

i have google question , find answer in day. know, data design many many table have list column,and mark pk , fk. why er-diagram have find this? data design process of designing database. main output of data design detailed logical data model of database. some people data design includes of needed logical , physical design choices , physical storage parameters needed generate design in data definition language. technically, database analysis, database analysts (dbas) trained do. while person can both data design , database analysis, these 2 different tasks. data design models data. database analysis takes model , applies 1 or more database engines (relational, hierarchical, nosql). a logical data model 1 of main outputs of data design. data model represented entity relationship diagram, or er diagram.

vim - How to create an alias for ctags in vimscript -

i have function invoked based on simple key mapping function! jumptodefinition() let filetype=&ft if filetype == 'coffee' exe '<c-]>' endif endfunction this works when manually <c-]> when try "exe" above "trailing whitespace" error. how can invoke in standalone function have above? note :execute runs resulting expression ex command, isn't want since there no <c-]> ex command. should using :normal . however, able use these "special keys", instead of characters represent, have pay attention 3 things: the correct way represent them backslash \<xxx> . check expr-string . use double quotes, not single quotes :normal accepts commands, not expression :execute so, items 1 , 2 above know "\<c-]>" should used, can't put in front of :normal . well, can, executed "quote, backslash, c, ...". solution go using :execut

html - adding img in paragraph is causing all its adjacent div slightly moved downward -

Image
i have set of div on webpage following html , css. <style type="text/css"> .div-set { margin: 5px 2px; } .div-set > .widget:nth-child(3n-1) { margin: 20px 32px; } .widget { width: 300px; height: 300px; border: 2px solid #dbdbdb; padding: 0px; position: relative; display:inline-block; } .widget h2 { color: white; text-align: center; margin: 0; padding: 2px 5px; font-weight: bold; margin: 2px; border-top-left-radius: 8px; border-top-right-radius: 8px; } .widget p { padding: 3px 10px; padding-bottom: 15px; } .widget > { position:absolute; bottom:0px;

c++ - Calculate transformation matrix from three 3D points -

i have 3d coordinate system of track 3 outer points 3d camera. have 3 points in (x,y,z) space. next frame track these 3 points again. use first 3 points initial situation. need draft transformation matrix gives me translation, rotation , scaling of second 3 points, in comparison initial position. now not know how this. there way directly make transformation matrix, or first have work out translation, rotation , scale matrix , make transformation matrix of these three? i work in c++ opencv , qt. got suggestions? not need full working example, can me on way appreciated. thanks! j this tutorial looks pretty nice (what looking called affine transform)!

forms - Restrict scope of HTML autocompletion -

i have web application frontend on / , backend on /backend, both have different login-sets. currently, autocompletion fills frontend user/pass in backend, , vice versa - way prevent this, still allow user/pass autocompletion? thanks! <form autocomplete ="off"> or use <input type="text" autocomplete ="off">

delphi - Reading ini file onCreate event causes 8 second delay -

i have complex software, , whittled delay in piece of code: procedure tform1.formcreate(sender: tobject); begin inherited; tinifile.create(path + '\filename.ini') try checkbox1.checked :=readbool('header','key',true); free; end; end; when debugging code, debugger showed hanging on create factory of tform inherited create(aowner); question time: why delphi hang when query ini file? ini file few keys big, standing in 64k windows api limit. oncreate has this? ini limitations , downsides tinifile class uses windows api imposes limit of 64kb on ini files. if need store more 64kb of data, should use tmeminifile. update: many comments ill try relate. i reason blame code, simple "try , see". removed ini file call, on create, , code run smoothly , instant window open. when compiling ini file call on oncreate, software hangs 8 seconds. moved call oncreate constructor create, code works smoothly. the ini

Universal Image Loader cache -

i'm trying integrate universal image loader android app. has gridview , shows images acquired internet. implemented using arrayadapter loads images in getview() in usual way. it works in terms of displaying picture correctly. found unexpected behavior in loading images memory cache. when activity launched, uil loads image internet or disc cache if exists. (of course, expected behavior.) scrolling down gridview until first column go out screen, , scroll top. in time, images @ first column loaded disc cache, instead of memory cache. then scrolling down , again. in time, images @ first column loaded memory cache. i expect images loaded memory cache @ second time of displaying, step 2 in operation above. don't know why disc cache used in case. here codes. imageloaderconfiguration imageloaderconfiguration mimageloaderconfig = new imageloaderconfiguration.builder(getapplicationcontext()) .defaultdisplayimageoptions(defaultoptions)

python - "Least Astonishment" and the Mutable Default Argument -

anyone tinkering python long enough has been bitten (or torn pieces) following issue: def foo(a=[]): a.append(5) return python novices expect function return list 1 element: [5] . result instead different, , astonishing (for novice): >>> foo() [5] >>> foo() [5, 5] >>> foo() [5, 5, 5] >>> foo() [5, 5, 5, 5] >>> foo() a manager of mine once had first encounter feature, , called "a dramatic design flaw" of language. replied behavior had underlying explanation, , indeed puzzling , unexpected if don't understand internals. however, not able answer (to myself) following question: reason binding default argument @ function definition, , not @ function execution? doubt experienced behavior has practical use (who used static variables in c, without breeding bugs?) edit : baczek made interesting example. of comments , utaal's in particular, elaborated further: >>> def a(): ... print("a exec

C : Array of strings - Can input only n-1 strings for an input size of n -

i have sort strings in lexicographical order using bubble sort technique without using library functions. have written following code working fine in sorting strings. problem if give n input (say n = 4), can enter n-1 strings (only 3 strings). problem can solved running loops 0 n, isn't logical solution. doing wrong here? #include <stdio.h> #include <string.h> #include <malloc.h> void swap(int indx[], int j) { int temp; temp = indx[j]; indx[j] = indx[j+1]; indx[j+1] = temp; } void sort(char **str, int indx[], int n) { int i, j, k; for(i=0; i<n; i++) { for(j=0; j<n-i-1; j++) { k = 0; while(str[j][k] != '\0') { if((str[indx[j]][k]) > (str[indx[j+1]][k])) { swap(indx, j); break; } else if((str[indx[j]][k]) < (str[indx[j+1]][k])) break;

php - Merging arrays in foreach loop -

i performing csv import database , have trouble adding loop inside array being inserted table. $lines = 0; $queries = ""; $linearray = array(); $data = array(); if ($csvcontent) $query = "truncate table $databasetable;"; @mysql_query($query); echo "part list ".$databasetable." updated.\n</br>"; foreach(explode($lineseparator,$csvcontent) $value){ $lines++; $value = trim($value," \t"); $value = str_replace("\r","",$value); $value = str_replace("'","\'",$value); $linearray = explode($fieldseparator,$value); $linemysql = implode("','",$linearray); $first = array_splice($linearray, 0, 2); <... here need have function takes values table , creates array looks $b variable....> $b=array("1","2","3","4","5","6"); foreach($linearray $x){ $b = implode(&q

ios - Is there a UIImagePickerController replacement that I can use from a controller that is already in a popover? -

i'm writing app uses uiimagepickercontroller let user choose images library. on ipad, shows in popover (because must) controller showing in popover, , you're not allowed show popover popover. can't rework whole app avoid files controller being in popover, i'd push image picker onto files controller's navigation stack. obviously isn't going work stock image picker, there a lot of alternatives . has used of them let me push them onto navigation stack, or need write own? the proper solution present image picker modal view controller existing view controller. set image picker's modalpresentationstyle uimodalpresentationcurrentcontext . this show image picker in same popover modal view controller on calling view controller.

reporting services - Formatting subtotals in a matrix report -

so have matrix report formatting data cells not inherited subtotals. read article ( http://social.msdn.microsoft.com/forums/en-us/sqlreportingservices/thread/d4d21769-2cb0-4bb1-b74b-89e4d31fb724 ) , seems need remove formatting of subtotals , add formatting data cells (i.e. inscope(row_rowgroup1) , such types of formulas). i've never used inscope before thought bothcing syntax. such, tried entering following 1 of data cells , still doesn't come in bold i'd expect. =iif(1=1,"bold","normal") i'm adding fontweight condition on data cell, should bold, right? i'm struggling see why bold data cell (i'm thinking should bold individual rows , subtotals literally nothing bold). i figured out. working, no displaying in preview mode. once deployed functionality desired. sheesh.

javascript - Slimit python minifier strange behaviour -

i trying minify javascript python 'slimit' package. import slimit slimit.minify('[1,2,3,4,5,6,7,8]') runs fine , returns '[1,2,3,4,5,6,7,8]' import slimit slimit.minify('[01,02,03,04,05,06,07,08]') gives error: syntaxerror: unexpected token (number, '8') @ 1:23 between lextoken(number,'0',1,22) , lextoken(rbracket,']',1,24) the strange thing minifying string [01,02,03,04,05,06,07] works ok. slimit returns error when minifying 8 or more 0 padded integers in array. this down lexer used slimit. numbers starting "0" (but not "0x") treated octal integers. sequence "08" therefore ends 2 separate tokens ("0", "8") hence "unexpected token" error. note following: >>> slimit import lexer >>> l = lexer() >>> l.input("02") >>> l.token() lextoken(number,'02',1,0) >>> l.input("08&q

Pagination links with a locale prefix in URLs Grails -

if you're using language prefix in url mappings such as /$lang/$controller/$action?/$id? and urls generating contain parameters in addition lang parameter, you'll following url, additional param such offset: /book/list?offset=10&lang=en but breaks mappings. instead, want url this: /en/book/list?offset=10 how can achieve that? create following bean (assuming lang param called "lang"): class langawareurlmappingsholderfactorybean extends urlmappingsholderfactorybean { @override public urlmappingsholder getobject() throws exception { def obj = super.object obj.default_controller_params = [urlmapping.controller, urlmapping.action, "lang"] set obj } } and adjust resources.groovy : "org.grails.internal.url_mappings_holder"(langawareurlmappingsholderfactorybean) { bean -> bean.lazyinit = true } and you'll get /en/book/list?offset=10 instead of /book/list?offse

javascript - BigVideo.js URL redirect at end of playback -

i have implemented background video on page using bigvideo based off video.js when div clicked, video plays in background. cannot life of me figure out how redirect url when video done playing. code using: link play video: <a href="vids/gem.mp4" class="home_g"></a> code redirect when ended: <script type="text/javascript"> _v_("home_g").ready(function(){ this.addevent("ended", function(){ {window.location = "www.google.com"} }); }); any appreciated. here full test site: test site after trying few days work correctly, i've resorted making redirect based on time of video if else has same problem. if has answer make work correctly great, if not else did: <script type="text/javascript"> redirecttime = "107000"; redirecturl = "index.htm"; function timedredirect() { settimeout("location.href = redirecturl;",redirectti

Suggestion of how to create a javascript class -

i have java app architecture: entity + persistence + business + rest services. i want create view layer without jsf, in other words, want use html + css + js (jquery + ajax). what better way create javascript class access rest services? var bookmark = function() { this.id; this.description; this.link; }; bookmark.prototype._insert = function() { // here should put jquery ajax call? }; bookmark.prototype._delete = function() { // here should put jquery ajax call? } bookmark.prototype._update = function() { // here should put jquery ajax call? } bookmark.prototype._findbyid = function() { // here should put jquery ajax call? } bookmark.prototype._findbyid = function() { // here should put jquery ajax call? } the above format acceptable? what have ok. problem might encounter if interaction server not fall realm of 1 model object, model layer going messy. why not on server, , create service layer? app.api = { login: function(onsuccess) {....} fi

c# - How to access the Request object in a custom exception handler in ServiceStack -

i want register custom exception handler in servicestack. wiki @ https://github.com/servicestack/servicestack/wiki/error-handling says: this.serviceexceptionhandler = (request, exception) => { //log exceptions here ... //call default exception handler or prepare own custom response return dtoutils.handleexception(this, request, exception); }; but in exception handler request argument not request object, rather service threw exception (at least can tell debugger). casting request ihttprequest fails invalidcast exception. since request / response members of service protected, cannot access request within exception handler. what access request? in particular, need access content-type , list of accepted languages send headers in request. from looking @ source, looks request should request dto, if need more that, can create own servicerunner<t> , , irequestcontext well, has contenttype property. https://github.com/servicestack/servic

java - Array filling that users inputs with Method -

i need project. i'm writing program show students informations users fills previously. how did learn methods. wrote program out methods. when write same things method encountered pass reference... filling 0. index when fill 1. index, 0. index became null. try cannot solve problem think thats returns... here code can me way coz can see java language level beginner:) ; //=========================================================== methods public static void record(string x, int y) string[] stringarray = new string[100]; stringarray[y] = x; return stringarray; } public static double[] record(double x, int y){ double[] doublearray = new double[100]; doublearray[y] = x; return doublearray; } and option ; case 1: { system.out.println("** recording new student"); system.out.println("*** please use lower case"); in.nextline(); // solve skipping system.out.print("enter student name , surname: "); string namex =

Gunicorn Django and logging info to a file -

i'm trying setup logging settings send logging.info('any message') file through stdout . this gunicorn_django script: $ gunicorn_django -w $num_workers --user=$user --group=$group --log-level=info --log-file=$logfile &>>$logfile these logging settings: import sys logging = { 'version': 1, 'disable_existing_loggers': false, 'formatters': { 'simple': { 'format': '%(levelname)s %(message)s' }, }, 'filters': { 'require_debug_false': { '()': 'django.utils.log.requiredebugfalse' } }, 'handlers': { 'console': { 'level': 'info', 'filters': ['require_debug_false'], 'class': 'logging.streamhandler', 'stream': sys.stdout, 'formatter': 'simple',

ssis - DTexec /ISSERVER path for package -

when try execute ssis package created in sql server data tools (vs 2010) using dtexec, receive error "is not valid server package path". documentation says use: dtexec /isserver [path package]. if connect via ssms can browse integration services catalog, , path is: "ssisdb\ktaktranslator\projects\ktaktranslatorpro\packages\ktaktrans.dtsx" however, dtexec /isserver \ssisdb\ktaktranslator\projects\ktaktranslatorpro\packages\ktaktrans.dtsx produces above error. i've tried: dtexec /isserver ssisdb\ktaktranslator\projects\ktaktranslatorpro\packages\ktaktrans.dtsx dtexec /isserver \ssisdb\ktaktranslator\projects\ktaktranslatorpro\packages\ktaktrans.dtsx dtexec /isserver \ssisdb\ktaktranslator\ktaktranslatorpro\ktaktrans.dtsx dtexec /isserver ssisdb\ktaktranslator\ktaktranslatorpro\ktaktrans.dtsx still same error. when tried execute package integration services catalog, , viewed execution report; package listed (under name component) "k

ruby - Rails form validation for custom setter during update_attributes? -

i have setup similar below. works fine, if validations in employee model fail (when custom setter invoked), how them fire when update_attributes called on employer model? views/employers/_form.html.erb <%= form_for @employer %> <% @employer.employees.each |employee| %> <%= fields_for "employer[employee_attributes][]", employee |e| %> # form here <% end %> <% end %> <% end %> model/employer.rb attr_accessible :employee_attributes has_many :employees def employee_attributes=(employee_attributes) employee_attributes.each_pair{|id,attributes| employee = employee.find(id) employee.update_attributes(attributes) } end solution: as per sockmonks answer below call employee.update_attributes!(attributes) instead (with bang @ end). raises exception. then in employer controller controllers/employers_controller.rb def update @employer = employer.find(:id) beg

asp.net - Is there any library to fetch current time of any location from other servers? -

i want local time of logged in user based on location. want library connects universal time server (google etc.) , returns current time of location passed parameter. one alternative have stored time difference in sql server table , calculate actual time utc time of logged user. approach won't give accurate results , doubt on how work. timezonedb provides free api: http://timezonedb.com/api genonames has restful api available current time given location: http://www.geonames.org/export/ws-overview.html . you can use greenwich, uk if you'd gmt.

reporting services - Fields not displaying in SSRS report using Display method -

i trying display field in ssrs report using display method. created display method in table returns required value. selected display method field in report. not show value in report generated using display method. i figured out. in case because display method not returning because of logical error. not able debug directly using breakpoints , debugger had create job debug display method , figure out problem.

android - How to call a method with View param -

i have source code of app android location network or gps. there next code: // callback method "both providers" button. public void usecoarsefineproviders(view v) { musefine = false; museboth = true; setup(); } there button, , on onclick event call "usecoarsefineproviders", question want delete button , call method oncreate method, don't know how this. i need learn things. help. your code isn't doing anything, or using view parameter passed in. if want move oncreate, it- take body of function, paste bottom of oncreate, delete function , code (probably in xml) telling call function in onclick.

thrift - Cassandra createSliceQuery clarification -

i'm trying retrieve columns of row in cassandra using thrift 1.0 lib. found examples googling , in particular: slicequery<string, string, string> slicequery = hectortemplate.createslicequery( stringserializer.get(), stringserializer.get(), stringserializer.get()); slicequery.setcolumnfamily("myname"); slicequery.setkey("myid"); slicequery.setrange(null, null, false, 20); queryresult<columnslice<string,string>> queryresult = slicequery.execute(); columnslice<string,string> slice = queryresult.get(); list<hcolumn<string, string>> retrievedcolumns = slice.getcolumns(); (hcolumn<string, string> column : retrievedcolumns) { system.out.println(column.getname() +"::"+ column.getvalue()); } however, not find information on parameters , types in hector objects are?? for example, here: slicequery<string, string, string> all types here string - types of? column name type? column value types?

php - cURL SSL version 2 vs version 3 -

i have written php script transfer large files (100mb+) server using curl. process wasn't working until set curlopt_sslversion 3. without setting option, process transfer 7mb, die. i understand why case before push process out of our customers' machines. server specific? certificate specific? want make sure won't have instances customers need ssl version set 2 work. if can enlighten me on this, appreciated.

python - Determining if a Part of a string is in a List -

given input guess='1 5k' and list playable=['ac','qs','5s','5k','kc'] how go determining if '5k' part of guess in playable? also, if in playable, how go determining if item 1 spot left of has either '5' or 'k' in it. playable become playable=['ac','qs','5k','kc'] with '5k' replacing '5s'. far have def onec(guess): split_em=guess.split() ##splits @ space card_guess=split_em[1] ##gets '5k' part of string if card_guess in playable: ##confusion area index1=playable.index(card_guess) ##finds index of '5k' index_delete= del playable[index1-1] ##deletes item left of '5k' my problem right i'm not sure how determine if '5' or 'k' in item 1 spot left. there way turn '5k' set of ('5','k') , turn element 1 spot left ('5

Solr on Tomcat not able to post xml files without error field unknown -

i installed solr on ubuntu following tutorial: http://feinan.com/2012/05/19/how-to-install-solr-3-6-0-on-ubuntu-12-04-lts/ which got me , running fine. but when want post new xml file (like ones in example/exampledocs), use following curl command: curl http://localhsot:8080/solr/core0/update -h "content-type: text/xml" --data-binary @vidcard.xml but continue error: error: unknown field 'manu' from other qa understand might wrong schema.xml file. fresh install, confused why have pre add each field xml upload (there ton of , it's not same schema wonder if have hand map in schema.xml before doing so). in addition, had followed official tutorial , , using java -jar post.jar solr.xml monitor.xml command index new xml , fine. but interested in being able update http how integrate our system. full disclosure: new solr (perhaps obvious). update @alexandre rafalovitch below, understand little more solr. problem remains. instance using vidcard.xm

python - Accessing remote MySQL database with peewee -

i'm trying connect mysql database on amazon's rds using peewee , can't work. i'm new databases i'm doing stupid, i'm trying: import peewee pw mydb = pw.mysqldatabase(host="mydb.crhauek3cxfw.us-west-2.rds.amazonaws.com",port=3306,user="user",passwd="password",db="mydb") class mysqlmodel(model): """a base model use our mysql database""" class meta: database = mydb class user(mysqlmodel): username = charfield() mydb.connect() it hangs on second line, saying __init__() takes @ least 2 arguments (1 given) what missing? why saying i'm giving 1 argument when i'm giving five? thanks lot, alex i changed , worked: import peewee pw mydb = pw.mysqldatabase("mydb", host="mydb.crhauek3cxfw.us-west-2.rds.amazonaws.com", port=3306, user="user", passwd="password") class mysqlmodel(pw.model): """

Remove a parent class from a child element before calling method on parent (javascript/jquery) -

say have following unordered list <ul class="foo"> <li> <div class="bar"> </div> <div class="baz"> </div> </li> <li> <div class="bar"> </div> <div class="baz"> </div> </li> </ul> <div class="nav"> <a class="prev-link">previous</a> <a class="next-link">next</a> </div> i pass list carousel $(".foo").caroufredsel(//options) don't want class bar affected carousel. i've tried $('.bar').removeclass('foo') before calling carousel, doesn't seem work... still part of carousel. how can prevent 1 div inheriting parent class or there different way can prevent div being treated part of carousel i.e. (just left in place)? you try using !important css rule on .bar class properties don't want overwr

ruby on rails - ActiveRecord::StatementInvalid unknown column error -

why work fine: tag.create(game_id: 1, tagged: u) but this: tags = tag.where(game_id: 1, tagged: u).includes(:tagged) gives error: activerecord::statementinvalid: mysql2::error: unknown column 'tags.tagged' in 'where clause': select `tags`.* `tags` `tags`.`game_id` = 1 , `tags`.`tagged` = 1 btw, u activerecord::base sublcass. tag table structure: create_table :tags, force: true |t| t.references :game t.references :tagged_by t.references :tagged t.timestamps end try doing tags = tag.includes(:tagged).where(game_id: 1, tagged_id: u.id)

Jackson JSON : Subclass fields not seralized if implements java.util.Set -

i have following inheritance interface resultset extends java.util.set<customresult> { public int getcount(); } @xmlaccessortype(xmlaccesstype.none) @xmltype(name = "customresultset") class customresultset extends linkedhashset<customresult> implements resultset { @xmlelement(name = "count") private int count; public void setcount(int count) { this.count = count } } . . public static void main() { objectmapper objectmapper = new objectmapper(); objectmapper.disable(deserializationfeature.fail_on_unknown_properties); objectmapper.disable(serializationfeature.fail_on_empty_beans); customresultset customresultset = new customresultset(); customresult customresult = new customresult(55, "abc"); customresultset.setcount(11); customresultset.add(customresult); system.out.println(objectmapper.writevalueasstring(customresultset)); } with above code serializes values in collection customresultset not field count i

ruby - Directory walk call method when directory is reached -

trying write script search through directory , sub-directories specific files. know how directory or directories come call method. this have tried , failed: def display_directory(path) list = dir[path+'/*'] return if list.length == 0 list.each |f| if file.directory? f #is directory? if file.directory?('config') puts "this config folder" end printf "%-50s %s\n", f, "is directory:".upcase.rjust(25) else printf "%-50s %s\n", f, "is not directory:".upcase.rjust(25) end end end start = file.join("**") puts "processing directory\n\n".upcase.center(30) display_directory start this want happen. app app/controllers app/helpers app/mailers app/models app/models/bugzilla app/models/security app/views app/views/auth app/views/calendar app/views/layouts app/views/step app/views/step_mailer app/views/suggestion app/views/suggestion_mailer app/views/task app

Error with jqgrid date formatting -

server returning string date in format "2/6/2013" after bind formatter, appears this: "12/4/2007" . { name: 'duedate', index: 'duedate', width: 110, align: 'center', resizable: false, formatter:'date', formatoptions: { newformat: 'm/d/y' }, datefmt: 'm/d/y' } why? try specifying source format in formatoptions . ie; formatoptions: { srcformat:'d/m/y',newformat: 'm/d/y' }, or can use custom formatter described here

c# - simple xpath not working to find a node -

iam trying particular node value equals input parameter,my xpath b node need string xpath = "/batches/measurement/batch[market=someval]/b"; <?xml version="1.0" encoding="utf-8" ?> <batches> <measurement> <batch> <market>someval</market> <b>someval</b> </batch> </measurement> </batches> var xmlnode = xmldoc.selectnodes(xpath); no nodes retruned count 0 ,i checked xmldoc loaded properly. your xpath perfect. keep in mind const values have put in apostrophe: "/batches/measurement/batch[market='someval']/b" update: c# code example: xmlnodelist nodelist; nodelist = root.selectnodes("/batches/measurement/batch[market='someval']/b"); foreach (xmlnode node in nodelist) { (int = 0; < node.childnodes.count; i++) { console.writeline(node.childnodes[i].innertext); } } the r

php - How to change separate associative arrays to something usable such as one indexed array? -

print_r($element_attrs); returns following arrays gathered xml file. array ( [weather-summary] => increasing clouds ) array ( [weather-summary] => thunderstorms ) array ( [weather-summary] => thunderstorms ) array ( [weather-summary] => cloudy ) array ( [weather-summary] => cloudy ) array ( [weather-summary] => sunny ) array ( [weather-summary] => clear ) array ( [weather-summary] => sunny ) array ( [weather-summary] => clear ) array ( [weather-summary] => sunny ) array ( [weather-summary] => clear ) array ( [weather-summary] => sunny ) array ( [weather-summary] => clear ) array ( [weather-summary] => sunny ) array ( [weather-summary] => fair ) array ( ) right 16 separate associative arrays in keys same except last 1 that's blank reason. i'd return value second last array array ( [weather-summary] => fair ) . i've been experimenting foreach() , for() loops try create either index can retrieve array

javascript - Filepicker.io SecurityError -

i took demo on github , , ran on local server. can pull upload dialog , select photo, keeps throwing javascript error when choose upload: uncaught error: securityerror: dom exception 18 which freezes page @ spinning uploading screen. api key has been entered well. suggestions working appreciated. according seems canonical stack overflow issue on topic ( uncaught error: security_err: dom exception 18 when try set cookie ), has fact window.history.pushstate call dialog makes not happy when run via localhost directly.

Replace the content in between using python regex -

i have string: '[text], text, {text}, itextm' i should end with: '[replaced], text, {replaced}, ireplacedm' how can python re module? thanks! in [1]: s='[text], text, {text}, itextm' in [2]: import re in [3]: re.sub(r'([[{])[^\]}]*',r'\1replaced',s) out[3]: '[replaced], text, {replaced}, itextm' edit ah... didn't notice last part of example, ireplacedm ! now should work example: in [8]: re.sub(r'([^ ,])text([^ ,])',r'\1replaced\2',s) out[8]: '[replaced], text, {replaced}, ireplacedm'

AgileToolkit OAuth add-on error 500 at facebook's mobile site -

i using oauth facebook controller add-on atk4. it works expected when authenticating facebook regular desktop browser. it works when authenticating using mobile browser telling face book it's desktop browser. it not work when facebook detects mobile browser , redirects m.facebook.com/dialog/oath. what's more, works fine signups mobile browsers (ie, when facebook asks user give permission app). the login flow stops error 500 at: https://m.facebook.com/dialog/oauth?redirect_uri= {my_url_encoded_landing_page_where_the_oauth_controller_lives}&scope=email&client_id={fb_app_id} what hell going on here? there isn't difference between facebook mobile service , regular 1 addon isn't taking care of, or there? it must i'm doing wrong. in init() on page handles fb, doing following: function init(){ parent::init(); $f = $this->add("oauth/controller_oauth_facebook", array('sign_method'=>'plaintext')); if ($f

c# - How can I open a specific text file without using OpenFileDialog? -

i have rich text editor have created in c#. 1 of features trying add templates. not want user have use openfiledialog navigate template , open file. specify filepath myself user has click 1 button in order open template. currently, trying achieve using following code: private void formallettertoolstripmenuitem_click(object sender, eventargs e) { try { filestream filestream = new filestream(@".\templates\tmp1.rtf", filemode.open); string str; str = filestream.tostring(); string filecontents = file.readalltext(filepath); filecontents = filestream.tostring(); try { if (richtextboxprintctrl1.modified == true); { newfile(); } richtextboxprintctrl1.rtf = filecontents; } catch (exception exception) { messagebox.show("there error open

c# - read html content of a page using ajax -

i have need.. hope can give me right advice ! i have read whole html content of page using ajax call, necessary client visiting page make request read html content, , not application (i mean using downloadstring method of c#) after this, need read response of ajax call (in case html content of page setted in "url:" parameter of ajax call) server-side (in code-behind) how can that? possible? thank help.. stefano stefano, html content through ajax using, exemplo, jquery this: $.get('ajax/test.html', function(data) { //data html }); after can make ajax call sending data "code-behind", can see in complete code: $.get('ajax/test.html', function(data) { $.ajax({ datatype: "json", data: "htmldata=" data type: "post", url: '/code_behind.aspx', success: function(response){ console.log(response); } }); }); i hope helps.

web services - Validate webservice parameters -

i'm quite new codeigniter kindly me through.. i'm writing restful web service codeigniter - there way validate parameters in 'post' request's json? by validating, mean kind of form_validation json parameters , not form (well obviously, there no form in use.) example post body: {"name":"foo","email":"foo@gmail.com"} if regular form post (not json), i'd use: $this->form_validation->set_rules('name', 'name', required | max_length[30]) $this->form_validation->set_rules('email', 'email', required | valid_email) how can implement in case? 10x

xaml - How do i set up borderbrush in radiobutton in windows phone? -

i have code <radiobutton content="femenino" height="72" margin="224,118,0,0" name="rbtn_fem" verticalalignment="top" visibility="visible" borderbrush="#ffa3cd5a" background="white" borderthickness="8" groupname="selsex" foreground="#ffa3cd5a" fontweight="extrabold" fontfamily="fonts/me likey.ttf#me likey ~"/> i have been trying made radio button green border , white center, seems going wrong button borderbrush property, since no matter color change it, doesnt appear. this because in windows phone 7 default control template radiobutton not utilize borderbrush or borderthickness properties. you'll have create own controltemplate use implement through