Posts

c# - Property will not serialize as XML attribute -

i attempting serialize class xml , have properties serialized attributes of class, rather nested node. using webapi automatically handle serialization of xml. this class: [datacontract (namespace="", name="attributetest")] [serializable] public class attributetestclass { [xmlattribute("property")] [datamember] public int property1 { get; set; } } here output receiving (note property1 not attribute in spite of being decorated [xmlattribute] ): <attributetest xmlns:i="http://www.w3.org/2001/xmlschema-instance"> <property1>123</property1> </attributetest> this output want receive: <attributetest property1="123" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> </attributetest> what missing? i'm not familiar webapi output receive looks it's serialized using datacontractserializer , not xmlserializer need. check if adding following application_...

How to draw a function curve in android? -

i have function, y = 50sin(x/50) + 100. want draw curve function, without additional info graph plotters, need wave on screen. x should correspond x parameter of screen , y y parameter of screen. here code of current view. public class sinusoid extends view { paint paint = new paint(); public sinusoid(context context) { super(context); paint.setcolor(color.red); } @override public void ondraw(canvas canvas) { //todo draw line using myfunction } private double myfunction(double x){ return 50 * math.sin(x / 50) + 100; } } now question is, should fill in todo? please help, documentation or example useful. thanks in advance. the idea have this: @override public void ondraw(canvas canvas) { (int x=0; x<canvas.getwidth();x++) { canvas.drawpoint(x,(float) myfunction(x),mpaint); } } but you'll need adjust value of function given canvas height.

java - hadoop writables NotSerializableException with Apache Spark API -

spark java application throws notserializableexception on hadoop writables. public final class myapp { public static void main(string[] args) throws exception { if (args.length < 1) { system.err.println("usage: myapp <file>"); system.exit(1); } sparkconf sparkconf = new sparkconf().setappname("myapp").setmaster("local"); javasparkcontext ctx = new javasparkcontext(sparkconf); configuration conf = new configuration(); javapairrdd<longwritable,text> lines = ctx.newapihadoopfile(args[0], textinputformat.class, longwritable.class, text.class, conf); system.out.println( lines.collect().tostring()); ctx.stop(); } . java.io.notserializableexception: org.apache.hadoop.io.longwritable serialization stack: - object not serializable (class: org.apache.hadoop.io.longwritable, value: 15227295) - field (class: scala.tuple2, name: _1, type: class java.lang.object) - object (class ...

asp.net - Not able to get nJupiter.DataAccess.Ldap work with our Internal LDAP (Lotus Domino) -

i've tried possible, setup njupiter.dataaccess.ldap membership provider on our intranet based web application built using asp.net 3.5. challenges facing: not able authenticate user using default login webpart (says login attempt not successful. please try again) i tried code , receive comexception : "there no such object on server." var ldapmembershipuser = system.web.security.membership.getuser("username") ldapmembershipuser; if (ldapmembershipuser != null) { var givenname = ldapmembershipuser.attributes["givenname"]; } i have placed web.config , njupiter.dataaccess.ldap.config here: web.config : http://pastebin.com/9xddnhuh njupiter.dataaccess.ldap.config : http://pastebin.com/wssehi98 i have tried possible permutations , combinations different values in xml , not able take forward. please guide. not able connec ldap , authenticate user or search users. just looking @ config unlikely enough since don't know dom...

html - Diagonally divs filling complete space of parent div -

i'm trying create div relative height , width, in 3 boxes, being diagonally aligned , fill complete space of relative parent div. it's kinda tough me explain, here's picture on how mean it: http://i.imgur.com/s2ustvu.png besides little space between red lines space should covered diagonal boxes. is possible somehow? i'm grateful every advice or tip can shoot me! following code got far. problem i'm stuck how make diagonal divs fill out complete space around them. <div class="parent"> <div class="box-1">box1</div> <div class="box-2">box2</div> <div class="box-3">box3</div> </div> css: .box-1 { -ms-transform: rotate(-10deg); -webkit-transform: rotate(-10deg); transform: rotate(-10deg); width: 100%; margin: 0px 0px 10px 0px; height: 33.33%; } .box-2 { -ms-transform: rotate(-10deg); -webkit-transform: rotate(-10deg); transform: rotate(-10deg);...

PHP: Using the ternary operator for something else than assignments – valid use case? -

unfortunately haven't found official resource on this. is allowed use ternary operator this, shorten , if/else statement: (isset($somevar) ? $this->setmyvar('something') : $this->setmyvar('something else')); in php documentation, ternary operator explained example: $action = (empty($_post['action'])) ? 'standard' : $_post['action']; this makes me believe use case might work, not valid because setter function not return anything. yes, can. php doc : [...] ternary operator expression, , [...] doesn't evaluate variable, result of expression. that quoted, although ternary used assigning values, can use suggested because function call expression appropriate function evaluated (and therefore executed). if setter function return value, not assigned , therefore lost. however, since said setter doesn't return anything, whole ternary operator evaluate nothing , return nothing. that's fine. if more...

apache - htaccess 404 Stopped Working -

i had custom 404 error redirect page working fine through htaccess. however, after adding new code htaccess, stopped working. what's causing conflict , how can fix it? edit: i've tried putting errordocument line @ top of page , still doesn't work. htaccess code: rewriteengine on #removes www rewritecond %{http_host} ^www\.(.+)$ [nc] rewriterule . http://%1%{request_uri} [r=301,l] #redirects extensionless php urls rewritecond %{the_request} ^[a-z]{3,9}\ /([^&\ ]+).php rewriterule .* /%1? [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ $1.php [l] #redirect nonexistent files 404 page (not working) errordocument 404 /404.html the problem not putting errordocument in top or in bottom of htaccess. you have infinite loop because of rule (the 1 rewriting php extension). need check if exists before rewriting it, otherwise you'll loop conflict between rule , errordocument . you can replace curr...

javascript - Update data in mysql with html form inside jquery dialog -

i need in making page can see data mysql query. every row echoed div unique id . <div class="column" id="<?php echo $row['id']; ?>"> it has same id data in mysql database. every div contains edit button: <a href="edit_column.php?id=<?php echo $row['id'] ?>" class="edit">edit</a> after clicking 'edit', jquery script executed: $('.edit').on('click', function() { var url = this.href; var dialog = $("#dialog"); if ($("#dialog").length == 0) { dialog = $('<div id="dialog" style="display:hidden"></div>').appendto('body'); } dialog.load( url, {}, function(responsetext, textstatus, xmlhttprequest) { dialog.dialog(); } ); ...

java - JDBC implementation: error with regard to parameters -

i working on creating jdbc program show list of grades selected student has in respective classes. however, keep getting error "procedure or function 'getstudenthistory' expects parameter '@studentid', not supplied." here stored procedure in sql server: create proc [dbo].[getstudenthistory] @studentid int select lastname, firstname, year, term, c.prefix + ' ' + cast(c.num char(3)) + ' - ' + sec.letter [course number], units, isnull(g.letter, ' ') grade student s inner join studentinsection sis on s.studentid = sis.studentid inner join section sec on sec.sectionid = sis.sectionid inner join course c on c.courseid = sec.courseid left outer join grade g on g.gradeid = sis.gradeid inner join semester sem on sem.semesterid = sec.semesterid s.studentid = @studentid order units desc here function within main class: @suppresswarnings("resource") public static voi...

java - Unit Testing a function that takes ActionEvent as a parameter -

how can test function takes "actionevent" type parameter in java/swing? following function want test: public void actionperformed(actionevent e) { // communicating model class // /** if "add" button has been pressed **/ if (e.getactioncommand() == "add") { string cust_name = view.getaddcustnamefield().gettext(); int ph_num = integer.parseint(view.getaddphonenumfield().gettext()); model.addentry(cust_name, ph_num, "controller"); } /** if "delete" button has been pressed **/ else if (e.getactioncommand() == "delete") { string cust_name = view.getdelcustnamefield().gettext(); model.deleteentry(cust_name, "controller"); } /** if "update" button has been pressed **/ else if (e.getactioncommand() == "update") { string cust_name = view.getupdcustnamefield().gettext(); ...

ASP.NET vNext MVC and Entity Framework issues -

i'm trying create little asp.net vnext webapi + angularjs + entity framework project. obviously, lot changed in ef7 experiencing following issues: i changed project.json following: "dependencies": { "microsoft.aspnet.server.iis": "1.0.0-beta1", "entityframework": "7.0.0-beta1", "entityframework.sqlserver": "7.0.0-beta1", "entityframework.commands": "7.0.0-beta1", "microsoft.aspnet.mvc": "6.0.0-beta1", "microsoft.aspnet.diagnostics": "1.0.0-beta1", "microsoft.framework.configurationmodel.json": "1.0.0-beta1" in datacontext class, trying following: using system; using project1.models; using microsoft.data.entity; namespace project1.dataaccess { public class datacontext { public dbset<website> websites { get; set; } public datacontext() { microso...

Java Self-Programmed Singly-Linked-List in Linked-List -

at least me, have tricky exercise university. task program singly-linked-list kind of methods. far easy, challenge store these singly-linked-lists afterwards in linked-list. in following see implementation of singly-linked-list runs smoothly: public class liste { listenelement first; listenelement last; listenelement current; int count; public liste() { first = null; last = null; current = null; count = 0; } // methods... the single-linked list consists of list elements implemented in following: public class listenelement { string content; listenelement next; public listenelement(string content, listenelement next) { this.content = content; this.next = next; } //methods... here problem: linkedlist<liste> zeilen = new linkedlist<>(); liste zeile1 = new liste(); liste zeile2 = new liste(); zeile1.addbehind("hello"); zeile1.addbehind("world"); zeile2.addbehind("hello"); zeile2.addbehind("world...

php - PDO + Angular: how to reconcile DB underscore_case with Angular's camelCase? -

i have angularjs app connects database using php pdo apis. this schematic data flow: db: create table person ( ... first_name, ... ); php api: $stmt = $this->db->prepare("select * person"); $stmt->execute(); $result = $stmt->fetchall(pdo::fetch_assoc); var_dump($result); ... 'first_name' => 'alice', ... angular service: getperson: function (id) { return $http({ method: 'get', url: apiuri + 'get' + '/' + id, }).then(handlesuccess, handleerror); }, angular controller: person.getperson(id).then(function(person) { var name = person.first_name; // throws jslint warning }); the problem sql recommended naming standard underscore_case, while angular's camelcase... i not disable jslint, useful, in other respects... i know avoid warnings with { "camelcase": false } in .jshintrc, i'd prefer not disable camelcase check globally... ...

Customize Laravel Homestead server settings? -

is possible use laravel homestead , change of settings of server created? for example, perhaps want different version of php,mysql or ubuntu. i looked through homestead source couldn't see these defined. the laravel/homestead virtual machine (hosted on vagrant cloud) built of below pre-installed: php 5.6 hhvm nginx mysql postgres node (with bower, grunt, , gulp) redis memcached beanstalkd laravel envoy blackfire profiler this stop need complex , lengthy provisioning process prior vm being usable. you have few options achieve want: (recommended option) add own bash scripts homesteads after.sh remove / add software required. downside script run on every vagrant up , need check first if package want install installed. add own provisioning homestead vagrant file. if follow route, i'd recommend fork homestead project on github , use fork changes. can in provisioner can in shell of vm. example latest version of php source , configure &...

Oracle database export missing tables -

i've exported instance of oracle 11g database (full) without shutting down find there 400+ tables missing (were not exported). database used application , possibly had users on it. the command used exp system@db1 full=y file="c:\backup.dmp" grants=y rows=y log="c:\backup.log" would not shutting down before exporting make skip these tables? exp not understand deferred segment creation , may not include these tables: select owner, table_name dba_tables segment_created = 'no' order 1, 2; have tried expdp instead? exp deprecated in 10g, although there bugs new tool , workaround use exp . if need use exp may need run command on tables: alter table unexported_table allocate extent;

Android Studio app using Django back-end login authentication? -

i've been working on android app using android studio using django backend. web application in place want make app in android it. the problem running in to, because i'm new app development, login authentication. i've researched on topic here , understand theoretically how should go doing this, have not been successful in logging in app. the problem have this: i csrf token authentication failure. states cookie not set. understand post request return this. i getting success transition in dopost method. i lost in how check if have logged in or not. , solution thought of cookie not being set request, parse cookie string , pass in post request. i'm not sold on being best strategy. bigger problem not being able tell if have logged in or not. how can check that? have read posts on kind of explaining how beginner hard translate code. how check if user authenticated? , appreciated. public class userlogintask extends asynctask<void, void, boolean> { p...

shell - Execute python script while open terminal -

i want this: execute python script while open terminal (i using iterm , fish-shell ). the fish-shell new me, read documentation - recommend. title " initialisation files ": http://fishshell.com/docs/current/index.html#initialization so looked call python scripts ~/.config/fish/config.fish so installed fish on macbook , had create config.fish file. in placed: ~/gash.py that executes python program gash.py in home directory. of course #! line has correct , have have execute permissions (as usual). entered fish shell , executed program. thanks that, fish-shell looks quite interesting. love stackoverflow.

cs-cart admin user login always act as vendor profile Issue -

Image
i face 1 issue , not found solution through cs-cart community - when login admin area admin url https://demo.com/admin.php , enter correct authentication infromation , click on login act vendor not admin means after login screen same vendor screen , cant access admin features. after login url same admin url act vendor instead of admin. double check database user settings , correct also. admin user_type 'a' , enabled also. cant trace issue server file side. is ssl issue? contribution please check if have vendor selected already, on top left, right side of admin logo, should have vendors ;)

c - Benchmarking functions -

i've written c code - below - have benchmark of functions. main purpose of benchmark test these functions on avr @ tiny85, on pc (for i'm using atmega168 instead of @ tiny85 - same). this benchmark executes big number of loops each function has test , "void" function receives same parameters of function tested, executes return. @ end of loops of each functions writes label , time expressed in usec. time duration of loops function specified label. i might think if subtract benchmark time of "void" function benchmark time of function tested , divide result number of loops, i've sufficient information duration of function tested. not true because interrupts (even measure time). in case think benchmark able indicate me fastest function. what's opinion? have suggestion about? here output example: void 2110168 norm 2121500 base 2337196 basl 2450964 basw 2333980 ant4 2235236 ant5 2242904 unro 2270484 unrl 2590444 vect 2754188 vesw 2732472 th...

ruby - Multiply all even indexed integers by two -

wanting take fixnum of integers , multiply even(indexed) integers two. figured best way first turn fixnum array. lets following number of 16 digits: = 4408041234567901 i know could: a.to_s.split('') which return 'a' array of 'stringed' numbers. cant follow with: a.map!.with_index {|i,n| i.even? n*2} guess i'm kinda stuck on how create method this. question may how turn group of numbers array of fixnums/integers instead of strings. to change array, do a = 4408041234567901 arr = a.to_s.chars.map(&:to_i) # => [4, 4, 0, 8, 0, 4, 1, 2, 3, 4, 5, 6, 7, 9, 0, 1] you can multiply alternate numbers 2 arr = a.to_s.chars.map.with_index {|n,i| i.even? ? n.to_i * 2 : n.to_i } # => [8, 4, 0, 8, 0, 4, 2, 2, 6, 4, 10, 6, 14, 9, 0, 1] improving little bit, can use hash find number multiplied. h = {true => 2, false => 1} a.to_s.each_char.map.with_index {|n,i| n.to_i * h[i.even?]} edit i can explain each step, better if can ...