Posts

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>))[?=&+...