Posts

Showing posts from January, 2012

android - Is it possible to add extras to browsable intents from HTML -

let's take per following manifest: <intent-filter> <data scheme="myscheme" host="myhost"> </data> <action name="android.intent.action.view"> </action> <category name="android.intent.category.default"> </category> <category name="android.intent.category.browsable"> </category> </intent-filter> i launch activity under above intent filter declared redirecting browser to: myscheme://myhost?param1=param1&param2=param2 however, i'm struggling understanding if possible same redirection, additional extras received programmatically with: myextra = getintent().getstringextra('myextra') any appreciated. this how overcome issue, i developed own browser , made browsable do uri data = getintent().getdata(); if(data == null) { // opened app icon click (without link redirect) toast.maketext(this, &q

google analytics - userId not showing up in BigQuery -

what can reason userid null in bigquery? data analytics sent bigquery userid not passed along. userid sent ga reason not available in bigquery? i operating under assumption field intentionally held out ga -> bq extracts based on following: https://support.google.com/analytics/answer/6205850?hl=en#limits of particular note, line " the user id value can not queried dimension in reports in either web interface or apis ". take mean never leave confines of ga, including bq. i have not been able null in tables either. sorry not have better news you!

refresh - How to make site redirect to same page before refreshing - PHP -

i trying make user redirect #contact page before refreshing. when clicking send message site goes first page , have scroll way down #contact page , 5 seconds later refreshes first page (which good). code below: php <?php if($_post['submit']){ if(!$_post['name']){ $error= "<br/>-please enter name" ; } if(!$_post['email']){ $error.= "<br/>-please enter email" ; } if (trim($_post['message']) == "") { $error.= "<br/>-please enter message"; } if(!$_post['contact']!=$match){ $error.= "<br/>-please enter contact number" ; } if ($error){ $result= "whoops, error: $error"; } else{ mail('mahdi.mashrafi@yahoo.com', "contact message", "name: ".$_post['name']." email: ".$_post['email']." email: ".$_post['n

javascript - how to print value regular interval of time? -

i using closure in java script print 1-10 value after each 2 sec.in other words first print 1 wait 2 second print 2 .i used closure nothing work . here code. for (var = 0; < 10; i++) { (function (index) { settimeout(function () { console.log(i); }, 2000); })(i); } use setinterval : function loopwithdelay(callback, delay, max, min) { var = min || 0; if (i <= max) { var id = setinterval(function() { callback(i); if (++i > max) clearinterval(id); }, delay); } } loopwithdelay(function(i) { console.log(i) }, 2000, 10); or use recursive settimeout : function loopwithdelay(callback, delay, max, min) { var = min || 0; if (i <= max) { settimeout(function() { callback(i); loopwithdelay(callback, delay, max, ++i); }, delay); } } loopwithdelay(function(i) { console.log(i) }, 2000, 10);

javascript - Using jQuery JSON function to populate textarea when a specific dropdown item is selected -

i might sound noob, me this? i have form dropdown select , within lot of text area boxes. what need: when specific option selected, i'd populate text area text (using json). code: html <label>name</label> <select> <option value="0" data-num="">name lastname</option> <option value="1" data-num="">name lastname</option> <option value="2" data-num="">name lastname</option> <option value="3" data-num="">name lastname</option> </select> <textarea name="name"></textarea> <textarea name="applicant"></textarea> <textarea name="applicant_en"></textarea> <textarea name="email"></textarea> <textarea name="vat"></textarea> <textarea name="rc"></textarea> json data { "id":["1&quo

html - Setting up a JavaScript that writes whether the store is Open or Closed -

i'm trying setup basic javascript, if day sunday or saturday, write "closed" in html, or if it's later 5:30pm, or it's earlier 9:00am, write out closed. my main problem if statement seems return true. i've tried multiple things fix , no avail. appreciated. code: http://pastebin.com/r5ke6fx6 this not complete answer, more advanced comment on code styling. your if statements complicated, still dont understand them. improve code make more readable. makes easier , improve it. example: status="opened"; if(date=="wednesday"){ if(time>closetime){ status="closed. late"; } if(time<opentime){ status="closed. youre early"; } } else { //code other dates } //echo code document.write(status);

algorithm - Java: priority queue (or min-heap) with O(log n) deletion of arbitrary node -

i've got bunch of items i'm storing in min-heap (via priorityqueue), , have need efficiently delete arbitrary items. know in standard min-heap implementation, deleting arbitrary element (given know position of element in heap) takes o(log n) time, while finding position o(n). so, basically, need keep separate data structure holds each item's position in heap. i more-or-less know how i'd implement scratch. i'm wondering if there's smart way utilize/subclass priorityqueue (which has other useful features) accomplish this. update: clarify, need o(1) peek-min pq/min-heap affords.

c++ - Searching std::vector of class objects by class attribute (eg. name) -

is there difference performance/safe-wise inspecting vector elements using for loop iterators vs. std:find_if(...)? 1. loop // 1. loop (llvm::smallvectorimpl<myclass>::const_iterator = v.begin(); != v.end(); ++it) { if (it->getname() == name) { // found element // smth... break; } } vs. 2. std:find_if // 2. find if llvm::smallvectorimpl<myclass>::const_iterator = std::find_if(v.begin(), v.end(), stringcheck<llvm::stringref>(name)); if (it != v.end()) { // found element // smth... } // stringcheck defined in header... template <class t> struct stringcheck{ stringcheck(const t &s) : s_(s) {} bool operator()(const myclass &obj) const { return obj.getname() == s_; } private: const t &s_; }; your for-loop continues iterating after match found. thing if multiple matches possible , want run code ea

html - Positions off in different browsers -

Image
i have oval positioned lower on right (safari) left (chrome) if carefully. although quite minor, still know can fixed. <body> <div class="player"> <input type="button" id="specific" value="<?php echo $id; ?>" onclick='window.open("<?php echo $specific; ?>")'> //other stuff .player { position: relative; width: 600px; padding: 30px 10px 10px 10px; border-style: solid; border-radius: 20px; margin: auto; text-align: center; font-family: "arial"; } #specific { display: inline-block; position: absolute; top: -2px; left: 50%; transform:translate(-50%, -50%); padding: 5px 15px; cursor: pointer; border: none; border-radius: 20px; text-align: center; color: #fff; font-size: 15; }

c# - Group by linq for nested objects -

i making group linq statement convert single list of data list nested list. here code far: [testmethod] public void linqtestnestedselect2() { // initialization list<combi> listtolinq = new list<combi>() { new combi{ id = 1, desc = "a", name = "a", count = 1 }, new combi{ id = 1, desc = "b", name = "a", count = 2 }, new combi{ id = 2, desc = "c", name = "b", count = 3 }, new combi{id = 2, desc = "d", name = "b", count = 4 }, }; // linq group var result = (from row in listtolinq group new { des = row.desc, count = row.count } new { name = row.name, id = row.id } obj select new { name = obj.key.name, id = obj.key.id, descriptions = (from r in obj select new b() { des = r.des, count = r.count }).tolist() }).tolist(); // validation of results assert.areequal(2, result.count); assert.areequal

android - Handling ListView recycle (duplicate on scroll) -

i have listview dynamically added images. when user scrolls down list, rows duplicates , shows wrong items + losing layoutparams setting. how can solve problem? here getview code: public view getview(int position, view view, viewgroup parent) { view rowview = view; viewholder viewholder = new viewholder(); if (rowview == null) { layoutinflater inflater = ctx.getlayoutinflater(); rowview = inflater.inflate(r.layout.list_row, null, true); viewholder.linearlayout = (linearlayout) rowview.findviewbyid(r.id.ll_row); viewholder.textview = (textview) rowview.findviewbyid(r.id.textview_row); rowview.settag(viewholder); } else { viewholder = (viewholder)rowview.gettag(); } imageresourseid = new arraylist<>(arrays.aslist(convertstringtoarray(imagenames.get(position)))); (int = 0; < imageresourseid.size(); i++) { linearlayout.layoutparams param = new linearlayout.layoutparams( 0,

sql server - Display all months even if values are NULL -

good day! working on chart need display months in year show sales per month. far, able display month there corresponding values. here stored procedure query far. select (datename (month, dateadd ( month, datepart(month, order_date), -1) )) month_name, sum ([order].net_amount) total_sales [order], order_details [order].order_id = order_details.order_id --and (datename (month, dateadd ( month, datepart(month, order_date), -1) )) = (datename (month, dateadd ( month, datepart(month, @order_month), -1) )) group month([order].order_date) order month_name it displays 1 month , sales month. can me out on this? in advanced! at first please use proper join syntax , aliases. you can create cte months , cte output , join them: ;with mcte ( select cast('2016-01-01' datetime) month_name union select dateadd(month,1,month_name) mcte datepart(month,month_name) < 12 ), octe ( select (datename (month, dateadd ( month, datepart(month,

javascript - How to make async wrap-function for async function? -

i have 'func1' wraps async 'func2' like: func1 = function(arg1) { func2 (arg1, function(result) { // parse , return parts of 'result' }, function(error) { alert (error.message); }) } how make 'func1' async (for external code). function wrapper(callback) {//async callback standard libs func1(arg1);//call original func1 defined. callback(); //first arg error, second result (you don't have result empty) }

mysql - Create databases from SQL file -

i'm working mariadb, have user following : user : aimad password : test and want execute command in cmd following : mysql –u aimad –ptest < create.sql in create.sql file have : create database `db_test_analyse` ; create database `db_backend` ; but when run command in console , no db created: d:\bdd>mysql –u aimad –ptest < create.sql mysql ver 15.1 distrib 10.1.16-mariadb, win64 (amd64) copyright (c) 2000, 2016, oracle, mariadb corporation ab , others. usage: mysql [options] [database] default options read following files in given order: c:\windows\my.ini c:\windows\my.cnf c:\my.ini c:\my.cnf c:\program files\mariadb 10.1\my.ini c:\program files\mariadb 10.1\my.cnf c:\program files\mariadb 10.1\ data\my.ini c:\program files\mariadb 10.1\data\my.cnf following groups read: mysql client client-server client-mariadb following options may given first argument: --print-defaults print program argument list , exit. --no-defaults don't rea

ios - How to declare weak notification -

maybe title not provide description please read following. i have notification set listen event: nsnotificationcenter.defaultcenter().addobserver(self, selector: #selector(self.checkifnotificationswereturnedonafteralertshowing), name: uiapplicationwillenterforegroundnotification, object: uiapplication.sharedapplication()) then want remove observer on notification. found need use deinit this: deinit { nsnotificationcenter.defaultcenter().removeobserver(uiapplicationwillenterforegroundnotification) print("deinit") } but problem when close view controller, program never executes deinit function. in answer found due strong reference. i checked many links not able find how declare weak reference notification. how can declare weak notification? hope question clear. looking forward help. i not able find way handle deinit decided remove observer in viewwilldisappear worked me. suggested rob napier in comment above

node.js - Opensource nodejs devices management -

i'm looking nodejs webbased opensource application manage hundred of devices. devices divided several models. each model defines both mandatory , optional parameters each device has (ip, location name few). in addition, information such documents , images associated each device. finally, devices can logically connected 1 each other. is there project in github such requirements? the best open source project found such requirements https://github.com/akeneo/pim-community-dev

cloud - Chef-vault - not creating vaults with create command, but creating simple data bags -

i trying create chef-vault store password using below command: knife vault create revrecsecrets revrecpass -a "revrec-validator,node1,node2,node3" -j data_bags/revrecpass.json -m client where revrecpass.json contains: { "oracle_pass":"welcome1", "ora_db_passwd":"welcome1", "weblogic_pass":"welcome1"} i have 3 clients : #knife client list node1 node2 node3 revrec-validator but while trying access vault, saying no vault: # knife vault list returns nothing. and : trying refresh : (says vault doesnot exists) # knife vault refresh revrecsecrets revrecpass error: chefvault::exceptions::itemnotfound: revrecsecrets/revrecpass not exist, use 'knife vault create' create. trying recreate :(saying exists) # knife vault create revrecsecrets revrecpass -a "revrec-validator,node1,node2,node3" -j data_bags/revrecpass.json -m client error: chefvault::exceptions::itemalreadyexists: revre

c# - Detect if deleting DataGrid row is valid to delete -

i use ef code-first datagrid itemssourse, how can detect on previewkeyup event if items user want delete valid deleted or not. for example, if user delete 'customer', , 'order' contains customerid illegal. there way know if identifier of item user want delete being used foreign key in table? ef has information on it? something that: private void datagridex_previewkeyup(object sender, system.windows.input.keyeventargs e) { if (e.key == key.delete) { if (e.originalsource datagridcell) { datagrid datagrid = sender; if (!isvalidtodelete(datagrid.selectedcells)) { e.handled = true; msgbox("not valid delete !"); } } } } it sounds there's selected row in customer grid, , you're evaluating whether or not delete selected customer . and customer , order both in ef model. so customer , find id, , write query checks order table in ef model orders

jquery - Meteor: Initing function (carousel) after data is was looped -

i trying make work flickity carousel initing in blaze helpers. have following error: exception in template helper: typeerror: $(...).flickity not function here helper carousel template: template.carouseltemplate.oncreated(function bodyoncreated() { this.state = new reactivedict(); meteor.subscribe('albums'); }) template.carouseltemplate.helpers({ albums() { return albums.find({}); }, initializecarousel () { $('.carousel').flickity({ // options "lazyload": true }); } }); and template itself: <template name='carouseltemplate'> <div class="carousel"> {{#each albums}} <div class="carousel-cell"> <img src={{cover}} alt="cat nose" /> </div> {{/each}} {{initializecarousel}} </div> <template /> p.s: open other ways in order make work. first make sure you're including flickity library using 1 of follo

javascript - ( Socket.io ) One socket connection multiple rooms -

i'm having problems socket.io. try create single socket connection connected multiple rooms. this current code: function joinroom(id){ socket = io(domain);   socket.on('connect', function (data) { console.log('connected ' + room); socket.emit('room', room); }); socket.on('message', function (data) { console.log(data); }); } the problem if remove var socket.io(domain) function not connected , not receive data room. example: socket = io(domain); function joinroom(id){   socket.on('connect', function (data) { console.log('connected ' + room); socket.emit('room', room); }); socket.on('message', function (data) { console.log(data); }); } if take socket.io() function of joinroom() function not receive messages message or anything. not work. doing wrong? solution? on client, create event indicate access room. on server, appl

php - Create tournament fixture lists -

i need figure out how solve this: we trying create fixture list tournament, below find table generated webinterface have. (not sure if ideal layout make fixture list, may changes store , use basis task below). the tournament concept x number of courts in same location. have court utilization close 100% possible. problem generate fixture list based on table without conflicts( team plays 2 games in same round) , have best utilization of courts. explanation of concept: tournament_id id of main tournament. have sub tournaments, , identified pool_id. each pool may have several groups play round robin (single/double) group_id. have done setup of games teams playing each other located in home , visit, , round within group indicated round. means if group has 2 games in round 1 maximum games can played in group round, if 1 game maximum 1. priority used this: equal priority means games should handled during creation of fixture list. in example pool_id=23 has 3 groups, 0,1,2. 1 , 2 ha

multithreading - Python threading interrupt sleep -

is there way in python interrupt thread when it's sleeping? (as can in java) i looking that. import threading time import sleep def f(): print('started') try: sleep(100) print('finished') except sleepinterruptedexception: print('interrupted') t = threading.thread(target=f) t.start() if input() == 'stop': t.interrupt() the thread sleeping 100 seconds , if type 'stop', interrupts how using condition objects: https://docs.python.org/2/library/threading.html#condition-objects instead of sleep() use wait( timeout ). "interrupt" call notify().

Repopulate Multiple select Box - Ruby On Rails -

i using html.erb templates , bootstrap .when creating post choose multiple options select box , save these values in database in form of array because i'm using serialize :column_name option in model . works far . when try edit post , select box values donot repopulate . have tried below options my select box in _form.html.erb <%= form_for(@post , url: { action: @definded_action }) |f| %> <%= f.select :skills, options_from_collection_for_select(@skills , :id,:title), {}, id: "sel1" ,class: "form-control selectpicker" , multiple: true%> <% end %> when debug in edit function fetching skills , shows me @post.skills = ["1","2","3","4"] in edit function i'm fetching database have tried this @post.skills = @post.skills.map(:&to_i) but no success. appreciated :) - can try following, same except collection_select : <%= f.collection_select :skills, @skills, :id, :title, {

android - Why sharedpreference value not getting in when retrieving? -

i aaded 3 shared preferences below code. , able retrieve onl n shared preference value. sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext()); sharedpreferences.editor editor = preferences.edit(); editor.putboolean("loggedin",true); editor.putstring("userid",userid); editor.putstring("pwd",password); editor.apply(); editor.commit(); i used following code retrieving activity. able retrieve boolean value. other values not there. getting default value string values. please me. sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext()); boolean loggedin=preferences.getboolean("loggedin", false); string userid=preferences.getstring("userid", "0"); string pwd=preferences.getstring("pwd", "0"

excel - count cell with color -

Image
i want count number of cell filled specific color. for ex. few cell red, few green few yellow. now want count total red/green/yellow. is there idea how apply on merged cell also. a prompt response appreciated. regards. follow instructions on link below mentioned change below link. https://support.microsoft.com/en-us/kb/2815384 change: change script given in link following, script microsoft uses color index may count other shades of color. function countcolor(range_data range, criteria range) long dim datax range dim xcolor long xcolor = criteria.interior.color each datax in range_data if datax.interior.color = xcolor countcolor = countcolor + 1 end if next datax end function

curl - Jenkins input pipeline step filled via POST with CSRF - howto? -

i have jenkins pipeline input step, , submit input(single string argument) via script. far trying curl, ideally i'll sending via python requests library. should easy post request, csrf becomes tricky. i've obtained jenkins-crumb (using curl in case, same machine , same bash session), still can't send content... i'm sending jenkins-crumb:xxx header, explained @ https://wiki.jenkins-ci.org/display/jenkins/remote+access+api my request looks this: curl -vvv -x post --user '${user}:${api_key}' -h "jenkins-crumb:${jenkins_crumb}" -d 'json="{"parameter":{"name":"${param_name}","value":"asd"},"jenkins-crumb":"${jenkins_crumb}"}"' 'http://${jenkins_url}/job/${job_name}/${build_nr}/input/' the url i'm posting @ same, 1 linked in build log (console output). there easier way, call proceedempty url jobs: curl -x post -h "jenkins-crumb:$

java - Drag and Drop functionality is not working in selenium Webdriver -

i trying learn selenium. have following site drag , drop functionality available http://html5demos.com/drag# . trying drag , drop using below codes. not able same. on appreciated. code 1 system.setproperty("webdriver.ie.driver", system.getproperty("user.dir")+"\\drivers\\iedriverserver.exe"); webdriver driver=new chromedriver(); driver.get("http://html5demos.com/drag"); driver.manage().window().maximize(); list<webelement> ele1=driver.findelements(by.id("bin")); system.out.println(ele1.size()); system.out.println(ele1.get(0).isdisplayed()); webelement ele2=driver.findelement(by.id("one")); system.out.println(ele1.get(0).isdisplayed()); system.out.println(ele2.isdisplayed()); actions builder = new actions(driver); action draganddrop = builder.clickandhold(ele2) .movetoelement(ele1.get(0)) .release(ele2) .build(); draganddrop.perform(); code 2 (new actions(driver)).draganddrop(ele2, ele1.get(0)).perform(); c

html - CSS3 Layout - 4 column with Polygin -

Image
i have big problem 4 columns layout inside view. i must build layout: anybody know how can make layout? use -clip method first div last div . 2 centered div ok first , last not. please, me if know how can this... here example using trapezoid borders in combination positioning: body { margin: 0; } .section { position: relative; display: inline-block; width: 25%; margin-right: -4px; } .background { position: absolute; top: 0; width: 100%; height: 0; border-right: 30px solid transparent; border-bottom: 300px solid #346; } .content { position: absolute; top: 0; color: #fff; padding: 10px 10px 10px 30px; z-index: 100; } .s1 .background { border-bottom-color: yellow; z-index: 5; } .s2 .background { border-bottom-color: blue; z-index: 4; } .s3 .background { border-bottom-color: navy; z-index: 3; } .s4 .background { background-color: black; border: none; height: 300px; } <

java - Unable to click on pop up screen -

after entering values few fields click on submit button produces pop screen should click go button. tried below code, worked once not working now. please help webdriverwait wait = new webdriverwait(driver, 6); wait.until(expectedconditions.visibilityofelementlocated(by.xpath(".//*[@id='lets_go']"))); driver.findelement(by.xpath(".//*[@id='lets_go']")).click(); how fix ? if it's alert use: driver.switchto().alert().accept(). if pop window, first switch window using windowhandler , click on element

java - 403 Forbidden error via ZUUL only -

i following error: aug 08, 2016 12:40:45 pm com.vaadin.server.defaulterrorhandler dodefault severe: org.springframework.web.client.httpclienterrorexception: 403 forbidden @ org.springframework.web.client.defaultresponseerrorhandler.handleerror(defaultresponseerrorhandler.java:91) @ org.springframework.web.client.resttemplate.handleresponse(resttemplate.java:641) @ org.springframework.web.client.resttemplate.doexecute(resttemplate.java:597) @ org.springframework.web.client.resttemplate.execute(resttemplate.java:557) @ org.springframework.web.client.resttemplate.exchange(resttemplate.java:503) @ com.primedex2.mservice.ui.trader.tradersrepo.modifytrader1step(tradersrepo.java:451) whenever call put, delete or post via restfull api: public <t> responseentity<t> exchange(string url, httpmethod method, httpentity<?> requestentity, parameterizedtypereference<t> responsetype, map<string, ?> urivariables) throws restclientexception { type type = responset

python - Why does pandas.Dataframe.drop() returns None? -

here in code read data csv: data = pandas.read_csv('dataset/job_functions.csv', names=["job","category"] ,skiprows=1).dropna().reindex() num_jobs = data["job"].size then want drop rows 'category' label not equal i : data = data.drop(data[data.category!=i].index,inplace = true) print(data.head()) even dropping list of index returns none: data = data.drop(data.index[[1,2,3]],inplace = true) error message: traceback (most recent call last): file "sample.py", line 162, in delete_common_words(27) file "sample.py", line 92, in delete_common_words print(data.head()) attributeerror: 'nonetype' object has no attribute 'head' here data until use drop() : job category 0 офис менеджер реализация гербицидовоформлени... 2 1 менеджер отдел продажа работа с существующий... 27 2 ведущий бухгалтер работа с вендер и поставщи

I want to generate 3000 above pdf files from prestashop back end -

i using tcpdf pdf generator generating eticket, same prestahsop generates pdf files invoices , trying generate pdf files of tickets( selling tickets online) ,3000 tickets daily need print end how 3000 tickets printing ??i mean how generate 3000 tickets of pdf in 1 click ? need validate printing whether 3000 pdf corresponding ticket generated or not how validation(count validation). public function generatepdf($object, $template) { switch($template) { case pdf::template_eticket: $format = 'jis_b5'; // replace desired size office eticket break; default: $format = 'a4'; // replace normal size } $pdf = new pdf($object, $template, context::getcontext()->smarty,'p', $format); $pdf = $pdf->render(false); return true; }

Rails Devise user password is always invalid (tested in rails console) -

i have 1 particular user in rails app can't log in anymore, password invalid, though changed manually. here's in rails console : > me = user.find(10) > me.password = '123456789' > me.save (0.3ms) begin user exists (0.6ms) select 1 one "users" ("users"."email" = 'myemail@gmail.com' , "users"."id" != 10) limit 1 sql (0.7ms) update "users" set "encrypted_password" = $1, "updated_at" = $2 "users"."id" = $3 [["encrypted_password", "$2a$10$mrhwiot3pu6yldtyrd/bc.wuqpthyfjhiqdgkyv14xcafvqntodwg"], ["updated_at", "2016-08-08 10:43:34.715229"], ["id", 10]] (31.3ms) commit => true > me.valid_password?('123456789') => nil this particular user id 10. exact same thing other user works. wrong ? edit : tried password confirmation that's not issue. said, exact manipulation works

How to access deep JSON element in Java -

i have following json response: { "destination_addresses" : [ "berlin, deutschland" ], "origin_addresses" : [ "mannheim, deutschland" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "624 km", "value" : 624195 }, "duration" : { "text" : "5 stunden, 53 minuten", "value" : 21156 }, "status" : "ok" } ] } ], "status" : "ok" } my question is: how access "text" element in "distance" section? i have following right now: jsonobject object = (jsonobject) new jsontokener(response).nextvalue(); jsonarray rows= null; rows= object.getjsonarray("rows");

c++ - Linked List: Segmentation fault error when assigning a value to the next part of a node -

this first question here , english not good, please bear me. i trying create linked list function insert element in position. need position predptr having trouble doing because whenever run program, segmentation fault. believe error in "predptr->next = first;" part inside insert() function, when set predptr (the line above) "predptr = new node()" works triggers second case in insert function. here's code: //class list class list { private: //class node class node { public: string data; node * next; //node constructor node() { data = ""; next = 0; } //node constructor value node(string val) { data = val; next = 0; } }; int mysize; node * first; public: //list constructor list() { mysize = 0; first = 0; } //insert function void insert(string val, int pos) { node * newptr, * predptr; newptr = new node(val); predptr = new node()

java - S2VUtils.getConnectionToVerticaHost(): FATAL ERROR. cound not get connection to any host in list -

i trying connect java based apache spark application vertica database using hpe vertica spark connector , i'm getting following exception. ip address mentioned ip address of vertica vm installed on machine. ip address executing command "ifconfig" on vm. environment: vertica-7.2.3_ovf vmware-player-12.1.1-3770994 windows 10 apache spark-1.6.2 hpe-vertica-spark-connector-0.2.2 code: hashmap<string, string> verticaconnectorproperties = new hashmap<string, string>(); verticaconnectorproperties.put("table", "testtable"); verticaconnectorproperties.put("db", "testdb"); verticaconnectorproperties.put("user", "testuser"); verticaconnectorproperties.put("password", "testpassword"); verticaconnectorproperties.put("host", "192.168.10.10"); // ip of vertica vm installed on machine dataframe.write() .format("com.vertica.spark.datasource.defaul

php - How can i read folder names? -

i have folder named categories has lots of folder inside.i need take names , insert database. is there function or way takes folder names php? just simple rtm have got you: readdir() <?php if ($handle = opendir('/path/to/files')) { echo "directory handle: $handle\n"; echo "entries:\n"; /* correct way loop on directory. */ while (false !== ($entry = readdir($handle))) { echo "$entry\n"; } /* wrong way loop on directory. */ while ($entry = readdir($handle)) { echo "$entry\n"; } closedir($handle); } ?> be sure read documentation gotchas!!!

How to implement properly multiple inequality filters on Google App Engine Datastore? -

according app engine restriction on inequality filters, there suggestions implement advanced searches (filtering results limiting ranges on many properties) filtering properties manually in ram: how run 2 inequality filters on queries in app engine so, feasible amount of sorting , filtering in ram large datasets? there java sample code demonstrates proper implementation? idea stick traditional rdbms in order avoid drawback? as andrei has mentioned, there isn't general solution problem of needing multiple inequality filter conditions. depends on data, queries , application requirements. here possible solutions use: perform filtering in application. if have 2 inequality conditions, , b, , know majority (e.g. > 80%) of entities meet condition meet condition b, query without condition b against datastore, , filter returned results in application code. lets continue use datastore, , efficiency hit shouldn't bad, since know > 80% match. however, extendin

ksh - Calling and returning a value from shell script using nohup -

i have 2 shell script files . 1 general file install on system , other file processes steps of installation. file1: main installation file file2: installation assistance file i calling file2 file1 using nohup ./file2.sh $1 </dev/null >../logs/schema.log 2>&1 & schema_status=$? echo $schema_status now because of nohup schema_status value coming 0 always. how return relevant value file2 file1 . in file2, have added return statement: if (condition) exit 101 else exit 102 fi please go through link problem similar discussed. suggest export environment variable in file1.sh , set environment variable in file2.sh. able return(indirectly) file2.sh file1.sh pass variables 1 shellscript another?

How to refer to types in Python? -

i know how refer types, i.e. str type('') , int type(1) etc. other types, such type(lambda: none) ? i know refer type(f) == type(lambda: none) comparison, but, there other way, except that? (no silly answer such code-golf, use return value lambda, etc.) edit : found out how utilize accepted answer! import types function = types.functiontype builtin_function_or_method = types.builtinfunctiontype classobj = types.classtype generator = types.generatortype object = type del types if want test if value a lambda : import types foo = lambda: none print(isinstance(foo, types.lambdatype)) see https://docs.python.org/3/library/types.html . you use isinstance testing if something , type() == type() frowned upon.

ios - How do I change the colour of scroll bar Indicator in UICollectionView apart from Default,Black or White? -

i want change color of horizontal scroll bar indicator of uicollectionview, apart default, black or white done in storyboard? you can use delegate method : 'scrollviewdidscroll' , add //get refrence of vertical indicator uiimageview *verticalindicator = ((uiimageview *)[scrollview.subviews objectatindex:(scrollview.subviews.count-1)]); //set color vertical indicator [verticalindicator setbackgroundcolor:[uicolor redcolor]]; //get refrence of horizontal indicator uiimageview *horizontalindicator = ((uiimageview *)[scrollview.subviews objectatindex:(scrollview.subviews.count-2)]); //set color horizontal indicator [horizontalindicator setbackgroundcolor:[uicolor bluecolor]];

Yii2 Relations to get a field using two foreign keys -

Image
i have issues field table using 2 foreign keys. explained relations of use tables below. user table hasmany companies(company_id). comapny table has company_id. facilities hasone company_id(based on user instance). area hasmany facilites(facility_id). the logged on user have areas related facilities_id in turn related company_id. i have a productlines hasmany products(product_id). the user should display products related areas. productlines hasmany areas(area_id). product lines has field called internal_code. product model has relation productlines on basis of products_id. i want display internal code on basis of product_id belongs specific areas. my code of not working : in product model. public function getfacility() { return $this->hasmany(facility::classname(),['facility_id' => 'facility_id'])->viatable('sim_users',['company_id'=> yii::$app->user->identity->company_id]); } publ

continuous integration - Get TeamCity build status -

Image
i've got teamcity running build, has artifact output of *.msi installer, need mark successfull , failed tests builds, like <filename>_<build_status>.msi i've set tc build installer if tests failed, in order send our tester. thing recieve build status teamcity environment, without using rest. i realise said didn't want use rest, need perform request url, substituting build configuration id. imo simplest approach (provided installer build config separate build) /httpauth/app/rest/builds/buildtype:installer_build/status if need implementing let me know. implementation 1) add parameter want set output request 2) add powershell step , run code source - get build status gist 3) update relevant parameters highlighted below match settings hope helps

Upload text file to Google uploads via PHP FTP PUT -

i trying upload text file created database via php. the text file created ok, when try , upload file via php ftp put fails. my code: $filename = "products_admin.txt"; $handle = fopen($filename, 'w+'); fwrite($handle, $content); fclose($handle); echo "attempting connect <i>uploads.google.com</i>...<br />"; $ftp_connect = ftp_connect("uploads.google.com", "21", "5000") or die("failed connect."); $login_result = ftp_login($ftp_connect, "{usernamehere}", "{passwordhere}") or die("error: username or password incorrect."); if((!$ftp_connect) || (!$login_result)) { echo "error: couldn't connect <i>uploads.google.com</i>, upload failed.<br /><br />"; echo "<a href=\"javascript:location.reload(true)\">try again</a>"; exit; } else { echo "connected <i>uploads.google.com</i

typescript - Why I get "typings WARN deprecated <packagename> is deprecated (updated, replaced or removed) -

i warning: >typings ls typings warn deprecated 2016-08-05: "registry:dt/react#0.14.0+20160423065914" deprecated (updated, replaced or removed) however, seems have latest version: >typings view dt~react --versions tag version description compiler location updated 0.14.0+20160805125551 0.14.0 github:definitelytyped/definitelytyped/react/react.d.ts#edcbaabb56bb0866df95dbfdf279f4a680051217 2016-08-05t12:55:51.000z 0.13.3+20160423065914 0.13.3 github:definitelytyped/definitelytyped/react/react-0.13.3.d.ts#3a44f976ba58e05adb666295d59168ef5e99ae17 2016-04-23t06:59:14.000z i see tag different, when try typings dt~react@0.14.0+20160805125551 -save -g the version latest tag not installed. why warning , how update it? it should --save pay attention -- . or can use -s instead. see documen

Salesforce HTTP Callout Headers -

in salesforce http callout use httprequest newrequest = new httprequest(); and set headers like newrequest.setheader('authorization','xxx'); newrequest.setheader('content-type','xxx'); newrequest.setheader('customheader','customparameter'); apart authorisation , content-type other parameters can set , purpose. great if can point me link description. the "salesforce" httprequest system.httprequest according docs notes looks want list of httprequest headers http protocol (should) pretty standard.

javascript - Grab dynamic input value in react -

Image
this form view: and dynamic input form code: ... let subjudulinput = []; // variable render (var = 0; < this.props.subtitleinput.index; i++) { let index = + 1; subjudulinput.push( <div key={'formgroup' + index} class="form-group"> {(i === 0) ? <label for="subjudulinput">sub judul</label>:false} <input key={'input' + index} type="text" class="form-control" placeholder={`masukan sub judul ${index}`}/> </div> ); } ... if click plus button, new input form show.. this form handler: onaddingtitle(event) { // if submit button pressed let formdata = {subjudul:[]}; event.preventdefault(); console.log(event.target.elements); } how can grab of dynamic input value? (best ways) formdata object. this: let formdata = {subjudul:[ 'sub judul 1 value here', 'sub judul 2 value here',

python - Django : 'WSGIRequest' object has no attribute 'user'? - AuthenticationMiddleware & SessionAuthenticationMiddleware are in sequence -

getting following error while try access django admin panel. environment: request method: request url: http://localhost:8000/admin/ django version: 1.9.8 python version: 2.7.10 installed applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bookapp'] installed middleware: ['django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware'] traceback: file "/library/python/2.7/site-packages/django/core/handlers/base.py" in get_response 149. response = self.process_exception_by_middleware(e, request) file "/library/python/2.7/site-packages/django/core/handlers/base.py" in get_response 147. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/library/