Posts

Showing posts from May, 2013

How to convert (decode) this url string to the actual word using PHP? -

what php function use convert this %25ce%2592%25ce%2595%25ce%259d%25ce%2596%25ce%2599%25ce%259d%25ce%2597 to actual string using php? the actual string written in greek characters , "ΒΕΝΖΙΝΗ" your string encoded 2 times. you can decode rawurldecode : $str = rawurldecode('%25ce%2592%25ce%2595%25ce%259d%25ce%2596%25ce%2599%25ce%259d%25ce%2597'); // $str = "%ce%92%ce%95%ce%9d%ce%96%ce%99%ce%9d%ce%97" $str = rawurldecode($str); // $str = "ΒΕΝΖΙΝΗ"

count - How to calculate total from Hashmap Java -

i have current output: first clusters: [[1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]] 0 : 4, probability: 0.8 , logval: -0.2575424759098898 1 : 1, probability: 0.2 , logval: -0.46438561897747244 0 : 3, probability: 0.6 , logval: -0.44217935649972373 1 : 2, probability: 0.4 , logval: -0.5287712379549449 0 : 5, probability: 1.0 , logval: 0.0 0 : 4, probability: 0.8 , logval: -0.2575424759098898 1 : 1, probability: 0.2 , logval: -0.46438561897747244 0 : 3, probability: 0.6 , logval: -0.44217935649972373 1 : 2, probability: 0.4 , logval: -0.5287712379549449 then each logval total them example: first data: 0 : 4, probability: 0.8 , logval: -0.2575424759098898 1 : 1, probability: 0.2 , logval: -0.46438561897747244 total[0] = (-0.2575424759098898) + (-0.46438561897747244) next, 2nd data: 0 : 3, probability: 0.6 , logval: -0.44217935649972373 1 : 2, probability: 0.4 , logval: -0.5287712379549449 total[1] = (-0.4421793564997

c# - xamarin how to open facebook and twitter app from my ios app by a button -

i'm developing ios app xamarin, in c#. have "contact" uiviewcontroller, buttons, including facebook , twitter. i need open facebook , twitter app app, points specific facebook page , twitter profile. which best way this? thanks in advance... try : device.openuri(new uri("fb://page/page_id")); device.openuri(new uri("twitter://user?user_id=userid")); for page_id right click on page , select view source page , find page_id facebook , same twitter find userid

javascript - Selected cells is not permanent when redraw table -

Image
i have table: <style> table .highlighted { background-color: #999; } table .unhighlighted { background-color: whitesmoke; } </style> <form> <div class="form-group"> <div class="input-group"> <div class="input-group-addon"> <i class="fa fa-search"></i> </div> <input type="text" class="form-control" placeholder="aramak İstediğiniz Ürün alanını giriniz" ng-model="src_product"> </div> </div> </form> </div> <div class="row"> <div class="col-md-10"> <br/> <table ng-table="userstable" id="prod

python - What is the asterisk for in signal and slot connections? -

in python qt, i'm connecting qlistwidget signal slot, this: qtcore.qobject.connect(self.mylist, qtcore.signal("itemclicked(qlistwidgetitem *)"), self.listeventhandler) my question is: trailing asterisk in qlistwidgetitem * do? a couple of bullet points explain (i'll try avoid c++ syntax): pyqt python wrapper around qt, written in c++. qt provides introspection classes inheriting qobject , using strings identify things. python has native introspection, c++ not. the syntax used called "old-style signals , slots" , uses c++ function signatures. c++ has more types of variables python. in c++, variable can value, reference, or pointer. pointers have asterisk after type name. qtcore.signal("itemclicked(qlistwidgetitem *)") refers qt signal called itemclicked has parameter pointer qlistwidgetitem , not item itself. in c++, looks like: void itemclicked(qlistwidgetitem *item); going strings introspection, identify signal

html5 - launch a web page automatically NativeScript -

there website of company, when open first time login page opens automatically. i'm going build mobile version of it. want when app opened, login page launched. how started? need use auto-launch? or need set page manually using openurl etc? is there typescript alternative this: // my-page.js var openurl = require("nativescript-openurl"); openurl("http://www.master-technology.com"); or should use webview? if so, how make launch automatically? thanks. if yоu using web-view need pass url , load on fly <webview url="https://www.nativescript.org" width="*" height="*"/> of course, can bind web-view url property , pass source dynamically. there plugin called nativescript-webview-interface can ease bi-directional communication. nice tutorial plugin can found here

yii - Outputting values not equal to certain values in yii2 -

Image
i output variables not equal values returns error of failed prepare sql: select * `tblsuunit` `unitid` != :qp0 there 2 models first model getting array of ids public function actionsunits($id){ $unitslocation = new unitslocation(); $id2 = unitslocation::find()->where(['officelocationid'=>$id])->all(); foreach( $id2 $ids){ print_r($ids['unitid']."<br>"); } } this outputs ids as 8 9 11 12 13 14 16 i take id , compare model(units model) , id values not similar above , output so have added $idall = units::find()->where(['!=', 'unitid', $ids])->all(); so whole controller action becomes public function actionsunits($id){ $unitslocation = new unitslocation(); $id2 = unitslocation::find()->where(['officelocationid'=>$id])->all(); foreach( $id2 $ids){ $idall = units::find()->where(['!=', 'unitid', $ids])->all();

java - Disable JPA query cache -

i have java ee program runs on wildfly 9 server. in program want record in database thousands of records in once. that's why in method use native query: public int record(collection<myentity> entities) { /** * following query like: * insert my_table (id, date, value) values * (1, '2016-02-24', 10), * (2, '2016-02-23', 8), * ... * (10000, '2016-02-01', 6); */ stringbuilder querystring = new stringbuilder("insert my_table (id, date, value) values "); (int = 1; <= entities.size(); i++) { querystring.append("?,?,?)"); if (i < parameters.size()) { querystring.append(','); } } query query = getentitymanager().createnativequery(querystring.tostring()); int parameterposition = 0; (myentity entity : entities) { query.setparameter(++parameterposition, entity.getid()); query.setparameter(++parameter

html - Make a sticky div in a bootstrap grid -

i'm looking way make div sticky bottom, footer, inside bootstrap grid, not on whole width. bootstrap has example of sticky footer , tried tweak make work in case couldn't. this approach, assumes sticky div not nested inside div. below code, need make .app-footer sticky bottom on width of it's parent div. <div class="row main"> <div class="col-xs-2 col-md-4 col-lg-5">...</div> <div class="col-xs-8 col-md-4 col-lg-2"> <div class="app"></div> <div class="app-footer"></div> </div> <div class="col-xs-2 col-md-4 col-lg-5">...</div> </div> edit: css i've tried doesn't work: html, body { height: 100%; } /* wrapper page content push down footer */ .app { min-height: 100%; height: auto; /* negative indent footer height */ margin: 0 auto -60px; /* pad bottom footer height */ padding: 0 0 60px; }

java - How to set my website page link in cron job? -

i trying add cron job comment link this . this page link , trying add link cron job comment section, /usr/bin/php -q /home/username/public_html/study_program/update_web_minner.php . wrong. how set cron job comment section? just edit crontab crontab -e add line previx # #my comment save cronjob again. thats all.

Count each word on a string Java -

i need make program reads multiple lines stdin count words , print words number of ocurrence if 2 or more words have same number have sort them alphabetically. e.g: hello world morning hello the output should be: hello: 2 good: 1 morning: 1 world: 1 i want know best way this, hashmap best way? this more interesting question looks on surface. basically hashmap<string, integer> choice, build map words count. you want entryset() out of map , drop entryset() map new arraylist<entry<string, integer>> . can use collections.sort sort arraylist custom comparator first sorts value , key. i'm not going provide code if you've specific questions of steps feel free ask.

saml 2.0 - LogOut from the application using Kentor -

in our asp.net project, using 'kentor.authservices.httpmodule' , have configured adfs. need implement logout functionality. found code "~/authservices/logout?returnurl=" + uri.escapedatastring(page.resolveurl("~/?status=loggedout")) samples. when implement in our code not work expected. (we believe session cookies not clearing). on logout need redirect adfs login page. configured saml logout endpoints in adfs , there no encryption certificate installed. reason issue? please find adfs bindings image thanks

isabelle - Should I use universal quantification in lemma formulation? -

for datatype natural = 0 | succ natural primrec add :: "natural ⇒ natural ⇒ natural" "add 0 m = m" | "add (succ n) m = succ (add n m)" i prove lemma add_succ_right: "⋀ m n. add m (succ n) = succ (add m n)" for being mathematical, important have universal quantification. however, using fact in simplifier, better without: lemma add_succ_right_rewrite: "add m (succ n) = succ (add m n)" what common wisdom these versions, 1 should prefer in circumstances? isabelle/hol has 3 ways universally quantify on variables in lemma statements: lemma 1: "⋀m n. add m (succ n) = succ (add m n)" lemma 2: fixes m n shows "add m (succ n) = succ (add m n)" lemma 3: "∀m n. add m (succ n) = succ (add m n)" additionally, free variables in lemma statements become automatically quantified: lemma 4: "add m (succ n) = succ (add m n)" lemmas 1, 2, , 4 yield same theorem, can used

CakePHP 3 : payment gateway integration like instamojo -

i want integrate instamojo payment gateway [github link] in cakephp 3 application. i'm new cakephp. there plugin integrate in application or other way use it. i'm using cakephp 3.2 1- go instamojo payment gateway , login credential 2- create payment button account 3- copy button (html) instamojo 4- paste in ctp file want.

What is this line in Android webview? -

Image
i`m trying make app webview in android , ios. , have question, when clicked area in android webview, orange line appear in android. furthermore doesn't appear in ios use same webview , same contents. line? guess android webview's attributes, i'm not sure. this screenshot when clicked area. little bit secure thing, please understand remove contents. it`s source : layout.xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/root" android:orientation="vertical" android:weightsum="10" style="@style/rootlinear" > <webview android:id="@+id/webview" style="@drawable/border" android:layout_width="match_parent" android:layout_weight="9.5" android:layout_height="0dp" /> and webview setting private void setwebviewinit(webview webview) { webview.setinitialscale(1); webview.getsettings().set

sql - Select different values from table based on condition -

the table structure below: ++id++++read_id++++read_type 101 201 30 102 201 35 103 201 40 104 201 60 105 202 50 106 202 60 i need select read_type based on following condition: condition 1: check each read_id if either 30,35 or 40 present. if present select maximum read_type present among 30, 35 , 40. instance read_id 201 has 30,35,40 , 60. result must 40. condition 2: if 30, 35 or 40 not present fetch maximum of read_type. instance read_id 202 has 50 , 60. result must 60. how can achieved single oracle sql query. you can using conditional aggregation: select read_id, (case when sum(case when read_type in (30, 35, 40) 1 else 0 end) > 0 max(case when read_type in (30, 35, 40) read_type end) else max(read_type) end) themax t group read_id;

GCC -O3 6.1.1, 5.3.1, 4.1.2 fails to compile a correct executable (recursive merge sort in C) -

the following program not compiled correct executable when using gcc (at least 6.1.1, 5.3.1, 4.1.2) , optimization -o3 (and -o2). gcc generates correct executable -o0 (and -o1). the output should (-o0): sorted array: 1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000 9.00010.0009999.00012.00013.00014.00015.00016.00017.00018.0001 9.00020.000 instead of (-o3): sorted array:11.00012.00013.00014.00015.00016.00017.00018.00019.00020.0009999.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000 9.00010.000 has idea of reason? bug of gcc? thanks! #include <stdio.h> #include <stdlib.h> double arr[20] = {20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; int merge(double arr[],int l,int m,int h) { double arr1[10],arr2[10]; int n1,n2,i,j,k; n1=m-l+1; n2=h-m; for(i=0; i<n1; i++) arr1[i]=arr[l+i]; for(j=0; j<n2; j++) arr2[j]=arr[m+j+1]; arr1[i]=9999; arr2[j]=9999; i=0; j=0; for(k=l; k<=h; k++) {

python - Processing all files in a directory- different types -

so i'm trying write code right run every file in directory function made. thing is, files in directory of 3 types (.wav, .txt, and, output of program, .textgrid), , need passed in arguments in code. so, example, specific .wav file must go it's specific .txt file, make names .textgrid file. these files arguments i'm passing through subprocess runs program, forced aligner penn state. let me know if confused code or function. also i'm new coding know code not efficient thing is. felt using input instead of argv easier instance, because don't know how specify there different amount of arguments each time (i'm trying make code more universal, purposes, there 1 program , 3 arguments each time. import subprocess import sys def run_file(num_args): prog = input('enter program directory: ') args = input('enter arguments\' directories separated space: ').split(' ', len(num_args)-1) subprocess.call([prog, args]) def main():

javascript - How to create a donut chart like this in chart.js -

Image
i not able put text 15% or 16% in graph. s there way it. since chart generation has changed lot chart 1.x ( docs ) 2.x ( docs ), depend on version using project : version 1.x not available doughnut charts if working pie charts, built in in data passing chart. see this jsfiddle more information , full result. version 2.x two methods : you can create new chart type using .extend() method. then during creation of new type, draw percentage in section. check this jsfiddle see result ( better first version, imho ). you can force tooltip enabled (as asked in this other question ). you have edit displayed in tooltip put percentage instead of value. , move (edit x , y positions) tooltip appear should be. the image displays pie chart, can make work doughnut.

google api client - Android Credentials API - No eligible accounts -

i attempting use google credentials api store credentials app. have downloaded , installed both sample apps here ( https://github.com/googlesamples/android-credentials ) tried code in own app. when attempting save credentials following error - status{statuscode=no eligible accounts can found, resolution=null}. i testing on nexus 5x single gmail account configured. any appreciated. to use credentials api google account smartlock enabled required. smartlock not supported accounts custom passphrase encryption (as issue). in addition, disabling custom encryption not seem update setting correctly on device, , not willing clear account , re-add see if fixes problem suggested me credit to: smart lock passwords not working on phones, error message "no eligible accounts on device"

uicollectionview - iOS Accessibility for CollectionView in a TableViewCell -

i'm working on accessibility of our project, , here uicollectionview put custom uitableviewcell. collectionview has tens of cells arranged in multiply rows rather 1 row. it raises issue when have voiceover on , move focus between collectionviewcells swiping left or right, system thought swiping between tableviewcells, since collectionview in tableview, , contentoffset of tableview changed according tableviewcell size, instead of collectionviewcell size. collectionview put in the tableview , don't think can change this. wondering has met case before , there anyway make collectionview accessible normal? this known bug in apple's sdk (sorry, don't have bug report reference) when nesting collectionview inside tableview. after experimentation, able work around using uiview wrapper collectionview before adding uitableviewcell's .contentview uiview *wrapperview = [[uiview alloc] initwithframe:cell.contentview.bounds]; wrapperview.accessibilityele

android - Using AnimationFactory.Java outToLeftAnimation -

i using method creator of animationfactory.java. can not figure out how implement 2 of these methods. i slide out 1 fragment , slide in one. here method trying use: * slide animations hide view sliding left. * * @param duration animation duration in milliseconds * @param interpolator interpolator use (pass {@code null} use {@link accelerateinterpolator} interpolator) * @return slide transition animation */ public static animation outtoleftanimation(long duration, interpolator interpolator) { animation outtoleft = new translateanimation( animation.relative_to_parent, 0.0f, animation.relative_to_parent, -1.0f, animation.relative_to_parent, 0.0f, animation.relative_to_parent, 0.0f ); outtoleft.setduration(duration); outtoleft.setinterpolator(interpolator==null?new accelerateinterpolator():interpolator); return outtoleft; } * slide animations enter view right. * * @param duration animation duration in milliseconds * @pa

user interface - Use Leanback UI on Mobile/Tablet for Android -

i developping mobile app phone/tablet devices looks leanback sample app . leanback ui used android tv. unfortunatly on android studio can't use leanback mobile projects. is there kind of custumized version of leanback can used on other devices ? p.s : i found project https://github.com/florent37/materialleanback i'm enable import on android studio, tells me don't have right sdk version. thanks in advance help. peace ! it looks project found old , using older dependencies. need go sdk manager , install sdk version 22 (lollipop mr1). you fork project , update use api version 24 works project.

python - How does this function find the value of another variable? -

here code: def caller(callee): callee() def wrapper(): def a(): print v0 in range(5): v0 = i*i caller(a) wrapper() the above code outputs: 0 1 4 9 16 but don't understand how a resolves variable v0 . can not find related python docs regarding language feature. the scope of variables defined in function includes nested functions within it. variables defined in wrapper() accessible within a() , because function nested in it. known lexical scoping , , it's used in creating closures. this explained in python resolution of names documentation: a scope defines visibility of name within block. if local variable defined in block, scope includes block. if definition occurs in function block, scope extends blocks contained within defining one, unless contained block introduces different binding name.

scala - How to access functions from traits? -

i new scala , trying use trait"s". code looks this. trait codehelper { def functioncall(x: integer){ def valuechecker(){ /*code perform required operation*/ } } } i access trait main scala class called "valuecreator" follows: class valuecreator() extends baseclass() codehelper { val value = valuechecker() } however code not work. error in main class "valuecreator" saying "not found: value valuechecker" could please tell me how access function trait? thank in advance time your definition of valuechecker inside method, functioncaller , called nested method . means former method function local , available functioncaller . if want make visible @ trait level, you'll need make separate method: trait codehelper { def functioncall(x: int) { } def valuechecker() { /*code perform required operation*/ } } although, seems want call functioncaller perhaps? class valuecreator

ios - Firebase storage error -

firebasestorage pod version (1.0.1) var storageref: firstoragereference! = firstorage.storage().reference() let uploadtask = storageref.putdata(uiimagepngrepresentation(image)!, metadata: nil) { metadata, error in if (error != nil) { } else { let downloadurl = metadata!.downloadurl print(downloadurl) } } i selected image imagepicker , tried save image data firebase storage. illustrated in firebase docs.( docs reference) upload data in memory section. it's throwing following error: *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsplaceholderdictionary initwithobjects:forkeys:count:]: attempt insert nil object objects[1]' *** first throw call stack: ( 0 corefoundation 0x02025494 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x03eb2e02 objc_exception_throw + 50 2 corefoundation 0x01f0

c# - Set Datetimepicker date NaN -

i have datetimepicker , save date selected save button in sqlserver code. reason need have nullable datetime: clienteadd.datalead = string.isnullorempty(form["datalead"]) ? (datetime?)null : datetime.parse(form["datalead"]); the save function works fine, problem when set datetimepicker loaded. recover data sqlserver code: var elemento = new{ datalead = clientelead.datalead } i sent 'elemento' view jquery , set datetimepicker: $('#datalead').datepicker('setdate', (new date(result.datalead))); when set 'datalead' have nan date. know problem conversion of datetime don't know how save , after load data. thanks all from docs here , javascript's date object can recive either milliseconds number or datestring . guess result.datalead object since datalead object (a c# datetime). that's why can't assignment want. the answer here explains how millis datetime . try following code (untested): v

qt - Zoom in scaled down QPixmap: can't restore original size -

Image
i making application need draw figures (i.e. rectangles) above picture , resize whole scene. i'm using qgraphicsview , qgraphicsscene . can't figure out why when using fitintoview() unable draw figures on top of picture (they drawn behind picture or outside bounds). now i'm using qpixmap.scaled() make image fit in qgraphicsscene . works fine except when need display big image , zoom in. because scaled image fit, became smaller , when call qgraphicsview.scale() image scales small 1 , can't find way "scale back" image original size. in zoom part of code tried replace pixmap not scaled copy can't scale same proportions figures scaling. appreciated! here load image , scale it qpixmap pix; pix = pixmap->scaled(wid, hei,qt::keepaspectratio, qt::smoothtransformation); scn = new qgraphicsscene(pw); pw->setscene(scn); p = new qgraphicspixmapitem(pix); p->setpixmap(pix); scn->additem(p); i draw figures this rect = new qgraphicsrecti

actionscript 3 - How can I get the Hit point on hit test between two dynamically added objects in AS3? -

Image
i want know actual hit point when dash line hitting triangle object. i using following codes hit between 2 object : target.hittestobject(border); where target triangle object , border group placed rectangle stroke solidcolordash. and using following codes getting hit coordinate : var x:number = target.x; var y:number = target.y; and giving x , y coordinate when dash line touching boundary of triangle object want coordinate when dash line touch bitmapdata of triangle object. so have idea how resolve issue or how hit coordinate. the following codes solve problem getting real collision: private var returnvalue:boolean; private var firstpoint:point; private var secondpoint:point; private var firstrectangle:rectangle; private var secondrectangle:rectangle; private var firstobjectbmpdata:bitmapdata; private var secondobjectbmpdata:bitmapdata; private var firstoffsetmatrix:matrix; private var secondoffsetmatrix:matrix; public function testcollision(clip1:disp

php - How to create integer out of array? -

is possible convert array values 1 single integer. example, have array numbers $array = array(7,4,7,2); is possible integer value 7472 array? simple use implode as $array = array(7,4,7,2); echo (int)implode("",$array);// 7472

html - How to write a CSS selector that works on nested divs and selects the closest match? -

Image
imagine have dynamically rendered page use classes class1 , class2 on divs contain each other: <div class="class1"> ... <div class="class2"> ... <div class="insider"> i have these selectors in css: .class1 .insider { ... } .class2 .insider { ... } now problem both selectors match above .insider , 1 later in css source code win. how can make selector win has classn parent closest .insider . below snippet reproduced problem, showed expectations inline styles. .other , .another div s there show depth of .insider not known, direct child selector ( > ) out of picture. /* layout: irrelevant issue */ .outer { height: 100px; width: 100px; } .inner { display: inline-block; height: 50px; width: 50px; margin: 25px 25px; } .insider { text-align: center; } /* colors: visual part should fixed */ .class1 { background-color: black; } .class2 { background-color: lightgray;

android - How to stop service immediately and forever -

can please explain me why service doesn't stop? , how stop service when device locked , stop forever. activity: public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); startservice(new intent(this, myservice.class)); intentfilter filter = new intentfilter(intent.action_screen_off); filter.addaction(intent.action_screen_on); broadcastreceiver mreceiver = new myreceiver(); registerreceiver(mreceiver, filter); } } my receiver: public class myreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { string action = intent.getaction(); if(intent.action_screen_on.equals(action)) { log.i("isscreen ","on"); } else if(intent.action_screen_off.equals(action)) { log.i("isscreen ","off");

javascript - Dividing a number to equal chunks -

i'm trying write function returns array of equally chunked dates , number of days pertaining dates. should there remainder of days appended array follow. expected outcome: [{ 'startdate' : 20160719 //dates generated momentjs 'numofdays': 5 },{ 'startdate' : 20160724 'numofdays': 5 },{ 'startdate' : 20160729 'numofdays': 3 }] below function i've written in can pass in start date (momentjs), total number of days (daystodisplay) , number of days divided (numofdays). function buildqueue(startdate, numofdays, daystodisplay) { if (!startdate || !numofdays || !daystodisplay) { throw new error('all params required!'); } var num = numofdays > daystodisplay ? daystodisplay : numofdays; var div = math.floor(daystodisplay / num); var count = daystodisplay; var rem = daystodisplay % num; var lastitem; var i; var arr = []; (i = 0; <= daystodisplay; += num) { ar

cocoa - Getting bundle identifier in Swift -

i'm trying bundleid using app's directory , i'm getting error: exc_bad_access(code=1, address=0xd8) application.directory! string let startcstring = (application.directory! nsstring).utf8string //type: unsafepointer<int8> let convertedcstring = unsafepointer<uint8>(startcstring) //cfurlcreatefromfilerepresentation needs <uint8> pointer let length = application.directory!.lengthofbytesusingencoding(nsutf8stringencoding) let dir = cfurlcreatefromfilesystemrepresentation(kcfallocatordefault, convertedcstring, length, false) let bundle = cfbundlecreate(kcfallocatordefault, dir) let result = cfbundlegetidentifier(bundle) and error on result line. what doing wrong here? one potential problem code pointer obtained in let startcstring = (application.directory! nsstring).utf8string //type: unsafepointer<int8> is valid long temporary nsstring exists. conversion c string can done "automatically" compiler (compare string

xml serialization - XML Serializing and Deserializing List<string> in c# -

i have object of following class [xmlroot("http://schemas.abc.com")] [datacontract] public class employee { [xmlattribute] [datamember] public list<string> positions { get; set; } } positions contains following 2 strings "project manager" , "senior project manager" i serialized object through following method , saved in db public static string serialize(employee entity) { var memorystream = new memorystream(); var serializer = new xmlserializer(typeof(employee)); using (var xmltextwriter = new xmltextwriter(memorystream, encoding.unicode)) { serializer.serialize(xmltextwriter, entity); xmltextwriter.close(); } return unicodebytearraytostring(memorystream.toarray()); } private static string unicodebytearraytostring(byte[] input) { var constructedstring = encoding.unicode.getstring(input); return constructedstring; } then retrieving , deserializing object through following

decorators execution of python -

registry = [] def register(func): print('running register(%s)' % func) registry.append(func) return func @register def f1(): print('running f1()') @register def f2(): print('running f2()') def f3(): print('running f3()') def main(): print('running main()') print('registry ->', registry) f1() f2() f3() if __name__=='__main__': main() in above program why doesnt f1() f2() , f3() in main work if return func not used in register function a decorator higher-order function takes function input , returns function output. decorator syntax way of calling higher order function. the lines @register def f1(): print('running f1()') are equivalent lines def f1(): print('running f1()') f1 = register(f1) usually, decorator modifies decorated function. in case returned unmodified. -- still returned. if decorator returned nothing decorator replace f1 none (which wouldn't usefu

performance - Which caching will be faster, data as files in folders and sub folders or data as database content? -

after getting answer @andrew regan, have edited question , explanation. i want serve html data millions. , came know - done caching. i knew html files , have read html pages stored in databases serve. thus question is, of following caching quicker - caching of html files in different folders , sub folders or - caching of html data in database. even if experiment done on single file / table record, method faster? (no doubt result single file or record out in nano seconds, yet, caching happen faster? e.g. either 1 procedure take 0.000000001 second , procedure take 0.000000002 seconds. you haven't told application's architecture, or expected traffic, or whether you've considered existing frameworks solving problem. high-level view. the answer caches . with static content shouldn't need expose end user performance of either filesystem or database. shouldn't want anyway. if you're serving fixed, unchanging, static content, on single se

laravel 5 - VueJS: Uncaught (in promise) TypeError: Cannot read property 'push' of undefined -

i getting 'cannot read property push of undefined' error: here vuejs code: data:{ coisignedlistuid:[] } methods:{ fetchcoisigned: function () { this.$http.get('/cimsm/public/api/fetchcoisigned/' + this.conflictofinterest.complaintid).then(function (response) { var data = response.data; this.$set('coisignedlist', data); data.foreach(function (detail) { this.coisignedlistuid.push(detail.uid); }); }); what doing wrong? thanks this.coisignedlistuid not defined probably because this not this think is you should do var _this = outside function , then _this.coisignedlistuid.push(detail.uid); alternatively, can use es2015 arrow syntax. instead of: .then(function (response) {} use: .then((response) => {} the 'this' available inside function no need creating new variable. full details here .

php - insert data in a wordpress database -

i'm developing wordpress plugin responsible getting data external html form , inserts in database. form code is: <html> <body> <form action = "http://wp.istic.online/wp-content/plugins/news-apps/index.php" method = "post"> name: <input type = "text" name = "name" /> <input type = "submit" /> </form> </body> </html> my plugin code is: <?php register($_post['name']); register($_post['name']); function register($name) { global $wpdb; $wpdb->insert( 'gcm_tokens', array( 'token' => $name ), array( '%s' ) ); } the data not inserted when try echo $name variable works perfectly. when try echo after insert function it's not working. any please? use wp_nonce_field() below <form> /* code */ <input type="hidden&qu

hadoop - Java: Downloading .Zip files from an FTP and extracting the contents without saving the files on local system -

i have requirement in need download .zip files ftp server, , push contents of archive(contents xml files) hdfs(hadoop distributed file system) . hence of now, i'm using acpache ftpclient connect ftp server , downloading files local machine first. later unzipping same , giving out folder path method iterate local folder , push files hdfs. easy understanding, i'm attaching code snippets below. //gives me active ftpclient ftpclient ftpcilent = getactiveftpconnection(); ftpcilent.changeworkingdirectory(remotedirectory); ftpfile[] ftpfiles = ftpcilent.listfiles(); if(ftpfiles.length <= 0){ logger.info("unable find files in given location!!"); return; } //iterate files for(ftpfile eachftpfile : ftpfiles){ string ftpfilename = eachftpfile.getname(); //skips files if not .zip files if(!ftpfilename.endswith(".zip")){ continue; } system.out.println("reading file -->

regex - Delete tags between specific tags in XML (Notepad++) -

Image
i used search function didn't find answer question. i have xml structure following (example): <task name="1b"> <person type ="xx" name="yy" height="zz"/> <person type ="xx" name="yy" height="zz"/> <person type ="xx" name="yy" height="zz"/> </task> <task name="1c"> <person type ="xx" name="yy" height="zz"/> <person type ="xx" name="yy" height="zz"/> <person type ="xx" name="yy" height="zz"/> </task> now want delete via notepad++ tag name "1b" , tags between open , closing tag. there way in notepad? tried regex pattern didn't right way. using regex html discouraged since leads many issues , unnecessary questions. see regex match open tags except xhtml self-contained tags . using xs

eclipse - Include one project's jar libraries in another project depending on the first -

i working on 2 projects in eclipse. project depends on jar files come project, , jar files have been added “libraries” tab in project a's “java build path” property in eclipse. project b depends on project a, directly using classes in of jar files in project a's build path. i had assumed adding project project b's java build class add jars in project a's build path, appears not case. do have manually add jars project b's build class, or overlooking setting? if so, why useful standard behaviour? you have manually add jars project b's classpath. adding project dependency means project depends on compiled output of project b. project b's output (its compiled .class files) doesn't contain .jar files depends on. why this? don't know rationale of eclipse authors, guess want keep classpath simple , verbose possible. things can confusing if have multiple versions of same library on classpath. in vanilla java can provide directory

Installing WordPress multisite on a domain with subfolder -

just moved wordpress multisite localhost live server. destination folder has 2 sub directories mydomain.com/dir1/dir2 i'm getting err_too_many_redirects error can me out. i've made necessary url updates in database. thanks wp-config /* multisite */ define('wp_allow_multisite', true ); define('multisite', true); define('subdomain_install', false); define('domain_current_site', 'mydomain.com/dir1/dir2'); define('path_current_site', ''); define('site_id_current_site', 1); define('blog_id_current_site', 1); .htaccess # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] # uploaded files rewriterule ^([_0-9a-za-z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [l] # add trailing slash /wp-admin rewriterule ^([_0-9a-za-z-]+/)?wp-admin$ $1wp-admin/ [r=301,l] rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriteru

wordpress - Limit wp-rest-api posts request to an array of postID's -

my complete project need return nearest-posts given geolocation . i succeeded in doing building custom callback function seeking nearest posts building custom array containing data-fields of nearest posts. if define function callback function of route works great! all ok return copy of default post-return, of course limited nearest posts. , not set of custom defined fields. i can't seem figure out how this. before going details know way go. plan, doesn't work, : extend wp_rest_posts_controller register (and initialize) new route define custom callback function in new route the custom callback function builds array of postid 's nearest ( lat&long passed in http request ) so far comes problem. how pass array of postid s get_items method of wp_rest_posts_controller in order " default " return of specific(nearest) posts clearly simple approach doesn't work public function custom_callback_function($geoloc_array) { // call f

visual studio - VS2015, how to add TimeStamp to the output directory name? -

i using vs2015, common c++ project. possible add current time or date or timestamp name of output directory? for example: press "build" button @ 15:23:45 , .exe file outputs /bin/2016_02_29-15_23_45. an alternative solution add post-build event running script adding folder link named timestamp , targeting output folder. for timestamp, follow this link something : set timestamp= ... mklink /d %timestamp% %1 invoke script passing first wanted vs2015 var, myscript.bat ${outputfolder} nb: may need have admin permissions invoke mklink

sql - How to design this DB structure in MySQL? -

Image
i stuck on how implement more complicated (at least me) database structure, seems me dynamic number of columns in table. what need create sql table/s shuttle module store many shuttles each has different number of seats , every seat should have different price. for example: 1 row: shuttle 8 seats, seat #1 = $20, seat #2 = $15, seat #3 = $13 ... seat #8 = $7. 1 row: shuttle 16 seats, seat #1 = $25, seat #2 = $22, seat #3 = $20 ... seat #16 = $15. the solution should handle different types of shuttles, 1 8 seats, 1 16 or other number of seats depends on number of seats admin wish add. now, thought few methods , think both not enough. 1. first idea is create table maximum of 16 columns seats, nullable , admin inserts new shuttle numbers of seats needed , rest null. feel bad idea. let's ignore case if admin wants add more 16 seats huge drawback, how table like: table: shuttle columns: id, name, num_of_seats, seat_1_price, seat_2_price, seat_3_price..., seat_16_price

Postgresql Linked Server Query very Slow -

i have problem: making queries on linked server postgresql slow, very, slow, example: if run in pgadmin query: select max(oldmedicionid) tl.tlinputtable it returns max result in just: 246 msec but if run on linked server (using sqlserver 2008), create dblink using odbc postgresql, if run this: select max(oldmedicionid) linkpdatl.pdatl.tl.tlinputtable the query give me result in 1 minute or more sometimes... what problema?, think not postgresql database, dblink slow, how can improve performance? identification : there chances aggregation max(x ) in odbc method being done @ client side (not @ server side). can cross-checked seeing doubling row-count approximately double query time well. resolution : if among few corner cases, create view computes on postgres server-side, , odbc pick aggregated value.