Posts

Showing posts from January, 2013

qt - Firing a CustomEvent into an IHTMLDocument instance from C++ -

i have qt 3.3 application instantiates webbrowser control , need fire customevent @ current document json string detail property. similar question has been asked before answer uses deprecated apis (e.g. createeventobject) recommended approach? having great difficulty finding documentation online , procedure seems quite complex achieve simple result.

sql - MYSQL Update Based On A Row Index Equaling An ID In Another Table -

i have 2 tables. i'd update row in table1 based on same row index in table2. ids don't match but id in table 2 matches row index. there more data in table 2, don't care if rows missed. how achieve in mysql update statement? table 1 ______________ table 2 _____________ row number | id | value | row number | id | value | |--------------| |-----|-------| 1 | 2 | | 1 | 1 | w | 2 | 4 | b | 2 | 2 | x | 3 | 6 | c | 3 | 3 | y | 4 | 4 | z | to: table 1 ______________ row number | id | value | |--------------| 1 | 2 | w | 2 | 4 | x | 3 | 6 | y | this works, it's not pretty. set @c=0; update t1 join ( select tx.id,t2.value t2 ...

java ee - HQL query throws an EJB Exception -

i tryin write hql queries 2 tables related on 1 many relationship there error on execution. string status = "vacant"; query query = em.createquery("select count(id) beds status=:status inner join rooms on beds.roomid=rooms.id rooms.hostelid=:hostelid"); query.setparameter("status", status); query.setparameter("hostelid", hostelid); list result = query.getresultlist(); return ((long)result.get(0)).intvalue(); the error trown javax.ejb.ejbexception: java.lang.illegalargumentexception: org.hibernate.hql.internal.ast.querysyntaxexception: unexpected token: join near line 1, column 67 [select count(id) portal.beds.model.beds status=:status join rooms on beds.roomid=rooms.id rooms.hostelid=:hostelid]

excel - Pivot table sorting by text string -

Image
it seems silly, trying set pivot table, , doesnt seem strongest side. the following picture demonstrates after: ... in data there currency string, seems if cant string represented in matix - in either row labels or columns labels, makes table unstructured. there way match security (row label) denominated currency ? this part of source table: ... ccy currency column within pivot table , not pivot row or column label. / phillip make pivot classic pivot, see how above person sees it. classic pivot answer of putting in text strings inside pivot. somehow aligns better. right click on pivot --> pivot table option --> display --> check box says "classic pivot table layout". take backup of excel copy before switch classic pivot. it's irreversible

asterisk - Elastix cutting off calls randomly at 30 seconds -

i've installed elastix sip trunk provided spitfire. i'm having issue in randomly disconnect @ 30 seconds. using akuvox handsets. we not using nat , believe setup correctly. i've attached log , noticed theres lot of unknowns, i'm unsure if correct? http://pastebin.com/zabbakjw cutting call @ 30 sec 99% nat configuration issue. please consult nat howto.

how to recover Ubuntu terminal path? -

Image
actually, path jjw or jjw/home but when run terminal, become how return original path? pwd - return working directory name (pwd - print working directory)

ubuntu 16.04 - gstreamer won't play rtsp -

i have gstreamer command plays stream 1 ubuntu 16.04 box 2 others. as far know have same packages installed regarding gstreamer on boxes because ran sudo apt-get install gstreamer1-0* gstreamer 1.0 packages installed. find strange not work on other following commands used: gst-launch-1.0 rtspsrc location=rtsp://<user>:<password>@<ip>/axis-media/media.amp user-id=root user-pw=xxxxxxxxxxc latency=150 ! decodebin max-size-time=30000000000 ! videoconvert ! autovideosink or gst-launch-1.0 playbin uri=rtsp://<user>:<password>@<ip>/axis-media/media.amp this open stream of axis camera h264. don't understand why not work on 2 ubuntu 16.04 boxes works on one. of these same ubuntu 16.04 same gstreamer packages installed. could there maybe package except gstreamer necessary in order gstreamer stream rtsp? the error when not playing setting pipeline paused ... pipeline live , not need preroll ... got context element 'autovideosink0...

angularjs - Angular ng-include with ng-Covervid -

i'm using ng-include in ionic slide : <ion-slide> <div ng-include src="'vid.html'"></div> </ion-slide> <ion-slide> <div ng-include src="'templates/rooms.html'"></div> </ion-slide> <ion-slide> <div ng-include src="'templates/splash2.html'"></div> </ion-slide> vid.html not in templates, in root folder, , file full screen video : <!-- video markup --> <section class="masthead"> <!-- directive element --> <covervid class="masthead-video" autoplay loop muted height="720" width="1280"> <source src="assets/videos/dreamscapes.mp4" type="video/mp4"> <source src="assets/videos/dreamscapes.webm" type="video/webm"> ...

ios - UITableView inside UIScrollView - Cell not clickable -

Image
i have problem uitableview not detecting touches. in iphone-only app, have uiviewcontroller, containts: uiscrollview uiview (let's content view) some labels uitableview (last) the labels have dynamic height, because contain text must retrive web, i'm using auto layout. i'm setting content size of uiscrollview inside viewdidlayoutsubviews method, , i'm doing summing uitableview.frame.origin.y , height. here comes problem: when labels contain words , uitableview not exceed iphone screen size, works ok. when grow, , uitableview gets pushed down, when scroll down can't click on cell anymore. also, if when loading view table half visible , half not, can click visible cells, if scroll down, can't click others. i'm using swift 2 , xcode 7. here example: clickable: unclickable: do following thing: yourview.cliptobounds = true now, if uitableview not appears means uiview not same bigger hold down uitableview . make...

Problems with my css stylesheet coding -

i have similar problem others have had, answers did not help. this coding: <div id="social-media"> <p>for aditional information<br>please call 03-5185-1208<p> <ul> <li> <a href="http://www.facebook.com"> <img src="images/social media/facebook 32x32.png"> </a> </li> <li> <a href="http://www.twitter.com"> <img src="images/social media/twitter 32x32.png"> </a> </li> </ul> </div> my css style sheet ul li{ display:inline; text-decoration:none; } but underline still remain. have tried included { border-bottom:none; } nothing did work. can please? use this ul li{ display:inlin...

java - Can't find valid JDBC driver when deploying Liberty app in Bluemix with ElephantSQL -

i have websphere liberty 16.0.0.2 webapp develop , run locally on laptop derby db using jpa work database. used deploy bluemix sqldb (retired ibm in may 2016) , worked fine automatic wiring of service. since sqldb no longer available, free sql able find on bluemix elephantsql, autowiring not seem work. here error after deployment: program error occured: cwwjp0013e: server cannot locate java:comp/env/jdbc/trireplicatordb data source trireplicatorpersistenceunit persistence unit because has encountered following exception: javax.naming.namingexception: cwnen1001e: object referenced java:comp/env/jdbc/trireplicatordb jndi name not instantiated. if reference name maps jndi name in deployment descriptor bindings application performing jndi lookup, make sure jndi name mapping in deployment descriptor binding correct. if jndi name mapping correct, make sure target resource can resolved specified name relative default initial context. [root exception com.ibm.wsspi.injectionengine.injecti...

ruby - Rails 4: How to prevent jumping to index -

i new rails , coding first app. created search name of tools model. it's passing params correctly (jumps/redirects/passes params) index of model. how can direct to tools#search site (site search form)? a url overview: http://localhost:3000/search # start http://localhost:3000/tools?utf8=%e2%9c%93&search=&commit=search # directed http://localhost:3000/search?utf8=%e2%9c%93&search=&commit=search # should direct a code overview: routes get '/search' => 'tools#search' tool model # search def self.search(search) if search where(["title ?", "#{search}"]) else end end tools controller def search @tools = tool.search(params[:search]).order("created_at desc") end search view (app/views/tools/search.html.haml) = form_tag search_path, :method => 'post' = text_field_tag :search, params[:search] = submit_tag "search" - @tools.each |tool| = image_tag ...

ruby - Insert Into DB using Sequel -

i want insert data postgres db using sequel. have pursued 2 approaches, none has yielded results want. my first approach " querying in sequel ": connection = sequel.connect('postgres://admin:admin@localhost:5432/test_tcp') insert_values = connection["insert cards (:card_number, :phone_number, :uuid, :created_at, :updated_at) values (?)", '766877868', '256700000000', '9043', '2016-09-07 11:11:31 +0300', '2016-09-07 11:11:31 +0300'] insert_values.insert connection.close my second approach " inserting records ": connection = sequel.connect('postgres://admin:admin@localhost:5432/test_tcp') cards = connection.from(:cards) cards.insert(:id => 1, :card_number => "13668389", :phone_number => "256700000000", :uuid => "9014", :created_at => '2016-09-07 11:11:31 +0300', :updated_at => '2016-09-07 11:11:31 +0300') connection.close ...

python - flask socket-io, sometimes client calls freeze the server -

i have problem flask socket-io freezing, , have no clue how fix it. my client connects socket-io server , performs chat sessions. works nicely. reason, client side, there call blocks whole server (the server stuck in process, , other calls frozen). strange server can blocked long client side app not totally shutdown.this ios-app / web page, , must totally close app or safari page. closing socket itself, , deallocating doesn't resolve problem. when app in background, sockets closed , deallocated problem persists. this small server, , deals both html pages , socket-server have no idea if socket or html blocks process. each time server freezing, log showed socket calls. here how configured server: socketio = socketio(app, ping_timeout=5) socketio.run(app, host='0.0.0.0', port=5001, debug=true, ssl_context=context) so question is: can freeze server (this seems happen when leave app or web-site open long time while doing nothing). if use services server never freez...

javascript - How to keep the navbar fixed to top in big screens only using jquery -

basically want menu activate fixed class when when scroll down 150 pixels , width of screen bigger 850 pixels. i used code menu still being fixed top in small screens(less 850px): $(window).on('resize', function() { if ($(window).width() > 850) { var num = 150; // $('nav#site-navigation').addclass('fixed'); $(window).bind('scroll', function () { if ($(window).scrolltop() > num) { $('nav#site-navigation').addclass('fixed'); } else { $('nav#site-navigation').removeclass('fixed'); } }); } else{ $('nav#site-navigation').removeclass('fixed'); } here css if needed: .fixed { top: 0%; width: 100%; text-align: center; bottom: aut...

javascript - Keeping data object after filtering -

small background intro i´m working user administration page of project , running small problem here. have table contains material-ui`s usercard. each user uses system exist´s 1 card. card´s generated data comes database , written redux store . the admin can several interactions database changes userdata. provide easy way find specific user <textfield /> implemented filter´s table of usercards. all of things mentioned here works! the problem as mentioned in intro data stored in redux store . when filter data, action dispatched export const filter_all_user_by_name = "filter_all_user_by_name" export const filter_all_user_by_department = "filter_all_user_by_department" export default function filteralluser(filter, filteroption){ return (dispatch, getstate) => { if(filteroption === 'name'){ return dispatch (filteruserbyname(filter)) }else{ return dispatch (filte...

android - How to create a dynamic tag by using angularJS? -

i trying create html element using angularjs. want because want download file client available on server. saw easy way using html element href attribute. here piece of code : $http({ url: '/process', method: 'post', headers: { 'content-type': 'application/json' }, data: appdata.elements }).then(function sucesscallback(response) { //create link , emulate click on }, function errorcallback(response) { }); so send request server. then, builds android project in purpose of generating apk. want download apk server clicking on element. create dynamic <a> tag, $http({ url: '/process', method: 'post', headers: { 'content-type': 'application/json' }, data: appdata.elements }).then(function sucesscallback(response) { ...

django - Python IF conditions -

i'm new django python if makes me feel confused. please me! im trying make if condition facebook chat bot api. whole function when user sends in facebook chat, bot remove punctuations, lower case text , split based on space. after pick joke json list keyword got. quick reply 2 buttons "yes" , "no" sent user joke. it checks if keyword absent. want when user types "no" in chat, bot send "then not". did wrong here? strong texttokens = re.sub(r"[^a-za-z0-9\s]", ' ', recevied_message).lower().split() joke_text = '' token in tokens: if token in jokes: joke_text = random.choice(jokes[token]) .... code send_message(fbid, joke_text) quick_text = "do want joke? " send_quick_reply_message(fbid, quick_text) break if not joke_text: joke_text = "i didn't understand! " \ "send 'stupid', 'fat', 'dumb...

android - Display only single line at a time, in a Multiline Edittext -

Image
i have tried android:singleline, maxlines, linespacing attributes edittext displays part of next line. how can force display single line @ time? <edittext android:layout_width="match_parent" android:layout_height="30dp" android:id="@+id/formulaview" android:textcolor="#000000" android:textcursordrawable="@drawable/visible_cursor" android:background="#ffffff" android:layout_margintop="1dp" android:textsize="18sp" android:maxheight="30dp" android:gravity="center_vertical" android:layout_marginbottom="1dp" android:paddingstart="10dp" android:paddingend="10dp" android:scrollbars="vertical" android:imeoptions="actionnext" android:completionthreshold="1" android:inputtype="textmultiline|textnosuggestions"/> don't use android:inpu...

postfix mta - SMTP Mail server authentication in ubuntu -

i new ubuntu , setting mail server on ubuntu 16.04 using zimbra , postfix(zimbra , postfix installed zimbra user). need enable authentication on server, purpose using dovecot. can tell me process of setting mail server on ubuntu single user. follow guide , fine.

python 2.7 - Comparing two dictionary keys and values -

i have 2 dictionaries in i'm trying first find matching key d1 in d2, output subtraction of 3rd value in key both dictionaries..can done in 1 loop function? first tried doing in 2 steps gives me empty list d3, tried use loop gives me error v not defined. d1 = {'alpha': [5, 9, 11], 'beta': [6, 10, 20], 'gamma': [12, 15, 19]} d2 = {'alpha': [3, 8, 20], 'omega': [15, 32, 40], 'ro': [22, 25, 4]} d3 = {} key in d1: if key in d2: d3.setdefault(key, []).append print d3 #should d3 = {'alpha': [3, 8, 20]} #compare , calculate difference between 20 , 11 in alpha key value = d3(key, v(2)) - d1(key, v(2)) print value #value = 9 #can loop find key in d2 , matches key in d1 #and calculate difference? key in d1: if key in d2: value = d2(key, v(2)) - d1(key, v(2)) print value thoughts? thank you. -jon you use dictionary comprehension: diff = {key: d2[key][2] - d1[key][2] key in d2 if key...

android - How do I reverse a running animation? -

when button touched, starts zoom animation. animation zoomin = animationutils.loadanimation(context, r.anim.zoomin); view.startanimation(zoomin); the zoomin.xml code: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:fillenabled="true" android:fillafter="true"> <scale android:fromxscale="1.0" android:toxscale="1.3" android:fromyscale="1.0" android:toyscale="1.3" android:pivotx="50%" android:pivoty="50%" android:duration="200" android:interpolator="@android:anim/accelerate_interpolator"/> </set> but if button released during still running animation, should reverse animation this point in time . how can achieve that? you use viewpropertyanimator achieve this. for example: ...

Is there any way to get the Uri string of a youtube video? -

i'm trying send video reciever. far have sent files 'myfile.mp4' i'm trying send youtube video. so, need send uri of it. can clarify 'send youtube video' ? if have videoid , want send uri use https://www.youtube.com/watch?v=videoid

400 Bad request on c# code -

getting error exception thrown on small piece of code can't figure out why / where. new apprecaited private void getservicedata(string url) { try { if (!string.isnullorempty(this.service) && !string.isnullorempty(url)) { string data = string.empty; string name = string.format("{0}data", this.service); using (webclient client = new webclient()) { data = client.downloadstring(url); } page.clientscript.registerhiddenfield(name, data); } } catch (exception ex) { shared.utilities.exceptionlog.writeexceptiontolog(ex, "coursefinderservicecontrol.getservicedata()"); } } if twitch, need specify client when requesting data.

Comparing SAS and R results after resolving a system of differential equations -

Image
i main objectif obtain same results on sas , on r. somethimes , depending on case, easy. otherwise difficult, specially when want compute more complicated usual. so, in ored understand case, have following differential equation system : y' = z z' = b* y'+c*y let : b = - 2 , c = - 4, y(0) = 0 , z(0) = 1 in order resolve system, in sas use command proc model : data t; time=0 40; output; end; run; proc model data=t ; dependent y 0 z 1; parm b -2 c -4; dert.y = z; dert.z = b * dert.y + c * y; solve y z / dynamic solveprint out=out1; run; in r, write following solution using lsoda function of desolve package: library(desolve) b <- -2; c <- -4; rigidode <- function(t, y, parms) { with(as.list(y), { dert.y <- z dert.z <- b * dert.y + c * y list(c(dert.y, dert.z)) }) } yini <- c(y = 0, z = 1) times <- seq(from=0,to=40,by=1) out_ode <- ode (times = times, y = yini, func = rigidode, parms = nu...

sql - Having placeholder columns when creating new database table -

is practice add placeholder columns when creating database table millions of rows, in case schema gets changed later? more efficient rename column insert new one? there many problems adding "placeholder" columns table. these columns may take useless space, , appear "sloppy". you may create many columns now, , have columns never used. you may not create enough columns now, , have end creating more anyways. you don't know column data types @ time. always remember if column needs added @ later date , not used of current rows in table, can still keep table normalized creating smaller table holds information, link them using primary key. let me know if have questions this. hope helps!

github - How to recover deleted fork? -

i don't know how happened, fork of repo dissapeared repositories on github. i have it's code on computer , resume working on though fork didn't dissapear. how that? thank in advance. update i don't think it's duplicate, becase guys problem in " how can push fork clone of original repo? " cloned , tried work original repo, worked fork, dissapeared. there's nothing wrong actions except somehow fork doesn't exist anymore. recreate fork , have commits , history of work i've done, on local computer. the solve simple feel stupid not doing before... all had fork repo again , use local files try , push again - worked. dumb me:)

javascript - Typescript : how to loop through enum values for display in radio buttons? -

this question has answer here: how 1 names of typescript enum entries? 10 answers what proper way loop through litterals of enum in typescript ? (currently using typescrip 1.8.1) i've got following enum : export enum motifintervention { intrusion, identification, absencetest, autre } export class interventiondetails implements oninit { constructor( private interservice: interventionservice ) { let i:number = 0; (let motif in motifintervention) { console.log( motif ); } } the result displayed list 0 1 2 3 intrusion, identification, absencetest, autre i want 4 iterations in loop there 4 elements in enum, don't want have 0 1 2 , 3 seem index numbers of enum. two options: for (let item in motifintervention) { if (isnan(number(item))) { console.log(item); } } or object.keys(motifinterve...

ruby on rails - Creating a dynamic xlsx with the write_xlsx gem -

i want export part of db user .xlsx i managed create static file , let user download it, that's not point. the user should select filter wants , result file should created , downloaded directly through browser. my code looks this: controller def download_pdf send_data generate_pdf, type: "application/xlsx" end private def generate_pdf workbook = writexlsx.new('export.xlsx') worksheet = workbook.add_worksheet worksheet.write(0, 0, 'status') worksheet.write(0, 1, 'date') worksheet.write(0, 2, 'customer') workbook end the result file , content name of object #<writexlsx:0x007fd9cf8aa290> i'm not sure if write_xlsx specific or if i'm missing obvious here. to save 'export.xlsx' disk, should use workbook#close. see generate_xlsx method below. def generate_xlsx workbook = writexlsx.new('export.xlsx') worksheet = workbook.add_worksheet worksheet.writ...

unix - sed multiline remove before pattern -

hi have big log file trying xml data passed it. i have big log file ressembles : 2016/01/01 bladh bqskjdqskldjqsdlqskdjqlskdj dazihzmkldjkdjqslkjd 2016/01/01: qsdhqsdlkqsmdjqsldjqslkdjqlskdjqslkdjqslkdjqskdjqsd 2016/01/01: qsjdqmlskdmlqskdmcxxxx [qskjd][qsdjqslkdj] payload :[<log><a>a</a> <b>b</b> <c>c</c> <id>xxxxx</id> <d>d</d> </log>]] 2016/01/01 bladh bqskjdqskldjqsdlqskdjqlskdj dazihzmkldjkdjqslkjd 2016/01/01: qsdhqsdlkqsmdjqsldjqslkdjqlskdjqslkdjqslkdjqskdjqsd 2016/01/01: qsjdqmlskdmlqskdmcxxxx [qskjd][qsdjqslkdj] payload :[<log> <a>a</a> <b>b</b> <c>c</c> <id>yyyyy</id> <d>d</d> </log>]] qskdmqlskdqlsdqlskdqlsdk qsdlkqsdlkqsdmlkqsdlk for using sed -n '/<start/{:start /\/end/!{n;b start};/xxxxx/p}' logfile and getting 2016/01/01: qsjdqmlskdmlqskdmcxxxx [qskjd][qsdjqslkdj] payload :[<log...

regex - Is there a RegExp.escape function in Javascript? -

i want create regular expression out of possible string. var usersstring = "hello?!*`~world()[]"; var expression = new regexp(regexp.escape(usersstring)) var matches = "hello".match(expression); is there built in method that? if not, people use? ruby has regexp.escape . don't feel i'd need write own, there's gotta standard out there. thanks! the function linked above insufficient. fails escape ^ or $ (start , end of string), or - , in character group used ranges. use function: regexp.escape= function(s) { return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); }; while may seem unnecessary @ first glance, escaping - (as ^ ) makes function suitable escaping characters inserted character class body of regex. escaping / makes function suitable escaping characters used in js regex literal later eval. as there no downside escaping either of them makes sense escape cover wider use cases. and yes, disappointing f...

Entity Framework: How to upgrade or downgrade during migration -

this migration code addisdefault. tell me how down grade later after upgrade , again upgrade later. command need issue @ package manager console. public partial class addisdefault : dbmigration { public override void up() { addcolumn("dbo.contacts", "isdefault", c => c.boolean(nullable: false)); } public override void down() { dropcolumn("dbo.contacts", "isdefault"); } } you don't need downgrade here.if don't need isdefault column remove on model , run migration again shown below. pm> add-migration "remove_isdefault" pm> update-database later if need add again,change model , run again new change.very simple :) update : on package manager console : pm> update-database –targetmigration: yourmigrationscriptname reference : code first migrations

TypeError: list indices must be integers, not tuple in Python SVD model -

i testing recommender based on svd model. got error message after running below: here testing code: import sys sys import argv import csv import recsys.algorithm recsys.algorithm.verbose = true recsys.algorithm.factorize import svd recsys.datamodel.data import data likes = [] open('/users/xps13mynotebook/desktop/w2v/likes.tsv', 'r') f: line in f.readlines(): username,user_likes = line.strip().split('\t') likes.append((username,user_likes)) data = data() value = 1.0 username in likes: user_likes in likes[username]: data.add_tuple((value, username, user_likes)) # tuple format is: <value, row, column> svd = svd() svd.set_data(data) k = 5 svd.compute(k=k, min_values=3, pre_normalize=none, mean_center=false, post_normalize=true) svd.similar('sheila') error: typeerror traceback (most recent call last) <ipython-input-30-913000ff4e0e> in <module>() 10 value = ...

Python Json to array -

i want put json array. have 6 json links (with same size different issues) that try: data=('0','0') response = urllib.urlopen(url) data[0] = json.loads(response.read()) response = urllib.urlopen(url) data[1] = json.loads(response.read()) do have initialize 3d array? later fine if can work on result that: result = data[0]['resu']['spc'] in end want build loop use dynamical json links that: for w in range(0,len(urls)): urls[w]['resu']['spc'] i suggest using requests (the current documentation so, too) can do: import json import urllib2 urls=["http://example.com/json","https://example.com/json2"] # urls here data=[] u in urls: response = urllib2.urlopen(u) data.append(json.loads(response.read())) # while works python 2, better use data.append(json.loads(response.read().decode("utf8")) for have find out/guess encoding of response. with requests simpler: import requ...

authentication - Force Authetication Method on Tortoise SVN Client -

im using tortoisesvn client 1.9.4. on svn server enabled both authentication options (windows authentication , basic authentication). on clients, can't use windows authentication, because it's users in domain server can't see. question is: "can somehow force svn-client use basic authentication?" know if clear cached data, client shows window lets me enter username , password. seems client first tries use windows authentication. needs lot of time , causes login failure on server event log. thanks bahrep! using windows credential manager helped avoid authentication errors on server. client no uses credentials entered in password tresor.

python - Parse JSON find value and append random number? -

i have json file login , integer valuer (some result), this: [ { "name":"tamara", "results":"434.545.234.664" }, { "name":"ted", "results":"434.545.234.664" } ] i need receive user login (name), find inserted name in json. if exists, add number "results". for example: if input "ted", number appended ted's results this: "results":"434.545.234.664+4343}" if name doesn't exist, add new record with: { "name":"new_name", "results":"some_number" } in it. my code, didn't work: with open('/users/users_db.json') jsonfile: user_name = '' while user_name == '': data = json.load(jsonfile) user_name = input('your name: ') user in data: if user_name in u...

mysql - Select ID That has multiple attributes and values -

i have table1 : +----+-------+ | id | name | +----+-------+ | 1 | name1 | | 2 | name2 | | 3 | name3 | | 4 | name4 | +----+-------+ i have table2 : +------+---------+----------+ | id | attribut| value | +------+---------+----------+ | 1 | 1 | 1 | | 1 | 3 | 3 | | 2 | 1 | 1 | | 2 | 3 | 4 | +------+---------+--------- + i want select distinct id(s) , name(s) in table1 have ( attribut 1 , value 1) , (attribut 3 , value 3) in table 2 the result 1/name1 in case thanks !! select * table1 id in(select id table2 (attribut, value) in ( (1,1), (3,3) ) group id having count(*)=2 )

c# - Nullable Bool in Getter Method -

the team discussing @ length how handle rather large account object. we don't want have initialize every property in constructor, overhead property might never used on web page. came following. public partial class account { private bool? projecho; public bool projectecho { { if (!projecho.hasvalue) { projecho = isprojectecho(); return (bool)projecho; } else { return (bool)projecho; } } } } this way, if using account object, , needs access property setter happens internally. aren't big fan of casting technique, way ensure have true/false value when code has ran. looks there wrong approach, seems efficient way have property filled in when need it. my question is: "is there better alternative achieve trying accomplish development standard perspective?" there's nothing wrong concept ...

c++ - Are there any issues reading directly into an std::string? -

i've seen in code direct read std::string contents intended interpreted string follows: std::string note; note.resize(n); read( &note[0], n ); assume n of fixed size, in parsing scenario. are there issues reading directly string? have seen lot of uses of ifstreams, seems excessive in case. first, if it's text file made several lines, find std::string class not choice "container"; prefer std::vector<char> , or if want additional parsing , break file single lines, std::vector<std::string> . i'd pay attention encoding used file: utf-8? other char -based encoding? for example, if file utf-16, reading raw sequence of bytes std::string misleading (and bug prone). moreover, it's important pay attention size of file. if have gigantic text file (e.g. 5gb) , building 32-bit windows application, code won't work (as 32-bit processes on windows limited 2gb default). in such cases, reading file content in smaller chunks (or ...

android - Unable to get key events for touchscreen keyboard from /dev/input/event1 -

i unable key events /dev/input/event1. i'm able filter out output absolute x , y touch coordinates event code 53 , 54. i'm confused why there's no output event code 1 when type on soft keyboard. want know key user presses , how pressure. hope understand problem. i'm on rooted samsung galaxy s4. because soft keyboard doesn't work that. isn't part of os, application. keyboard app given touch events, , call java functions tell main app pressed. doesn't go through hardware input channels @ after press. os doesn't know keys where, ever. most keyboards don't generate key events- generate word @ time output via committext. basically, can't want in way want. way know keys pressed, without altering os, on other side of inputconnection processing commands inputmethodservice (keyboard).

javascript - Why two arrays are "equal" for getter when they have the same values? -

i'd have custom getter , setter method object wraps map . somehow when use arrays key getter behaves equal when have same values. though 2 different references. (tested in ff , chrome). jsfiddle var cons = function (){ this.data = new map(); }; cons.prototype.initialisegetterandsetter = function initialisegetterandsetter(prop){ object.defineproperty(this, prop, { get: function(){ return this.data.get(prop); }, set: function(val){ this.data.set(prop, val); } }); }; var obj = new cons(); var arr1 = [1]; var arr2 = [1]; var arr3 = [2]; obj.initialisegetterandsetter(arr1); obj[arr1] = 1; document.getelementbyid('box1').innertext = obj[arr1]; // 1 expected document.getelementbyid('box2').innertext = obj[arr2]; // expected undefined got 1 document.getelementbyid('box3').innertext = obj[arr3]; // undefined expected as can see doesn't matter if pass getter same reference expecting. checks if has same values kind...

java - Using PowerMock with embedded Tomcat -

i'm trying mock static method called embedded tomcat instance. here test class: @runwith(powermockrunner.class) @preparefortest(externalapi.class) @powermockignore({"javax.management.*"}) public class testexternalapi { @before public void setup() { tomcat tomcat = new tomcat(); tomcat.setport(8080); tomcat.enablenaming(); tomcat.addwebapp("/app", new file("src/test/webapp").getabsolutepath()); tomcat.start(); } @test public void testapi() { mockstatic(externalapi.class); when(externalapi.getdata()).thenreturn(new data()); //call tomcat triggering call externalapi.getdata() } } with configuration following exception: java.lang.nosuchmethodexception: org.apache.catalina.deploy.webxml addservlet @ org.apache.tomcat.util.introspectionutils.callmethod1(introspectionutils.java:849) @ org.apache.tomcat.util.digester.setnextrule.end(setnextrule.java:201...

python - How to return the Index when slicing Pandas Dataframe -

df2= pd.dataframe(df1.iloc[:, [n n in random.sample(range(1, 7), 3)]]) returns df1 rows , selected columns returns generic index 0,1,2,3..etc instead of returning datetime index of df1 want keep. tried: df2=df1.copy(deep=true) df2= pd.dataframe(data=none, columns=df1.columns, index=df1.index) df2= df1.iloc[:, [n n in random.sample(range(1, 7), 3)]] but not work... try this: df2 = pd.dataframe(df1.ix[:,random.sample(range(1,7),3)]) this give result wanted. df1 out[130]: 1 2 d nan 4.0 b 2.0 2.0 c 3.0 3.0 1.0 1.0 df1.ix[:,random.sample(range(0,2),2)] out[131]: 2 1 d 4.0 nan b 2.0 2.0 c 3.0 3.0 1.0 1.0 this randomly sample columns , returns them in df2. return rows of randomly sampled columns index in df1. edit- maxu has suggested, can use: df2 = df1.ix[:, random.sample(df.columns.tolist(), 3)].copy() instead of calling pd.dataframe() constructor.

javascript - Control GIF animation with JS. Play, stop, play backwards -

what i'm trying achieve interactive animated logo. default it's on frame 1. when hovered, plays forward , stops @ last frame. on mouseleave plays last frame first (backwards) , stops @ first frame. if mouseleave during forward animation -> current frame , play backwards. i tried using canvas , sprites it's challenging. in fact don't understand it. tried this plugin , it's possibilities limited. so wondering if can using gif? maybe current animation frame , play gif backwards frame? yes, can control gif js lib, this: https://github.com/buzzfeed/libgif-js html: ``` <div id="controller-bar"> <button id="backward" href="#">|< step </button>&nbsp;&nbsp; <button id="play" href="#"> play | pause </button>&nbsp;&nbsp; <button id="forward" href="#"> step forward >|</button> </div> ``...

sql server - How to search max value from group in sql -

i learning sql, have question. -i have table name tabl -a variable :ccname has value " bottle " the table follows: +----------+---------+-------+--------+ | name | price | qty | code | +----------+---------+-------+--------+ | rope | 3.6 | 35 | 236 | | chain | 2.8 | 15 | 237 | | paper | 1.6 | 45 | 124 | | bottle | 4.5 | 41 | 478 | | bottle | 1.8 | 12 | 123 | | computer | 1450.75 | 71 | 784 | | spoon | 0.7 | 10 | 412 | | bottle | 1.3 | 15 | 781 | | rope | 0.9 | 14 | 965 | +----------+---------+-------+--------+ now want find code variable :ccname higher quantity! translated this: select code tabl group :ccname qty=max(qty) in perfect world turn result 478 . in sql world should write in order 478 ? try this select code tablename qty = (select max(qty) tablname name = :ccname)

html - Bootstrap CSS Align Text Middle Div -

Image
i have bootstrap row 3 columns. in middle column, there input field increasing height of row , throwing aligning text in first div @ top. i tried adding css align div text in middle wasn't working. .filteroption{ display: table-cell; vertical-align: middle; } my html basic , looks so: if(field.isinput == '1'){ output += '<div class="row">' + '<div class="col-md-2 filteroption">'+field.fieldname+'</div>' + '<div class="col-md-9"><input type="text" class="form-control" id="field_'+field.fieldid+'" name="field_'+field.fieldid+'" placeholder="'+field.placeholder+'"></div>' + '<div class="col-md-1"><button type="button" class="btn btn-danger btn-sm pull-right"><i class="fa fa-remove"></i></button></div>...

grails 3.0 - "IllegalArgumentException: Name must not be null" when deploying to jboss -

(i solved problem, posting here others.) i upgraded grails 2.4.4 grails 3. when deploying jboss eap 6.4 (wildfly 7), receive following error in server log , application fails start: 09-06 20:46:18,463 error [org.jboss.as.web.deployment.jbosscontextconfig] (serverservice thread pool -- 90) jbas018202: error calling onstartup servlet container initializer: org.springframework.web.springservletcontainerinitializer: java.lang.illegalargumentexception: name must not null @ org.springframework.util.assert.notnull(assert.java:115) [spring-core-4.2.5.release.jar:4.2.5.release] @ org.springframework.util.classutils.forname(classutils.java:214) [spring-core-4.2.5.release.jar:4.2.5.release] @ org.springframework.util.classutils.resolveclassname(classutils.java:284) [spring-core-4.2.5.release.jar:4.2.5.release] @ org.grails.transaction.chainedtransactionmanagerpostprocessor.resolvetransactionmanagerclass(chainedtransactionmanagerpostprocessor.java:158) [grails-core-3.1.5.ja...

networking - Will others be able to connect to a web server running on my laptop when it is connected to a public WiFi network? -

if run webserver on laptop, on public network such university's, other people on network able connect application through browsers? the project made flask, , running file code: from my_project import app if __name__ == '__main__': app.run(host='0.0.0.0', port=7000, debug=true, threaded=true) i run mysql database server stores data flask application. on workplace computer, other computers on network connect it, believe; same flask app. however, when developing on laptop on public network, others able connect, either flask web server or mysql database server? i'm not sure mysql server, on same wifi network able connect flask server. hosting on 0.0.0.0 (host on available ip addresses), allowing has ip address connect. however, people on other networks not able connect, since public wifi network hasn't port forwarded laptop. edit: if want develop web server on public wifi network, host on 127.0.0.1 instead. way, host computer able c...

linux - Virtualbox responding to SSH on vboxnet0 even when all guests are off -

i have macos host , virtualbox running kali linux guest. wanted set ssh host guest. didn't work (wrong password error). realised guest down, getting same error. output of ifconfig on host: ``` lo0: flags=8049<up,loopback,running,multicast> mtu 16384 options=3<rxcsum,txcsum> inet6 ::1 prefixlen 128 inet 127.0.0.1 netmask 0xff000000 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=1<performnud> gif0: flags=8010<pointopoint,multicast> mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863<up,broadcast,smart,running,simplex,multicast> mtu 1500 ether 00:05:69:3c:69:5f inet6 fe80::205:69ff:fe3c:695f%en0 prefixlen 64 scopeid 0x4 inet 172.26.88.44 netmask 0xfffff000 broadcast 172.26.95.255 nd6 options=1<performnud> media: autoselect status: active en1: flags=963<up,broadcast,smart,running,promisc,simplex> mtu 1500 options=60<tso4,tso6> ether 72:00:00:44:ee:70 media...

linux - Flush specific Redis DB using a single command -

in order flush specific redis database, need following: enter redis interactive cli ( > redis-cli ) select database ( > select 0 ) flush db ( > flushdb ) but there way run these 2 interactive commands single shell command? can pass 1 command interactive application using pipe: "echo select 0" | redis-cli , not both of them. you can select database call cli using -n switch. for running more 1 command, redirect file instead of piping echo, or feed cli raw protocol --pipe switch.

ios - Unable to change the primary language on iTunes Connect -

Image
when creating application accidentally selected spanish primary language. now, in app information on itunes connect when try change primary language "english" following: i have added screenshots. don't understand why not letting me change primary language english. as per apple guidelines: how can change app's default language? change default language of app, select added language primary language dropdown menu in app information section under app store. add new language, new binary must submitted , reviewed. if localize app, customers need have localized language set in os. if app not include localization set os language, app reverts designated default language. offering app in more default language can reach additional customers , increase number of app downloads. how can edit localization information language have added app? edit localization shared metadata, select language language menu in app information section under app store. edit lo...