Posts

Showing posts from April, 2014

html - How to Stop infinite animation in javascript -

i have develop animation can see below.... animation goes infinite time.. have conditions.. 1.) if click button ball goes , down have stop on default position... 2.)if u click button second time shows 2 balls colliding... how rectify issues through javascript function animationone(cobj) { var circle = document.getelementbyid("circle" + cobj); var h = window.innerheight - 50; var btmpos = 0; var isforward = true; setinterval(function () { if (btmpos < h && isforward) { btmpos += 10; isforward = true; } else { if (btmpos > 20) { isforward = false; btmpos -= 10; } else { btmpos += 10; isforward = true; } } circle.style.bottom = btmpos + "px"; }, 100); }; body{ background-color: gray; position: relative; min-height

java - Autowired KafkaTemplate in SpringBoot/spring-kafka application throws null pointer -

Image
i'm trying use spring-kafka kafkatemplate, inside spring boot application, write messages kafka topic. i created kafkaconfig class: @configuration @enablekafka public class kafkaconfig { @value("${kafka.broker.address}") private string brokeraddress; @bean public producerfactory<integer, string> producerfactory() { return new defaultkafkaproducerfactory<>(producerconfigs()); } @bean public map<string, object> producerconfigs() { map<string, object> props = new hashmap<>(); props.put(producerconfig.bootstrap_servers_config, brokeraddress); props.put(producerconfig.retries_config, 0); props.put(producerconfig.batch_size_config, 16384); props.put(producerconfig.linger_ms_config, 1); props.put(producerconfig.buffer_memory_config, 33554432); props.put(producerconfig.key_serializer_class_config, integerserializer.class); props.put(produce

android - setting minimum Date in DatePicker -

hello guys new android , facing problem have searched lot not getting solution m using datepickerdialog box , when running application selecting previous dates though have set minimum date. have tried subtracting 1 second current time. , datepicker starting january1990. want start today , block previous dates. ... public void onbuttonclickdate() { btn_date = (button)findviewbyid(r.id.button); edit_date = (edittext)findviewbyid(r.id.edittext); btn_date.setonclicklistener ( new view.onclicklistener() { @override public void onclick(view view) { datepickerdialog datepickerdialog = new datepickerdialog(mainactivity.this, new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) view.setmindate(system.currenttimemillis()); edit_date.settext(dayofmonth + "-" + (month

ios - DZNEmptyDataSet not working for Collection View? -

as says in title using dznemptydataset library uicollection view. tableview controller, have following in viewdidload : self.tableview.emptydatasetsource = self tableview.emptydatasetdelegate = self tableview.tablefooterview = uiview() but collection view? there not seem similar tablefooterview . what right way go doing this?

doctrine2 - How to set doctrine associated data into Zend Form? -

how set associated data zend form in zf2? i getting error : zend\form\view\helper\formselect not allow specifying multiple selected values when element not have multiple attribute set boolean true after using below code. $data = entity object[ 'name' => 'test' 'email' => 'test@test.com', 'type' => object[ 'id'=>1, 'type'=>'admin' ] ] when used set data $form->setdata($data->toarray()) it gives me above error. i using zf2, doctrine2 , mysql please me fix this.

serial port - c# console application sending commands to LCD Screen -

i have small lcd screen. @ moment can write text it, , commands such clear screen etc. these commands came user manual, , have been working fine, want able change colour of lcd screen. all commands changing colour have (0x255) in them causing problem. error occurs saying 'constant value 597 cannot converted byte'. the commands have send hex. here code have been using: byte[] bytestosend = { 0xfe, 0xd0, 0x0, 0x0, 0x255 }; port.write(bytestosend, 0, bytestosend.length); is there way around this? thanks, lucy you mean "0xff" or "255" decimal, not "0x255". not within range of bytes.

javascript - How to rotate THREE.TubeGeometry segments? -

Image
i've created flat three.tubegeometry radiussegments = 2, when added scene perpendicular ground: is possible rotate each tube segment parallel ground? jsfiddle example. var points = []; (var = 0; < 5; i++) { var randomy = i*5/2*10 + -50; var randomx = 15*math.sin(5*i); points.push(new three.vector3(randomx, randomy, 0)); } var tubegeometry = new three.tubegeometry(new three.splinecurve3(points), 64, 6, 2, false); tubemesh = createmesh(tubegeometry); scene.add(tubemesh); my recommendation use custom flat geometry (not tubegeometry!) , calculate vertices want them (not rotate!). methodology geometry like: create random points (here math needed in order have them want them be, funny part!) get spline points each curve triangulate on them if decide go forward code here change have parallel plane. add generatetube function, after tubemesh creation: tubemesh.rotatey(math.pi/2);

python - pandas DataFrame very slow when initializing with numpy structured array -

i have numpy structured array has integers , floats, use initialize pandas dataframe : in [497]: x = np.ones(100000000, dtype=[('f0', '<i8'), ('f1', '<f8'),('f2','<i8'),('f3', '<f8'),('f4', '<f8'),('f5', '<f8'),('f6', '<f8'),('f7', '<f8')]) in [498]: %timeit pd.dataframe(x) slowest run took 4.07 times longer fastest. mean intermediate result being cached in [498]: 1 loops, best of 3: 2min 26s per loop in [499]: xx=x.view(np.float64).reshape(x.shape + (-1,)) in [500]: %timeit pd.dataframe(xx) 1 loops, best of 3: 256 ms per loop as can seen code above, initializing dataframe structured array slow. however, if change data continuous float numpy array, fast. still need dataframe have mixture of floats , integers. after more tests, realized dataframe copying whole structured array (this not occur when using structured

sql - MYSQL get AVG for each row -

i need avg each row of table. lets have id val 1 5 2 6 3 7 i need id val 1 0.277 (5/18) 2 0.333 (6/18) 3 0.388 (7/18) can easy in mysql without joining same table? you can sum val column , divide val column sum. select id, 1.0*val/(select sum(val) tablename) val tablename

angular - Two levels of items in an array list in ionic 2 -

i have array list of items: items = [ {id: '1', title: 'item 1'}, {id: '2', title: 'item 2'}, ] i want add categories list , filter based on that, example -items -- cat1 --- item 1 --- item 2 -- cat2 --- item 1 --- item 2 -- cat3 --- item 1 --- item 2 also, how change ngfor code select cat <ion-list> <ion-item *ngfor="let item of items" (click)="clicked($event, item)"> <h2>{{item.title}}</h2> </ion-item> </ion-list> clicked (event, item){ console.log(item.title); } if want add categories, items array this: this.items = [ { id: 1, title: 'category 1', items : [ {id: 1, title: 'item 1'}, {id: 2, title: 'item 2'} ] }, { id: 2, title: 'category 2', items : [ {id: 3, title: 'item 3'}, {id: 4, title: '

mfc - CMFCToolBar dragging -

i have 2 toolbars ,which want drag, have conditions: i don't need close button if it's real do, need drag toolbars inside bars. mean don't want floating in client area, in previous picture. such in rebar before mfc pack!

python - oozie: add a file tag to a workflow.xml -

i'm trying build oozie job python spark action , need add file tag <file> /path/to/myfile.py <file> workflow.xml. have access hue interface (3.7.0) , can't use cli. p.s have no problem shell script since input box directly available during shell action definition.

class - Interfacing and Inheritage of template classes in c++ -

i have problem project using template class inheritance. idea have agent has pointer msgtype. msgtypes can differ, that's why template class comes game. idea store different message types via interface class. initialize interface pointer in agent instance of msgtype need include #include "msginterface.h" , #include "msgtype.h". unfortunately, if include "msginterface.h", project compiles fine. if add #include "msgtype.h" in agent.h require initialization. crazy error: the error is: error: expected template-name before ‘<’ token class msg:public msginterface{ ^ /home/catkin/src/template_class/src/msg.h:10:30: error: expected ‘{’ before ‘<’ token /home/catkin/src/template_class/src/msg.h:10:30: error: expected unqualified-id before ‘<’ token do have idea what's reason error? the error can reproduced following code: //main.cpp #include <stdio.h> #i

javascript - API for autopilot -

Image
i newbie @ using api's. because of work, have learn use autopilothq. there api in javascript: http://developers.autopilothq.com/ but question basically, how implement these functions? have make administration site, implement these functions, or in online program called from? for example, in console of site autopilot , can type following: var sessionid = autopilotanywhere.sessionid; sessionid; then 24 digit number. number can attached contact_id. how execute line of code on site? should make js file , make functions in here, call script head tag? updated question: if want use javascript access api, create html document contains javascript script xmlhttprequest (ajax) request rest -api code 1 example in screenshot. you need specify private api key (it acts kind of username , password in 1 thing) allow script access account. create request body , use http method send request (see crud ). api returns json encoded string (or error) can work in script. so ye

pass by reference - C# call for 'int foo(QByteArray &memDump)' does not copy into dump into variable -

i'm accessing activexserver in c# programm. 1 function defined int foo(qbytearray &memdump) , puts own data onto memdump . if size of byte array wrong or write memdump not work, return values != 0. think must correct. i create byte array with: byte[] dump = new byte[size]; int rtn = foo(dump); am doing wrong here? address operator in variable list of foo , function supposed work directly on memdump , not copy of - not manipulate data.

postgresql slow: primary key on 80M row table -

i've 64gb ram machine, 20 cpus, , command create primary key on table 80m rows: alter table wikipedia_article add constraint pagelinks_pkey primary key (language, title); the problem i've got that: only 1 cpu used 100% (avg load 99%), rest aren't used @ all the write speed during primary key creation quite low, 2.6 m/s, read speed missing report produced pg_activity this table structure: table "public.wikipedia_article" column | type | modifiers | storage | stats target | description --------------+------------------+-----------+----------+--------------+------------- language | text | not null | extended | | title | text | not null | extended | | langcount | integer | | plain | | othercount | integer | | plain | | totalcount | integer | | p

printing - print thailand characters on bluetooth printer android -

i need print thailand characters through bluetooth printer. if print data android console it's displays in thai language. but same data when sent bluetooth printer, prints junk value. i have tried encoding charset.forname("utf-8").encode("วันที่").array(); string str = "วันที่".getbytes(charset.forname("ts-620")). but nothing seems working fine. can 1 guide me on this.

ios - Get material by name in SceneKit -

i have imported collada .dae file scenekit. can see in scene editor/inspector there list of entities , materials named materials. have no clue how ask these programatically. i can ask material name geometry object if know 1 node , geometry uses it, so: myscene.rootnode.childnodes[68].geometry?.materialwithname("carpaint") but these reusable materials used on many sub geometries, there should global index somewhere(?) i have expected like myscene.materialwithname("carpaint") what ended doing create extension scnnode , scnscene give me index materials: import scenekit extension scnscene { func buildmaterialindex() -> dictionary<string, scnmaterial> { return self.rootnode.buildmaterialindex() } } extension scnnode { func ispartof(node: scnnode) -> bool { return (node === self) || (parentnode?.ispartof(node) ?? false) } private class _dictbox { var dict = dictionary<string, scnmateria

encryption - AES in java can run in windows but not in linux -

this question has answer here: better way create aes keys seeding securerandom 1 answer i finished aes class decrypt or encrpyt ,and runs on windows can't run on linux throwing errors following : given final block not padded the full code following : /** * aestest.java * * @author liuyincan * @time 2013-12-12 下午1:25:44 */ public class aes { public static string generatekey(int len) { try { keygenerator keygen = keygenerator.getinstance("aes"); keygen.init(len); key key = keygen.generatekey(); return parserstringutils.tohexstring(key.getencoded()); } catch (exception e) { return null; } } /** * 加密 * * @param content * 待加密内容 * @param key * 加密的密钥 * @return */ public static string encode(string content, string key) { try { keygenerator kgen =

sql - What are the drawbacks of having million+ tables in same DB? -

i have designed db create tables dynamically , load data it. (single user's data stored in single table) so db having around million+ tables 2% having millions of rows in , 30% having million of records , 68% having 1000-10,000 rows in each (but in single db)...!!! out of these around 10-20% of tables having same schema. is safe db's memory? affect performance of queries? or should have merge 10% of data single table? if merged save space?

Is it possible to override sonar.modules in the sonarqube gradle plugin? -

i'm trying set sonar analysis across non-standard multi-project directory structure root project aggregate sonar data. using sonarqube runner, i've tried set property sonar.modules sub-projects (which not in child directories), plugin seems override property erroneous default values cause build fail. the overwrite seems happen in java class : https://github.com/sonarsource/sonar-gradle/blob/master/src/main/java/org/sonarqube/gradle/sonarqubeplugin.java on line 190. is there way around problem? i have not tried, looking @ how other properties(sonar.projectkey, sonar.projectname, sonar.projectversion) within same addgradledefaults method begin set, did try same pattern followed configuring other properties per sonarqube plugin documentation ? fyr, here link sonarqube on how use plugin , or override default values within gradle build script. http://docs.sonarqube.org/display/scan/analyzing+with+sonarqube+scanner+for+gradle here code snippet apply plu

.htaccess - Complex Apache Limit/SetEnvIf, allow all from domain except for IP -

i have following .htaccess: <limit post> setenvif host www.livedomain.com allow setenvif remote_addr 1.1.1.1 allow setenvif remote_addr 2.2.2.2 allow setenvif remote_addr 3.3.3.3 allow order deny,allow deny allow env=allow </limit> this .htaccess used on 2 domains. on www.livedomain.com want access. on www.stagingdomain.com want ips 1.1.1.1, 2.2.2.2, 3.3.3.3 have access. this works fine. now, on live site, want make change allow except 1 ip (let's 9.9.9.9). i've tried doing this: <limit post> setenvif host www.livedomain.com allow setenvif remote_addr 9.9.9.9 deny setenvif remote_addr 1.1.1.1 allow setenvif remote_addr 2.2.2.2 allow setenvif remote_addr 3.3.3.3 allow order deny,allow deny allow env=allow </limit> but doesn't work. have thought env variable overwritten 'deny' , final allow statement wouldn't apply. not case? what's simplest way allow 1 dom

performance - Memory and processing efficient multi-dimensional data structure C++ -

what best way store multi-dimensional data in c++? looking dynamic data structure rather static multi-dimensional arrays, number of elements stored in structure can not pre-determined. additionally, looking data structure can minimize memory cost , provide faster lookup. there ready made data structure or must implement multi-dimensional tree-based data structure? edit: have store multi-dimensional stream data in data structure. e.g., data stream of form: (key1, key2, key3, value1), (key1, key2, key3, value2), (key1, key2, key3, value3), ... later search data respect different keys. i have store multi-dimensional stream data in data structure. e.g., data stream of form: (key1, key2, key3, value), (key1, key2, key3, value), (key1, key2, key3, value), ... later search data respect different keys. boost::multiindex allows add different kinds of indices container. it's pretty complex library , can bit painful used it. that's worth trouble, because

mysql - get updated date field row after inner joining table -

i have situation row inserted whenever schedule created call_back_date value la_id same each row, want recent row max(call_back_date) have written query fetch entries schedule after inner joining 3 tables: select la_details.application_no, la_details.id la_det, la_details.client_id client_id, la_details.la_name la_name, la_details.sex sex, la_details.advisor_name advisor_name, la_details.client_phone client_phone, la_details.client_mobile client_mibile, la_details.level level, la_details.state state, la_details.pin_code pin_code, trans_schedules.id schedule_id, trans_schedules.*, comments.descriptions la_details inner join trans_schedules on trans_schedules.la_id=la_details.id inner join comments on comments.comment_id=trans_schedules.comment_id (trans_schedules.comment_id<>'1' or trans_schedules.list_followup = '1' or trans_schedules.counter_flag='0') , la_details.case_closed='0' order trans_schedules.call_back_date ) a1 inner

ios - Use enum swift issue -

i have enum: enum vaxsettingscells : int { case switchmodecell = 0 case switchercell = 1 case newprogramcell = 2 case createdprogramcell = 3 } which use in uitableview delegate: override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cellid = vaxsettingscells(rawvalue: indexpath.row) switch cellid { case .switchmodecell: let cell = thetableview.dequeuereusablecellwithidentifier(vaxsettingsswitchmodecell.reusablecellidentifier()) as! vaxsettingsswitchmodecell cell.delegate = self return cell but error: enum case 'switchmodecell' not found in type 'vaxsettingsviewcontroller.vaxsettingscells?' how rid of error? can use raw values int , work want use enum data instead don't want use default case of switch. you first need unwrap vaxsettingscells return optional value. if define enumeration raw-value type, enumeration automatic

Windows batch script to change names with some logic -

i have directory following layout: 1 януари 2012 2 февруари 2012 1 януари 2013 and want yyyy-mm-dd : 2012-01-01 2012-02-01 2013-01-01 Януари / февруари cyrillic names of months map numbers - 01 / 02 . the script has to: take dir name rename in correct format i new batch script coding. so if me great. assuming, need rename folders януари , февруари , replace c:\folders real full path target directory, save script test.bat , open cmd prompt script folder, , test it. works me in win10 english dir names regardless of current cmd codepage. @echo off setlocal enabledelayedexpansion set "dir=c:\folders" /f "tokens=4" %%a in ('chcp') ( if not %%a==855 set "enc=%%a" & chcp 855 >nul) /f "tokens=1,2,3" %%g in ('dir /b /a:d "%dir%"') ( set "yea=%%i" & set "fold=%%g %%h %%i" /f "tokens=1,2 delims=я" %%b in ("%%h") ( if not %%c.

javascript - AngularJS directive templateUrl function using 2-way data binding -

this question has answer here: angular.js directive dynamic templateurl 6 answers i try parameterize template of page using directive. have array of objects 'type' value. want use different templates when types different. here tried: directive.js angular.module('core') .directive('mysolutiondisplay', function () { return { restrict: 'e', scope: { solution: '=' }, templateurl: function (elem, attr) { return 'path/to/template/solution-'+attr.type+'.template.html'; } }; }); view.html <div class="row"> <my-solution-display type="vm.solution[0].type" solution="vm.solution"></my-solution-display> </div> i following error : angular.js:11706 error: [$compile:tpload] failed load template: path/to

Android activity has java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView Exception and get crashed -

Image
it got below error sometime when android activity starting. java.lang.illegalargumentexception: view=com.android.internal.policy.impl.phonewindow$decorview{16055902 v.e..... r......d 0,0-639,154} not attached window manager this .java file step 1 : invitefriendsactivity.java public class invitefriendsactivity extends appcompatactivity implements view.onclicklistener { @bind(r.id.btn_invite) monoserratregularbutton btninvite; @bind(r.id.ll_main) linearlayout llmain; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_invite_friends); butterknife.bind(this); btninvite.setonclicklistener(this); } } step2 :login.java private void loadurl(boolean istrue) { mapp = new instagramapp(this, applicationdata.client_id, applicationdata.client_secret, applicationdata.callback_url, istrue); mapp.setlistener(

postgresql - ERROR: type "datetime" does not exist -

i trying migrate hibernate-based app mysql postgres, there seems problem date format in entity have @entity @table( name = "app_users" ) public class user { @id @generatedvalue(generator="increment") @genericgenerator(name="increment", strategy = "increment") private int id; private string username; private string email; private string password; private string firstname; private string lastname; private timestamp joindate; ... but error when creating table error: type "datetime" not exist the sql "showsql" is hibernate: create table app_users (id integer not null, email varchar(255), firstname varchar(255), joindate datetime, lastname varchar(255), password varchar(255), username varchar(255), primary key (id)) i have postgresql-9.5.3-1 installed locally , using hibernate version 5.0.10.final searching error on google gives me few results. the top restu

javascript - Ajax wait till big image is loaded -

i need load big imges step step using ajax. want fade out last image when next image loaded. i have checked several solutions in actual browsers nothing seems work. so have now: <div id="imgtoshow"> <img class="imgzoomclass" src="firstimage.jpg"> this ajax function loads onclick actual image (path) , next image path: $.ajax({ type: "post", url: "../ajax/getimages", cache: true, data: "instance_id=" + $("#instance_id").val() + "&daterange=" + activerange + "&index=" + slideindex + "&direction=next&resolution=" + $("#resolution").val(), success: function(json){ var data = jquery.parsejson(json); if(data){ $("#imgtoshow").append('<img id="imgzoom" class="imgzoomclass" data-index="'+data.index+'" data-time="'+data.time+'&qu

android - Random Espresso Tests Failing -

i have test class in have 6 espresso tests. if run test class, 3 pass, 3 fail. if run each test individually tests pass expected. of these have race conditions (api request) understand , im looking @ using idlingresource, others not, example there's nomatchingviewexception android.support.test.espresso.nomatchingviewexception: no views in hierarchy found matching: text: "sort best match" incorrect view there , found when test run on it's own, passes expected. i'm wondering has come across , if share how fix it. make sure reset app-state if 1 of tests making changes , second test relying on vanilla state. can use @before , @after annotations set/reset app state check race-conditions , async processes in app on slow test devices perform(click()) can result in longpress-action: android espresso performs longclick instead of click i found pretty summary of reasons , fixes here: https://semaphoreci.com/community/tutorials/how-to-deal-with-and

javascript - How to wait on the data from net.socket to be fully submitted -

i need receive big json string windows application. can't seem figure out how need wait on data transmitted before close connection. i've read need wait on callback, i've looked through documentation , can't wrap head around it. i'm new node.js , javascript programming in general bear me here. client.on('data', function(data) { completedata = data; //close connection client.end(); }); client.on('end', function() { //parse data after receiving full json responsedata = json.parse(completedata); console.log('received data \r\n' + json.stringify(responsedata, null, 4)); client.destroy(); console.log('connection closed'); next(); }); edit: i've tried it's still closes before data. client.on('data', function (data) { if (newlineregex.test(data)) { console.log('received: ' + data); responsedata = json.parse(data); console.log('received data \r\n&

jquery - How to print Data-table with div content -

unable print datatable border , div content. tried datatable print plugins can print datatable.. html : <div class="col-md-12 col-xs-12 col-sm-12 panel panel-default" id="testreporttable"> <button class="btn btn-default" id="btnprint">print</button> <div class="col-md-12 col-xs-12 col-sm-12 text-center" > <h4>stack overflow test</h4> </div> <div class="col-md-12 col-xs-12 col-sm-12"> <h5><b>test page</b></h5> </div> <div class="col-md-12 col-xs-12 col-sm-12 table-responsive"> <table class="table table-striped table-bordered table-responsive" id="testreporttable"> <thead> <tr> <th>name</th> <th>locatio

.net - How to set Multiple return types with same status code in swagger swash buckle -

i working on swagger , want make multiple return types known swagger single function same status code. i have been using these tags on functions: [swaggerresponse(httpstatuscode.ok, type = typeof(pagedresult<getincidentsreportresponse>))] [swaggerresponse(httpstatuscode.ok, type = typeof(ienumerable<getcountresponse>))]

swift - TextField number input using Arabic keyboard -

we using few inputs in our app use number pad type of keyboard. storing values int. few days ago encountered error 1 of our app users uses arabic keyboard. when trying save input database encounter error since input in arabic symbols , doesn't recognised int. i wonder how guys solve kind of problems. thinking of converting input value created little extension string class: func converttonumber() -> int { let locale = nslocale(localeidentifier: "en") let formatter = nsnumberformatter() formatter.locale = locale let number = formatter.numberfromstring(self) let returnnumber = int(number!) return returnnumber } is there other better approach? i used code below convert arabic numbers "١٢٣٤٥٦٧٨٩٠" english numbers "1234567890" i'm returning value string maybe difference. if still need return int value try change code: let returnnumber = int(number!) to if int(number!) != nil { return int(number!

ios - difference in app working between simulator and iphone/ipad -

i building ios chatting app in obj c. user can post messages. there anomalies in working of app on iphone/ipad. works on simulator. 1) on iphone, when post message, though pop says messaged posted successfully, doesn't show on message screen. when delete message, though pop says message deleted successfully, still appears in messages screen. problem not there in simulator. 2) on ipad, when try add image message, crashes app. in ipad simulator, problem doesn't exist. there no compilation warnings or errors. simulator working fine. features not working on real device. any thought?

How to convert a dynamic object to JSON string c# -

i have following dynamic object i'm getting third party library: iorderstore os = ss.getservice<iorderstore>(); iorderinfo search = os.orders.where(t => t.number == "test").firstordefault(); iorder orderfound = os.openorder(search, true); dynamic order = (dynamic)orderfound; dynamic requirements = order.title.commitments[0].requirements; i need parse json string. i tried (using json.net): string jsonstring = jsonconvert.serializeobject(requirements); return jsonstring; but seemingly corrupted json string, below: [{"$id":"1"},{"$id":"2"},{"$id":"3"},{"$id":"4"},{"$id":"5"},{"$id":"6"},{"$id":"7"},{"$id":"8"},{"$id":"9"},{"$id":"10"},{"$id":"11"},{"$id":"12"},{"$id":"13"},{"$id":&

swift firebase retrieving data error -

my if not working feelingref.child("conditions/needsattention").observeeventtype(.value) { (snap: firdatasnapshot) in print((snap.value?.description)!) if (snap.value?.description)! == 1 { self.conditionlabel.text = "관심필요" } } when print snap's value prints 1 if not working!!! it can string type check dynamictype of variable print(snap.value!.description.dynamictype) if (snap.value!.description)! == "1" { self.conditionlabel.text = "관심필요" }

bash - Keep only nth line if keyword present -

assume text file contains lines starting foo , bar , respectively. assume further print every fourth line of ones starting bar ; lines starting foo should printed. foo bar qux # deliberate empty line bar baz 1 bar baz 2 bar baz 3 bar baz 4 bar baz 5 bar baz 6 bar baz 7 bar baz 8 # miscellaneous code comment the following code prints every fourth line irrespective of first word , not looking for. awk '/^bar/ nr == 1 || nr % 4 == 0' infile what correct code (preferentially awk )? edit: thanks fedorqui excellent suggestion. considering potential appearance of empty lines , comments in input file, using following code: user$ awk '!/^bar/ || (/^bar/ && !(++c%4))' file foo bar qux # deliberate empty line bar baz 4 bar baz 8 # miscellaneous code comment just use counter: awk '/^foo/ || (/^bar/ && !(++c%4))' file this prints lines accomplish either of these: start "foo" start "bar" , happens

openlayers 3 - Feature grid not taking data from geoserver layer WMS using geoext 3 -

this grid.js file included in grid.html. don't know wrong code. have seen examples , tried perform same geoserver layer no output. code after variable store not working. want load file on web , display data in feature grid using geoext 3.0.0. kindly help. ext.require([ 'ext.container.container', 'ext.panel.panel', 'ext.grid.gridpanel', 'geoext.component.map', 'geoext.data.store.features' ]); ext.onready(function () { var wmslayer = new ol.layer.image({ source: new ol.source.imagewms({ url: 'http://localhost:8080/geoserver/opengeo/wms', params: {'layers': 'opengeo:abc'}, servertype: 'geoserver' }) }); var baselayer = new ol.layer.tile({ source: new ol.source.tilewms({ url: 'http://ows.terre

html - Font-weight vs <strong> vs <b> [ SEO, Semantics ] -

ok, need clarification here. 1) difference between <b> , <strong> tags fact <strong> used browsers don't support css-styling? accessibility browsers etc? if not, heck else needed, because otherwise don't understand meaning of "semantics" or "meaning" use <strong> instead of <b> . 2) there difference between <b> or <strong> tags , font-weight:bold in terms of seo? the theoretical , practical sides both interesting 2 above questions. thanks they same regarding seo, know difference between them. matt cutts google talked topic in 2006 , made video it, both same, on of them used in html , other 1 used inside wysiwyg editors. you can use them both , browsers , search engines understand them, , here video matt https://www.youtube.com/watch?v=awto_wceoj4

web scraping - how to get specific text after a div with xpath -

i trouble specific texts located between 2 tags. mean, want text after em tag. want this. , text after p tag. want this. . there way of doing that? in advance. <article> <h1 id='h1'>heading 1</h1> <img src='mypath/pictures/pic.jpg'></img> <p></p> <div id='div1'> <time datetime='2016'>2016</time> </div> <br></br> <em>my location, tn, united states</em> text after em tag. want this. <p></p> text after p tag. want this. <div id='div2'> </div> </article> you can following sibling texts using following-sibling::text() so em after text //em/following-sibling::text()[1] the same p tag, , join them string-join(em/following-sibling::text()[1] | p/following-sibling::text()[1] , ',') i hope help!

PHP How do I read the form variables with empty square brackets in their name -

Image
in php file when submit i'm able read following variables quite (see attached picture) $mobile = $_request['mobile']; $about = $_request['about']; $comment = $_request['comment']; now question is.. how read " category[] " form value? just read read normal variables. $category = $_request['category']; unlike other variables return php array . can iterate on variable normal php array . foreach($category $cat) { echo $cat; } make sure check if request have value you're looking using isset() . otherwise above code might throw undefined indexed error.

php - WooCommerce Checkout url hook - Change condition based on product category -

wondering if me customize code. change applied condition in code: <?php /* plugin name: modify klarna checkout url plugin uri: http://krokedil.com description: change checkout url klarna checkout if user isn't specific country version: 1.0 author: krokedil author uri: http://krokedil.com */ add_filter( 'woocommerce_get_checkout_url', 'krokedil_change_checkout_url', 30 ); function krokedil_change_checkout_url( $url ) { $allowed_countries = array('no'); $customer_country = wc()->customer->get_default_country(); if( !in_array( $customer_country , $allowed_countries ) ) { $url = wc_get_page_permalink( 'checkout' ); } return $url; } is possible instead, products belongs category in woocommerce, have custom checkout url? thanks yes it's possible, making changes: add_filter( 'woocommerce_get_checkout_url', 'krokedil_change_checkout_url', 30 ); function krokedil_change_checkout_url

objective c - Storing information about users in iOS -

i want store basic information , in cause sensitive data. the information typically want store is: username identityid (unique user identityid amazon users) other basic user details email (but no passwords stored) i read using nsuserdefaults easy hack or see , storing of usernames , identityid isn't enough. should use core data or else? need encrypt core data? data isn't super sensitive i'd still air on side of caution. technically 1 piece of data logged in user , cleared when user logs out. any simple tutorial on 1 record core data file great. use key chain store kind of data: import uikit import security // identifiers let serviceidentifier = "myserivice" let useraccount = "authenticateduser" let accessgroup = "myserivice" // arguments keychain queries let ksecclassvalue = ksecclass.takeretainedvalue() nsstring let ksecattraccountvalue = ksecattraccount.takeretainedvalue() nsstring let ksecvaluedatavalue = ksecvalueda

java - @WebFilter exclude url-pattern -

i use filter check url patterns logged in user. but have many url patterns need filter. { "/table/*", "/user/*", "/contact/*", "/run/*", "/conf/*", ..., ..., ...} it's becoming unmaintainable. simpler exclude: { "/", "/login", "/logout", "/register" } how can achieve this? @webfilter(urlpatterns = { "/table/*","/user/*", "/contact/*","/run/*","/conf/*"}) public class sessiontimeoutredirect implements filter { protected final logger logger = loggerfactory.getlogger("sessionfilter"); @override public void dofilter(servletrequest req, servletresponse res, filterchain chain) throws ioexception, servletexception { httpservletrequest request = (httpservletrequest) req; httpservletresponse response = (httpservletresponse) res; if (request.getsession().getattribute("id&quo

javascript - TypeError: $location.path is not a function -

<span class="button-icon pull-left" ><i class="ti ti-plus" ng-click="itemopen()"></i></span> this html code. $scope.itemopen=function() { return $location.path('/consultationparametermaster'); }; this script. , error is. $location.path not function you need inject $location in controller if going this. missing 'focus' parameter app.controller('samplecontroller', ['$scope','$http','$location', function($scope,$http,$location) { $scope.itemopen=function() { return $location.path('/consultationparametermaster'); }; } edit: according comment,you need arrange dependencies, coremodule.registercontroller('medicalrecordscontroller', ['$rootscope', '$scope', '$sessionstorage', 'restangular', '$element', '$thememodule', '$filter', &#

java - Arraylist Index adding with hashmap? -

inside arraylist need add hashmap values , declared arralist public static arraylist<map<string, object>> uploadingarray = new arraylist<>(); , map map<string,object> image_details=new hashmap<>(); , int imageid; for(int i=0;i<4;i++){ imageid=i; new method() } image id change when function calling activity imageid=(another activity).imageid; new method(){ image_details.put("imageid",i); image_details.put("status","new"); uploadingarray.add(imageid,image_details); } result of uploadingarray [0] id=3; status=new [1] id=3; status=new [2] id=3; status=new [3] id=3; status=new why id same position? 1 know issue please me? model "i" value changed calling method they have same values because you're adding same object multiple times arraylist . you should create new map object inside loop: arraylist<map<string, object>> list = new arrayli

angular - Angular2 - page refresh 404ing when hosted in Azure -

i working on angular2 app. uses "@angular/common": "2.0.0-rc.4" , "@angular/router": "3.0.0-beta.2". my problem when use browser refresh on of pages see error saying... " the resource looking has been removed, had name changed, or temporarily unavailable." this happens if hit url directly. an example url is... https://tilecasev2.azurewebsites.net/profile/therichmond however if view pages via homepage work ok until refreshed ( https://tilecasev2.azurewebsites.net ). i have below in index.html head... <base href="/"> why happen , how can fix it? hashlocationstrategy avoids issue including # in of angular routes doesn't fix it. to make angular routes without hashes work in azure same way in local development environment, need configure iis rewrite requests root. lets angular handle routing. to this, add web.config file site's root folder following contents: <configuration&