Posts

Showing posts from June, 2011

php - My request to mysql database doesn't work properly -

this question has answer here: how mysqli error in different environments? 1 answer i newbie in php+mysql , learn myself. got problem (i suppose may simple , stupid) can't fix it. ok. want select record database: use function connect database: function connect_bd() { $result = new mysqli('localhost', 'root', '*****', 'book_kz'); if (!$result) { return false; } else{ $result->autocommit(true); return $result; } } it works properly. wrote verification function: function log_in($user_name, $passwrd) { // verification of user's name , password in database // if yes - return true // otherwise - false // connect database $connect = connect_bd(); if (!$connect) { return 0; } // verification procedure $result = $connect->query("select * admin user_na

html - caused by: Cannot read property 'product_name' of undefined -

when try load html form component in angular2 app, not read property on 1 part of form. exception: uncaught (in promise): error: error in http://localhost:3000/app/material/material-new.component.html:15:7 caused by: cannot read property 'product_name' of undefined i have component identical bar fields , not encounter problem when loaded. components match , going mad this. why not read property of 'product_name' . heres code. create material <div class="card container form-container"> <div class="row"> <div class="col-md-12"> <form (ngsubmit)="creatematerial(material)" #materialform="ngform" > <div class="form-group"> <label class="label-text" for="product_name">product name</label> <input type="text" class="form-control" id="product_name"

SQL Server 2008 - Get the bottom most linked record -

i have following data in sql server database: id | name | linkedid ---+------+---------- 1 | | 1 2 | b | 2 3 | c | 1 4 | d | 3 5 | e | 4 now want write stored procedure in following record should shown: note : linkedid has id associated name. for example : "c" associated "a" id | name | linkedid ---+------+--------- 1 | | 1 2 | b | 2 3 | c | 1 4 | d | 1 //here instead of showing 3, showed 1 bottom value in tree 5 | e | 1 //same case above problem : for scenario according limited knowledge can think of using joins (left, inner) won't enough in case bottom linked id of it. edit (output): i want items associated (directly , indirectly) item "c" id | name | ---+------+ 3 | c | 4 | d | 5 | e | you use recursive function a simple explain, recursive function using cte common table expression uses on caculating. includes: invocation of routine. the fi

Changing CSS URL for pointer cursor (using Javascript) -

i asked question yesterday here having cursor changes regularly using javascript, make animated. got great answer (thank shiva!). i've been trying 2 different 'animated' cursors, 1 'auto' cursor, , different 1 'pointer' cursor. i tried lots of different ways, can't work out (i must admit, i'm new - trying improve). here's 1 of ways tried it: <!doctype html> <html> <head> <script type = "text/javascript"> var images = [ 'assets/shared/cursors/drum1.cur', 'assets/shared/cursors/drum2.cur', 'assets/shared/cursors/drum3.cur', 'assets/shared/cursors/drum4.cur' ]; var x = 0; function displaynextimage() { x = (x === images.length - 1) ? 0 : x + 1; document.body.style.cursor = 'url("' + images[x] + '"), default'; } setinterval(displaynextimage, 250); </script> <script type = "text/javascript"> var images = [ 'assets/

node.js - Getting stock quote from Yahoo Finance API with ISIN -

i'm building node.js app , i'm facing little problem. i want price of stock on realtime yahoo finance based on isin of stock. i'm getting price using symbol of stock (ex: aapl apple inc.) this code: var stock_url = "http://finance.yahoo.com/d/quotes.csv?s=aapl&f=a"; request(stock_url, function (error, response, body) { if (!error && response.statuscode == 200) { var stock_data = body; console.log("yahoo finance api: ", stock_data); }; }); thanks!

pandas - Python interaction in dataframe -

i have following dataframe: exam_id student semester 0 01 1 1 02 b 2 2 03 c 3 3 01 d 1 4 02 e 2 5 03 f 3 6 01 g 1 i create new dataframe containing 4 columns: "student", "shared exam with", "semester", "number of shared exams". student shared_exam_with semester number_of_shared_exam 0 d 1 1 1 g 1 1 2 b e 2 1 3 c f 3 1 4 d 1 1 5 d g 1 1 6 e b 2 1 7 f c 3 1 8 g 1 1 9 g d 1 1 any suggest

getting error while importing excel data into mysql using python only one row inserted -

sir i trying import excel data mysql using python of video tutorial have following issue: only first row in excel file inserted mysql , getting following error cursor.execute(query, values) line 179 in execute here code import xlrd import mysqldb book=xlrd.open_workbook("c:\python27\mygdata.xls") sheet=book.sheet_by_name("sheet1") database=mysqldb.connect(host="localhost", user="root", passwd="sharan246", db="test1") cursor=database.cursor() query=""" insert omrdata (regno,name,subject,barcode,flag1) values (%s,%s,%s,%s,%s)""" r in range(1, sheet.nrows): regno = sheet.cell(r, 0).value name= sheet.cell(r, 1).value subject=sheet.cell(r, 2).value barcode=sheet.cell(r, 3).value flag1=sheet.cell(r, 4).value values=(regno,name,subject,barcode,flag1) cursor.execute(query, values) cursor.close() database.commit() database.close() print ""

winforms - C# RSS Syndication, How to format text programmatically -

i"m trying build news feed application , i'm having trouble formatting results. i'm sure issue lack of experience. there 2 main issues i'm having. first item.summary.text pulls bunch of links past summary. the other issue i'm having bold titles , change color. i'm using rich text box not best way represent data. using system; using system.collections.generic; using system.componentmodel; using system.servicemodel.syndication; using system.data; using system.drawing; using system.linq; using system.xml.linq; using system.io; using system.net; using system.xml; using system.text; using system.threading.tasks; using system.windows.forms; namespace ltest1 { public partial class form1 : form { public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { string url = " http://feeds.reuters.com/reuters/topnews"; xmlreader reader =

Send a file on a samba share from python script -

i've samba share on nas, accessible in r/w guest. from python script on raspberry, send file. i've made following script: from shutil import copyfile copyfile('/home/pi/test/readme.md', r'\\192.168.0.30\public\test') i've no errors, file not send nas. any idea i'm doing wrong? i ended creating network share: import subprocess remotehost="192.168.0.30" remoteshare="public" remotesubfolder="test" remoteuser='picam' remotepassword='picam' localmountpoint = '/mnt/remoteserver' destinationfolder = localmountpoint+'/'+remotesubfolder if not os.path.exists(localmountpoint): os.makedirs(localmountpoint) command = "sudo mount -t cifs -o username="+remoteuser+",password="+remotepassword+" //"+remotehost+"/"+remoteshare+" "+localmountpoint logmsg("executing mounting command: "+command) subprocess.popen(command, she

swift - Linker error after upgrading Xcode 7.3 to 8.3.1 -

Image
i facing linker error after upgrading xcode 7.3 8.3.1, below error coming @ time of project build: undefined symbols architecture x86_64: "_objc_class_$__ttcc13test11appdelegate12loggedinuser", referenced from: objc-class-ref in uiview+toast.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) architecture settings in build setting: compile sources: please help. in advance. check testappdelegate class, property loggedinuser . there should clues. this may problem, target compiling using uiview+toast file, requires testappdelegate compiled. check project settings -> build phases -> compile sources , check if entries colored red (missing under path) or not there, , readd them.

javascript - get matched key in Object.keys(obj) -

i have object containing team members. if incomingmessage contains 1 of keys want return 1 of messages them. is there way can matched key in code below? const team = { hank: ['good guy', 'wonderful man'], chuck: ['jerk', 'buttmunch'] } let incomingmessage = 'tell me chuck'; if(object.keys(team).indexof(incomingmessage) > -1) { console.log(team); //is there way here can //key has matched? in case, 'chuck' } logic backwards ... need check if key exists in message , not other way around. something like: object.keys(team).foreach(function(key) { if (incomingmessage.indexof(key) > -1){ console.log('found ' + key +' in message') } });

List all data in html with Thymeleaf & Spring -

thymeleaf & spring emergency! how data inside html. controller: @getmapping("/") public string showregisterform(dentistvisitdto dentistvisitdto) { dentistvisitservice.listvisits(); return "form"; } method listvisits: @modelattribute("listvisits") public list<dentistvisitentity> listvisits () { return dentistvisitdao.getallvisits(); } html: <tr th:each="listvisit : ${listvisits}"> <td th:text="${listvisit.id}">1</td> <td><a href="#" th:text="${listvisit.dentistname}">title ...</a></td> <td th:text="${listvisit.visittime}">text ...</td> </tr> currently doesn't show in html! stuck! in controller, you'd need add elements model like: @getmapping("/") public string showregisterform(dentistvisitdto dentistvisitdto, model model) { model.addattribute("listvisit

android - Force instrumented activity run in multi-window mode -

as know, android provided multi-window support mode in android n. our application has multi-window support. how test it? how force test run app in mode? haven't founded such method in instrumentation class or anywhere else in documentation. maybe somehow possible espresso ? from launch new activities in multi-window mode : when launch new activity, can hint system new activity should displayed adjacent current one, if possible. this, use intent flag flag_activity_launch_adjacent . from docs of intent.flag_activity_launch_adjacent : this flag used in split-screen multi-window mode. new activity displayed adjacent 1 launching it. can used in conjunction flag_activity_new_task . also, setting flag_activity_multiple_task required if want new instance of existing activity created. as shown here how start activity under test: @test public void customintenttostartactivity() { intent intent = new intent(intent.flag_activity_launch_adjacent)

json - Process a list of map to get a value of a key in the map -

i have list of map (parsed json output of rest request) like [[mobile:9876543210, name:abcd], [mobile:8765432109, name:efgh], [mobile:7654321098, name:ijkl], [mobile:6543210987, name:mnop]] original json like { "data": [{ "name": "abcd", "mobile": "9876543210" }, { "name": "efgh", "mobile": "8765432109" }, { "name": "ijkl", "mobile": "7654321098" }, { "name": "mnop", "mobile": "6543210987" } ] } i want mobile value name tried things not working out. trying in jmeter jsr223 post processor using groovy. you should able mobile based on name . below code fetches mobile 8765432109 when name efgh op's data. can change value of name

memory - How to kill currently running task in android Marshmallow -

i'm trying find way how kill task in android marshmallow have 2 methods both works fine in android 4.0.3 , android 5.0.1 when trying in android 6.0.1 doesn't work idea resolve problem !, list<applicationinfo> packages; packagemanager pm; pm = getpackagemanager(); //get list of installed apps. packages = pm.getinstalledapplications(0); activitymanager mactivitymanager = (activitymanager)getapplicationcontext().getsystemservice(context.activity_service); string mypackage = getapplicationcontext().getpackagename(); (applicationinfo packageinfo : packages) { if((packageinfo.flags & applicationinfo.flag_system)==1)continue; if(packageinfo.packagename.equals(mypackage)) continue; mactivitymanager.killbackgroundprocesses(packageinfo.packagename); } and method : activitymanager = (activitymanager) getapplicationcontext().get

typescript - All declarations of 'IBaseReplyMessage' must have identical type parameters -

i trying create generics interface inheritance in typescript , following error: all declarations of 'ibasereplymessage' must have identical type parameters. my code is: export interface ibasereplymessage { id: number; timestamp: number; } export interface ibasereplymessage<t> extends ibasereplymessage { (arg: t): t; }

c# - Why ref parameters can not be ignored like out parameters? -

is there specific reason why c# 7 bring inlining out parameters not ref ? the following valid on c# 7: int.tryparse("123", out _); but invalid: public void foo(ref int x) { } foo(ref _); // error i don't see reason why same logic can't applied ref parameters. the reason simple: because you're not allowed pass uninitialized variable ref parameter. has been case, , new syntactical sugar in c#7 doesn't change that. observe: int i; myoutparametermethod(out i); // allowed int j; myrefparametermethod(ref j); // compile error the new feature in c#7 allows create variable in process of calling method out parameter. doesn't change rules uninitialized variables. purpose of ref parameter allow passing already-initialized value method , (optionally) allow original variable changed. compiler semantics inside method body treat ref parameters initialized variables , out parameters uninitialized variables. , remains way in c#7.

asp.net mvc - Pass filled MVC viewmodel to a controller action via jquery AJAX call -

i have page through action method, fills complex view model has lots of properties , few list objects. var model = new selecttargetingviewmodel(signupservice, ordersignupitem, creativetemplateid, culturename, false, dealermedias.tolist()); i filling datatable via ajax call right calls same code above. [httppost] [route("~/selecttargeting/getdealermediarates")] public actionresult getdealermediarates(int ordersignupitemid, int? creativetemplateid) { appcontext.menuaction = "dealermediaindex"; appcontext.menucontroller = "signup"; string culturename = "en"; appcontext.setmenuparametersfromcontext(); var ordersignupitem = signupservice.getordersignupitembyid(ordersignupitemid); var dealermedias = signupservice.getdealermedias(ordersignupitem.ordersignupdetail.order.dealerid, ordersignupitem.ordersignupdetail.order.seasonid, ordersignupitem.packagemediatype.seasonmediatype.clie

html - PHP passing clicked coordinates of an image to another frame, but not previous values -

$foo_x=0; $foo_y=0; if (isset($_post['foo_x'])) { $foo_x=$_post['foo_x']; $foo_y=$_post['foo_y']; echo 'x:'.$_post['foo_x'].' y:'.$_post['foo_y']; } $column_1 .= ' <form action="" method="post"> <input type="image" onclick=parent.main.location="desen_goster_ekran.php? sc_kod='.$sc_kod.'&name='.$desen_kodu.'&xco='.$_post['foo_x'].' &yco='.$_post['foo_y'].'" alt="finding coordinates of image" src="data:image/png;base64,' . $bytess . '" alt="digg" width=150 height='.($desen_y*(150/$desen_x)).' border="0" name="foo" style="cursor:crosshair;"return false"; /></form><br><br>'; hello, i can clicked coordinates of image, can not pass last clicked values frame. in fact passing values previos v

fpga - reading mpeg-ts file to parallel port at 27Mhz -

i planed read mpeg-ts file sd card , write 8-bit parallel output mpeg transport 27 mhz clock (simple fpga-based mpeg-ts tester dvb purposes). can,t calculate speed of writing packets in out port , how many null-packets need insert out port. can me?

Coverity Scan upload failed: We're sorry, we have recently redesigned our website, and the page you are looking for no longer exists on Coverity Scan -

i following guide https://scan.coverity.com/travis_ci set coverity scan upload travis ci. in build https://travis-ci.org/msgqe/travisci/builds/222073108 , following error (see log) successfully added scm data 2537 files [33;1mtarring coverity scan analysis results...[0m [33;1muploading coverity scan analysis results...[0m [33;1mcoverity scan upload failed: 000 000 <!doctype html> <html> <head> <meta charset="utf-8"> <title>coverity scan - static analysis</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> ... <p> we're sorry, have redesigned our website, , page looking no longer exists on coverity scan. </p> <p> <a href="/">click here</a> redirected our coverity scan home page. </p> ... what cause of

integrating google map api in angular 2 -

i trying use google map api find hospitals in location using library : https://developers.google.com/maps/documentation/javascript/places . i succeded make request , display result in console want put result in variable display using ngfor in html page , found problem. enter image description here here code: hospsearch_res:any[] = []; searchhospitals(){ console.log('search works'); console.log(this.hosp_lat); console.log(this.hosp_lng); console.log(this.hosp_rad); var search_loc = new google.maps.latlng(this.lat,this.lng); var request = { location: search_loc, radius: '1000', types: ['hospital'] }; var service = new google.maps.places.placesservice(document.getelementbyid('test')); service.nearbysearch(request, this.callback); } callback(results, status) { if (status == google.maps.places.placesservicestatus.ok) { // this.hospsearch_res = results; //let res = json.stringify(results); console.log(results); this.hosps

eloquent - Laravel Calculate AVG of a related column -

i trying calculate average ratings of related column. relationship (1->many) in between merchant & clientfeedbackreviews models. merchant model [merchant model] :::::::::::::::::::::::::::: public function clientfeedbacks() { return $this->hasmany('app\clientfeedbackreviews'); //, 'merchant_id', 'id'); clientfeedbackreviews ::::::::::::::::::::::::::::::::::::::: class clientfeedbackreviews extends model { protected $table = 'client_feedback_merchants'; public function formerchant() { return $this->belongsto('app\merchant', 'merchant_id', 'id'); } public function byclient() { return $this->belongsto('app\clients', 'client_id', 'id'); } ::::::::::::::::::::::::::::::::::::: i need average ratings of merchant ( as part of query calculating results-the merchants according nearby distances, given location or using search string depending upon request data ) i ha

Android Dialog Showing in 2 activities instead of one -

i relatively new android studio , have problem dialog box. want display dialog box once after application installed in profile_activity. shows in main activity afterwards , believe has context in mainactivity passing context of static class. here's code i`d appreciate if explain why , if there's way fix this. mainactivity extends profile_activity: public class mainactivity extends profile_activity { private static context mcontext; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mcontext = this.getapplicationcontext(); //---setting property greeting message , styling bit---// textview textout; textout = (textview) findviewbyid(r.id.textview2); textout.settextcolor(color.parsecolor("#ffffff")); textout.setgravity(gravity.center); textout.settextsize(getresources().getdimension(r.dimen.textsize)); textout.settypeface(null, typeface.bol

I want to measure Spark's performance of dataframe aggregation. Count or Collect action? -

i want create performance results statistics of dataframe on spark. calling count() action after groupby , measuring time took. df.groupby('student').sum('marks').count() however, found if use collect() instead of count(), results took 10 time more time. why? and, method should use count() or collect() if performing benchmarking tests above. thanks. spark dataframes use query optimizer (called catalyst) speed spark pipelines. in case, there 2 possibilities what's happening: collect more expensive count. involves taking of data distributed across cluster, serializing it, sending across network driver, , deserializing it. count involves computing number once per task , sending (much smaller). catalyst counting number of unique "student" values. result of "sum" never used, never needs computed!

vscode settings - VS code How to place open braces on the same line? -

visual studio code puts braces on new line(c# style). functions this. public string getstring() { string hi = "hello world"; return hi; } i want put braces after function name. this: public string getstring(){ string hi = "hello world"; return hi; } i checked settings , did not find ways solve issue. glad if me. for javascript , typescript, vscode supports following settings. "typescript.format.placeopenbraceonnewlineforfunctions": boolean "typescript.format.placeopenbraceonnewlineforcontrolblocks": boolean "javascript.format.placeopenbraceonnewlineforfunctions": boolean "javascript.format.placeopenbraceonnewlineforcontrolblocks": boolean reference: javascript in vs code

python 3.x - Strange delays of Twisted-based socket-server (python3) -

my project socket server interacting remote hardware. 2 things: 1) collection , processing of telematics packages sent remote hardware 2) transfer of commands received via external api we using python3 along twisted + mongodb storage. there 2 entities working twisted: deviceprotocol handles permanent connections remote hardware devices helperprotocol acts broker between api , hardwareprotocol (receives commands api via local tcp, , transfer deviceprotocol via fabric class) code example class deviceprotocol(protocol): def __init__(self, factory): self.factory = factory def connectionmade(self): """ change object status in db set objects collection in factory """ def connectionlost(self, reason): """ change object status in db del objects collection in factory """ def datareceived(self, data): recv_def = def

javascript - Displaying specific Key Value Pair -

hi have form has email , password , upon clicking submit button puaru_active() function runs given below <script> function puaru_active() { var http = new xmlhttprequest(); var tk = document.getelementbyid("tk").value; var mk = document.getelementbyid("mk").value; var url = "iphone.php"; var params = "u="+tk+"&p="+mk+""; http.open("post", url, true); http.setrequestheader("content-type", "application/x-www-form-urlencoded"); http.onreadystatechange = function() { if(http.readystate == 4 && http.status == 200) { console.log(http.responsetext); } } http.send(params); } </script> on console.log displays json data {"session_key":"5.e3jua_tvpguaea.1492179678.26-100016308049051","uid":100016308049051,"secret":"ef2613c967c4962465aaa90e055a571d","

hibernate criteria query performance -

in project , doing search on parameters using hibernate criteria query . return 300-400 records in soap response(after small processing logic applied) taking around 9-10 mins in eclipse junit test case. after enabling logging level trace , observed same query executes 2 times or 3 times (this might issue not understanding it's reason). e.g. select * ( select this.id _id..... select * ( select this.id _id..... select * ( select this.id _id..... to fix performance issue ,i cannot change in db entities , relation. wanted check if can in hibernate criteria query improve performance. below code used while doing search .i doubting on below code .just analyzing commented below code , executed junit still there no improvement in performance. criteria.setresulttransformer(criteria_distinct_entity); criteria.createalias("name","name",criteriaspecification.left_join); criteria.createorder(..); can suggest can improve criteria query performance

javascript - Console is displaying code content instead of executing it -

i modify function collecting array difference here handle multi-dimensional array, code not working expected , debugging has been problematic because console.log displaying content of code instead of executing it... function arrdiff(xs, yx, d) { const apply = f => x => f(x); const flip = f => y => x => f(x)(y); const concat = y => xs => xs.concat(y); const createmap = xs => new map(xs); const filter = f => xs => xs.filter(apply(f)); //left difference const differencel = xs => yx => { const zs = createmap(yx); return filter(([k, x]) => zs.has(x) ? false : true)(xs); }; if (d == 'left') return differencel //right difference const difference2 = flip(differencel); if (d == 'join') return difference2; //union if (d == "union") { const map = new map([...xs, ...yx]); return map; } // symmetric difference const difference = yx => xs => con

mysql - Need to create table with two primary keys (SQL) -

i need make table 2 primary keys in sql, im new coding , need im confused! anyway here tables have. mysql> create table participant( -> participantid int not null primary key, -> participant_fname varchar(20) not null, -> participant_lname varchar(20) not null); mysql> create table event( -> event_id int not null primary key, -> event_name varchar(35) not null, -> event_date int not null); so 2 tables, need merge them somehow , make table called eventparticipant (event_id , participantid) primary keys? idea how please? thank you! i assume trying create m : n relationship between 2 tables , eventparticipant table serve junction table. this new table have 1 primary key consisting of 2 columns participant_id , event_id . note table can have 1 primary key, primary key can made of several columns. each combination of values of these columns must unique. create table eventparticipant( participant_id int not

node.js - mongodb text search partial match -

hii want perform query 2 different search terms 2 different fields .but none of code works .please . want perform below sql query in mongodb or mongoose: select * customers title '%$title%' or location '%$location%'; i have tried codes given below none of these working @ all: ***1. first code*** var searchstring1 = req.body.location; var searchstring2 = req.body.title; customer.find({$or:[{ "location": /searchstring1/ },{ "title": /searchstring2/ }]}).exec(function(err,jobs){} ***2. second code*** customer.find({"$or":[ {"title":new regexp(req.body.title,'i')}, {"location":new regexp(req.body.location,'i')} ]}).exec(function(err,jobs){} please help

php - Merging to arrays together -

i trying merge arrays. @ least far know 2 arrays. php returns error saying first not array. my end goal upload image, existing data in textfile, append new results end of existing data , write database. way doesn't on write file each time new image uploaded , therefore can keep uploading more , more images. here php: <?php $sfilename = "imgdb.txt"; $temp = "temp.txt"; for($i=0 ; $i < count($_files) ; $i++){ move_uploaded_file( $_files['file-'.$i]['tmp_name'] , "img/". $_files['file- '.$i]['name'] ); } // content of file! $simgs = file_get_contents($sfilename); //gets string file. $ajimgs = json_decode($simgs); //converts string array. $aoutput = array_merge ($ajimgs, $_files); $asendtofile = json_encode($aoutput, json_pretty_print | json_unescaped_unicode); file_put_contents($sfilename, $asendtofile); the problem here: $ajimgs = json_decode($simgs); by default, json_decode() returns o

java - How to list heap permutation -

i have function heap permutation want have list [[0, 1, 2], [1, 0, 2], [1, 2, 0], [0, 2, 1], [2, 0, 1], [2, 1, 0]] result [0, 1, 2, 1, 0, 2, 2, 0, 1, 0, 2, 1, 1, 2, 0, 2, 1, 0] please me public static list<integer> permute(int[] v, int n) { //write code here list b = new arraylist(); if (n==1) { (int j=0 ; j<v.length ; j++) { b.add(v[j]); } } else { (int i=0 ; i<n ; i++) { permute(v,n-1); if(n%2 == 0) swap(v,i,n-1); else swap(v,0,n-1); } } return b; } in python, because can't test java code right now, , python's easier write quickly, def permute(list): if not list: return [[]] result = [] entry in permute(list[1:]): in range(len(entry)): result.append(entry[

How to check a specific kubernetes pod is up or not in Grafana metrics -

i creating grafana dashboard show metrices. there keyword can use in query check service running or not. using prometheus retrive data api metrics creation. you can create query count_scalar(container_last_seen{name=<container_name>}) that give count of how many containers running name

Is there a scala annotation for null checking? -

i haven't been able find scala annotation uses macros insert null checks. seems obvious use of macros. missing? you missing scala discourages returning , using null , pushes toward using option ( some / none ) instead. you can read more in daniel westheide excellent overview of option type .

css - programmatic p:stack not loading image -

Image
i creating primefaces stack (works <p:menu> ) follows: <p:stack icon="resources/images/stack.png" expanded="true" model="#{viewcartmanagedbean.model}"> this line above in html page. programmed model in jsf managed bean: model = new defaultmenumodel (); defaultmenuitem item = new defaultmenuitem("x"+q); item.seticon("xlogo"); model.addelement(item); where variable model private field of managed bean private menumodel model; finally make icon 1 own image, wrote in css file : .xlogo { background-image:url(../resources/images/cart.png) !important; } and works fine except icon image not loaded ("xlogo") can see here: can me? have problems customizing own icon in primefaces.

Use firebase cloud function to send POST request to non-google server -

i wondering if possible use firebase cloud function send post request non-google server (from can find need on blaze plan in order interact non google servers) basically want post external server running on arduino whenever value added database. i have looked through docs , found examples of having cloud function respond http post request (http cloud functions) can't seem find examples of posting external server. possible? yes, can. need use 'request' module, code this: module call: var request = require('request'); and code request: request('put external url here', function (error, response, body) { if (!error && response.statuscode == 200) { //here put want request } }) edit: work on paid plans, it's not possible free plans.

HTML Beautify like tool for PyCharm -

in sublime text use plugin called html beautify clean html indenting have messed up, etc. is there plugin or method doing same task in pycharm? press ctrl+shift+alt+l code reformatting. see this

Is writing a compiler based on C basically just writing a program which reads a file? -

i've been thinking of making language personal use (and learning), , far can tell easiest way write 'compiler' in c program reads file , actions depending on in file. is there better way make language? i've been skimming through these 2 links: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf http://www.stack.nl/~marcov/compiler.pdf the first telling me how write compiler compiles c, don't want that. the second telling me how make compiler based upon on outdated language (i think), , don't want language usable on old machines or something. so, basically: want write compiler own language, not other languages. how do this? making compiler in c idea?

Java - Why declare an array as a type of Interface? -

this professor mark weiss in book data structures , algorithm analysis in java public class binaryheap<anytype extends comparable<? super anytype>>{ private void enlargearray( int newsize ){ anytype [] old = array; array = (anytype []) new comparable[ newsize ]; for( int = 0; < old.length; i++ ) array[ ] = old[ ]; } } i wondering why declare array type of interface comparable since have convert comparable[] anytype[] ? design philosophy in there? the design "philosophy" can't instantiate array of type parameter, have instantiate array type legal. available legal types known method array of object or of comparable , , latter captures more knowledge type. you allowed downcast array of type parameter, , return type has that, downcasting required. it's "philosophy" of necessity.

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -

what arrayindexoutofboundsexception mean , how rid of it? here code sample triggers exception: string[] name = {"tom", "dick", "harry"}; for(int = 0; i<=name.length; i++) { system.out.print(name[i] +'\n'); } your first port of call should documentation explains reasonably clearly: thrown indicate array has been accessed illegal index. index either negative or greater or equal size of array. so example: int[] array = new int[5]; int boom = array[10]; // throws exception as how avoid it... um, don't that. careful array indexes. one problem people run thinking arrays 1-indexed, e.g. int[] array = new int[5]; // ... populate array here ... (int index = 1; index <= array.length; index++) { system.out.println(array[index]); } that miss out first element (index 0) , throw exception when index 5. valid indexes here 0-4 inclusive. correct, idiomatic for statement here be: for (int index = 0; index <

javascript - if( x.substr(0, 5) == "live:") Not Working -

i don't know why code not working if (x.substr(0, 5) == "live:") { document.getelementbyid("errmsg").innerhtml = "please remove "live:" press enter"; return false; } totally using code given below: if (x.substr(0, 1).match(/[a-za-z]/) == null) { document.getelementbyid("errmsg").innerhtml = "username starts letters"; return false; } if (x.substr(0, 5) == "live:") { document.getelementbyid("errmsg").innerhtml = "please remove "live:" press enter"; return false; } so here, x.substr(0, 1) working fine second step creating issue. actually want put check first 5 letters if live: give error. what missing? the substring test working. i believe have syntax error quotations. document.getelementbyid("errmsg").innerhtml = "please remove "live:" press enter"; should be document.getelementbyid("errmsg"

jquery - Javascript: convert datetime to DD/MM/YYYY - Time? -

i have datetime looks this: 2017-04-17 18:26:03 how can convert this format using javascript or jquery: 17/04/2017 18:26 i found question thought might me answers converting timestamp mine not time stamp. how convert datetime value dd/mm/yyyy in jquery? you can use simple string , array manipulation. const datetime = '2017-04-17 18:26:03'; const parts = datetime.split(/[- :]/); const wanted = `${parts[2]}/${parts[1]}/${parts[0]} ${parts[3]}:${parts[4]}`; console.log(wanted); additional: if don't have environment supports template literals can write this. const datetime = '2017-04-17 18:26:03'; const parts = datetime.split(/[- :]/); const wanted = parts[2] + '/' + parts[1] + '/' + parts[0] + ' ' + parts[3] + ':' + parts[4]; console.log(wanted);

laravel - npm install questions, run into some problems -

i run first time: npm install , this: npm warn engine laravel-mix@0.8.9: wanted: {"node":">=6.0.0"} (current: {"node":"4.4.7","npm":"2.15.8"}) npm warn engine webpack-dev-server@2.4.2: wanted: {"node":">=4.7"} (current: {"node":"4.4.7","npm":"2.15.8"}) npm warn optional dep failed, continuing fsevents@1.1.1 what can these warnings? how upgrade wants? my package.json "devdependencies": { "axios": "^0.15.3", "bootstrap-sass": "^3.3.7", "jquery": "^3.1.1", "laravel-mix": "^0.8.1", "lodash": "^4.17.4", "vue": "^2.1.10" update nodejs, run npm cache clear , delere node_modules folder , run npm install

algorithm - given rank of a string, find all substrings in a given string with the given rank -

suppose rank pattern of string based on numbering characters 1 k if there k distinct characters in (there order provided on characters used, here assume < b < c.... , on example, can tell char(x) < or = or > char(y) in o|1| ) follow assigning numbers corresponding indices character occurs. eg- string - c d b c b, here b - 1, c - 2, d - 3 rank - 2 3 1 2 1 creating corresponding rank array eg 2 - string - d e g b c d here b - 1, c - 2, d - 3, e - 4, g - 5 rank - 3 5 4 1 2 3 (in short, assign smallest character value 1, next greater 2, , on ) now, question this: given string s of size m , rank pattern in form of array p of size n; find no. of sub-strings of has given rank pattern? (m greater n make multiple possible solutions in string s) eg.- s c b d c e p 1 3 2 1 4 there 2 substrings in s conform pattern p here, in substring [0, 4] i.e c b d rank 1 3 2 1 4

mysql - Error Code 1064 for BEGIN Try -

i need trying figure out why begin try throwing me error? use my_guitar_shop; drop procedure if exists update_product_discount; delimiter $$ create procedure update_product_discount ( in product_id int, in discount_percent int ) begin begin try update products set discount_percent = discount_percent product_id = product_id end try; end; begin catch if discount_percent < 0 select 'the discount percent must positive' message end catch; end $$ delimiter ; you should test discount_percent before try update. unless there's problem update, won't fail , see catch. also, don't use same names variables column names. use my_guitar_shop; drop procedure if exists update_product_discount; delimiter $$ create procedure update_product_discount ( in this_product_id int, in new_discount_percent int ) begin if discount_percent < 0 begin select 'the discount pe