Posts

Showing posts from March, 2010

c - How to set an image as background of an annotation in MuPDF? -

i want set image background of annotation in mupdf using following code: fz_context *ctx = doc->ctx; const fz_matrix *page_ctm = &annot->page->ctm; image_document *image_doc = (image_document *)fz_open_document(ctx, "/users/zidane/downloads/a.jpg"); fz_image *image = image_doc->image; fz_matrix local_ctm = *page_ctm; float w = image->w * dpi / image->xres; float h = image->h * dpi / image->yres; fz_pre_scale(&local_ctm, w, h); fz_pre_translate(&local_ctm, 0, -1); fz_fill_image(dev, image, &local_ctm, 1); can tell me why not work?

c# - How to make WCF Service take only one call at a time -

we have wcf service public class myservice { [operationcontract] public void opperationa() { } [operationcontract] public void opperationb() { } [operationcontract] public void opperationc() { } [operationcontract] public void opperationd() { } } we have client wcf service windows service invokes operations above operationa/b/c/d new proxies. with current implementation have there issues client invoking operations @ same time. instancecontextmode = percall , concurrencymode = single is there combination of instancecontextmode , concurrency can change service take 1 request @ time, mean if client proxy has called operationa , service processing request , if client proxy b tries call operationb (or other operation), should blocked until first request finished. thanks it should sufficient change instancecontextmode single. msdn documentation here : concurrencymode=single : service instance single-threaded , not accept reentrant calls.

android - FragmentStatePagerAdapter with dynamic data, IllegalStateException -

i have main fragment has list of items, on clicking item, open detailed view of item in new fragment using transaction.replace(r.id.container, feeddetail.newinstance(title, position)).commit(); the detailed fragment has fragmentstatepageradapter show sliding list of items. works right, main list of item gets updated in background (asynctask). when sliding items in detailed view, java.lang.illegalstateexception: application's pageradapter changed adapter's contents without calling pageradapter#notifydatasetchanged! expected adapter item count: 30, found: 40 pager id i call adapter.notifydatasetchanged() onpostexecute(), still not fix issue. guess issue similar 1 shared here http://translate.google.co.in/translate?hl=en&sl=zh-cn&u=http://blog.csdn.net/hlglinglong/article/details/34845519&prev=search not sure though. have tried different values in getitemposition() of adapter without success. nice hint on issue. pasting detailed fragment code h

multithreading - The background music is intrerrupted when loading files -

using delphi xe6 , firemonkey have following problem: we have tmediaplayer playing in main thread mp3 music when load jpg files (for example, think @ slide show) in moment in file loaded through mybmp.loadfromfile(myfile) music interrupted short amount of time, causing unpleasant 'hiccups'. we have 2 variants: 1 loadfromfile in main thread , other loadfromfile in thread. last 1 tried lower thread priority this: begin {$if defined(mswindows)} priority:=tthreadpriority.tplower; //to not bother music {$elseif defined(posix)} // ** priority integer ** priority:=priority-2; //to not bother music {$endif posix} tmpbmp.loadfromfile(filename); {$if defined(mswindows)} priority:=tthreadpriority.tpnormal; //to not bother music {$elseif defined(posix)} // ** priority integer ** priority:=priority+2; //to not bother music {$endif posix} end; ...however without success. can enlighten why music interrupted on i5 (4 cores) @

unidirectional @oneToMany without joinTable in openJpa 2 -

i trying create unidirectional onetomany mapping in openjpa 2.3.0 , want define column name hold foreighn key on source table. far know in jpa 2.0 can done follows : @entity public class source { private list<target> targets = new arraylist<>(); @onetomany @joincolumn(name="source_fk") public list<target> gettargets() { return targets; } } but following exception : <openjpa-2.3.0-r422266:1540826 fatal user error> org.apache.openjpa.persistence.argumentexception: have supplied columns "source.targets", mapping cannot have columns in context. @ org.apache.openjpa.jdbc.meta.mappinginfo.assertnoschemacomponents(mappinginfo.java:382) @ org.apache.openjpa.jdbc.meta.strats.relationtomanytablefieldstrategy.map(relationtomanytablefieldstrategy.java:97) @ org.apache.openjpa.jdbc.meta.strats.relationcollectiontablefieldstrategy.map(relationcollectiontablefieldstrategy.java:94) @ org.apache.openjpa.jdbc.meta.fie

Trying to do an HTTP POST command from embedded board to Apache server -

Image
i'm trying c code going on embedded board running freertos , using tcp/ip stack post simple file apache server running on desktop. i can pull file from apache server to board fine, know apache server running. i have attached wireshark screenshot of http post packet goes out embedded board. can see hex values of exact message @ bottom. i send tcp packet out twenty bytes of data. have tried , attaching twenty bytes of data same packet header in. in both cases couple of packets desktop outlining error. tells me there 404 error found on 1 site means: http/1.1 404 not found the post path of command incorrect. the index.html file on apache server in /var/www/html/ directory. created incoming subdirectory , gave full permissions everyone. drwxrwxrwx 2 root root 4096 nov 19 10:07 incoming/ -rw-r--r-- 1 root root 174 nov 11 22:20 index.html so, believe should able post incoming address. request /index.html in command, believe request: post /incoming

java - Changing the value of a textfied in JFrame class1, JFrame class2,... by selecting an item from jtable in Jframe class3 -

i have 14 jframe classes , 1 jframe class holding jtable acts calendar. want date of text field or other component in of 14 jframe classes changed when user selects date jtable calendar . now, frames appear 1 @ time , jtable instantiated jbutton on of 14 jframe classes. my dilemma how identify jframe class has instantiated jframe contains jtable it's text field value can changed. code instantiates jframe containing table: private void jbutton1actionperformed(java.awt.event.actionevent evt) { jframe frmmain = new calender(); frmmain.setvisible(true); frmmain.setsize(367, 342); } code changes value of textfield 1 of 14 jframe classes : @override public void mouseclicked(mouseevent me) { if (me.getclickcount()==2){ int selected1 = jtable1.getselectionmodel().getleadselectionindex(); int selected2 =jtable1.getcolumnmodel().getselectionmodel().getleadselectionindex(); object c

php - Change event not populating dropdown with data -

i have been trying past few days figure out how chosen.js handles change events no success hence post. have tried many options , configurations, admitting defeat , hoping can help. i have simple select populates mysql. works ok. now, when trigger change event, can see data being returned in firebug, no data present in dropdown. so, guess question is, how hell work change events in chosen.js. if take chosen out of equation, works well. getting confused why can see data in firebug select not updating. many thanks. fyi: assume libraries loaded , working. html <div class="fieldset"> <h1><span>select customer</span></h1> <p> <select data-placeholder="choose customer..." class="chosen-select" style="width:250px;" name="dstr_customer" id="dstr_customer"> <option value=""></option> <opti

c# - How to encrypt jpeg file correctly using xor operation -

i have problem encrypting jpeg file using xor operation. here how decoding file: stream imagestreamsource = new filestream(filename, filemode.open, fileaccess.read, fileshare.read); jpegbitmapdecoder decoder = new jpegbitmapdecoder(imagestreamsource, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.default); bitmapsource bitmapsource = decoder.frames[0]; return bitmapsource; here how encoding , encrypting it(bs decoded bitmapsource): int stride = bs.pixelwidth * 3; int size = bs.pixelheight * stride; byte[] pixels = new byte[size]; bs.copypixels(pixels, stride, 0); pixels = xoring(pixels, size); int width = bs.pixelwidth; int height = bs.pixelheight; bitmapsource image = bitmapsource.create( width, height, bs.dpix, bs.dpiy, bs.format, bs.palette, pixels, stride);

session - PHP remember url parameter value using $_SESSION -

i made script shows value of " school_id " in url parameter. http://mywebsite.com/mygrade?school_id=00000 i use $_get['school_id'] display id number. <?php echo $_get['school_id']; ?> but want if parameter " school_id " empty, want display previous data entered. example, user browse http://mywebsite.com/mygrade?school_id=00000 browse http://mywebsite.com/mygrade?school_id= id has no value. still display 00000 previous id used. i used code below doesn't work.. :( <?php session_start(); $_session['schoo_id'] = $_get['school_id']; if ($_get['school_id'] === null || $_get['school_id'] == ""){ echo $_session['schoo_id']; } else{ $_get['school_id']; } ?> anyone point , me? i'm going break down line line, please let me know in comments if need explain further: self explanatory: <?php session_start(); there typo here: $_session

android - Why isn't one of my tabs acting like the others? -

i'm still working on passing data between each fragment in tab navigation app . using callbacks set , value, didn't work properly. switched current method of calling methods in activity set , values, that's acting strange well. when run app first fragment (first tab) gets value, , able change it. when swipe second tab, value not should be. when swipe third tab, value correct. value persistent on first , third tab (fragment), second tab doesn't want cooperate. example: start - persistent_value = 0 tab1 displayed - value shown 0 change value on tab1 - persistent_value = 9 swipe tab2 - value shown 0 swipe tab3 - value shown 9 change value on tab3 - persistent_value = 34 swipe tab2 - value shown 0 swipe tab1 - value shown 34 i'm not sure why second tab not updating, while both first , third are. doing wrong, or there i'm not aware of here? here's example code i'm using try , solve problem. public class mainactivity extends act

magento - Fatal error occurred: "Wrong max deactivate lock item time." -

when trying list our product on amazon magneto backend getting fatal error occurred: "wrong max deactivate lock item time.". we using m2epro version 6.0.3 the problem can caused enabled compilation during upgrade. to solve should click "run compilation process" in system -> tools -> compilation. remember disable " compilation" option ( system -> tools -> compilation) before each upgrade , enable again once upgrade process completed.

Why do I need the WRITE_EXTERNAL_STORAGE permission with getExternalCacheDir() on Android Lollipop? -

my app writes (and reads) cache files getexternalcachedir() location. before android lollipop (api 21) i've been using permission success: <uses-permission android:name="android.permission.write_external_storage" android:maxsdkversion="18" /> the maxsdkversion there because permission shouldn't needed after api v18: http://developer.android.com/reference/android/manifest.permission.html#write_external_storage but on android lollipop (5.0) i'm getting access permission (with log output show actual path used): 11-19 13:01:59.257 4462-4541/com.murrayc.galaxyzoo.app e/android-galaxyzoo﹕ createcachefile(): ioexception filename=/storage/emulated/0/android/data/com.murrayc.galaxyzoo.app/cache/52 java.io.ioexception: open failed: eacces (permission denied) @ java.io.file.createnewfile(file.java:941) @ com.murrayc.galaxyzoo.app.provider.itemscontentprovider.createcachefile(itemscontentprovider.java:528) i see

java - Spring @Autowired chains and regular 'new XYZ()' instantiations -

is impression correct using regular new xyz() way of instantiating component xyz prevents spring processing @autowired fields inside xyz? second question: correct cannot use dependency injection in xyz , @ same time use final fields in xyz because of that? example: @component public class xyz { @autowired private somedep dep; private final int value; public xyz(int value) { this.value = value; } } how make working? so, well, accepting there no nicer way, let's way: @component public class xyz { @autowired private somedep dep; private final int value; // factory instantiation xyz() { value=0; } private xyz(somedep dep, int value) { this.dep = dep; this.value = value; } public xyz getinstance(int value) { return new xyz(dep, value); } } ??? ugly. , gets uglier when want move dependency declaration parent class....... ??? thought di nice. think have reconsider th

php - Kohana_Exception [ 0 ]: Directory APPPATH\cache must be writable help needed -

website created kohana shows error "kohana_exception [ 0 ]: directory apppath\cache must writable" appears. im using windows 7 xampp , have no idea do. syspath\classes\kohana\core.php [ 281 ] kohana::$cache_dir = apppath.'cache'; } if ( ! is_writable(kohana::$cache_dir)) { throw new kohana_exception('directory :dir must writable', array(':dir' => debug::path(kohana::$cache_dir))); } if (isset($settings['cache_life'])) { as answered here check whether file exists (application/cache), folder comes empty kohana, , versioning systems , other software delete , ignore empty folders. if not exist, create folder , insert blank file in (ie, empty.txt) if error persists, give appropriate permissions.

jquery - Show content on scroll -

Image
i'm trying post content stay hidden until user scrolls ( example ). far haven't been successful. so far have code - jquery - $('.content-post').hide(); $('div').on('scroll', function(){ if($(this).scrolltop() > 25)$('.content-post').show(); else $('.content-post').hide(); }); css - .content-post { background-color: #ede3de; margin: 0 auto; text-align: left; } html - <div class="content-post"> lorem ipsum dolor sit amet, consectetur adipiscing elit. </div> here jsfiddle , website i studying jquery please go easy :) css body{ height:2000px; } if box parent more big child, works on-scroll! $('.content-post').hide(); //$(document).scroll(function(){ //$(document).on('scroll', function(){ $(document).bind('scroll', function(){ if ($(this).scrolltop() > 25) { console.log($(this).scrolltop()); $('.content-post').show(); } el

Django why inline formset validation fails? -

view def add_poll_checkbox(request): new_poll = poll.objects.create(author=request.user) if request.post: form = addpoll(request.post, instance=new_poll) if form.is_valid(): poll = form.save(commit=false) poll.author = request.user poll.poll_type = 1 formset = choiceformset(request.post, instance=poll) if formset.is_valid(): poll.save() formset.save() return httpresponseredirect('/admin/teacher/') else: formset = choiceformset(instance=new_poll) else: form = addpoll(instance=new_poll) formset = choiceformset(instance=new_poll) return render_to_response('add_poll_checkbox.html', {'form': form, 'formset': formset}, context_instance=requestcontext(request)) form class addpoll(forms.modelform): class meta: model = poll choiceformset = inlineformset_factory(poll, choice, extra=2, can_delete=false) please tell m

How to convert Ascii value to character in c#? -

this question has answer here: how character given ascii value 7 answers i have ascii value stored int , want ascii convert character. private void button2_click(object sender, eventargs e) { string text3 = textbox1.text; string text4 = ""; byte[] array = encoding.ascii.getbytes(text3); foreach (char c in array) { int ascii = (int)c; ascii = ((((ascii / 37 + 657) / 12) - 582) / 11); text4 += ascii + "-"; } textbox3.text = text4; } this simplest way of converting ascii value character , string: int = 123; char c = (char)i; string s = c.tostring(); in example should work following: text4 += (char)ascii + "-";

model - Laravel eloquent count hasMany relations -

i have database, 2 main tables : etablissement site so created 2 models site.php class site extends eloquent { public function etablissement() { return $this ->hasone('etablissement','code_etablissement','code_site'); } } etablissement.php class etablissement extends eloquent { public function sites() { return $this ->hasmany('site', 'code_etablissement', 'code_etablissement'); } public function etablissementcountsites() { return $this->sites->count(); } } as can see, here's how relations working : "etablissement" can have multiples "site" "site" can have 1 "etablissement" "etablissement" primary key "code_etablissement" "site" primary key "code_site", having the foreign key "code_etablissement" referencing "etablissement.code_etablissement" i wa

java - Issue with stateful ejb on servlet without @EJB injection -

i trying use stateful ejb servlet, understood shouldn't use @ejb injection that, , lookup instead. the problem is, far way managed achieve using anotation on servlet: @ejb(name="loginremote", beaninterface = loginremote.class) loginremote loginhandler; then lookup: loginhandler = (loginremote) new initialcontext().lookup("java:comp/env/loginremote"); otherwise javax.servlet.servletexception: javax.naming.namenotfoundexception error. is acceptable or should avoid @ejb injection completely? thanks no, don't want inject instance servlet. instead, can use @ejb annotation on servlet class declare reference without injecting: @ejb(name="loginremote", beaninterface = loginremote.class) public class myservlet { you can use @ejbs if want declare multiple references in same servlet. (note when using annotation on field in example, beaninterface parameter redundant field type, required when using class-level annotation clas

c# - Current type of the build action from Visual Studio - Microsoft.VisualStudio.Shell.Interop -

in extension implement ivsupdatesolutionevents2 , ivssolutionbuildmanager2 used registering caller adviseupdatesolutionevents for example, called before build actions have begun: public int updatesolution_begin(ref int pfcancelupdate) { ... } however, need getting status or type of current build action, example: build/rebuild/clean/deploy available & known variants: buildevents with events.buildevents can subscribe onbuildbegin, example: _buildevents.onbuildbegin += new _dispbuildevents_onbuildbegineventhandler((vsbuildscope scope, vsbuildaction action) => { buildtype = (buildtype)action; }); and use buildtype in places, because vsbuildaction provides necessary information but updatesolution_begin / updatesolution_startupdate called first as priority advising method, , result buildtype sets late.. also can use onbuildbegin instead of updateprojectcfg_begin / updatesolution_startupdate, our handling needed as possible priority caller ivsup

scala - How to create private fields that my functions will return -

my class looks like: class webconfig(config: config) { def this() { this(configfactor.load()) } def dbport = config.getint("mysql.port") } i don't when call dbport, has call , cast config each , every time. so want create private fields , set them in constructor, calling dbport return private field has. how can this? i tried creating private var getting error: class webconfig(config: config) { private var _dbport: int def this() { this(configfactor.load()) _dbport = config.getint("mysql.port") } def dbport: int = _dbport } error: abstract member may not have private modifier can't write this: class webconfig(config: config) { def this() { this(configfactor.load()) } val dbport = config.getint("mysql.port") } it read config parameter 1 time.

python - XPATH: Specific word in paragraph -

i have been trying figure out how exact xpath e.g. third word in paragraph: e.g.: <p>here text</p> then if want third word ("some"), can't figure out how single out using xpath. however, focal point here not exact match of word "some", instead third word (whatever may be). i have been trying this: ../p[3], doesn't help. use python , scrapy framework. i hope can point me in right direction. thank you. if using scrapy, question tagged, consider using scrapy's .re() support, i.e: >>> response.xpath('//p/text()').re('\w+')[2] u'some'

ActionBar's text color of actions and dropdown menus changes from Android version to another -

Image
what on nexus 5 (android 5): what on asus memo pad (android 4.2.2): my themes.xml : <?xml version="1.0" encoding="utf-8"?> <resources> <!-- theme applied application or activity --> <style name="hhtheme" parent="@android:style/theme.holo.light"> <item name="android:actionbarstyle">@style/myactionbar</item> <item name="android:textcolor">@color/themegraydarker</item> <item name="android:actionmenutextcolor">@color/themewhite</item> <item name="actionmenutextcolor">@color/themewhite</item> <item name="android:popupmenustyle">@style/myapp.popupmenu</item> </style> <!-- actionbar styles --> <style name="myactionbar" parent="@android:style/widget.holo.actionbar"> <item name="android:titletexts

scheduled tasks - Making a java application run automatically once in a day? -

i did reminder application in java.i want run application @ 12 p.m generates mail client .the thing generate mail done,but main issue how make application run @ 12 p.m daily... use cron (unix only) add cron tab 0 0 * * * /path/to/your/file.sh >/dev/null 2>&1 file.sh #!/bin/sh java com.package.yourmainclass edit on windows 8, take here : using task scheduler in windows 8

objective c - header file in iOS 8 embedded frameworks -

Image
i'm trying create embedded framework use ios8. after creating 1 called samplekit (btw; there convention here, should used prefix?), contains header file puzzling me: //! project version number samplekit. foundation_export double samplekitversionnumber; //! project version string samplekit. foundation_export const unsigned char samplekitversionstring[]; i know foundation_export macro extern or extern "c" , i'm not sure 2 constants. supposed set value them? project > build settings > versioning > current project version :

javascript - Which element effects the positioning of my jquery drop-down menu --> making it go right -

since while using drop-down jquery check list. though, styling purposes want make list not drop down rather have fold/go right. i try'd couple of things (in css) accomplish nothing seems work far, cant find right element effects menu dropping down. or perhaps jquery handled cant see jquery doing that.. this html of drop-down list: <form method="post"> <div id="list1" class="dropdown-check-list"> <span class="anchor">select country in event takes place</span> <ul class="items"> <li><input type="checkbox" name="columns_location[]" value="belgium" />belgium</li> <li><input type="checkbox" name="columns_location[]" value="denmark" />denmark</li> <li><input type="checkbox" name="columns_location[]" value="england&

c++ - Towers of Hanoi algorithm without printing anything to terminal window -

the typical towers of hanoi problem solver following: void hanoi(int disknumber , int start, int temp, int finish) { if(disknumber == 1) { cout<< " move disk " << disknumber<<" " << start <<" "<< finish<<endl; } else { hanoi(disknumber-1,start,temp,finish); cout<<"move disk " << start <<" "<<finish<<endl; hanoi(disknumber - 1,temp,start,finish); } } but want calculating time algorithm runs. thus: int main { //hanoi: cout<<"hanoi tower problem:"<<endl; //3 disks: clock_t htimer3 = clock(); hanoi(3, 1,2,3); cout<<"cpu time n = 3 is: " <<clock() - htimer3/clocks_per_sec<<endl; //6 disks: clock_t htimer6 = clock(); hanoi(6, 1,2,3); cout<<"cpu time n = 6 is: " <<clock() - htimer6/clocks_p

Perl - Logging to terminal from a long running system call -

i calling external program perl code using backticks print `<some long running program>` the long running program prints detailed log messages onto standard output. problem i'm having due buffering, output long running program printed @ once after has finished execution. tried making stdout filehandle "hot" did not help. is there anyway can have program print continuously onto screen? open exec pipe rather using backticks. open ( $prog_stdout, "-|", "/your/program" ) or die $!; this fork , exec give access $prog_stdout things with. e.g. while ( <$prog_stdout> ) { print; } (it'll close if external program exits, while terminate). you may want include autoflushing of filehandle. http://perldoc.perl.org/io/handle.html but may not necessary, output won't buffered indefinitely.

Rails: Preselect Option from dropdown menu -

i have working filter on table, want preselect 1 of filters according in team user is. code filter following <%= form_tag request.path, :method => 'get' %> <%= select_tag "filter", options_for_select([ "alle", "men", "women", "juniors" ], params[:filter]), class: 'my_filter'%> <% end %> now every user belongs 1 of 4 groups, in user db identified team_id if open page want select according fitler each user default. thank help edit: working js update code <script type="text/javascript"> $(function(){ $('select.my_filter').on('change', function(){ alert($(this).val()) $(this).closest('form').submit() }) }) options select accepts selected option: options_for_select(["alle", "men", "women", "juniors"], selected: "men") see http://apidock.com/rails/actionview/help

datasource - Spotfire - Data source reference missing while moving library & data source from 5.5 to 6.5 server -

steps followed: from 5.5 server, exported data source & library(elements/infolinks/reports) 2 separate exports copied these files 6.5 folder (tomcat/application-data/...) from 6.5 server, a. imported data source first (need edit , input password , save it. otherwise giving me error) b. import library items(3 parts). at point, getting error missing references (mainly data source not referenced). logs attached. tried multiple times of deleting/importing different combinations of replace/add new items etc. setup details: spotfire database on 5.5 oracle (express edition) whereas on 6.5 ms sql server(trial version) data source being imported & exported mysql. both 5.5 & 6.5 on same physical server , running 1 @ given time. my questions: is there specific sequence in order export(5.5) & import(6.5) library & data sources? does both datasource & library has exported & imported in 1 single shot or missing something? how resolve this?

amazon web services - AWS S3 Website Hosting - Url Redirect Issue -

the below link mentions redirection of website hosted in s3 bucket. https://docs.aws.amazon.com/amazons3/latest/dev/howdoiwebsiteconfiguration.html i have url www.myurl.com. want below redirection www.myurl.com www.myurl.com\page\mainpage www.myurl.com\page www.myurl.com\page\mainpage question whether possible above redirection. have gone through documentation mentioned in above link not possible redirect. according documentation, should able like: <routingrules> <routingrule> <condition> <keyprefixequals>/</keyprefixequals> </condition> <redirect> <replacekeyprefixwith>/mainpage/</replacekeyprefixwith> </redirect> </routingrule> <routingrule> <condition> <keyprefixequals>page/</keyprefixequals> </condition> <redirect> <replacekeyprefixwith>/page/mainpage/</replacekeyprefixwith> </redirect> </routingrule>

java - How would I display the position of an element in an array? -

my dilemma after user inputs number, number checked see if it's in array, if i'll let them know in array along position of said number. have prompts user number, after arrayindexoutofboundsexception error. here's have far: int [] igrades = new int [30]; system.out.print ("enter grades, when you're done input (-1) "); (int i=0; i<igrades.length;i++) { igrades [i]= kb.nextint(); if (igrades [i]< 0) { break; } } system.out.print ("\nenter grade check if it's in array"); ival = kb.nextint(); for(int i=0; i<=igrades.length; ++i) { if(ival == (igrades[i])) { found = true; for(int j=0; j<=igrades.length; ++j) { igrades[j]=j+1; } break; } } if (found == true) { system

Silverstripe 3 template loops functions and nested loops -

good morning, i've been struggling silverstripe, , it's template parsing regards nested loops , functions within loops while now, it's becoming maddening. if can alternate solution besides ajax (it must pure php/html/ss), acceptable, thanks. [situation] have 2 data objects: objecta [ has_many objectb ], , objectb [ has_one objecta ]. i've implemented tab-pane using css-bootstrap, , display these 2 objects linked in respective tabs. example: objecta_car mapped [objectb_process1, objectb_process2] objecta_plane mapped [objectb_process3, objectb_process4] scenario 1: please see sample pseudo code below: ///>sample.ss snippet <% loop objecta_datalist %> <div class="tab-pane"> <h3>$objecta_datalist.title</h3> <!-- prints objecta title --> <hr /> <h4>$objecta_datalist.description</h4> <!-- prints objecta description --> debug: $pos <!-- prints objecta

jquery - $.ajax always go to error callback function -

i trying check if file exist or not when run code go error callback function if filename url of existing file. why $.ajax enter error callback function? $.ajax({ url: filename, type: 'get', datatype: 'text', async: false, cache: false, success: function () { alert('file found.'); }, error: function () { alert('file not found.'); } }); there more problems: the file might not think is the file might crash , fail respond the file might run long while , request might crash due timeout you should check these possibilities.

How to properly decode or encode a string in python? -

i have following string giving me following error when try upload database: string_from_source = 'stringÊ' string_in_dataset = 'string\xe6' when try decode or encode, following error: unicodedecodeerror: 'ascii' codec can't decode byte 0xe6 in position 17: ordinal not in range(128) for example, error 'string\xe6'.encode() 'string\xe6'.decode() 'string\xe6'.encode('utf-8') i've tried: 'string\xe6'.decode('utf-8') unicodedecodeerror: 'utf8' codec can't decode byte 0xe6 in position 17: unexpected end of data is there way eliminate type of error once , all? want exclude special characters.

python - Can I detect the text codec used in a string? -

i'm reading string file(which can modify) , don't know type of coded string is. there function like getcodec = mystring.getcodec() which return like getcodec = 'utf-8' or getcodec = 'ascii' ? no, there no such function, because files not record codec used write text contained. if there more context (like more specific format such html or xml) can determine codec because standard specifies default or allows annotating data codec, otherwise reduced guessing based on contents (which tools chardet do). for file can modify, have no hope document codec should used.

javascript - Replacing DIVs with List Items inside form -

i'm trying format , change structure of standard html form. @ moment output looks this <form accept-charset="utf-8" autocomplete="off" method="post"> <ol class="questions"> <div> <label>first name *</label> <input type="text" /> </div> <div> <label>email *</label> <input type="text" /> </div> <div class="submit"> <input type="submit" value="submit" /> </div> </ol> </div> </form> i need change divs list items , add span around labels if possible. i've got far it's not altering unfortunately. window.onload = function() {

user interface - What do you advise to show data on computer via a serial port -

i have device. when connect pc using serial port, can see data on hyper terminal. i know send meter on hyper terminal as: tx = voltage_phase_a while serial port communication stable! now, here question. i not want use terminal. have own version of terminal. simple window grabs data out of device , show on pc. so, language think straightforward , easy use , ide should use make such gui? project east do? examples can have? you can write separate c++ app listens serial port in loop. writing serial listener in c++ not straight forward, can in c#: here sample app in c#: http://www.codeproject.com/articles/75770/basic-serial-port-listening-application

git Best Practice Recommendation -

i looking @ setting git repositories coming background in svn. here want: product repositories - these capture stand alone individual products (an application, library example) application a application b library c . . . project repositories - these capture aggregations of products form solution particular customer. project x repository project y repository project z repository . . . each project built of different combinations of products. example, project x built of application a, application b, , project specific code. project y build of application b, application c, , application d project specific code , settings. idea. in svn, project repositories use svn-externals include version of products. can accomplish repository concept detailed above or should thinking of different technique given power of git? consider using git submodules. details can found in submodules chapter of free online git book . quoting book: submodules allow keep

rust - Is it possible to store a value in a struct through a trait? -

editor's note: code example version of rust prior 1.0 , not syntactically valid rust 1.0 code. updated versions of code produce different errors, answers still contain valuable information. i tried , without box , , without lifetimes: trait traittoimpl { fn do_something(self, val: i32); } struct cont { value: i32, } impl traittoimpl cont { fn do_something(self, val: i32) { println!("{}", val); } } struct storetrait<'a> { field: box<traittoimpl + 'a>, } fn main() { let cont = box::new(cont { value: 12 }) box<traittoimpl>; let = storetrait { field: cont }; a.field.do_something(123); } all error: error: cannot convert trait object because trait `traittoimpl` not object-safe the problem is, error message says, trait traittoimpl not object safe. is, not safe use particular trait through reference (i.e. &traittoimpl or box<traittoimpl> . specifically, do_something met

asp.net mvc 5 - What is the difference between using AuthorizeAttribute or IAuthorizationFilter? -

authorizeattribute requires override onauthorization method , iauthorizationfilter requires implement onauthorization method. seems same thing me, there other differences? why 1 used on other? edit: clarify, i'm trying understand difference between following 2 pieces of code. public class passwordexpirationcheckattribute : authorizeattribute { private int _maxpasswordageindays; public passwordexpirationcheckattribute(int maxpasswordageindays) { _maxpasswordageindays = maxpasswordageindays; } public override void onauthorization(authorizationcontext filtercontext) { if (!filtercontext.actiondescriptor.getcustomattributes(typeof(bypasspasswordexpirationcheckattribute), true).any()) { iprincipal userprincipal = filtercontext.requestcontext.httpcontext.user; if (userprincipal != null && userprincipal.identity.isauthenticated) { var userstore = new applicationuserstore