Posts

Showing posts from April, 2013

Java jar getResource not working in linux -

this question has answer here: get resource using getresource() 4 answers same lines of code work in windows not in linux. code run through executable jar file. entries in buildpath: {project}/src,{project}/res project path of test1.java: /src/com/qe/util/test1 project path of tc_mapping.xml: /res/tc_mapping.xml . package com.qe.util; public class test1{ public static void parsetcmapping(){ ... string xmlpath = tcdetailsextractor.class.getclassloader().getresource("tc_mapping.xml").tostring(); system.out.println(xmlpath); inputstream = tcdetailsextractor.class.getclassloader().getresourceasstream(xmlpath); ... } } if have resource in jar should use getresourceasstream() method obtain content. might when files not in jar not when application packed in jar.

c++ - Call a function when button clicked in QT -

i have seen similar questions mine on here, still having issues. i have button in qt, have function defined in main.cpp file. when push qt button want call function in main.cpp , let function thing. mainwindow.cpp: void mainwindow::on_startmotor_clicked() { sendcmd(100); } main.cpp: void sendcmd(int value) { } but error: error: 'sendcmd' not declared in scope sendcmd(100); ^ im new qt dont think understand slots , signals thing. thanks! this not issue qt basic c++. general recommendation, therefore, buy book , learn language beginning @ basics. in particular setting, have 2 cpp files. in context, called translation units because each of these files compiled separately. result of so-called object files (.obj). linker has job make functions of 1 object file known other file. now, linker can job if translation units know of declarations of functions of other translation units. usually, have ...

javascript - Why do regex constructors need to be double escaped? -

in regex below, \s denotes space character. imagine regex parser, going through string , sees \ , knows next character special. but not case double escapes required. why this? var res = new regexp('(\\s|^)' + foo).test(moo); is there concrete example of how single escape mis-interpreted else? you constructing regular expression passing string regexp constructor. you need escape \ string literal can express data before transform regular expression.

angularjs - Logout state that doesn't change view -

currently have problem states in angularjs 1.x. we've in our application "logout" state looks this: .state('logout', { onenter:function($window) { cookies.remove('cookietest'); $window.open('http://url/', '_self'); } }) now redirect works , cookie getting removed. how ever, i'm switching states, ng-view changing blank page. in cases we've got ng-leave defined in our css animation appear. is there way how can functionallity described above, within .state() not change ng-view? as can see tried firstly "onenter" maybe redirect before switching states. tried play information posted accepted answer in topic: ui-router change state without changing url . makes sure url doesn't change, don't want ng-view change. who can me out?

xamarin.forms - Xamarin Forms Listview row width -

is there way in xamarin forms set width of listview row , not expand on entire screen? have tried requestwidth of listview , worked grid , layouts in listview. the width of row inside listview take entire width of listview itself. there no way have space between end of row , edge of listview, nor make sense. what can make listview smaller. this, need give position not "fill". it's horizontallayoutoptions needs either start, center or end in order not take entire width. you can use startandexpand / centerandexpand / endandexpand if want list view try , force it's parent control take width available, though list view still take space "needs" or requests using widthrequest. hope clears bit, please refer layout documentation xamarin.forms if you're stuck.

angular directive - Angularjs datetimepicker not working on partial html view -

i trying use jquery plugin date , time picker in angularjs project receive date user in form. <html> <head> <title>datetime picker</title> <link href="bootstrap.min.css" rel="stylesheet" > <link href="jquery.datetimepicker.css" rel="stylesheet"> </head> <body> <div class="container"> <form> <input type="text" id="datetimepicker" class="form-control"> </form> </div> <script src="jquery-3.1.1.min.js" ></script> <script src="bootstrap.min.js"></script> <script src="jquery.datetimepicker.full.js"></script> </body> <script type="text/javascript"> $('#datetimepicker').datetimepicker(); </script> </html> so, when click on form, datetime widget appears quite ...

fortran - Proper way to pass pointers into many subroutines -

i'm not programmer , i'm trying interface model provides data pointers. these pointers passed down through several subroutines before data written them. i'm not sure how avoid memory leaks. let's have array pointer a passed several subroutines before being written to, how handle declarations, allocations, , deallocations? module data implicit none contains subroutine s1(a) real, pointer, intent(out) :: a(5,5) call s2(a) end subroutine s1 subroutine s2(a) real, pointer, intent(out) :: a(5,5) integer :: = 1,5 a(:,i) = 5.0 end end subroutine s2 end module data program test use data, : s1, s2 real, pointer, dimension(:,:) :: => null() allocate(a(5,5)) call s1(a) write(*,*) deallocate(a) end program test please note code not fortran 90. intent attribute dummy (formal) arguments pointers introduced in fortran 2003. the intent refers association status of pointer, not target. also, if argument derived type pointer components, intent applies...

c++ - Remove first item of vector -

here type : struct rule { int m_id = -1; std::wstring name; double angle; }; vector of type : std::vector<rule>& toppriorityrules; i trying erase first element: toppriorityrules.erase(toppriorityrules.begin()); but can't it. looks need iterator overloading. can 1 suggest iterator overloading struct? given std::vector<rule>& toppriorityrules; the correct way remove first element of referenced vector toppriorityrules.erase(toppriorityrules.begin()); which suggested. looks need iterator overloading. there no need overload iterator in order erase first element of std::vector . p.s. vector (dynamic array) wrong choice of data structure if intend erase front.

Python, find variable/key based on maximum value -

i have several values, this: value_a = 5 value_b = 10 value_c = 20 i want find largest value , print name of value. use val = [value_a, value_b, value_c] print max (val) but gives me value , not name. instead of defining variable, need create dict map name value. need call max() operator.itemgetter() key it. example: my_dict = { 'value_1': 10, 'value_2': 30, 'value_3': 20 } operator import itemgetter var_text, value = max(my_dict.items(), key=itemgetter(1)) # value of: # `var_text`: "value_2" # `value`: 30 here, max() return tuple maximum value in dict . if not care maximum value, , want key holding it, may do: >>> max(my_dict, key=my_dict.get) 'value_2' explanation: my_dict.items() return list of tuple in format [(key, value), ..] . in example gave, hold: [('value_1', 10), ('value_3', 20), ('value_2', 30)] key=itemgetter(1) in satement tell max() perfo...

java - How to remove similar named strings in a list? -

given list/array of strings: document document (1) document (2) document (3) mypdf (1) mypdf myspreadsheet (1) myspreadsheet myspreadsheet (2) how remove duplicates retain highest copy number? ending result be: document (3) mypdf (1) myspreadsheet (2) you put in broad question, here comes unspecific (but nonetheless) "complete" answer: iterate on strings identify lines contain braces. in other words: identify strings "x (n)" then, each "different" x found, can iterate list again; can find occurrences of "x", x (1)", .. , on doing allow detect maximum n each of xes. push "maximum" "x (n)" results list. in other words: takes such simple receipt solve problem; takes time turn these pseudo-code instructions real code. for record: if layout of file shown above, things become bit easier - seems numbers increasing. mean is: x (1) x (2) x (3) is easier treat than x (1) x (3) x (2) as in ...

xpath - JCR query to return excerpt and parent identifier -

Image
i query jackrabbit repository on versions have stored. my repository looks following: following xpath query works well: //element(*, nt:frozennode)[jcr:contains(., '" + keyword + "') ]/rep:excerpt(.) , row object returned can excerpt found in de:template nodes 'de:content' property (for full-text indexable have own lucene configuration). the problem is: how know elements excerpt found for, since query returns me path found (/jcr:system/jcr:versionstorage/95/c8/3e/95c83efc-8441-4017-b3af-ae7be49f07e5/1.0/jcr:frozennode/de:template) , excerpt itself. so know identifier of nt:versionhistory node, stored in jackrabbit. i have solution well, getting parent nodes until nt:versionhistory reached , getting identifier: row row = (row) rows.next(); node node = row.getnode(); node frozennode = node.getparent(); node versionnumber = frozennode.getparent(); string versionid = versionnumber.getidentifier(); however takes time , lots of versions bad per...

python - Tkinter programming -

i've made basic tk window , kept button delete widgets imprint of widgets left over. how can remove blank part? problem still persists from tkinter import * class window(frame): def __init__(self, master=none): frame.__init__(self, master) self.master = master self.init_window() def init_window(self): self.master.title("sample") self.pack(expand=1) loginb = button(self, text="log in",command=self.login, height=2, width=20) loginb.grid(row=1) def quit(self): exit() def login(self): widget in frame.winfo_children(self): widget.destroy() self.grid_forget() self.grid() e1 self.l = {} label1 = label(text="enter code:").grid(row=1,column=0) e1 = entry(textvariable=e1).grid(row=1,column=1) def f1(): self.l["code"] = e1.get() return b1 = button(text="ok"...

php - $_SESSION['x'] exist after session_unset(); and session_destroy(); How to remove? -

how make sure $_session removed. have page with <?php session_unset(); session_destroy(); header("location: threads.php"); ?> you must load/start session before can destroy it: <?php session_start(); session_destroy();

Trying to figure out why eslint-watch doesn't work with docker-compose correctly -

i have been trying front-end working on docker past day , have narrowed down irregular behaviour eslint-watch , docker. have recreated minimal working repo of bug experiencing. it seems linting somehow staggered when using docker-compose ( docker-compose up specifically, docker-compose run seems work fine). rather last console log statements staggered. not sure is, reading best interpretation can give log messages should printed out linting reason not flushed out of node message queue. i have narrowed down message printing eslint watcher file. if add in more console logs @ end of method prints out linting fine, staggers logs (i.e. last logs in execution). funny thing is, if save again flushes rest of message queue i.e. previous logs print out. to replicate, download repo, run docker-compose up , edit test.js file , save. watch logs in terminal linting. see mean. i hope descriptive enough, it's strange bug , difficult explain in question. any ideas how can figure ...

pthreads - double free or corruption (!prev) in c , using thread, malloc -

i'm tired problem. use valgrind also. don't know why. please find problem in code. #include <stdio.h> #include <stdlib.h> #include <pthread.h> static pthread_t *tid=null; static int **data3=null; typedef struct _thdata { int *data; int size; int nthread; } thdata; thdata *tdata=null; void *bubble(void *d){ thdata *arr =(thdata *)d; int i,j,tmp; int n=arr->size; printf("thread #=%d n=%d\n",arr->nthread,n); for(i=0;i<n;i++){ for(j=0;j<n-1;j++){ if((arr->data[j])>(arr->data[j+1])) { tmp = (arr->data[j]); (arr->data[j])=(arr->data[j+1]); (arr->data[j+1])=tmp; } } } for(j=0;j<n;j++) printf("%d ",(arr->data[j])); printf("\n"); pthread_exit((void *)1); } int main(int argc, char **argv){ file * fd; int i,j; int ...

JSON to JAVA POJO of dynamic key-value pair -

i have create pojo class of following json, problem key p_d has variables dynamic name s_t, n_t, n_p , etc. real json big , facing problem part only, shared partial json. using jackson parsing. { "flag": true, "flag2": false, "r_no": [ { "room_type": 250067, "no_of_rooms": 1, "no_of_children": 1, "no_of_adults": 2, "description": "executive room, 1 king bed, non smoking", "children_ages": [ 8 ] }, { "room_type": 250067, "no_of_rooms": 1, "no_of_children": 0, "no_of_adults": 2, "description": "executive room, 1 king bed, non smoking" } ], "r_code": "abc", "r_key": "123", "p_d": { "s_t": [ { "name": "xyz", ...

Should I use use express or switch to javascript and html? -

i have been building web application takes user input , after doing modifies files on server side. core logic of build in node.js , works through command line, of site build using javascript , html. i've read using express easier in conjunction node modify server-side files. enough reason switch or should revamp code in regular javascript? pd: i'm new , first web application express javascript. library; codebase can more , write less. recommend it, if first web app. it important, general rule, don't learn express. because can use express , nothing else doesn't mean should. challenge learn inner workings of how framework things, , how web apps, regular apps, work. having knowledge make easier in long run, isn't should reinvent wheel. overall, use express, make sure know how on own.

javascript - Is it allowed to use window.postMessage() in a chrome extension? -

i have finished coding extension chrome , firefox (webextensions). have used window.postmessage() communication between website script , extension , works. but reading there methods chrome ( https://developer.chrome.com/extensions/messaging ) chrome.runtime.sendmessage() to send messages. extension rejected if use window.postmessage() have recode everything? yes, valid way of communication - between page , content script. in fact, if @ content script documentation , lists postmessage way of communication content script. the method described @ messaging documentation allows cut out content script middleman, , provides degree authentication messages (only indended recipient receive them), providing configured "externally_connectable" . but "externally_connectable" not supported in firefox yet, , can't find bug tracks implementation.

Angular 2 service property values undefined in my lazy loaded modules -

i have several properties in service share in other lazy loaded modules my service defined as: @injectable() export class appsettingsservice { private _deviceid: string; private _accountid: string; constructor() { } initialise(): promise<any> { if(this.getdeviceidfromlocalstorage() && this.getaccountidfromlocalstorage()) { return promise.resolve(errorcode.existing_user); } } setapplicationid(applicationid): void { this._deviceid = applicationid; } getapplicationid(): string { return this._deviceid; } setaccountid(accountid): void { this._accountid = accountid; } getaccountid(): string { if(typeof this._accountid !== 'undefined') { return this._accountid; } else { return '0'; } } public getdeviceidfromlocalstorage(): boolean { let deviceid = localstorage.getitem(appkeys.device_id); if((typeof deviceid !== 'undefined') && (deviceid !== ...

java - How to use Angular 2 in exist Spring MVC project -

i have spring mvc project , use jsp. want use angular 2 don't want disrupt project. @requestmapping("") string amethod(httpservletrequest request, model model) { //doing return a.jsp } my project this. use lots of jsp. when search angular 2, examples use 1 index.html. i want create different components angular 2 , use component's selector in jsp files. but don't know how can that. because there no example in anywhere. how should code structure be? how can use angular 2 this?

ios - Streaming on demand videos to android devices without RTP/RTSP server - NOT live -

i need able stream or view video on android devices. files @ remote location , stream must on demand. not have "stream" need able allow user watch video somehow. using html5 <video> element not going since has limited support file types , there subtitles errors , bugs, , current library of videos have converting them not close doable. after searching internet 2 weeks found 2 ways of doing this: 1. use rtp server 2. parse file location existing player app (mx player / ios player / video player...etc) using rtp server not possible since fees prohibitely expensive. hard subject search on internet using internal app hasn't been easy accomplish either, need set intent many other things in app apps 3rd party apps want use. i stuck , have no clue here. prefer html5 <video> tag not need transcoding, set file's location content client , client deals viewing. of course flash out of picture here. i found similar want do. if have android phone can ...

html - style a div based on the condition that a separate table with no tds -

i have table , div next it. <table> <tbody> <tr> <th> name </th> <th> age </th> </tr> </tbody> <table> <div>table has not tds</div> i wanted highlight div based on condition above table has no tds. i tried this: table tbody td:empty + div { background-color: red; } the above not working. can suggest solution pure css? the + on css selector not work because <div> not sibling of <td> . on other hand, table + div { something: } would work, because on same hierarchical level. aside that, unfortunately, afaik, there's no way make css rule child affects parent (nor siblings of parent). basically, html need restructured in way want. could, example, write small bit of js code adds class table if has no <td> s, class used css rule.

.net core - Error on netcoreapp1.1 when adding a netstandard1.6.1 reference -

Image
i tried update website project netcoreapp1.0 netcoreapp1.1 , dal project (netstandard1.6.1) error pops when try add dal project reference website project. heres project.json of projects: dal project(netstandard1.6.1) { "version": "1.0.0-*", "dependencies": { "microsoft.aspnetcore.identity.entityframeworkcore": "1.1.0", "microsoft.entityframeworkcore.sqlserver": "1.1.0" }, "frameworks": { "netstandard1.6": { "imports": "dnxcore50", "dependencies": { "netstandard.library": "1.6" } } } } website project(netcoreapp1.1) { "dependencies": { "bundlerminifier.core": "2.2.301", "microsoft.aspnetcore.authentication.cookies": "1.1.0", "microsoft.aspnetcore.diagnostics": "1.1.0", "microsoft.aspnetcore....

php - Doctrine AnnotationDriver Excepted AnnotationReader,but could use CachedReader -

when use cachedreader doctrine 2.5 annotationdriver this: $reader = new cachedreader(new annotationreader(), $cachedriver,false); $driverimpl = new annotationdriver($reader,$modelpath); i got tip ide: excepted annotationreader, give cachedreader. i check annotationdriver source code , shows annotataiondriver constructor(extends abstract class) need annotationreader. i know both of annotationreader , cachedreader implements reader interface. why not annotationdriver need interface of reader annotationreader class?

javascript - Angular JS - ng-repeat error -

i not speak english well, apologize in advance misspellings i creating user administration page on site developed angular js first time i'm using , can not figure out error when click on list on index.html page sent page amministrazione2.html "should" start script data db , insert them in table, video show <tbody> <!-- ngrepeat: prezzo in prezzi --> <t/ body> instead of data index.html, there list on left , evry item redirect .html page <!doctype html> <html ng-app="sin..."> <head></head> <body> <div class="left_col scroll-view"> <div ng-include="'includes/header.html'"></div> </div> </div> <div ng-include="'includes/footer.html'"></div> </div> <script src="//code.angularjs.org/1.5.7/angular.js"></script> <script src="//code.an...

c++ How to change a character in char* in for loop -

hey guys got assignment cant seem solve. char* string , need make upper case letters (everything in ascii) lower case using bit operations. i'm adding code keeps crashing. #include <iostream> #include <cstring> using namespace std; void converttolower(char* string) { (unsigned int = 0; < strlen(string); i++) { if (string[i] >= 65 && string[i] <= 90) { string[i] |= 32; } } cout << string << endl; } int main() { converttolower("hello"); return 0; } you're trying modify string literal i.e. read-only memory: that's reason crash (or undefined behavior more precise) void converttolower(char* str) { (unsigned int = 0; < strlen(str); i++) { if (str[i] >= 65 && str[i] <= 90) { str[i] |= 32; } } cout << str << endl; } int main() { char arr[] = "string"; converttolower(arr); ...

prolog - List all reachable nodes -

i have predicate bi-directional , tells, whether 1 node connected another. e.g. has(a, b). has(b, c). has(d, b). now list nodes can reached (from specific node) given number of steps. connected_nodes(a, t, 2). should therefore output t = c t = d my current code looks this: connected_nodes(a, b, 0) :- write(a). connected_nodes(a, b, n) :- n > 0, m n - 1, has(a, x), connected_nodes(x, b, m). this works t = c not t = d, bi-directional relation. am thinking correctly in terms of recursion or how in other way problem have solved? your connected predicate seems fine. might have made more sense make base case rely on has , it's you. however, say has predicate "bi-directional" haven't explicitly created rule indicates this. the following code "bi-directional" version of code: has(a, b). has(b, c). has(d, b). bi_has(x,y) :- has(x,y). bi_has(x,y) :- has(y,x). connected_nodes(a, b, 0) :- write(a). connected_no...

html - Header Creation -

Image
in head want use "your image more important ours" emphasis on more important. i want underlined , shadowed match red background (white shadow). emphasis i'm debating if should blink or fade in. for reason, css isn't working on it. html code: <!-- html document--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="dld.css"> <title>dave's logo designs</title> </head> <header> <div id="header"> <h1>your image <em>more important</em> ours</h1> </div> </header> <body> <h1>welcome official site of dave's logo designs<h1> </body> </html> css far: header { width: 100%; height...

tsql - SQL Server grouping by weeks but only capturing the max date -

some screenshots of i'm trying do: what returning current code claim no 456 multiple service dates what returning current code claim no 456 this return hoping for explanation: i work claims processing in healthcare industry , trying compile report based on service dates , received dates. i counting claim numbers service dates vs date received , grouping dates received , service dates weeks. however, receiving physical therapy may have multiple service dates within month. recounting claim number every week. is possible count claim number once last service date? not want claim no 456 counted 3 times, 1 each separate week. here's have far: select dateadd(week, datediff(week, 0, service_fromdate),0) dos, count(distinct claim_no) no_claims, dateadd(week, datediff(week, 0, date_received),0) rec claims_table cast(convert(varchar, service_fromdate, 101) date time) >= '07/01/2016' group dateadd(week, datediff(week, 0, service_...

.Net combobox allow typing the value not just in the list -

in .net form, want have combobox allows customer choose value dropdown list , can type value not in dropdown list. set dropdownstyle = comboboxstyle.dropdown. property allows type value in list. otherwise got error: formatting, display. setting property dropdownstyle = comboboxstyle.simple not working because display dropdown list. if inherit combobox datagridviewcomboboxcell, not display dropdown list. if let program dynamically add new item when customer type new value, dropdown list become bigger , bigger, it's not want. so, there way let combobox allow typing value not in list , keep dropdown list not change? lot

c++ - Vector subscript out of range - vector of structures -

i have following code. it's supposed count number of repetitions of given letter in given file. however, when try run vector subscript out of range. other people same error trying access undefined parts of it, doesn't seem issue here think. struct letters { char letter; int repetitions=0; }; void howmanytimes(const string &output) { ifstream file(output); vector <letters> alphabet; (int = 0; < 'z' - 'a' + 1; i++) { alphabet[i].letter = 'a' + i; } string line; while (file.eof() == 0) { getline(file, line); (char c : line) { if(c >= 'a' && c <= 'z') alphabet[c - 'a'].repetitions++; else if (c >= 'a' && c >= 'z') alphabet[c - 'a'].repetitions++; } } cout << alphabet[10].repetitions; } vector <lette...

python - finding repeat characters in a list for Hangman-python3 -

for hangman application code followed; text=list(input("enter word guessed:")) guess=[] tries=5 clue=input("enter clue: ") print('rules:\n 1) type exit exit applcation \n 2) type ? clue') in range(len(text)): t='_ ' guess.append(t) print(guess) while true: g=input("guess letter: ") if g in text: print("you guessed correct") y=text.index(g) guess[y]=g print(guess) continue elif g=='exit': exit() elif g=='?': print(clue) elif tries==0: print ("you have run out of tries, bye bye") exit() else: print(g,' not in word') tries -=1 print("you have",tries,'tries left') continue for code instance if text guessed 'avatar', when 'a' guessed, return first instance of letter , not positions; text[2][4] your issue comes using y = text.index(g) . return index of first match find...

git - GitHub page returns 404 only for some files -

i've pushed gh-pages local dist folder containing demo ng2 component with: git subtree push --prefix dist origin gh-pages everything's loading ok, except vendor...js/css files. my gh-pages website: https://nkalinov.github.io/ng2-datetime/ my gh-pages source code: https://github.com/nkalinov/ng2-datetime/tree/gh-pages what missing ? i had similar issue today use github page host static site dislike "vendor.bundle.js" generated webpack(was working before though). i searched day , landed here change "lib.bundle.js" worked. by way .nojekyll file not working me.

VS 2013 Build Configuration Selector Dissabled -

Image
for reason can no longer select between release/debug in solution configuration menu item in vs 2013. honest i'm not sure when disabled think after moved components separate class libraries. it looks both configurations firing perhaps why it's irrelevant?

sql server - Ignore warning in Stored Procedure / Prevent procedure from stopping -

i manage database collective 40 different individual servers identical structures own unique data. have multiple stored procedures on central system bulk insert .txt files compiled these servers tables. due 40 different off-site servers, there times data missed due packet loss. question is, there anyway have procedure ignore warning , continue processing? in particular case, skip on errors such as: msg 547, level 16, state 0, line 36 insert statement conflicted foreign key constraint "fk_appointmentpatient". conflict occurred in database "eaglesoft", table "patient.patient". i realize it's throwing error because primary key looking not in corresponding table foreign key relation. i'd update data possible during automated process , check logs afterward , fix individual issues afterward. other jobs. here stored procedure being used: create table patient.tempappointment --create temporary table data ( clinicid int null, app...

mysql load data infile auto_increment mutiple incrementation -

while executing same file multiple times auto incrementation value wrong. file sample.csv name,phone,address a,9401003026,dsa b,9658746542,fsa c,9865742310,hgfh d,9865869537,hf e,9401003026,hf s,9658746542,hf h,9865742310,hf j,9865869537,hf and query load data local infile '/home/anson/ansonbackup/python/newtest/sample.csv' table `sample` columns terminated ',' lines terminated '\n' ignore 1 lines (named,phone,address); if excecute 1 time value of id 8 when reexecute same file id starts 16..why???? my table create table `sample` ( `id` int(11) not null auto_increment, `named` varchar(30) default null, `phone` varchar(30) default null, `address` varchar(30) default null, primary key (`id`) ) engine=innodb default charset=latin1 if possible, never depend on auto_increment columns have values, same issue describe can happen. id gets increased every time insert in table. if need to, includ...

bash - How to check if a variable has "mysqli" or "mariadb" value -

i have following piece of script: set ${db_type:='mysqli'} echo $db_type if [ $db_type -eq "mysqli" -o $db_type -eq "mariadb" ]; #do stuff else echo >&2 "this database type not supported" echo >&2 "did forget -e db_type='mysqli' ^or^ -e db_type='mariadb' ?" exit 1 fi but piece of script somehow fails on: if [ $db_type -eq "mysqli" -o $db_type -eq "mariadb" ]; so how can compare if $db_type id either "mysqli" or "mariadb"? it useful know how fails there few things wrong following: if [ $db_type -eq "mysqli" -o $db_type -eq "mariadb" ]; variables unquoted (dangerous within [ ) -eq comparing integers, = should used strings (see this question detailed discussion of difference) as you've tagged bash should aware of improved [[ allows write this: if [[ $db_type = mysqli || $db_type = mari...

sql - Postgresql simple query very slow response time -

i have simple database using build out json elasticsearch. i'm person connected database, , using specific task. anyway, hitting tables on database incredibly slow, slow take months build out elasticsearch index working on. i've looked @ articles regarding postgresql tuning, etc, , nothing i'm changing fixing issue. query doing, can see below in explain analyze portion, simple query, no joins or else, , it's still slow. i'm trying figure out can speed up, because see no reason slow. here's relevant information can think of, if more needed, can add. system specs [root@pgdb ~]# free -m total used free shared buffers cached mem: 61444 39416 22027 458 8 38531 -/+ buffers/cache: 876 60568 swap: 0 0 0 [root@pgdb ~]# cat /proc/cpuinfo processor : 0 vendor_id : genuineintel cpu family : 6 model : 62 model name : intel(r) xeon(r) cpu...

typescript - createUserWithEmailAndPassword and handling catch with firebase.auth.Error give compilation error TS2345 -

when call following method , want catch error , check error code can't specify type of error other error type can't access error. code firebase.auth.error . methode description : (method) firebase.auth.auth.createuserwithemailandpassword(email: string, password: string): firebase.promise specifing firebase.auth.auth in work firebase.auth.error give me compilation error. error ts2345: argument of type '(error: error) => void' not assignable parameter of type '(a: error) => any'. types of parameters 'error' , 'a' incompatible. type 'error' not assignable type 'firebase.auth.error'. property 'code' missing in type 'error'.   this.auth.createuserwithemailandpassword(username, password) .then( (auth: firebase.auth.auth) => { return auth; } ) .catch( (error: firebase.auth.error) => { let errorcode = error.code; let ...

Does file truncate operation supported in Storage Access Framework (Android Lollipop API 21)? -

i need truncate file on removable sd card. can't call truncate(somesize) directly on file due storage access framework (saf) restrictions , forced use: parcelfiledescriptor pfd = getcontentresolver().openfiledescriptor(documentfile.geturi(), "rw"); fileoutputstream fos = new fileoutputstream(pfd.getfiledescriptor()); filechannel = fos.getchannel(); filechannel.truncate(somesize); as result have exception: java.nio.channels.nonwritablechannelexception @ java.nio.filechannelimpl.checkwritable(filechannelimpl.java:86) @ java.nio.filechannelimpl.truncate(filechannelimpl.java:460) why above channel not writable if opened file descriptor in rw mode? there way truncate file under saf on lollipop!?

relational database - Is this BCNF correct? -

i given problem find out bcnf of relation converted 3nf. asks , 1) find key , 2) convert bcnf. relation student(studentid,courseid,lecturerid,grade) fds {studentid,courseid} -> grade {studentid,courseid} -> lecturerid lecturerid -> courseid what got far 1) since ${studentid,courseid}$ can have attributes in closure of {studentid,courseid}, key composite attribute. that's got first question. 2) has asked provide bcnf of given relation. considering first fd can see satisfies bcnf since left side consist of key attribute. im using decomposition algorithm here so considering second fd, consists of key composite attribute in left side. satisfies bcnf. in third 1 see doesn't satisfy bcnf. have split relation. r1 : (lecturerid,courseid) r2 : (lecturerid, studentid, grade) so r1 , r2 relations answers. my problem i need check answers 1 , 2. can please verify that. thank you.

sql server - Get execution count of Stored procedure in SQL 2005 -

we want capture execution count of selective stored procedure on 1 of our databases in sql 2005. can please advise, how can capture same...with below cached sps data. in our case, want selective sps specific our application select db_name(st.dbid) dbname ,object_schema_name(st.objectid,dbid) schemaname ,object_name(st.objectid,dbid) storedprocedure ,max(cp.usecounts) execution_count sys.dm_exec_cached_plans cp cross apply sys.dm_exec_sql_text(cp.plan_handle) st db_name(st.dbid) not null , cp.objtype = 'proc' group cp.plan_handle, db_name(st.dbid), object_schema_name(objectid,st.dbid), object_name(objectid,st.dbid) order max(cp.usecounts)

eclipse - Incompatible JavaHL library loaded. Subversion 1.8.x required not going away -

Image
i using ubuntu 16.04 , have following subclipse/javahl installation on eclipse mars. and seems on line http://subclipse.tigris.org/wiki/javahl i have 1.10.xx subclipse version 1.8.xx javahl version. yet on every eclipse mars startup keep getting error message , when see eclipse team->svn>svn interface tab see so right using svnkit instead. idea on causing this. , information, have eclipse neon that's running fine using ok after trying lot of things did not work, managed solve updating javahl native library adapter 1.9. did not know tried eclipse marketplace . help --> eclipse marketplace --> installed tab --> subclipse --> update (click on ltlle arrow in button if install showed select it) make sure javahl adapter checked , update.

java - JComponents are not showing up on JPanel -

my jcomponents aren't showing on jpanel reason. here's code: main class import java.awt.color; import java.awt.dimension; import java.awt.graphics; import java.awt.graphics2d; import javax.swing.jframe; import javax.swing.jpanel; // main class - executes game public class main extends jframe { public static int width = 800, height = 800; private jpanel jp; private dimension d; private snake s; private food f; public main() { settitle("snake"); setsize(width, height); setvisible(true); setdefaultcloseoperation(jframe.exit_on_close); setlocationrelativeto(null); d = new dimension(width, height); jp = new jpanel(); jp.setbackground(color.gray); jp.setpreferredsize(d); getcontentpane().add(jp); // adds snake s = new snake(); jp.add(s); // adds food f = new food(); jp.add(f); } @override pu...

python - Sockjs and tornado: How Sent and Read Data -

i’m trying learn sockjs small university project. i’ve local server (with typical lamp configuration), goal writing python script (running on local server) able send data client browser in order update text information. sockjs seemed me best solution (tornado-sockjs python server). read tutorial examples ( https://github.com/mrjoes/sockjs-tornado/tree/master/examples ) i’ve difficult understand basic functions. it useful understand example code. example be: a python-server script generates random number each 5 seconds , send number client. in webpage there definite element update value. in same webpage there button send text message python server. when python server received message, print in server console. thank in advance help. i hope post useful other people.

java - Is it possible to set FLAG_NOT_TOUCHABLE on an activity, but also close the activity when a touch occurs? -

i set flag_not_touchable on transparent activity allow interaction activity below. there way close transparent activity when user touches screen while these flags set? i not believe you'd able determine if user touched screen if flag_not_touchable set. activity not receive touch events @ all. instead, can set ontouchlistener root view, return false indicating not want handle touch. way, you'll receive first touch event ( action_down ) allows call finish() , go.

php - How to Add to MySQL Configuration on Travis CI When Not Sudo -

i trying figure out how change mysql configuration before travis ci test run. using "sudo:false" directive, think use containers...i'm not best devops person. but when set sudo true, can't restart mysql after try add lines "/etc/mysql/my.cnf". so, - cat "some/directory/my.cnf" | sudo tee -a /etc/mysql/my.cnf - sudo /etc/init.d/mysql restart gives me: "start: job failed start", don't want use sudo. php config, can like: - echo "apc.shm_size=256m" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini but can't see in home folder mysql. i know about: - mysql -e "set global innodb_buffer_pool_size = 512m;" but things want set give me: error 1238 (hy000) @ line 1: variable 'innodb_buffer_pool_size' read variable so, i'm @ loss on how accomplish changing mysql configuration on travis ci, , every internet search , method i've tried has failed me.