Posts

Showing posts from July, 2014

ruby on rails - How can I perform password complexity validation on devise without having to install other gems? -

i using devise authentication in rails app. want add validation password complexity rules. seems don't have access raw password @ model level before has been hashed. such, cannot validate raw password provided conforms password complexity rules have set. other way can @ controller-level. however, i'm afraid that approach pollute controller. ideas how can perform validation without having install other gem? here simple method of adding password strength / complexity requirement @ model level. #app/models/user.rb validate :password_complexity def password_complexity if password.present? if !password.match(/^(?=.*[a-z])(?=.*[a-z])/) errors.add :password, "password complexity requirement not met" end end end

excel - Error 91 on Frame Control upon Start Up -

i have microsoft form 2.0 frame control 3 option buttons. name of frame control side , 3 option button captions x , o , , random names xoption , ooption , , randomside respectively. code runs fine, except upon startup, if open excel , run program immediately, give me error 91 , note 1 of options ( x , o , or random ) selected. in order rid of error, need explicitly select option, error goes away. don't know why happens. here sub frame control public sub side_click() sideletter = side.activecontrol.caption if strcomp(sideletter, "random") = 0 randomize temprand = int((rnd() * 2 + 1)) if temprand = 1 sideletter = "x" else sideletter = "o" end if end if end sub the line sideletter = side.activecontrol.caption 1 causing issue. have not explicitly declared side frame control in case that's helpful information because i'm thinking object declared making frame control. in advance! you need ch...

c++ - What is "Argument-Dependent Lookup" (aka ADL, or "Koenig Lookup")? -

what explanations on argument dependent lookup is? many people call koenig lookup well. preferably i'd know: why thing? why bad thing? how work? (note: meant entry stack overflow's c++ faq .) koenig lookup commonly known argument dependent lookup in c++ , of standard c++ compilers support it. the c++11 standard § 3.4.2/1 states: when postfix-expression in function call (5.2.2) unqualified-id, other namespaces not considered during usual unqualified lookup (3.4.1) may searched, , in namespaces, namespace-scope friend function declarations (11.3) not otherwise visible may found. these modifications search depend on types of arguments (and template template arguments, namespace of template argument). in simpler terms nicolai josuttis states 1 : you don’t have qualify namespace functions if 1 or more argument types defined in namespace of function. a simple code example: namespace mynamespace { class myclass {}; vo...

java - How can I set max total disk size for RollingFileAppender? -

i'm using log4j , log4j.extras create rollingfileappender rolls on 2 conditions: the working filesize exceeds maxfilesize threshold. the system's date changes. following this guide , appender needs both timebasedrollingpolicy , sizebasedtriggeringpolicy , example: <appender name="file_logger" class="org.apache.log4j.rolling.rollingfileappender"> <rollingpolicy class="org.apache.log4j.rolling.timebasedrollingpolicy"> <param name="activefilename" value="/fxh/logs/d3fixfeeds.log" /> <param name="filenamepattern" value="/fxh/logs/d3fixfeeds.%d{hh-mm}.%i.log" /> </rollingpolicy> <triggeringpolicy class="org.apache.log4j.rolling.sizebasedtriggeringpolicy"> <param name="maxfilesize" value="50000" /> <!-- in bytes --> </triggeringpolicy> <layout class=...

nuget - Issues with MsBuild, SpecificVersion, and VSTS -

the scenario follows: we have set of common .net libraries: commonlib.main commonlib.specialized we have ci build builds both of these libraries, , places them our nuget repo. both available individual nuget packages - user may want load main, or can pull specialized package, include main. specialized references main nuget package. i'm making upgrades these packages. first, upgraded main. updated version of main in assemblyinfo 1.1.0. 2.0.0. msbuild include build number in "*" location. the ci build ran, , version of main called " commonlib.main, version=2.0.0.345 " published our nuget repo. on nuget repo, version listed "2.0.0", expect. next, upgraded commonlib.specialized , , updated nuget reference commonlib.main, version=2.0.0. i checked in these changes, , ci build ran again. so now, ci build has create new version of main, version 2.0.0.346 , , placed on nuget repo. here's problem: now, when run our ci build a...

Write data from Database to File in Java -

i trying write data database text file. the text file remains empty. tried deg. here code: public void writetext() { try { class.forname("com.mysql.jdbc.driver"); } catch(exception e) { e.printstacktrace(); } final string db_url ="jdbc:mysql://mis-sql.uhcl.edu/gattupalliv3940"; connection conn = null; statement stat = null; resultset rs = null; try { conn = drivermanager.getconnection(db_url,"gattupalliv3940","1552688"); stat = conn.createstatement(); rs = stat.executequery("select * student_2"); filewriter fw = new filewriter("data.txt"); bufferedwriter bw = new bufferedwriter(fw); string line =""; while(rs.next()) { line = rs.getint(1)+"\t"+rs.getstring(2)+"\t"+rs.getdouble(3); bw.write(line); bw.newline(); } ...

python - Flask and subprocess Popen - Send same data to multiple users -

the code below need. when second user connect, new subprocess.popen created, need run 1 subprocess.popen , send same data multiple users. example: first user connect, start subprocess.popen, begins receive result starting number 0, when second user connect 30 seconds after, begins receive result starting de number 30. #!/usr/bin/env python import os functools import partial subprocess import popen, pipe flask import flask, response # $ pip install flask file = 'test.file' app = flask(__name__) @app.route('/' + file) def stream(): process = popen([ "bash", "-c", "for ((i=0;i<100;i=i+1)); echo $i; sleep 1; done" ], stdout=pipe, bufsize=-1) read_chunk = partial(os.read, process.stdout.fileno(), 1024) return response(iter(read_chunk, b''), mimetype='audio/mp3') if __name__ == "__main__": app.run(host='0.0.0.0',threaded=true) to honest not sure if work. not use subproces...

c++11 - Using std::move, and preventing further use of the data -

i have been using c++11 time avoided using std::move because scared that, while reading library user not have access code, try use variable after move it. so like void loaddata(std::string&& path); would not enough make user understand moved. expected use of && imply data moved. know comments can used explain use case, lot of people dont pay attention that. is safe assume when see && data moved, or when should use std::move , how make explicit signature. is expected use of && imply data moved. generally speaking yes. user cannot call loaddata lvalue. must provide prvalue or xvalue. if have variable pass, code loaddata(std::move(variable)) , pretty indicator of you're doing side. forward ing employed, you'd still see @ call site. indeed, speaking extremely rude move parameter not rvalue reference.

mysql - An error with the LIKE clause -

if(!empty($count)){ $battingquery->where('countries_id', 'like', '%'.$count.'%'); } i running query yield problem, if run search on country id 11, 12, 13, 14; country_id of 1 aswell 11 example. how make equals? both '=' , equals return nothing , break query. the query builder has useful where clauses . $count = 13; if(!empty($count)){ $battingquery->where('countries_id', $count); } this return models countries_id equal 13

r - Duplicating (and modifying) discrete axis in ggplot2 -

Image
i want duplicate left-side y-axis on ggplot2 plot onto right side, , change tick labels discrete (categorical) axis. i've read answer this question , can seen on package's repo page , switch_axis_position() function has been removed cowplot package (the author cited (forthcoming?) native functionality in ggplot2). i've seen reference page on secondary axes in ggplot2, examples in document use scale_y_continuous rather scale_y_discrete . and, indeed, when try use discrete function, error: error in discrete_scale(c("y", "ymin", "ymax", "yend"), "position_d", : unused argument (sec.axis = <environment>) is there anyway ggplot2? hacked solution suffice me. in advance. (mres below) library(ggplot2) # working continuous plot 2 axes ggplot(mtcars, aes(cyl, mpg)) + geom_point() + scale_y_continuous(sec.axis = sec_axis(~.+10)) # working discrete plot 1 axis ggplot(mtcars, aes(cyl, as.factor(mpg...

api - How to count total twitter shares accurately like Buzzsumo -

i working on script tries find total shares of blog post or youtube video via url or title. i'm trying create similar buzzsumo. if aren't aware, buzzsumo website searches content online , ranks in terms of social shares. they able total share count twitter, though twitter disabled feature in api since 2014. i've tried these 2 methods 1.) use twitter api search tweets mention url or title. (this isn't accurate because twitter api allows me fetch tweets no more 9 days old.) 2.) used twitter scraper scrape tweets in history mention url or title. (this method takes long time process if post popular) but results seem vary compared buzzsumo's. times vary close buzzsumo , far off. for example when searching buzzsumo popular linking articles brought post had 1400 twitter shares, run same article through scarper , 1380 (quite close), article buzzsumo 1100 shares , 108 (quite far off). questions am accurately counting total number of twitter shares. ...

using directives - ng-show and ng-hide usage in AngularJS -

i aware of difference between ng-show , ng-hide asked question in interview why need ng-hide if have ng-show because know both shows or hides given html element based on values can true or false. reason should favor ng-show on ng-hide or vice versa? readability. ng-show="feature.enabled" more readable ng-hide="!feature.enabled" . double negations harder understand.

paper trail gem - Filter paper_trail version history by column -

using airblade's papertrail gem, need track changes particular model columns, need filter selectively see changes 1 particular column. make more concrete, if have file model has label attribute/column , want display label history, can right all version history file, include non-label updates other attributes. (furthermore, don't need label update itself, whodunnit , created_at associated version.) i don't see in documentation - closest i've come adding metadata, allows me more access information attribute, doesn't return filtered collection of pertinent version history. answer: anywhere update label column, can update paper_trail_event, e.g. file.update!(label:'foo', paper_trail_event: 'update label') . can query on event, e.g. versions.where(event: 'update label')

c# - WPF Datagrid Superheader -

i using basic wpf datagrid. need add superheader. each superheader has span of 2 columns. also, has dynamically created because number of columns determined based upon data in database. have got this: superheader . problem is, if resize columns, superheader not moving expected. below code: mainwindow.xaml: <tabitem header="tab4"> <stackpanel> <grid name="grdsuperheader"/> <datagrid name="grdsample" scrollviewer.horizontalscrollbarvisibility="disabled" autogeneratecolumns="false"> <datagrid.columns> <datagridtextcolumn x:name="samplecolumn1" header="column 1"></datagridtextcolumn> <datagridtextcolumn x:name="samplecolumn2" header="column 2"></datagridtextcolumn> <datagridtextcol...

SQL count multiple cells as combination -

i have following sql table shows case number , value, case number appear 2 cases in group, want count how many combinations same case number appearing in table. ware order different, see case , c, both of them should count same combination. case value 1992 1956 b 2000 b 2001 c 1956 c 1992 the goal total number of each combination, output format doesn't matter. 1 of expected result: seq value frequency 1 1992 2 1 1956 2 2 2000 1 2 2001 1 what if there 3 cases combination? this works number of values case. increment frequency count when cases have same number of values , each 1 have match, no matter in order. create table #table1 ([case] varchar(1), [value] int) ; insert #table1 ([case], [value]) values ('a', 1992), ('a', 1956), ('a', 1997), ('b', 2000), ('b', 2001), ('c', 1956), ('c', 1992), ('c', 199...

How can I disable urlencoding with Nginx Proxy -

i have trouble nginx. nginx proxy receives urlencoded uri this. get /x/y/z.aspx?id=abc%3d%3d and, noticed nginx applies urlencoding again, , make uri this. get /x/y/z.aspx?id=abc%253d%253d how can disable nginx apply urlencoding this? want transfer uri is. is there way modify request uri? according nginx documentation, says.. $request_uri full original request uri (with arguments) so, specified proxy_pass below. proxy_pass http://x.x.x.x$request_uri; nginx still sends request below. get /x/y/z.aspx?id=abc%253d%253d it seems nginx applies url encode when sends message. so, can make nginx decode request when receives? then, nginx should automatically encode when sends, meaning ends expected parameter below. get /x/y/z.aspx?id=abc%3d%3d don't use $request_uri in proxy_pass has not been url-decoded. if want construct uri containing query string, use: $uri$is_args$args

Get data from Resolver into a Component using Angular 4 -

i'm struggling data resolver component. returning null. i can see fetching data server, , displaying page template correctly, , has no errors, doesn't access data. student.component.ts import { component, viewchild } '@angular/core'; import {mdpaginator, mdsort} '@angular/material'; import { student, studentservice } '../shared'; import 'rxjs/add/operator/startwith'; import 'rxjs/add/observable/merge'; import 'rxjs/add/operator/map'; import {activatedroute, router} "@angular/router"; @component({ selector: "student", templateurl: './student.component.html', styleurls: ['./student.component.scss'] }) export class studentcomponent { constructor ( private route: activatedroute, private studentservice: studentservice, private router: router, ) {} students: student[]; displayedcolumns = ['userid', 'username', 'progress']; @viewchild...

Find row Index of strings in cell Array (Matlab) -

if have cell array c : c = {'name' 'hh' '23' [] [] 'last' 'bb' '12' '8' 'hello' 'in' 'kk' '12' '2131' [] 'name' 'kk' '23' [] [] 'name' 'cv' '22' [] [] 'name' 'ph' '23' [] [] } ; how can row index of rows have 'name' in first column , '23' in third column? indexresult = [1,4,6] the simplest way this (all-versions compatible) use strcmp , can accept cell arrays , "string compare". one liner indexresult = find(strcmp(c(:,1), 'name') & strcmp(c(:,3), '23')); % indexresult = [1; 4; 6]; explanation % logical array of rows first column 'name' logicalname = strcmp(c(:,1), 'name'); % logical array of rows third column '23' logical23 = strcmp(c(:,3), '23'); % logical array bot...

angular - how to pevent ng2-idle instantiating multiple times with each successful login -

i have problem set idle display popup minute before session expiration. session times out or user logs out. next time user logs on, have 2 popups when there timeout. user logs out , in again , have 3 popups, , on. how destroy current instance of idle when user logs out? my setup follows: constructor(private idle: idle, ...) {} ngoninit() { this.setidle(); } private setidle() { // client activity timeout. 29 minutes 'idle', 1 minute beyond timeout this.ngzone.runoutsideangular(() => { // this.idle.setidle(29 * 60); // this.idle.settimeout(1 * 60); this.idle.setidle(10); this.idle.settimeout(10); this.idle.setinterrupts(default_interruptsources); }); this.idle.ontimeout.subscribe(() => { this.ngzone.run(() => { this.errordialogref.close(); sessionstorage.setitem('sessionexpired', 'true'); this.displayerrormodal(true); }); }); ...

Rails 5 assets return 404 in development -

i know question asked lot, i'm losing mind here. started building app using rails 5. deployed aws eb , set env development. assets aren't loading. getting 404. implemented sprockets , require 'rails/all' in application.rb file running rake assets:precompile . tried config.asset configurations in development.rb: config.assets_compile config.public_file_server.enabled config.assets.digest config.assets.enabled my nginx error log full of following each of assets. path wrong. didn't put assets in /var/app/current/public , put them in /var/app/current/app/assets . @ point, had fetching there (don't remember how) still didn't work: 2017/07/28 01:16:15 [error] 2994#0: *1387 open() "/var/app/current/public/assets/merck-logo.png" failed (2: no such file or directory), client: 76.218.103.88, server: _, request: "get /assets/merck-logo.png http/1.1", host: "merckcoupons-dev1.dv3ww3wmii.us-west-1.elasticbeanstalk.com", ...

arduino - Calculate RPM with a quadrature rotary encoder -

i have written following code calculate rpm of dc motor using quadrature rotary encoder , arduino mega: int n3 = 7; //n3 sur la l298n motor shield int n4 = 8; //n4 sur la l298n motor shield int enb = 9; //enb sur la l298n motor shield int potpin = a0; //analog pin 0 sur la carte arduino int valeurlu = 0; //valeur lu du potentiomètre int valeur_a_ecrire = 0; //valeur à envoyer au moteur int pin_a_encodeur = 3; int etat_courant_encodeur = 0; int etat_precedant_encodeur = 0; void setup() { attachinterrupt(digitalpintointerrupt(3),updateposition,change); pinmode(n3, output); pinmode(n4, output); pinmode(enb, output); pinmode(a0, input); pinmode(pin_a_encodeur, input); serial.begin(9600); } void loop() { valeurlu = analogread(potpin); valeur_a_ecrire = (255.0/1023.0)*valeurlu; digitalwrite(n4, high); digitalwrite(n3, low); analogwrite(enb, valeur_a_ecrire); etat_courant_encodeur = digitalread(pin_a_encodeur); serial.print(valeur_a_ecrire); serial.print...

Keep on clicking button 1 until button 2 appears in selenium using java -

i testing native ios mobile app using selenium , appium java code. part of teardown, have keep on clicking "back" button until "setting" button appears can logout of application. i tried few things using while not working. can please ? try code may you try { boolean flag = true; while(flag) { webelement backbtn = driver.findelementbyname("back"); backbtn.click(); thread.sleep(1000); boolean isfindsettingbtn = driver.findelementsbyname("setting").size() !=0; if(isfindsettingbtn) { break; } } }catch(exception e) { e.printstacktrace(); }

node.js - Using Oauth2 without a webserver with Node? -

is possible using node script authenticate using oauth2 login , token back? sounds absurd me, i've been looking @ stuff passportjs , i'm not quite sure that's i'm looking for. looking @ if possible open connection page in web browser , having them login, don't know how i'd token back. edit: i'm guessing it's not possible using github page create popup window login mopidy does? i'm assuming possible on actual webserver can make requests this?

php - laravel 5.4 auth facade does not work -

the laravel 5.4 auth facade not work. auth middleware functional normally. call protected route produces login page, expected. malformed credentials produce expected error. correct credentials produce correct page, expected. commenting out line "use illuminate\support\facades\auth;" produces error "class 'app\http\controllers\admin\auth' not found", expected. specifically, auth::check() produces false, , auth::user() returns nothing, in spite of successful login. calls either of these implementations of auth facade not produce error. this code worked in laravel 5.2. deviation procedure of aware during migration laravel 5.4, did not run command "php artisan make:auth" in new laravel implementation. a search "laravel 5.4 auth facade not work" not produce relevant results, either in bing or in stackoverflow internal search engine. pertinent code displayed, below: namespace app\http\controllers\admin; use illuminate\http...

java - Old Connection increasing TempDB size -

i have java application in connected mssql database query using java thread every 1 sec information, below pseudo new connection query db if information looking processes else sleep 1 sec clean resources/connect resources free so happening is, sql server allotted spid 60 query , when java cleaned , closed connection , after 1 sec again asked connect execute same query sql server allotted spid 60 due tempdb file never free , keep increasing. question is: how ensure each time new session in sql server? tempdb not keep increasing , holding space. problem connection pool settings , 1 java code keep pooling in 1 sec because of connection never closed. below settings jboss 5 , mssql server <?xml version="1.0" encoding="utf-8"?> <datasources> <local-tx-datasource> <jndi-name>base_nucleusdv</jndi-name> <driver-class>com.microsoft.sqlserver.jdbc.sqlserverdriver</d...

angular - When we need to import component (parent/child) in another component (child/parent)? -

i following tutorial in angular official website ( https://angular.io/tutorial/toh-pt3 ). when learn how parent component ( appcomponent ) communicate child component( herodetailcomponent ), since add in parent component's template, <hero-detail [hero]="selectedhero"></hero-detail> , looks me parent component talks child component, why not import child component parent component ( import { herodetailcomponent } './hero-detail.component'; ) , import parent component child component ( import { appcomponent } './app.component'; )? if not that, how can angular know how works ( [hero]="selectedhero" )? 'hero' child component's property, 'selectedhero' parent component's property? when should need import component? when not need to? i think don't quite understand why need imports. essentially, modules allow split code different files. suppose have following in 1 file/module: class acomp ...

Using R for lack-of-fit F-test -

Image
i learnt how use r perform f-test lack of fit of regression model, $h_0$: "there no lack of fit in regression model". where df_1 degrees of freedom sslf (lack-of-fit sum of squares) , df_2 degrees of freedom sspe (sum of squares due pure error). in r, f-test (say model 2 predictors) can calculated anova(lm(y~x1+x2), lm(y~factor(x1)*factor(x2))) example output: model 1: y ~ x1 + x2 model 2: y ~ factor(x1) * factor(x2) res.df rss df sum of sq f pr(>f) 1 19 18.122 2 11 12.456 8 5.6658 0.6254 0.7419 f-statistic: 0.6254 p-value of 0.7419. since p-value greater 0.05, not reject $h_0$ there no lack of fit. therefore model adequate. what want know why use 2 models , why use command factor(x1)*factor(x2) ? apparently, 12.456 model 2 , magically sspe model 1 . why? you testing whether model interaction improves model fit. model 1 corresponds additive effect of x1 , x2 . one way "check"...

Security Headers for WordPress -

i'm testing out security headers , got following setup currently: # security headers <ifmodule mod_headers.c> header set content-security-policy: "default-src https: 'unsafe-inline' 'unsafe-eval'; img-src https: data:; font-src https: data:;" header set x-frame-options "sameorigin" header set x-xss-protection "1; mode=block" header set referrer-policy: no-referrer-when-downgrade </ifmodule> with hsts , nosniff headers applied in cloudflare. any suggestion improved changed upon? , know how configure public-key-pins flexible cloudflare ssl certificate? thanks further information in advance!

Converting multivariate dataframe to univariate time series using R -

these head of data set using. hour count <chr> <int> 1 00 22462 2 01 13293 3 02 10595 4 03 9371 5 04 14325 6 05 38598 to perform forecasting using auto arima should convert data univariate. make.univ(rsms,sms.hour,tname="time1", outname="multdv") i used above code convert univariate, gives error. error in data.frame(timedat = rep(0:(nrepobs - 1), nrow(x)), outdat = as.vector(t(dvs))) : arguments imply differing number of rows: 4123938, 48 original dataset: rsms [2million records(1 day data)] sample dataset : sms.hour[24 records (class(sms.hour) = "tbl_df" "tbl" "data.frame"] can me solve this? your data univariate. i'm not sure, think lines below make data output of make.univ() call: rsms$hour <- as.numeric(rsms$hour) names(rsms) <- c("time", "multdv")

php - How to remove unnecessary rows from multidimensional array? -

i have fingerprint records this "our company";"100";"100";07/25/2017 5:02:57 pm;"check out";"1";"";0;"fingerpint";"" "our company";"102";"102";07/25/2017 7:45:53 am;"check in";"1";"";0;"fingerpint";"" "our company";"102";"102";07/25/2017 7:45:54 am;"check in";"1";"";0;"fingerpint";"" "our company";"102";"102";07/25/2017 6:01:34 pm;"check out";"1";"";0;"fingerpint";"" "our company";"102";"102";07/25/2017 6:01:35 pm;"check out";"1";"";0;"fingerpint";"" "our company";"104";"104";07/25/2017 8:00:06 am;"check out";"1";"";0;"fing...

Android: How to select part of image? -

Image
in application. there's section select block of apartment. in there a , b block. want choose or b block single image. image there way this? i guess use getlocationonscreen() and hardcode values want. if user clicks on part of image prompts 1 response, if click somewhere else prompts response. more info here android: how x y coordinates within image / imageview?

c - adding same variables with different values in loop -

so, need ask user how many numbers wants add, , ask him input numbers, have no idea how add numbers without having them stored in same variable, or how add same variable different values, extremely easy in pascal, don't know how in c. here code far... int main(int argc, char *argv[]) { int i, n, age; printf("how many numbers want add?\n"); scanf("%d", &n); (i = 1; <= n; = i++) { printf("type in number:\n"); scanf("%d", &age); } return 0; } to compute sum of numbers entered, can define variable sum , add each number entered. note there undefined behavior in code: i = i++; cannot have both side-effect , modify i in same expression, unless there sequence point, unlikely find in beginner's code. i++ sufficient increment i . here how fix , complete code: #include <stdio.h> int main(int argc, char *argv[]) { int i, n, age, total = 0; printf(...

ios - Use of rangeOfCharacter in Swift 3.0 -

i attempting use rangeofcharacter create app, unable understand documentation: func rangeofcharacter(from: characterset, options: string.compareoptions, range: range<string.index>?) -finds , returns range in string of first character given character set found in given range given options. documentation link: https://developer.apple.com/documentation/swift/string#symbols i working on exercise create function take in name , return name, minus consonants before first vowel. name should returned unchanged if there no consonants before first vowel. below code have far: func shortnamefromname(name: string) -> string { var shortname = name.lowercased() let vowels = "aeiou" let vowelrange = characterset(charactersin: vowels) rangeofcharacter(from: vowels, options: shortname, range: substring(from: shortname[0])) any appreciated. apologies newbie mistakes. i hate swift ranges. things better swift 4. let name = ...

Show dirty area (Custom warning message) dialog in JSF/ Primefaces -

i working on primefaces application, if changed in page, , clicked page without saving, need show popup dialog saying that, hey changed want save or not , based on user selection should either save/cancel/no function. i seen link, to track changes in jsf , if in same bean class , clicked on cancel button, can write function , show dialog. but, if user clicked on other link/page or menu item how handle case. is there anyway like, before flow go other bean last method should called. as searched because of security browsers not showing custom warning messages. @predestroy public void destroy() { ..} i tried this, method not getting called correctly if click on other link every time. there other way? to capture changes in application, may need introduce dirty flag, if of component value getting changes, application should set dirty flag value true. below example. <h:inputtext id="someid" onchange="setdirty();" value="#{mymanag...

javascript - D3 Pie chart add scroll bar to Legends -

i facing issue getting more 30 legends , legends not shown in vertical way nor horizontal way. add scrollbar legend box legends visible scroll or there way add legends side side 3 in row that i tried adding overflow property not work. below code var data =[]; for(var p = 0 ;p <unique.length;p++) { data.push({ legendlabel:unique[p], magnitude:uniquecount[p] }); } var canvaswidth = this.getwidth(), //width canvasheight = this.getheight(), //height outerradius = 60, //radius color = d3.scale.category20(); //builtin range of colors var vis = d3.select("#"+this.htmlobject) .append("svg:svg") //create svg element inside <body> .data([data]) //associate our data document .attr("width", canvaswidth) //set width of canvas .attr("height", canvasheight) //set height of canvas .append("svg:g") //make group hold our pie chart .attr("transform...

signal processing - BPSK modulation and SNR : Matlab -

Image
considering additie white gaussian communication channel signal taking values bpsk modulation being transmitted. then, received noisy signal : y[k] = s[k] + w[k] s[k] either +1,-1 symbol , w[k] 0 mean white gaussian noise. -- want estimate signal s , evaluate performance varing snr 0:40 db. let, estimated signal hat_s . so, graph have on x axis snr range , on y axis mean square error obtained between known signal values , estimates i.e., s[k] - hat_s[k] question 1: how define signal-to-noise ratio? formula of snr sigma^2/sigma^2_w . confused term in numerator: variance of signal, sigma^2, considered? question 2: but, don't know value of variance of noise is, how 1 add noise? this have done. n = 100; %number of samples s = 2*round(rand(n,1))-1; %bpsk modulation y = awgn(s,10,'measured'); %adding noise don't know variance of signal , noise %estimation using least squares hat_s = y./s; mse_s = ((s-hat_s).^2)/n; please correct me wrong. thank...

c++ - Can't get exact position of BSTR data in VARIANT struct -

Image
i have strange problem reading bstr value variant struct. i use following javascript code send data c++ code: external.cppcall("zhttshow", 1, "y"); in invoke function in c++ code, tried access data: hresult stdmethodcalltype webbrowser::invoke(_in_ dispid dispidmember, _in_ refiid riid, _in_ lcid lcid, _in_ word wflags, _in_ dispparams *pp, _out_opt_ variant *pvarresult, _out_opt_ excepinfo *pexcepinfo, _out_opt_ uint *puargerr) { if (dispidmember == 100) { unsigned int k = pp->cargs; if (k > 0) { variant *vvariant = &pp->rgvarg[k - 1]; if ((vvariant->vt & vt_bstr) == vt_bstr && vvariant->pvarval->bstrval) { wchar_t *wide = (wchar_t*)(vvariant->pvarval->bstrval); // other code } } } } in above code, wide point undefined position. if pointer of vvariant->pvarval->bstrval poin...

html - I want to reduce the width of one of my flex-items in my navigation bar -

Image
how reduce width size of levi link without affecting other tabs? this reason want when click on space between levi , rest of links goes page connected levi link. width of levi link wide. how reduce it? in image below levi spans large area of navigation bar. want reduce it. adjust width of preview see effect of css declarations this html <md-whiteframe class = "main-toolbar "> <md-theme name = "teal"> <md-toolbar id = "flex-container"> <router-link id = "nav" class = "nav-link " :to = " { name: 'levi' }" style = " text-decoration: none; color: #ffffff; background-color: red; ; ">levi</router-link> <router-link class = "nav-link" :to = "{ name: 'product' }" style = " text-decoration: none; color: #ffffff; background-color: yellow;">using levi</router-link> <router-link class...

r - Linear programming: not all constraints should be satisfied -

using r, easy linear programming lpsolve , lpsolveapi packages. now, want linear programming part of constraints satisfied. say, 80% of constraints satisfied. can not predefine constraints should satisfied. how implement using r? an example here. there 100 different tissue samples, each sample, 10000 ~ 20000 genes expressed. now, want select @ 10 samples purpose cover many genes possible. 1 solution based on lpsolve set 100 samples variables , 20000 genes constraints. first, manually filter genes, , lp , until solution hit 10 samples. however, laborious , not optimal. set.seed(123) t.mt <- matrix(sample(c(0,1),100000,rep=true),nr=1000) f.obj <- rep(1,100) f.dir <- rep(">=",1000) f.rhs <- rep(1,1000) t.lp <- lp("min",f.obj,t.mt,f.dir,f.rhs,all.int=true,all.bin=true) t.lp$solution is there possible solution using r problem? thank you!

android - (Indy) How to catch a Button click event before ConnectTimeout is reached -

i want make simple function user clicks on on/off button , makes indy tcp client try connect ip, connection takes long (due bad phone signal) , user may tap once again button turn off. indy catch event (button click) when connecttimeout reached or when connection succeed. thinking in put low connecttimeout , make multiple tries connect can catch button click without waiting long, there way catch button click event anytime when trying connect? thank you. @edit: well, decided make first idea: multiple tries connect low connecttimeout , count them until reach desired connecttimeout, while in mean time can check button press turn off. i tested using phone hspa+ connection , metal plate (to simulate bad signal) , apparently work. the simplified code ended this: var disconnectedonce: integer; procedure tform1.idtcpclient1disconnected(sender: tobject); begin if buttoniniciar.text = 'stop' begin try idtcpclient1.connect; except if dis...