Posts

Showing posts from September, 2015

Why do we use internal classes for constants in C#? -

i have seen in many projects. why developers use internal classes store constant variables in c#? for instance: internal static class constants { public const double pi = 3.14159; public const int speedoflight = 300000; // km per sec. } simply, designer decided class need used within same assembly. , not exposed or accessed project referencing assembly. when download nuget package, can't access classes internal. developers decided don't need access these. these values "private" package. more on access modifiers: public :access not restricted. protected :access limited containing class or types derived containing class. internal: access limited current assembly. protected internal : access limited current assembly or types derived containing class. private : access limited containing type.

scala - Using the kronecker product on complex matrices with scalaNLP breeze -

i had piece of code: def this(vectors: list[densevector[double]]) { this(vectors.length) var resultvector = vectors.head (vector <- vectors) { resultvector = kron(resultvector.todensematrix, vector.todensematrix).todensevector } _vector = resultvector } it worked way wanted work. problem needed complex values in stead of doubles. after importing breeze.math.complex, changed code to: def this(vectors: list[densevector[complex]]) { this(vectors.length) var resultvector = vectors.head (vector <- vectors) { resultvector = kron(resultvector.todensematrix, vector.todensematrix).todensevector } _vector = resultvector } this results errors: error:(42, 26) not find implicit value parameter impl: breeze.linalg.kron.impl2[breeze.linalg.densematrix[breeze.math.complex],breeze.linalg.densematrix[breeze.math.complex],vr] resultvector = kron(resultvector.todensematrix, vector.todensematrix).todensevector

android - Basic camera in app -

Image
i trying activate camera in app have done following , kept simple possible. androidmanifest file <uses-permission android:name="android.permission.camera"/> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> ... <activity android:name=".cameraact" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> cameraact.class public class cameraact extends appcompatactivity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_camera); // have camera? if (!getpackagemanager()

javascript - Why Selenium can't find an element that is graphically visible -

i'm using selenium test appllication running on firefox browser, when want click on button selenium, don't find it. find strange since can see element eye. have tried multiple method worked other exemple : wait.until(expectedconditions.visibilityofelementlocated(by)) wait.until(expectedconditions.presenceofelementlocated(by)); (i use xpath in path variable, , i'm sure correct) setting implictlywait on driver putting thread.sleep(1000) then again, post here because don't understand why selenium not see element diplayed on browser. important information maybe giving me proper answer html dom dynamically generate websocket triggered javascript event. edit 1: <button type="button" class="btn btn-xs btn-block btn-stroke" id="252_button"> delete </button> the element i'm trying access. use xpath it. it's not in iframe element. to access element did method supposed find , click on giving xpath in para

php - Insert data into database in angularjs -

i trying insert data in database not working @ all! followed tutorial , work according not working. tried lot no success till now. here html file <!doctype html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script> <body> <div ng-app="myapp" ng-controller="myctrl"> <form> name:-<input type="text" ng-model="bname" /> phone:-<input type="text" ng-model="bphone" /> <input type="button" value="submit" ng-click="insertdata()" /> </form> </div> <script> var app = angular.module('myapp',[]); app.controller('myctrl',function($scope,$http){ $scope.insertdata=function(){ $http.post("insert.php", { 'bname':$scope.bname, 'bphone':$scope.bphone}) .success(function(data,status,headers,config){ c

Android chat application architectures -

i have requirement need build group chat application. chat app contain multimedia messages. as know can architect chat app using gcm/fcm , xmpp protocol. problem gcm/fcm is, cannot handle multimedia messages , xmpp heavy architecture. do have other servers or architectures apart gcm/fcm , xmpp? thank you use fcm. when want multimedia items use url of items. fcm can send receive urls easily. you can point multimedia files stored on hosting servers.

dns - 1and1 domain to my heroku app -

Image
i'm trying make fresh new domain point heroku app, , don't know if made right. me out ? 1st screenshot : 1and1 base domain configuration 2nd screenshot : 1and1 www subdomain overview 3rd screenshot : 1and1 www subdomain's cname configuration 4th screenshot : heroku domain configuration and if go mydomain.com or www.mydomain.com, stills point 1and1 default page. did right or have wait until redirection done ? maybe need forward requests root domain: yourdomain.com -> www.yourdomain.com

postgresql - rails foreign key setup with AR and postgres -

i realized have issues when deleting parent models. i have setup: user.rb has_many :conversations, foreign_key: "sender_id", dependent: :destroy conversation.rb belongs_to :sender, class_name: "user", foreign_key: "sender_id" belongs_to :recipient, class_name: "user", foreign_key: "recipient_id" schema (postgres db) add_foreign_key "conversations", "users", column: "recipient_id" add_foreign_key "conversations", "users", column: "sender_id" as can guess if user.destroy called , there conversation user recipient raise pg::foreignkeyviolation error: update or delete on table conversations violates foreign key constraint... to deal problem i'm planning following: user.rb #this solve rails side of problem has_many :received_conversations, class_name: "conversation", foreign_key: "recipient_id", dependent: :destroy schema (db):

functional programming - Why does function composition compose from right to left in Javascript? -

function composition composes right left: const comp = f => g => x => f(g(x)); const inc = x => x + 1; const dec = x => x - 1; const sqr = x => x * x; let seq = comp(dec)(comp(sqr)(inc)); seq(2); // 8 seq(2) transformed dec(sqr(inc(2))) , application order inc(2)...sqr...dec . functions invoked in reverse order in passed comp . isn't intuitive javascript programmers, since they're used method chaining, goes left right: o = { x: 2, inc() { return this.x + 1, }, dec() { return this.x - 1, }, sqr() { return this.x * this.x, } } o.dec().sqr().inc(); // 2 i consider confusing. here's reversed composition: const compl = f => g => x => g(f(x)); let seql = compl(dec)(compl(sqr)(inc)); seql(2); // 2 are there reasons why function composition goes right left? your question order of arguments in definition of function composition operator rather right- or left-associativity. in mathematics, write "f o g" (equ

r - How to fit model with individual measurement error in DiceKriging, or can it? -

i have set of 5 data points ( x=10,20,30,40,50 , corresponding response values y , noise s.d. of y ). these data obtained stochastic computer experiments. how can use dicekriging in r fit kriging model these data? x <- seq(from=10, to=50, length=5) y <- c(-0.071476,0.17683,0.19758,0.2642,0.4962) noise <- c(0.009725,0.01432,0.03284, 0.1038, 0.1887) examples online heterogeneous noise pre-specified coef.var , coef.trend , coef.theta . unlikely can have a priori on these. i have referred answer here . however, other references suggest adding nugget parameter lambda similar adding homogeneous noise, not "individual errors". the use of km noise quite simple: model <- km(~1, data.frame(x=x), y, noise.var = noise, covtype = "matern3_2") however, noise term make line search part of l-bfgs algorithm fail. may due fact is correlated y , because when run following lines, works: noice <- c(0.009725,0.01432,0.03284, 0.001, 0.1887)

django - Rejecting some POSTs for some users -

this should simple question, yet keep drawing blanks drf documentation. models.py: class datapoint(models.model): value = models.integerfield() ... serializers.py: class datapointserializer(serializers.modelserializer): class meta: model = datapoint fields = ('value', ...) views.py: class datapointviewset(viewsets.modelviewset): queryset = datapoint.objects.all() serializer_class = datapointserializer permission_classes = [permissions.isauthenticated, ] ... i want every logged-in user able , post viewset. restriction non-staff users need keep value below 100 , this: if request.data['value'] > 100 , not request.user.is_staff: raise permissiondeniedvalidationerrorwhatareyoudoing("santaz gonna know") my question boils down to: is job custom validator or permission? problem permission drf (specifically mixins.createmodelmixin ) happily save posted data without checking permissions. later p

javascript - success message not appearing after ajax form submitted -

i have prepared 1 html form backed jquery , php. form giving correct out put in php when form submitted, not showing success message & not getting fields empty. code given below: function sendcontact() { event.preventdefault(); var valid; valid = validatecontact(); if (valid) { jquery.ajax({ // input submisssion though ajax url: "xxxx.php", data: 'username=' + $("#username").val() + '&useremail=' + $("#useremail").val() + '&subject=' + $("#subject").val() + '&content=' + $(content).val(), type: "post", success: function (data) { // thankyou message on sucessful submission. $("#mail-status").html(data); $('#mail-status').show(); // clear form.

Understanding the Storm Architecture -

i have been trying understand storm architecture, not sure if got right. i'll try explain possible believe case. please explain - if - got wrong , right. preliminary thoughts: workers http://storm.apache.org/releases/2.0.0-snapshot/understanding-the-parallelism-of-a-storm-topology.html suggests worker process http://storm.apache.org/releases/2.0.0-snapshot/concepts.html "worker processes. each worker process physical jvm", http://storm.apache.org/releases/1.0.1/setting-up-a-storm-cluster.html states worker node "nimbus , worker machines". website http://www.michael-noll.com/tutorials/running-multi-node-storm-cluster/ mentions "master node" , "worker nodes". what: worker process or physical node (or node process)? think there 2 things: worker nodes , worker processes . what believe true entities in play master node = management server worker node = slave node nimbus jvm process, running on master node zookeeper jvm p

sitecore - Test item is not in workflow -

Image
when setting basic a/b test on component using page editor, received error following appearing in log: exception: system.invalidoperationexception message: test item not in workflow source: sitecore.analytics @ sitecore.analytics.data.items.testdefinitionitem.start() @ sitecore.shell.applications.webedit.commands.testing.starttest.run(clientpipelineargs args) attempting start test created multivariate test definition item empty workflow section in test lab i'm thinking workflow fields should have been appropriately set when using ui on page editor create , start test. i guess i'll try reflector find error message in binaries , keep digging. sitecore version: 6.5.0 (rev. 120706) i realize old question, encountered same thing in 8.1 update 3. in case because workflow associated testing (analytics testing workflow, unless you've made own) had been deleted on local installation. restoring 1 of our other servers made error go away.

mysql - count from single column with multiple value -

i have table value below, id tank_id filledtime 1 tind10 6pm,7pm,9pm,9pm,7pm,11pm,7pm,9pm,7pm,7pm,8pm,7pm,10pm,8pm,7pm,8pm,8pm,6pm,8pm,9pm,8pm,11pm,8pm expecting output : tank_id nooftimefilledinspectime tind10 2(6pm),7(7pm),4(9pm),2(11pm),7(8pm),1(10pm) note : filledtime single column how achieve using mysql query? is select work on? select tank_id, count(filledtime), filledtime yourtable filledtimein (select filledtimefrom yourtable) , tank_id = 'tind10' group tank_id,filledtime; should outputting this: tank_id | count | filledtime tind10 | 2 | 6pm and on...

javascript - bootstrap-datetimepicker: display value of input -

how can persuade datetimepicker display value in input text field @ initial pageload? in case value attribute of datepicker text-input set, field displayed blank. therefore i've tried set 'data-date-defaultdate' attribute @ initial pageload text field´s still blank. after reload value displayed expected. the form (excerpt): <form name="news" method="post" class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label required" for="news_validfrom">start time</label> <div class="col-sm-8 col-md-6"> <div class="input-group date datetime-picker" id="datetime1"> <input type="text" id="news_validfrom" name="news[validfrom]" required="required" class="form-control" value="2016-07-08t00:00:00+02:00" />

Syntax to create a Windows Service -

i have 2 folders 'c:\apps-a\' , 'c:\apps-b\', both need same service installed. it installed in folder 'b' not 'a'. (was deleted while ago , needs installed again) path running executable 'c:\apps-b\windows service\convertservice.exe' i running following sc create doesnt seem work.. c:\windows\system32>sc create "cs" binpath="c:\apps-b\windows service\convertservice.exe" start= auto please correct syntax, when run it, usage instruction this resolved now, looks sc need make sure there space after equal sign (binpath) c:\windows\system32>sc create "cs" binpath= "c:\apps-b\windows service\convertservice.exe" start= auto

extjs - Set tooltip on click event on the grid cell -

i'm trying show tooltip when user clicks on grid cell. when click on cell, tooltip appears. problem is, after click, keeps popping whenever move mouse on other cell. i'm using ext js 4.2.1. let down code treating cellclick event in controller , way creating tooltip. oncellclick: function (view, td, cellindex, record, tr, rowindex, e, eopts) { var store = ext.getstore('pontoeletronico'); if (view.tip) { view.tip.destroy(); view.tip = null; } if(cellindex > 0 && cellindex < 5) { view.tip = ext.create('ext.tip.tooltip', { autoshow: false, showdelay: 0, stateful: false, target: view.el, width: 100, title: 'horário original', delegate: view.cellselector, trackmouse: false, autohide: true, listeners: { beforeshow: function (tooltip, eopts) {

parameter passing - C++, pointer to a function as a new type -

in c++ 2003, typedef may used on complete types. hence, not allow create pointer function , generic t type: template <typename t> typedef t(*f_function)(t, t, t); is there way how evade issue in c++ 2003 or in c++0x using syntax using (*f_function)(t, t, t); // i use pointer function fff class member template <typename t> class { public: f_function fff; a() {fff = null;} a( f_function pf){fff = &pf;} }; template <typename t> t f1(t x, t y, t z) { return x + y + z;} template <typename t> t f2(t x, t y, t z) { return x - y - z;} and initialize value in constructor. subsequently: int main() { <double> a(f1); double res = a.getx(1.1, 2.2, 3.3); } is construction safe? there other way how solve problem? help. you may use alias template (c++11) declaration: template <typename t> using f_function = t(*)(t, t, t); example: http://coliru.stacked-crooked.com/a/5c7d77c2c58aa187 #include <iostream>

jquery - How should I use the RegExp to get my want in javascript? -

i tried 3 hours. face problem using javascript regexp. i have string below var str = 'test123↵↵http://www.youtube.com/watch?v=6w89smj25ni'; i use regexp url match, want other text except url. var match = 'https://www.youtube.com/watch?v=6w89smj25ni'; var str = 'test123↵http://www.youtube.com/watch?v=6w89smj25ni'; var str2 = 'test123↵↵'; function checkstringcontainurl(s) { var re = new regexp("([a-za-z0-9]+://)?([a-za-z0-9_]+:[a-za-z0-9_]+@)?([a-za-z0-9.-]+\\.[a-za-z]{2,4})(:[0-9]+)?(/.*)?"); if(re.test(s)) { console.log("url inside"); console.log(re.exec(s)[1] + re.exec(s)[3] + re.exec(s)[5]); // want console 'test123↵↵' } else { console.log('no url inside'); } } function checklink(match) { var re = /https?:\/\/(?:[0-9a-z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\s*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+

java - why parameter.getType().isInstance(HttpServletRequest.class) return is false,but use "==" is true -

parameter[] ps = method.getparameters(); map<string,integer> map = new hashmap<string,integer>(); for(int ij = 0;ij<ps.length;ij++){ parameter p = ps[ij]; requestparam rp = p.getannotation(requestparam.class); if(rp != null){ //do }else { system.out.println(p.gettype()); system.out.println(p.gettype().isinstance(httpservletrequest.class)); system.out.println(p.gettype() == httpservletrequest.class); } } the output is: interface javax.servlet.http.httpservletrequest false true why use "isinstance" false , use "==" true? because "instance of" can't judge implements relationship? isinstance equal instanceof this method dynamic equivalent of java language instanceof operator. the method return false because comparing class (returned p.gettype()) class httpservletrequest.class instead method want instance example: dog bobby = new bobbydog(); // class bob

spring boot logging using log4j to external file with shared, external log4j configuration -

i have spring boot application. pulls log4j.properties external location in file system; specify file's location in application.yml file: ... logging: config: ${log_config_location}/log4j.properties ... since log4j.properties file shared other applications, in it, cannot use ... log4j.appender.fileappender.file=log_file_name.log ... because ... applications log same file (probably wouldn't work b/c of io) what want do, leverage application's name specified in application.yml file: ... spring: application: name: my_foo_application ... and set log file name , location to ${log_files_location}/services/${spring.application.name}/${spring.application.name}.log i tried inside application.yml file: spring: application: name: my_foo_application logging: config: ${log_config_location}/log4j.properties file: ${log_files_location}/services/${spring.application.name}/${spring.application.name}.log this had no effect - not see log file in lo

java - Passing an array to android app with JSON -

ive tried solutions found here nothing seems work me. i'm new android , problem. i have php script gets mysql data , passes array <?php $con = mysqli_connect("localhost", "username", "passwod", "database"); $result = array(); $getacceptedsotres = mysqli_query($con, "select * offer type='sale' , approved = 'approved'"); while($rowgetid = mysqli_fetch_assoc($getacceptedsotres)){ $storeid = $rowgetid['id']; $getstores = mysqli_query($con, "select * sale offerid = '$storeid' "); while($row = mysqli_fetch_assoc($getstores)){ array_push($result,array( 'title'=>$row['title'], 'offerto' => $rowgetid['offerto'], 'type' => $rowgetid['type'], 'percentageoff'=>$row['percentageoff'] )); } } echo json_encode(array($result)); when php script executed gives me this: [[{"title

html - Anchor tag with jquery not working -

calling jquery dynamically generated anchor tag not working. whereas same hard coded anchor tag jquery working fine. code: <!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"> </script> <script> $(document).ready(function(){ var value = "hi!!!"; $("button").click(function(){ $("#box").html("<a class='dynamic' href='#' dataid='"+value +"'>generate</a>"); }); $(".hardcode").click(function () { alert("calling function"); }); $(".dynamic").click(function () { alert("ggsss function"); }); }); </script> </head> <body> <a class="hardcode" href="#" dataid="sss">generate</a> &l

opengl es - Thick 3D textured lines with constant screen width -

Image
i'm trying draw 3d textured lines constant screen width . (opengl es 2.0) in reality wanted have simple "volumetric" lines minimum guaranteed (clamped) screen width. when far away don't become thin. any input on how there appreciated but have feedback on problem i'm facing right now. misunderstanding of how perspective correct interpolation works... so have triangle strip this: struct tvtx { vec3 mpos; vec3 mdir; vec2 mtexcoord; }; auto vtxs = std::vector< tvtx >{ { vec3{ -1,0,0 }, vec3{ 1,0,0 }, vec2{ -1, 1 } }, { vec3{ -1,0,0 }, vec3{ 1,0,0 }, vec2{ -1, -1 } }, { vec3{ -1,0,0 }, vec3{ 1,0,0 }, vec2{ 0, 1 } }, { vec3{ -1,0,0 }, vec3{ 1,0,0 }, vec2{ 0, -1 } }, { vec3{ 1,0,0 }, vec3{ 1,0,0 }, vec2{ 0, 1 } }, { vec3{ 1,0,0 }, vec3{ 1,0,0 }, vec2{ 0, -1 } }, { vec3{ 1,0,0 }, vec3{ 1,0,0 }, vec2{ 1, 1 } }, { vec3{ 1,0,0 }, vec3{ 1,0,0 }, vec2{ 1, -1 } } }; and transform in "world" space this: pt1

php - Retrieving data from MySQL and Displaying it -

i've encountered problem when working on private project. improved environment buying virtual private server (vps). installed apache, mysql , php able save data in database followed parsing php , final stage displaying on ios app i'm creating. i looked through quite few tutorials on internet on how retrieve data php file , show in tableview , first problem encountered. i'm not going use tableview , reason have been struggling getting data dictionary/array without issues. problem: i've followed tutorial , made work tableview when trying customize output don't manage right. i information saved dictionary when try use dictionary in kind of way breakpoint , simulation stops. code: class - locationmodel.swift import foundation class locationmodel: nsobject { var id: string? var name: string? var address: string? var city: string? var country: string? var typ: string? var lastresult: string? override init() { } i

Python Flow Controls Not Working -

ok in have issue if answer "n" still continue else statement. how fix this? (this in function, edit: other if statements work fine) if command == "exit": exit = 1 while exit == 1: print("quit? y/n:", end="") ex = input() if ex == "y": quit() elif ex == "n": break else: print("err") the code seems work fine. i assumed want : on entering exit ask user y or n if user enters y quit program if user enters n want break out of while loop. works fine both cases can add else question illustrate problem. i recommend try using return statnment while trying break multiple loop or if creating function purpose. make sure not entering small alphabets . can use .upper() function make sure use uppercase.

javascript - Display result of js calculation in span -

i'm trying calculate in javascript , display result in <span></span> . code i've got @ moment: <script type="text/javascript"> window.onload = function() { function minus_number() { var first_number = '50'; var second_number = '30'; var result = parseint(first_number) - parseint(second_number); document.getelementbyid('spend').value = result; } } and html <p><i class="fa fa-truck"></i>want free delivery? spend <span id="spend"></span> free standard delivery</p> it doesn't display result in span though, can tell me i'm doing wrong? try this, call function using event listener . function minus_number() { var = document.queryselector("#spend"); var first_number = '50'; var second_number = '30'; var result = parseint(first_number) - parseint(secon

visual studio - Warning major version 52 is newer than 51, the highest major version supported by this compiler -

Image
basicly i'm super newbie , started internship in company. installed vs xamarin. problem i'm facing frustrating. when create empty project can't compile , error : severity code description project file line suppression state warning major version 52 newer 51, highest major version supported compiler. i searched on google , asked many people , still no fix of problem. if can me via skype or teamwiever appreciate much. skype: toniterdal , feel free add me. i having same issue, , tearing hair out. had jdk version 8 installed, these warnings wouldn't go away, , generated build-breaking error. when went tools -> options -> xamarin, , looked @ android settings, java development kit location pointing jdk.1.7.xxxx, in program files (x86) . i changed 1.8.0_101, in program files . restarted visual studio, , same error happened again. somehow, visual studio detecting version 7 of jdk , pointing automatically. so solution turned out simple. installing v

gundb - Confused about keys in gun DB -

var stallone = {stallone:{first:'sylvester',last:'stallone',gender:'male'}}; var gibson = {gibson:{first:'mel',last:'gibson',gender:'male'}}; var movies = gun.get('movies') movies.put(stallone).key('movies/action').key('movies/actors').key('movies/action/rambo') movies.put(gibson).key('movies/action').key('movies/actors').key('movies/action/roadwarrior').key('movies/comedy'); movies.get('movies/action').val(); returns {_: object, stallone: object, gibson: object} nice. movies.get('movies/comedy').val(); returns {_: object, stallone: object, gibson: object} erm..what sly doing here? not nice!! gun.get('movies/comedy').val(); returns {_: object, stallone: object, gibson: object} same thing!! this behaviour leads couple of questions: 1) why bother creating movies ? i'm working var movies = gun.get('movies') why have create key 

java - dial outbound with Twilio -

a previous question asked how dial web browser . fair enough, how dial number soft-phone, jitsi, or ip phone? i have build app purpose, using client ? oddly, incoming calls require no configuration ip phone , dialing api easy. think you're looking sip. https://www.twilio.com/docs/api/twilio-sip/sending-sip-how-it-works making outbound , inbound calls using sip domain using asterix example, call flow 5000@example.sip.com(sip endpoint) alice@example.sip.us1.twilio.com should this: sip end point ----> yourname(asterix pbx) ----> internet -----> twilio cloud ----> sip domain(example.sip.us1.twilio.com) -----> alice now once call reaches alice, web hooks can used make necessary modifications per individual use case. you can use concept make outbound call lets alice.example.sip.us1.twilio.com calls 5000@example.sip.com can achieved using <sip> part of <dial> verb in twiml. making outbound , inbound calls using sip trunking c

api - ASP: Upload Image to Twitter -

this code work ok m_struseragent="user agent" m_strhost="api.twitter.com" m_metodo="post" url_publish = "https://api.twitter.com/1.1/statuses/update.json" url_publish_img = "https://upload.twitter.com/1.1/media/upload.json" oauth_consumer_key = "xxxxxxxxxxxxxxxxxxxxx" oauth_consumer_sec = "xxxxxxxxxxxxxxxxxxxxx" oauth_token = "xxxxxxxxxxxxxxxxxxxxx" oauth_token_sec = "xxxxxxxxxxxxxxxxxxxxx" post_text="sample text" oauth_nonce = year(now) & month(now) & day(now) & hour(now) & minute(now) & second(now) & replace(request.servervariables("remote_addr"),".","") oauth_signature_method = "hmac-sha1" oauth_timestamp = datediff("s", "01/01/1970 00:00:00", now()) oauth_version = "1.0" oauth_sign = "oauth_consumer_key=" & oauth_consumer_key & "&oauth_nonce=" &a

xamarin.android - How to bind signature byte array on signature pad xamarin forms? -

i have signature pad in xamarin forms app. user sign on signature pad , moves next screen. when user come on signature pad screen, previous signature gets remove signature pad. how can set signature should not delete until user @ current state of app? i save signature value byte array when user moves next screen. can bind byte array @ signature pad show signature? regards, anand dubey since xamarin forms, i'm assuming you're using allan ritchie's acr.xamforms.signaturepad classes. the signaturepadview class exposes method: loaddrawpoints , allows load signature data view. since method, can't databind it, can add code hosting view load signature: // note: below assumes // a) you're using mvvm (as should :) ) // b) viewmodel class name myviewmodelclassname (change appropriately) // c) property on vm exposes signature points named signaturepoints (change appropriately) protected override onappearing() { loadsignature(); } protected override o

vb.net - Visual Studio error: file 'xxx.Designer.vb' could not be found -

i'm having minor setback. deleted usercontrol visual studio still looking designer file. error preventing me building program. how can solve problem? full error message: severity code description project file line suppression state error file 'j:\vb.net - addin\em_addin\em_addin\userforms\documentdisplaycontrol.designer.vb' not found em_addin j:\vb.net - addin\em_addin\em_addin\vbc

javascript - Polymer 1.0 reading select value when there is an inside template(dom-repeat) in select tag -

Image
i'm having trouble polymer 1.0 element. have print inside select every option of book size (a5, a4) , prices every selection(this information js array returned _returnselitemdataarr). array data looks this: _returnselitemdataarr: [array[id, name, extra], array[id, name, extra]]. here bit of source code : <select id="sizeselect" value="{{itm.id::change}}" aria-labelledby="sizelabel"> <template is="dom-repeat" items="{{_returnselitemdataarr(item, 'sizes')}}" as="itm"> <option value="{{index}}" selected$="[[_computeselected(index, itm)]]">{{itm.name}} (+{{itm.extra}} lei)</option> </template> </select> select compute function: _computeselected: function(index, itm) { return index+1==

performance - Speed up bmp image loading in python -

i reading in 24 bpp bitmap image in python. using struct module , reading in file byte byte , storing bgr elements in multidimensional array. see code below: char = fileobject.read(1) self.blue[w][h] = struct.unpack('=b', char)[0] char = fileobject.read(1) self.green[w][h] = struct.unpack('=b', char)[0] char = fileobject.read(1) self.red[w][h] = struct.unpack('=b', char)[0] this takes long time (10 seconds 2732 x 1536 pixel image). i want speed i'm not sure how. thinking this: threechar = fileobject.read(3) self.blue[w][h] = ((threechar >> 8) << 8) #knock of not-needed bits self.green[w][h] = ((threechar >> 4) << 8) self.red[w][h] = (threechar << 8) i'm not sure how go speeding things here. can give me advice? slow here , why slow? how speed up?

Image Orientation Lost During Compression Swift ios -

i use following function create thumbnail of image: func scaleimage(image: uiimage, tosize newsize: cgsize) -> (uiimage) { let newrect = cgrectintegral(cgrectmake(0,0, newsize.width, newsize.height)) uigraphicsbeginimagecontextwithoptions(newsize, false, 0) let context = uigraphicsgetcurrentcontext() cgcontextsetinterpolationquality(context, .high) let flipvertical = cgaffinetransformmake(1, 0, 0, -1, 0, newsize.height) cgcontextconcatctm(context, flipvertical) cgcontextdrawimage(context, newrect, image.cgimage) let newimage = uiimage(cgimage: cgbitmapcontextcreateimage(context)!) uigraphicsendimagecontext() return newimage } i call in following way : let imagethumb = self.scaleimage(currimage, tosize: cgsizemake(currimage.size.width/4, currimage.size.height/4)) i encode imagethumb using following function : func compressimage(image:uiimage) -> nsdata { // reducing file size 10th var actualheight : cgfloat = image.size.height var actualwidth : cgfloat =

return - Java : Proper way a method() should handle a bad call -

i confronted question. let's see quick example, got simple method : retrieves position of string in string[] . public int getstringposition(string s, string[] text) { (int = 0; < text.length; i++) { if (text[i].equals(s)) { return i; } } return text.length; } but if string isn't in array? here, returns size of array (an int couldn't come normal use of method). return -1 . wish return null doesn't seem possible. anyway, method used in same class other methods. question pretty general, how handle cases can't return expected? if inability find string constitutes error , exceptional condition , should throw exception caller. e.g., throw new runtimeexception("string not found"); if inability find string normal situation caller want handle in normal flow of code, should use special return value. type of search method, no normal return value negative, , convention return -1 , string.indexof , li

javascript - updateOne deleting my data -

alright, i've been tinkering night , have sleep i'm asking here. why updateone deleting data when should updating it? db.collection('users').updateone({"name":"bob"}, {"age":"20"}, (e,i) => { console.log(i); }); i.result.ok prints 1 , when go search bob after doing this, data gone entirely, vanished. my first question why happening, second how can update, since apparently isn't way it. i can run find({"name":"bob"}) fine before hand, data exist before running this. after, gone. please, blood pressure getting way high. try following:- you need use $set update specific fields. {} give blank, if there no find query. db.collection('users').updateone({"name":"bob"},{$set: {"age":"20"} }); to answers, refer mongodb-update . hope hep solving problem.

Spring boot interaction with Spring MVC + Spring Security + Hibernate + HSQLDB -

Image
i have finished work on spring-based(spring-mvc) web application uses spring security , hibernate , hsqldb (and maven of course). running web app on jetyy 9.x server integrated in intellij idea, need packaged in single executable jar embedded jetty server. people offered me use spring boot embedding jetty purpose. found out (because tried , read info) spring boot not understand xml configuration files app using configuring spring-mvc , spring security. how can make spring components interract each other , sould considering current (non spring boot project structure)? the project structure , settings (non spring boot): code of configuration files: hibernate.cfg.xml <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- database conne