Posts

angularjs - Empty an array before push -

i took project using angularjs. there filtering system. actually, click on category add category list. industries got category shown. note click on selected category remove category. i click replace filtering category each click not add category. how should modify code: $scope.changercategorie = function(category , name ){ if( jquery.inarray(category, $scope.selected ) !== -1) { angular.foreach($scope.selected , function(obj,index){ if( category == obj ){ $scope.selected.splice(index,1); $scope.selected_name.splice(index,1); } }); }else{ $scope.selected.push(category); $scope.selected_name.push(name); } $scope.selected_filter = $scope.selected.join(', '); } i tried doesn't work $scope.changercategorie = function(category , name ){ $scope.selected = 0; $scope.selected_name = 0; $scope.selected = category; $scope.selected_name = ...

jsf - Is it possible to stop perfoming validation after one of validators threw an exception -

i have jsf-page: <h:inputtext> <f:validator binding="{validator}" /> </h:inputtext /> <!-- other inputs validators --> is possible skip validation phase after 1 of validators failed , render response validation message?

math - Probability of getting specific sum after rolling n dice. Ruby -

what best solution finding probability of rolling sum n dice? i'm solving finding mean. standard deviation. z_score numbers below x z_score numbers above x converting both probabilities subtracting 1 other this i've done far. # sides - number of sides on 1 die def get_mean(sides) (1..sides).inject(:+) / sides.to_f end def get_variance(sides) mean_of_squares = ((1..sides).inject {|sum, side| sum + side ** 2}) / sides.to_f square_mean = get_mean(sides) ** 2 mean_of_squares - square_mean end def get_sigma(variance) variance ** 0.5 end # x - number of points in question def get_z_score(x, mean, sigma) (x - mean) / sigma.to_f end # converts z_score probability def z_to_probability(z) return 0 if z < -6.5 return 1 if z > 6.5 fact_k = 1 sum = 0 term = 1 k = 0 loop_stop = math.exp(-23) while term.abs > loop_stop term = 0.3989422804 * ((-1)**k) * (z**k) / (2*k+1) / (2**k) * (z**(k+1)) / fact_k sum += term k += 1 ...

How to test the APNS p12 certificate environments ruby? -

i'm developing service sending push notifications, can't tell if uploaded apns certificate p12 sandbox or production. test in order avoid human error when uploading certificate. the common name of issued certificate tells if it's sandbox or production. example production: apple production ios push services: your.app.identifier my ruby skills bit rusty should it: require 'openssl' raw_cert = openssl::pkcs12.new(file.read(path_to_your_cert), your_pwd) # if want read .p12 cert cert = openssl::x509::certificate.new(raw_cert) cert.subject.start_with?("apple production ios") see here: http://ruby-doc.org/stdlib-2.0.0/libdoc/openssl/rdoc/openssl/x509/certificate.html

sql server - Security to run stored procedure with CTE -

i have stored procedure mystoredprocedure uses cte , returns it. create procedure mystoredprocedure mytemptable(foo) ( select bar mytable ) select foo mytemptable i have fixed requirement security. there fixed user myuser can give role myrole , , have granted myrole execute permissions mystoredprocedure . but error: create table permission denied in database 'mydatabase'. questions: am correct assume because cte creates table? how give myrole little access possible create cte, not alter everything? note: it has been impossible me search answer feel free edit or post correct words people search gets more help. i don't know if useful answer, had overlooked a select * mytable2 i had no idea potentially generate create since mytable2 exist

ruby - Stripe Connect in Rails -

trying necessary information after stripe user connects application, started out , have far, putting data in specific variables so: provider = request.env["omniauth.auth"].provider, uid = request.env["omniauth.auth"].uid, access_code = request.env["omniauth.auth"].credentials.token, publishable_key = request.env["omniauth.auth"].info.stripe_publishable_key when "skip form" redirected session#index , error undefined method provider nil:nilclass here routes: rails.application.routes.draw root 'login#index' 'login/log_in' => 'login#log_in' post 'login/log_in' => 'login#log_in' 'login/logout' 'sessions/index' '/auth/stripe_connect/callback', to: 'sessions#index' end

sql - Access UNION and JOIN query -

situation: access database i'm working on separates parts left , right parts. same part can used on both sides. trying create query count total number of individual parts needed per week. question: how create query allows union multiple fields , join shown below? table 1: part # |left part | left part qty | right part | right part quantity 1 xyz 5 lmn 7 2 abc 8 xyz 4 table 2: part # | needed 1 10 2 25 query: part | quantity xyz 150 (5 * 10) + (4 * 25) abc 200 (8 * 25) lmn 70 (7 * 10) you have problem in ms access, because cannot put union / union all subquery. if have table of parts (which should have), can use left join , think following want: select p.partname, sum(nz(t1l.leftpartqty * t2.needed) + nz(t1r.rightpartqty * t2.needed)) ((part p inner join table2 t2 on p.part# - t2.part# ) left join table1 t1l on t1l.left...