Posts

Showing posts from June, 2015

rust - Trouble with Encodable Trait Bounds on Enums and Structs -

taking rust test drive. fun far, i'm uncertain how set trait bounds in instance useful. failed find implementation of trait serialize::serialize::encodable,std::io::ioerror> t it seems me need set bound on enumeration list<t: encodable> . however, compiler gets bit upset when try this. error: trait bounds not allowed in enumeration definitions so assumed have put bounds on implementation impl<t:encodable> , got this... error: wrong number of type arguments: expected 2 found 0 if that's case, how in rust? extern crate serialize; use serialize::{ json, encodable }; #[deriving(decodable, encodable)] pub enum list<t> { node(t, box<list<t>>), nil } impl<t> list<t> { fn to_json(&self) -> string { json::encoder::str_encode(self) } } seems work fine when work don't try encapsulate encoding, since knows int encodable... let mut list: list<int> = nil; ... let encoded

github for windows - How do I fix a broken git revision that has no ident? -

i have git repository lots of revisions. i'm developer, commits me far. somehow, ended single commit has no ident information. tried running: git filter-branch --env-filter ' >> git_author_name=myusername >> git_author_email=myuseremail@website.com >> export git_author_name >> export git_author_email but keep getting error: rewrite deadbeefdeadbeefdeadbeefdeadbeefdeadbeef (112/123)fatal: empty ident name (for ()) not allowed not write rewritten commit rm: cannot remove '/c/some/directory/that/leads/to/my/repository/.git-rewrite/revs': permission denied rm: cannot remove directory '/c/some/directory/that/leads/to/my/repository/.git-rewrite': directory empty what doing wrong? see online ident tells how fix commits before make them: do after commit through? to sure, set author and committer, , use git commit-tree , record change. you can see full example in " change author of commit in git ". note: reset

Parse.com settings not displaying my app's Application Keys -

my parse.com backend works properly, under myapp > settings > application keys, blank screen no info. https://dl.dropboxusercontent.com/u/9144870/screen%20shot%202014-06-27%20at%2012.35.10%20am.png the other settings sections work fine. any idea why happening, how fix it, or how access information elsewhere?

java - Writing new line notepad -

simply trying move new line after printing each element inside of notepad. searching has yielded uses of \r\n, doesn't seem work either. for(string element : misspelledwords) { writer.write(element + "\n"); } try this bufferedwriter writer = new bufferedwriter(new filewriter("result.txt")); (string element : misspelledwords) { writer.write(element); writer.newline(); } adding line separator @ end (like "\n") should work on os,but on safer side should use system.getproperty("line.separator")

datatables - jQuery delegate each function -

i using jquery datatable display list of options. table consists of multiple pages , users have option de-select/select options datatable entries using checkbox. able initiate delegate event on checkboxes, however, problem when have option de-select/select checkboxes, works first page. other checkboxes still remain selected. not sure, how delegate pages. can please throw light here. here code: $('body').delegate('[name="selectall"]', 'change', function () { if($(this).is(':checked')){ $('[name="all_barcodes[]"]').each(function(){ this.checked = true; }); }else{ $('[name="all_barcodes[]"]').each(function(){ this.checked = false; }); } }); thank you.

java - Status bar notification click event Android for background foreground app state -

on click of status bar notification. want check if app in foreground state notification cancel or if app in background state open app. have managed app state using code in application class public static boolean isactivityvisible() { return activityvisible; } public static void activityresumed() { activityvisible = true; } public static void activitypaused() { activityvisible = false; } private static boolean activityvisible; and putting these activities @override protected void onresume() { super.onresume(); myapplication.activityresumed(); } @override protected void onpause() { super.onpause(); myapplication.activitypaused(); } for notification using code notificationmanager notificationmanager = (notificationmanager) context .getsystemservice(context.notification_service); notification notification = new notification.builder(context) .setcontenttitle(title).setcontenttext(message) .setsmal

ruby on rails - What's the better practice to reuse the where query -

how reuse same queries in 2 methods ? .where(sony_alarm_tests: {ip: sony_alarm_test.ip}) .where(sony_alarm_tests: {round: sony_alarm_test.round}) .where(sony_alarm_tests: {firmware_version: sony_alarm_test.firmware_version}) the trouble me queries depends on .joins(:sony_alarm_test) . i have no idea ? thanks def previous(event_name=self.name) sonyalarmlog.joins(:sony_alarm_test) .where{ utc_time.lt (my{self.utc_time} - time_correction) } .where{ name =~ event_name } .where(sony_alarm_tests: {ip: sony_alarm_test.ip}) .where(sony_alarm_tests: {round: sony_alarm_test.round}) .where(sony_alarm_tests: {firmware_version: sony_alarm_test.firmware_version}) end def following(event_name=self.name) sonyalarmlog.joins(:sony_alarm_test) .where{ name =~ event_name } .where{ utc_time.gt (my{utc_time} + time_correction) } .where(sony_alarm_tests: {ip: sony_alarm_test.ip}) .where(sony_alarm_tests: {round: sony_alarm_test.round}) .w

class - How can I have a variable be changed throughout multiple Python modules? -

i've been stuck on trying work hours now. i'm inexperienced programming, i'm sorry if i'm trying ridiculous. if @ possible, avoid creating .txt,.config, or .json (or other file isn't .py) file keep variables simplicity's sake. i want program have 'experience' variable. throughout game, able add onto variable @ given instance in game in multiple different files. (there around 10 other variables program able use throughout multiple modules). i'm sorry if you've seen me ask similar question today. feel i'm getting close solving error , ends not working. i'm close! #file1.py experience = 0 file2 import givexp class game: def give_xp(self,given_xp): global experience experience += given_xp print('experience: ',experience) player = game() def main(): print('1) give xp') print('2) give 500 xp') donow = input() if donow == '1': givexp() #this in file2.py

ios - Can I have a NSURLSession delegate method in a different ViewController in iOS7? -

i using ios7 , xcode 5. i have instantiated nsurlsession object url in 1 viewcontroller , want write delegate in different viewcontroller. possible? basically, want make call in 1 viewcontroller, , after making call transit other viewcontroller. once transition made, want receive response in second viewcontroller through nsurlsession delegate methods , display data. possible? note: don't want keep user waiting in first viewcontroller until server comes response, because while server processing data, can keep user engaged in second viewcontroller other images/elements displayed. your api.h #import <foundation/foundation.h> typedef void(^successtypeblock)(nsdata*); typedef void(^errortypeblock)(nserror*); @interface testapi : nsobject<nsurlconnectiondelegate> -(void)hitapiwithurl:(nsurl*)url successblock:(successtypeblock)success failureblock:(errortypeblock)failure; @end your api.m @interface testapi() { } @property(nonatomic,copy) errortypeb

Windows doesn't refresh files on Android device SD card -

i'm developing app. app reads , writes files on sd card. have got inconvinience. if app writes file on sd card want see via windows 7x64 file manager (any file manager: explorer or total commander). files not shown until reconnect device (directly pull out , insert wire usb port). files shown in file manager on android. device - samsung galaxy s3 possible fix bug? try this mediascannerconnection.scanfile (this, new string[] {file.tostring()}, null, null);

c# - Accessing WCF service hosted as Windows service over LAN -

i beginner wcf services , windows services. i've couple of questions regarding wcf services hosted windows services yet i've read on articles msdn: 1) have wcf service hosted in windows service running on 1 machine on lan. want make silverlight applications running on other machines on same lan consume service. need architecture implemented across many lan networks i.e. each lan have 1 machine on windows service running , other machines on same lan should able access service. feasible architecture? technical issues may come (e.g. firewall setting may restrict client accessing service)? shall have make different configurations in client applications each lan? side note, want mention want run service when there no internet connection. 2) ways make client on lan consume wcf service hosted in windows service other adding service reference project? 1) - use net.tcp bindings endpoints. firewall won't issue if client , server on same network. - client configuratio

php - Mysql result loop for template engine -

what trying loop results use of simple template engine. problem script executes same result many times.. right there 3 test works in database(test_1,test_2,test_3), result looks now: test_3 test localhost test_3 test localhost test_3 test localhost $result = $pdatabase->query($query) or die('query failed: ' . mysql_error()); while ($row = mysql_fetch_array($result)) { //loop template (row) $works_row = new template("works_row.tpl"); //changing $row[] {} $rows[]=$row; $works_row->set("category",$row['category']); $works_row->set("name",$row['name']); $works_row->set("link",$row['link']); } foreach ($rows $row) { $works_templates[] = $works_row; } $works_contents = template::merge($works_templates); mysql_free_result($result); //content part calls works $works_list = new template(&

java - Configure JAXB plugin for eclipse -

i'm trying create java classes xsd file. used jaxb plugin link here . using eclipse-java-helios-sr2-win32 version. after added plugin, couldn't able access jaxb project. jaxb project (jaxb - 2.1 , 2.2) working fine in kepler versions. but, need jaxb version 2.0 specifically. that's why using older eclipse versions. help? it seems following plugin you: http://sourceforge.net/projects/jaxb-builder/ in description, says creates jaxb 2 want.

html - Response.Write into <%If Else%> issue -

i've code : <td class="tr-inverse"> <div> <% if nbvetementsnonrendu <= 0 response.write(string.format("<b>{0} vêtement(s) en activité</b>", nbvetementsnonrendu)) else response.write(string.format("<span style='font-weight:bold; color:red'>{0} vêtement(s) en activité</span>", nbvetementsnonrendu)) end if %> </div> it's works pretty perfectly. problem string write 2 times : 1 before head , 1 @ cells. we've found solution block first writing : <td class="tr-inverse"> <div> <% response.write(affichageresult(dldetail)) %> </div> </td> and vb.net code : public function affichageresult(byval dl datalist) string dim retour string = string.empt

c# - How to call a child action in the Home controller View called index -

i have controller named product , partial view named product details want call child action inside index view of default home controller , tried , model returned null in view. here product controller , here ids how call child action in view. @foreach (var product in model) { html.action("displayproduct", new { product.id, product.name, product.description, product.price } ) ; } and public class productcontroller : controller { // // get: /product/ public actionresult index() { list<product> products = new list<product>() { new product { id =1, name ="product 1", description ="description 1", price = 10m}, new product { id =2, name ="product 2", description ="description 2", price = 20m}, new product { id =3, name ="product 3", description ="description 3", price = 30m}, new product { id =4, name ="produc

php - Deleted table appears while generating entities (using doctrine) in symfony 2 -

i had table "user" , later renamed "users", while generating entities doctrine: generate entities command, deleted table appears. surprisingly, same table not appearing among in doctrine orm.xml files list. i had removed orm.xml files, entities files, cleared cache , tried again, still same error appears. it helpful if can guide me since im beginner in doctrine. thanks , regards, tismon varghese

utf 8 - XmlBeans generates Java source files with ANSI encoding -

i using xmlbeans 2.6.0 compile xsd files contain enumeration of greek words: <xs:simpletype name="t_series_report"> <xs:restriction base="xs:string"> <xs:enumeration value="Γενική"/> <xs:enumeration value="Ειδική"/> </xs:restriction> </xs:simpletype> the compilation performed using ant task included in xbean.jar of zip binary distribution of xmlbeans. xsd files saved utf-8 , correctly stated in header java files <?xml version="1.0" encoding="utf-8"?> the problem java files generated xmlbeans seem saved in ansi character set , during compilation errors like: [xmlbean] c:\projects\myproject\workspace\prj\build\xmlbeans\test\src\com\company\project\schema\myschematype\cl\cle\ext\tmytype.java:61: illegal character: \8220 [xmlbean] static final int int_ΓΕ�?ΙΚΉ = 1; [xmlbean] is there way force xmlbeans save generated java files utf-8

java - Android - Error connecting with login URI -

i'm trying connect google spreadsheet in code. worked while, lately stopped working. started after moved workspace directory. did not change else... here error: 06-01 17:04:56.108: w/system.err(1290): com.google.gdata.util.authenticationexception: error connecting login uri 06-01 17:04:56.118: w/system.err(1290): @ com.google.gdata.client.googleauthtokenfactory.getauthtoken(googleauthtokenfactory.java:549) 06-01 17:04:56.118: w/system.err(1290): @ com.google.gdata.client.googleauthtokenfactory.setusercredentials(googleauthtokenfactory.java:397) 06-01 17:04:56.118: w/system.err(1290): @ com.google.gdata.client.googleservice.setusercredentials(googleservice.java:364) 06-01 17:04:56.118: w/system.err(1290): @ com.google.gdata.client.googleservice.setusercredentials(googleservice.java:319) 06-01 17:04:56.118: w/system.err(1290): @ com.google.gdata.client.googleservice.setusercredentials(googleservice.java:303) 06-01 17:04:56.118: w/system.err(1290): @ goog

android - AsyncTask<Void, Void, Integer> always return 0 -

private class notesdb extends asynctask<void, void, integer> { @override protected void onpreexecute() { super.onpreexecute(); //displayprogressbar("downloading..."); } @override protected integer doinbackground(void... params) { db.getcount(); result = db.getcount(); return result; } @override protected void onpostexecute(integer result) { super.onpostexecute(result); log.e(result+"",result+""); if(result==null){ log.e("db","empty") }else{ log.e("db","not empty") } //dismissprogressbar(); } } int result = 0; new notesdb().onpostexecute(result); public int getcount() { string countquery = &quo

java - Multiple simultaneous hibernate sessions per thread -

i'm working on rest webservice uses hibernate or mapper. upgraded hibernate 3.2 4.3 , got error described here . transaction got rolled somewhere , got error when wanted use session again (which correct hibernate behavior). i think figured out why got error. because when receive request long session started. session opens transaction open longer period of time. besides long running session/transaction small session/transaction should opened on same thread. far found out, sessions same usertransaction work , since small transactions commit , rollback transaction run in error described in other post. since i'm working huge code base easy change code side session run in different thread (in case help) or refactor whole service 1 transaction can open @ time. actual question starts here is there possibility start multiple simultaneous sessions/transactions in 1 thread? if so, have do, tell hibernate that? if not possible way of accomplishing similar behavior suggest?

php - Laravel system returns NotFoundHttpException -

my laravel 4 projects prints error in error logs following: exception 'symfony\component\httpkernel\exception\notfoundhttpexception' in /var/www/html/projectname/bootstrap/compiled.php:5336 stack trace: #0 /var/www/html/projectname/bootstrap/compiled.php(4685): illuminate\routing\routecollection->match(object(illuminate\http\request)) #1 /var/www/html/projectname/bootstrap/compiled.php(4673): illuminate\routing\router->findroute(object(illuminate\http\request)) #2 /var/www/html/projectname/bootstrap/compiled.php(4665): illuminate\routing\router->dispatchtoroute(object(illuminate\http\request)) #3 /var/www/html/projectname/bootstrap/compiled.php(706): illuminate\routing\router->dispatch(object(illuminate\http\request)) #4 /var/www/html/projectname/bootstrap/compiled.php(687): illuminate\foundation\application->dispatch(object(illuminate\http\request)) #5 /var/www/html/projectname/bootstrap/compiled.php(1146): illuminate\foundation\application->

c# - Validating Positive number with comma and period -

i need regular expression validation expression will allow positive number(0-9) , , . disallow letter(a-z) any other letter or symbol except . , , for example, on asp.net text box, if type anything@!#-- , regular expression validation disallow it, if type 10.000,50 or 10,000.50 should allowed. i've been trying use regex: ^\d+(\.\d\d)?$ but textbox must allow , symbol , tried using integer regex validation, did disallow if type string, disallow . , , symbol while should allow number(0-9) , . , , symbol your regex be, (?:\d|[,\.])+ or ^(?:\d|[,\.])+$ it matches 1 or more numbers or , or . 1 or more times. demo

uiviewcontroller - Passing value from one ViewController to another in Storyboard in SWIFT Language -

i start project in swift language. apps done. single viewcontroller logics done. need communicate each other viewcontroller. i want pass value 1 viewcontroller viewcontroller. i'm using storyboard. want pass value using prepareseague function objective-c has. there way without using delegate-way. in first view controller handle prepareforsegue method , provide additional values second view controller, like: override func prepareforsegue(segue: uistoryboardsegue!, sender: anyobject!) { if segue.identifier == "someidentifier" { let vc = segue.destinationviewcontroller mysecondviewcontroller // vc.someproperty = somevalue } }

php - How to pass function in sort parameter in solr through drupal7 hooks -

i want pass function "map" in sort parameter drupal using hooks. moto sort listing after mapping fields. my solr server query is: http://local.host:8983/solr/collection1/select?q= %3a &sort=map(is_site_web_id%2c2%2c2%2c1%2c0)+desc&fl=site%2curl%2clabel%2cis_site_web_id&wt=json&indent=true its working fine on solr server. i third below code in drupal7: function my_solr_module_apachesolr_index_document_build_node(apachesolrdocument $document, $entity, $env_id) { $document->setfield('is_site_web_id', 1); } function my_solr_module_apachesolr_query_alter($query) { $query->addparam('fl', array('is_site_web_id')); //$query->addparam('bf', array('freshness' =>'map(is_site_web_id,2,2,1,0)')); $query->setsolrsort('is_site_web_id', 'asc'); //$query->setsolrsort('map(is_site_web_id%2c2%2c2%2c1%2c0)', 'desc'); } function my_solr_module_apach

linq - Double-use of C# iterator works unexpectedly -

this first go @ coding in c# - have background in c/python/javascript/haskell. why program below work? expect work in haskell, lists immutable, struggling how can use same iterator nums twice, without error. using system; using system.collections.generic; using system.linq; using system.text; namespace helloworld { class program { static void main(string[] args) { var nums = new list<int?>() { 0, 0, 2, 3, 3, 3, 4 }; var lastnums = new list<int?>() { null } .concat(nums); var changesandnulls = lastnums.zip(nums, (last, curr) => (last == null || last != curr) ? curr : null ); var changes = changeornull in changesandnulls changeornull != null select changeornull; foreach (var change in changes) { console.writeline("change: " + change); } } } } in code nums not ienumerator<t> (iterator), i

latex - get html output from mathquill in javascript function -

i use mathquill html ouput in string var, in javascript code. something var latexcode = 'x^2'; var htmltext = mathquill(.... thanks, mathieu why need rendered latex in javascript? think should try this. $('<span>x^2</span>').appendto('body').mathquill() or .mathquill('editable') or if want comparison $('<span>x^{-1}</span>').mathquill().mathquill('latex') === 'x^{-1}'

javascript - Spring MVC modelandview object returned or not? -

i have method instantiating clicking on link in jsp page as html: <div class="panel accordion clearfix" id="dispdir"> <script type="text/javascript"> window.onload = function() { //showdirectorysegment(${s3directorylist},"folder",null); showbucketlist(${s3bucketlist}); }; </script> </div> javascript: function showbucketlist( bucketlist ) { markup = "<div class=\"clearfix\">"; $("#dispdir").append(markup); ( var = 0; < bucketlist.length; i++ ) { var bid = "bucket_"+bucketid; var key = bucketlist[i].replace(/ /g,"+"); var uri = "/accountingreports?bucketname=" + key; var res = encodeuri(uri); markup = "<div class=\"well clearfix\" style=\"background-color:#a5ffed;font-size:15px\">"; markup += &qu

Animation with three images in android -

i want 3 images a,b,c 1 on other, portion of each image visible can click images. @ start there should image on top, b in middle , c @ bottom. after few seconds should animate , b should come on top, c in middle , @ bottom , on... clicking on of image should come front. please me this.

php - Complex-ish query in Laravel (Eloquent) -

i've read laravel documentation can't quite work 1 out. does know if query possible in eloquent? if so, how write it? select monthname(postdate) monthname, date_format(postdate,'%m') month, year(postdate) year, count(monthname(postdate)) num postdata status = 1 group monthname, year order postdate desc while using db::raw whole query work, doesn't feel right me. might wanna try solution using query builder. db::table('postdata')->select([ db::raw('monthname(postdate) monthname'), db::raw('date_format(postdate, \'%m\') month'), db::raw('year(postdate) year'), db::raw('count(monthname(postdate)) num'), ])->where('status', 1) ->groupby('monthname', 'year') ->orderby('postdate', 'desc'); it still uses db::raw , select clause. anyway, have used postdata model instead of db::table('postdata') , since woul

jar - Data in Hbase are not structured as it should be - Twitter Flume -

users, greetings ! i have installed flume on cloudera 4.6, , trying tweets twitter. so created hdfs sink , hbase sink, , gathering tweets... data in hbase not structured. as data not structured, can't make queries on impala. i created table tweets {name => 'tweet'}, {name => 'retweet'}, {name => 'entities'}, {name => 'user'} and flume configuration : http://pastebin.com/4b5d3r8q i following tutorial, don't know serializer. https://github.com/aronmacdonald/twitter_hbase_impala have make jar ? i have in hbase: http://pastebin.com/angbsvb7 in column tweets... i recompiled , used flume-sources-1.0-snapshot.jar git: https://github.com/cloudera/cdh-twitter-example , there no promblem when using 'twitteragent.sources.twitter.type = com.cloudera.flume.source.twittersource' install maven, download repository of cdh-twitter-example. unzip, execute inside (as mentionned) : $ cd flume-sources $ mvn

php - If statement in variable -

i've seen many posts problems couldn't find right answer worked out. problem have code says if ... empty, make variable ... (see code below). variable form , in form have things name, message etc. want placeholder of name, if user logged in name, saved in database. code: $action = isset($_post["action"]) ? $_post["action"] : ""; if (empty($action)) { // send contact form html $output = "<div style='display:none'> <div class='contact-top'></div> <div class='contact-content'> <h1 class='contact-title'>stuur een bericht voor hulp:</h1> <div class='contact-loading' style='display:none'></div> <div class='contact-message' style='display:none'></div> <br><br><form action='#' style='display:none'> <input type='text'

winapi - Get the class that SetClassLongPtr uses -

i have multiple firefox profiles running each multiple windows. when pick random window each profile , run code on windows hwnd sets icon windows in profile. setclasslongptr(targetwindow_handle, gclp_hiconsm, ctypes.cast(hiconsmall, ctypes.uintptr_t)); i wondering how class? i tried using getclassname on window handles returns mozillawindowclass windows regardless of profile. yet setclasslongptr not apply across profiles, that's how know class of windows in first profile different class of windows in second profile. private window classes registered per-process. whilst each of windows used window class same name, names defined relative per-process namespace. so, window class name foo in process different window class named foo in process b. from knowledge, , facts report in question, appear firefox uses separate processes distinct profiles. imagine different versions of firefox behave differently. seems me implementation detail should not rely upon.

c# - WPF+EF - The operation cannot be completed because the DbContext has been disposed -

creating wpf app entity framework 6. have view model list of categories , list of items (in selected category). when selectedcategory changes, i'm using following method fill list of items: currentlist = new observablecollection<t>(context.set<t>().where(p => p.isgroup == false).where(m => m.parentid == _currentcategory.id)); i'm mot showing different error handling etc. open form, select categories, , works perfect. if close , open same form few times, exception: "the operation cannot completed because dbcontext has been disposed". after 2nd open, - after 3rd or 4th access same form. context disposed when form closes. what wrong , why exception raises not regularly , never on first opening? ------upd 1------ ok, i'm showing more code i'm sure problem in row. form creation: context = new entities(); context.set<t>().load(); loadcurrentlist(); loadcurrentlist(): if ((currentcategory == null) || (currentcategory.id ==

Combining Django Templates and Polymer -

i've been stuck past few hours trying figure out why core polymer elements not being displayed in django application i'm making act personal webpage. application @ moment points index.html page which, if follow tutorial on polymer, step one. however, components not loading on page. static files set correctly, , there's subtle animation css files being loaded correctly, roboto font , core-elements not being displayed. running site normal html file correctly. is there specific way user polymer in django template? thanks. see eric's answer on polymer-dev mailing list: https://groups.google.com/forum/?fromgroups=#!searchin/polymer-dev/django/polymer-dev/n2r8qknaloi/58zhc1gwfh4j relevant excerpt: django 1.5 has support verbatim tag. can wrap inlined element definitions in that: https://docs.djangoproject.com/en/1.5/ref/templates/builtins/#verbatim example code snippet: {% verbatim %} <template repeat="{{item items}}"> <my-ele

Issue Login activity in Android -

i have created android application , work properly. when try login in android application display me log cat error like: >06-27 05:26:11.082: w/system.err(4308): org.json.jsonexception: value <!doctype of type java.lang.string > cannot converted jsonobject >06-27 05:26:11.092: w/system.err(4308): @ org.json.json.typemismatch(json.java:111) >06-27 05:26:11.092: w/system.err(4308): @ org.json.jsonobject.<init>(jsonobject.java:159) >06-27 05:26:11.092: w/system.err(4308): @ org.json.jsonobject.<init>(jsonobject.java:172) >06-27 05:26:11.092: w/system.err(4308): @ > //error display in background > com.sunmobileappnow.mobileappnow.loginactivity$sigin.doinbackground(loginactivity.java:446) > 06-27 05:26:11.092: w/system.err(4308): @ com.sunmobileappnow.mobileappnow.loginactivity$sigin.doinbackground(loginactivity.java:1) > 06-27 05:26:11.092: w/system.err(4308): @ android.os.asynctask$2.call

android - Why can I pass a serializable with a bitmap through a Bundle but get an error when the system tries to serialize it? -

so have class, image implements serializable: public class contact implements serializable { ... public static final string contact_key = "contactkey"; private transient bitmap mimage; ... } i pass fragment: bundle bundle = new bundle(); final fragmentmanager fragmentmanager = getfragmentmanager(); // load fragment fragment contactfragment = new contactfragment(); contactfragment.setarguments(bundle); fragmentmanager.begintransaction() .replace(r.id.contactcontainer, headerfragment, "contactfragment") .commit(); and pull image out ( successfully ) , use it: public class contactfragment extends fragment { private static final string tag = "contactfragment"; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { bundle arguments = getarguments(); if (arguments != null) {

ArrayIndexOutOfBounds Exception for program compiled using Java -

i new java. code is: public class hi { public static void main(string[] args) { system.out.print("hi, "); system.out.print(args[2]); system.out.print(","); system.out.print(args[1]); system.out.print(", and"); system.out.print(args[0]); system.out.println("."); } } i following exception upon running program: exception in thread "main" java.lang.arrayindexoutofboundsexception: 2 @ hi.main(hi.java:5) i glad know why had got exception , how resolve it. you passing parameters less 3, thats why getting error. try below command, java hi test test test

java - Sorting a list of constructed objects alphabetically using collections.sort -

i need take collection of objects using compareto() command, , have these stored in list, , use collections.sort() command sort them alphabetically last name, first name if last name isn't strong enough, , print off entire list @ end. this code have far: package sortlab; import java.io.*; import java.util.*; public class sortlab { public static void main(string[] args) throws exception { file yousaiduseourrelativefilenameforstudentdata = new file("c:/my192/sortlabproj/src/sortlab/student.data"); scanner sc = new scanner(yousaiduseourrelativefilenameforstudentdata); arraylist<student> studentlist = new arraylist<student>(); while (sc.hasnextline()) { student teststudent = new student(sc.next(), sc.next(), sc.next()); sc.nextline(); studentlist.add(teststudent); } } } and next class: package sortlab; import java.util.*; class student impleme

multiple json objects in in object (json.net) -

is possible format : "list":{ "one":{ "fieldone":"-----", "fieldtwo":"-----" }, "two":{ "fieldone":"-----", "fieldtwo":"-----" } } i don't want array [] or names "one" , "two" removes, struggling exact following format. if put items dictionary instead of list can result want. here example: class program { static void main(string[] args) { rootobject obj = new rootobject(); obj.items = new dictionary<string, item>(); obj.items.add("one", new item { fieldone = "foo", fieldtwo = "bar" }); obj.items.add("two", new item { fieldone = "fizz", fieldtwo = "bang" }); string json = jsonconvert.serializeobject(obj, formatting.indented); console.writeline(json); } } class rootobject { [jso

jquery - How to hide JqGrid column names -

i new jqgrid. want hide column names of grid. gone through documentation of grid options & colmodel. found nothing. please find jsfiddle link - jsfiddle example want hide column names such client, inv no, date, amount, tax, total & notes. please me. in advance enter code here i marked duplicate answers question, answer given there place following line under grid declaration: $('.ui-jqgrid-hdiv').hide();

Monolog, how to log PHP array into console? -

i using browser handler log message js console require_once 'vendor/autoload.php'; use monolog\logger; use monolog\handler\browserconsolehandler; $log = new logger('name'); $log->pushhandler(new browserconsolehandler); $data = array(1,2,3,4); // add records log $log->addwarning('foo'); i wondering, possible log array such $data console reassemble array content? try this: $log->addwarning('foo: ' . var_export($data, true));

c - Why floating point does not start from negative numbers when it exceeds its range? -

as know when integer varible exceeds range starts other end negative numbers. example int a=2147483648; printf("%d",a); output: -2147483648 (as expecting) now tried same floating points. example float a=3.4e39;//as largest float 3.4e38 printf("%f",a); outout: 1.#inf00 (i expecting negative float value) didn't above output know represents positive infinity. question why not start other end(negative values integers)? floating point numbers stored in different format integer numbers, , don't follow same over-/under-flowing mechanics. more specifically, binary bit-pattern 2147483648 1000000000000000 in two's complement system (like 1 used on modern computers) same -2147483648 . most computers today uses ieee754 format floating point values, , handled quite differently plain integers.

java - How to correctly write CRLF for maximum portability? -

i have software creates file send bank software reads file. software rejecting file because says file not have crlf line separator. until now, file created on windows machines, , line separator use "\r\n" . searched , found out if on windows, generates in different way generating on linux or mac. how can generate crlf independent of platform? update 1 this method use create file, replace \r\n \n , \n \r\n, ensure when whoever calls method passing \n line separator, file generated correctly \r\n: public static void createfile(string filepath,string content){ try{ file parentfile=new file(filepath).getparentfile(); if(parentfile!=null && !parentfile.exists()){ parentfile.mkdirs(); } bufferedwriter bw=new bufferedwriter(new filewriter(filepath)); bw.write(content.replaceall("\r\n","\n").replaceall("\n","\r\n")); bw.flush(); bw.close(); }catch(ex

php - How to find out the character set of a user uploaded document? -

i wrote script allows users upload/import lots of users @ once using csv-file. i'm using mysql's load data local infile make working: $query = "load data local infile $file table my_table fields terminated $delimiter lines terminated '\\n' (email, name, organization); but user tried import document contained name günther . saved database "g" (cutting of rest). document turned out in latin1 causing problems. don't want bother users character sets , stuff. i know character set option supported load data local infile. but, though don't error when put character set latin1 in query, want utf-8. , happens if users uses file that's neither in utf-8 or latin1? so how found out in character set user uploaded document , how convert utf-8? you can find character encoding using mb_detect_encoding before running $query. detect encoding before load file. suppose file name in $str here basic example might help. <?php /* de

Google Maps marker alignment issues during zooming when using a svg marker -

Image
for reason, when zooming in , out svg marker that's defined using path, marker isn't aligned correctly it's position. evident in one of google's examples . interestingly, if use 1 of built in svg symbols , not appear problem. i using svg path marker , suffers alignment issues: m 256,480c-84.828,0-153.6-68.157-153.6-152.228c0-84.081, 153.6-359.782, 153.6-359.782s 153.6,275.702, 153.6,359.782c 409.6,411.843, 340.828,480, 256,480z m 255.498,282.245c-26.184,0-47.401,21.043-47.401,46.981c0,25.958, 21.217,46.991, 47.401,46.991c 26.204,0, 47.421-21.033, 47.421-46.991 c 302.92,303.288, 281.702,282.245, 255.498,282.245z what cause of problem? edit: mrupsidown solving problem. svg needs have anchor point @ (0,0) of canvas. see image (i using illustrator, other svg editing app should do): updated fiddle here: http://jsfiddle.net/tf83z/ you have define anchor point of svg marker. see documentation: https://developers.google.com/maps/documentation/jav

django TemplateSyntaxError Invalid block tag: 'trans' -

after running runserver command following error: templatesyntaxerror @ /questions/ invalid block tag: 'trans' does know what's reason? this template syntax: {% extends "two_column_body.html" %} {# template split several blocks included here blocks within directory templates/main_page relative skin directory there no html markup in file #} <!-- questions.html --> {% block forejs %} {% include "main_page/custom_head_javascript.html" %} {% endblock %} {% block title %}{% spaceless %}{% trans %}questions{% endtrans %}{% endspaceless %}{% endblock %} {% block content %} {% include "main_page/tab_bar.html" %} {% include "main_page/headline.html" %} {# ==== begin: main_page/content.html === #} <div id="question-list"> {% include "main_page/questions_loop.html" %} </div> {# ==== end: main_page/content.html === #} {% includ

javascript - How does the "this" keyword work? -

i have noticed there doesn't appear clear explanation of this keyword , how correctly (and incorrectly) used in javascript on stack overflow site. i have witnessed strange behaviour , have failed understand why has occurred. how this work , when should used? i recommend reading mike west 's article scope in javascript ( mirror ) first. excellent, friendly introduction concepts of this , scope chains in javascript. once start getting used this , rules pretty simple. ecmascript standard defines this keyword that: evaluates value of thisbinding of current execution context; (§11.1.1). thisbinding javascript interpreter maintains evaluates javascript code, special cpu register holds reference object. interpreter updates thisbinding whenever establishing execution context in 1 of 3 different cases: initial global execution context this case javascript code evaluated when <script> element encountered: <script type="text/javascr