Posts

Showing posts from June, 2013

php - Retrieving data from multiple arrays using a while loop -

i'm looking way optimize following code using while loop.. i've got 4 arrays , pull 1st value each array in efficient way. original code works fine: $arr1 = array ("55", "66", "77"); $arr2 = array ("54", "64", "771"); $arr3 = array ("53", "62", "772"); $arr4 = array ("52", "60", "773"); $x = 1; $result = "null"; echo $arr1[0] . " | " ; echo $arr2[0]. " | " ; echo $arr3[0]. " | " ; echo $arr4[0]. " | " ; blow attempt optimize doesn't seems working: $arr1 = array ("55", "66", "77"); $arr2 = array ("54", "64", "771"); $arr3 = array ("53", "62", "772"); $arr4 = array ("52", "60", "773"); $x = 1; $result = "null"; while($x < 5) { $result = "$arr".$x."

Draw a polyline in Android google maps as the user move -

hy, i'm newbie in android, , i've learned android google maps. i'd tracking user movement , draw polyline path in android google maps in real time, can me example? can location chage interval still don't know how apply polyline , keep data latlng array. you need add this/related g.play services virsion line in gradle in case haven't. compile 'com.google.android.gms:play-services-maps:8.4.0' as official doc says , use code. googlemap map; // ... map. // add thin red line london new york. polyline line = map.addpolyline(new polylineoptions() .add(new latlng(51.5, -0.1), new latlng(40.7, -74.0)) .width(5) .color(color.red)); note : methods modify polyline must called on main thread if not, illegalstateexception thrown @ run-time. for sake know can find code here small logic keep start , end position latlng variables ( startlatlng , endlatlng ) as can see in example cannot send hard coded values,pass real values

ios - UICollectionView Animate when touched -

could point me in right direction on how animate uicollesctionview's cell when touched? i've read there several methods between didselectitemat uiview.animate or willdisplaycell caanimations. please point me in right direction in swift? goal tap cell , have scale/ change x position i choose "didselectitemat", "uiview.animate" override func collectionview(_ collectionview: uicollectionview, didselectitemat indexpath: indexpath) { let cell = collectionview.cellforitem(at: indexpath) animatedimage = uiimageview(frame: cell.frame) animatedimage.image = ... view.addsubview(animatedimage) uiview.animate(withduration: 0.5, animations: { self.animatedimage.frame = self.view.bounds self.view.layoutifneeded() }, completion: {(finished) in ... }) }

How to specify different readme files for github and npm -

both use readme.md description when publish. common practice use single shared file. but if need have different readme , still publish single local repo no manual editing/replacement ps i tried use "readme": "npm-readme.md" in package.json displays value of field, not content of а file

angular - Toggling the menu programmatically if I have more than one menu? -

if having 2 menu component in template below <button md-icon-button [md-menu-trigger-for]="menu"> <md-icon>more_vert</md-icon> </button> <md-menu #menu="mdmenu"> <button md-menu-item>refresh</button> <button md-menu-item>settings</button> <button md-menu-item>help</button> <button md-menu-item disabled>sign out</button> </md-menu> <button md-icon-button [md-menu-trigger-for]="menu1"> <md-icon>more_vert</md-icon> </button> <md-menu #menu1="mdmenu"> <button md-menu-item>refresh</button> <button md-menu-item>settings</button> <button md-menu-item>help</button> <button md-menu-item disabled>sign out</button> </md-menu> how programatically toggle second menu component?. @viewchild(mdmenutrigger) can use following if have 1 menu component in template. the

go - Correct on input but panic on output in golang -

trying write bit of go, create sort of cat function in golang: package main import ( "fmt" "os" "io/ioutil" "log" ) func main() { // part ask question , input fmt.print("which file read?: ") var input string fmt.scanln(&input) fmt.print(input) // part give output f, err := os.open(os.args[1]) // open file if err != nil { log.fatalln("my program broken") } defer f.close() // close things open bs, err := ioutil.readall(f) if err != nil { log.fatalln("my program broken") } // part print output fmt.printf("input", bs) // %s convert directly in string result } but go panic on execution , not find more explicit infor

python - Why can I not implement inheritance like this? -

this question has answer here: python assignment self in constructor not make object same 4 answers to begin with, know there right way implement inheritance this: class parent(): def __init__(self, last_name, eye_color): self.last_name = last_name self.eye_color = eye_color class child(parent): def __init__(self, last_name, eye_color, number_of_toys): parent.__init__(self, last_name, eye_color) self.number_of_toys = number_of_toys miley_cyrus = child("cyrus", "blue", 5) print(miley_cyrus.last_name) print(miley_cyrus.number_of_toys) when run piece of code, there result that cyrus 5 however when change 7th line : self = parent(last_name, eye_color) and the code has become: class parent(): def __init__(self, last_name, eye_color): self.last_name = last_name self.eye_color =

javascript - HumHub message notification body change -

Image
i want change how email notification looks like. i want in red rectangle gone. , button view now. any ideas?

jquery - Target first element inside its parent -

i'm having trouble targeting first element inside list item using :first. <li data-id="321"> <ul> <li data-id="380"> <ul> <li data-id="385"></li> </ul> </li> <li data-id="382"></li> </ul> </li> $(".drop .position").click(function() { $this = $(this); $targetid = $(".box-cont.active ").closest("li.box").data("id"); $childrenarray = new array(); if ($target.find("ul:first").find("li").length > 0) { $target.find("ul:first").find("li").each(function() { $this = $(this); $childrenarray.push($this.data("id")); }); alert($childrenarray); } else { alert("no children"); } i'm trying target children of first ul inside

Can't make a numeric textbox with one comma or dot in c# wpf -

i'm making program finances management in wpf , need textboxes ones title describes. before call duplicate, have searched in multiple sites , solutions proposed work fine numbers, don't seem recognize dot key or comma key (i use latin american qwerty keyboard), dont know if solutions tried region specific (because of keyboards) or on code. so far have tried: this, multiple regex have found around internet should have same result the same before manually comparing e.keychar convert.tochar(".") using keydown event , multiple if (e.key == key.dx) (this worked dot, not numbers , tried d0-d9 keys , oem ones) none of these seem work me, , because need math numbers , because of purpose need them have decimal dot (or comma) any or ideas appreciated. you use standard textbox allows character, , use event handler on keydown or textchanged checks text illegal characters (anything other number, comma, or period). this: private void textbox1_textchang

ios - Reuse same view in list and detail ViewController -

i have common list-detail app. tableview displaying index of items , detail viewcontroller showing single item more details. list: +-----------------+ | | | image 1 | | | +-----------------+ |button1 button2 | |=================| | | | image 2 | | | +-----------------+ |button1 button2 | |=================| | . | | . | | . | detail: +-----------------+ | | | image 1 | | | +-----------------+ | text | +-----------------+ |button1 button2 | <= same actions/handlers in list |=================| both have button bar multiple buttons (like, save, etc). how reuse logic of button bar? you want add functions (save, etc) class contains data (image, text etc). can call function anywhere want , same. example: class post { var image: uiimage? var text: string? func save() { // put cod

java - I am trying to launch app and it is crashing -

error: 01-14 20:59:18.266 27103-27103/com.example.android.cricketscore e/androidruntime: fatal exception: main process: com.example.android.cricketscore, pid: 27103 java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.android.cricketscore/com.example.android.cricketscore.mainactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'android.view.window$callback android.view.window.getcallback()' on null object reference @ android.app.activitythread.performlaunchactivity(activitythread.java:2366) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2517) @ android.app.activitythread.access$800(activitythread.java:162) @ android.app.activitythread$h.handlemessage(activitythread.java:1412) @ android.os.handler.dispatchmessage(handler.java:106) @ android.os.looper.loop(looper.java:189) @ android.app.activitythread.main(activitythread.java:5529) @

ImageView not displaying (Android) -

Image
i have code: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.ioann_000.cainstructionquiz.playactivity" android:clickable="false" android:animationcache="false" android:clipchildren="false" android:contextclickable="false" android:filte

angularjs - Module is not available, multiple controllers -

i spent 2 days , didn't find error: error: $controller:ctrlreg controller name not registered. controller name 'clientcontroller' not registered. i have 2 controllers , app.js: js/app.js js/controllers/client-controller.js js/controllers/login-client-controller.js clientcontroller: angular.module('loginclientmodule',[]) .controller('clientcontroller', ['$scope', '$http', '$state', function($scope, $http, $state) {....//some code }]) logincontroller: angular.module('loginclientmodule',[]) .controller('loginclientcontroller', ['$scope', '$http', '$state', function($scope, $http, $state) {....//some code }]) the app.js: const app = angular.module('clientproviderapp', [ 'ui.router', 'loginclientmodule' ]) app.config(['$stateprovider', '$urlrouterprovider', function($stateprovider, $urlrouterprovider) {

angular - how to set Index for angular2 -

<template ngfor let-item [ngforof]="faculytlecturemaster" > <tr *ngif="item.subjectname != 'break' && item.facultyname != 'na'" (click)="onlectureclick(item,0)" [class.selected]="item === _selectedhero" > <td> **set index number here** </td> <td>{{item.lectstart}}-{{item.lectend}}</td> <td>{{item.facultyname}}</td> <td>{{item.subjectname}}({{item.subjectcode}})</td> <td>{{item.attendtotal}}</td> <td>{{item.present}}</td> <td>{{item.absent}}</td> <td>{{item.section}}</td> </tr> </template> i want set index template in angular2 $index in angular1 i searched got solutions *ngfor="let item of _studentlist let i=index" work norm

php - issue in echo html attribute -

im trying added style attribute in conditions html input im using code if($verrou==true){echo '"style= font-weight: bold; color:#000;" '; echo "disabled"; $verrou=false;} i'm expecting output this: "style= font-weight: bold; color:#000;" disabled but im getting this "style="font-weight:" bold;="" color:#000;"="" disabled="" i can't figure out why happening , why code printing me things not in it so problem having attributes not formatted correctly in code - , if @ results in browser dom inspector, instance, browser it's darn best understand , "fix" wrong attributes gave it... so should expecting: style="font-weight: bold; color:#000;" disabled note position of double-quotes... this, code work: if($verrou==true) { echo 'style="font-weight: bold; color:#000;" '; // again, notice position of double-quotes echo &

c# - Error when create Sql job to remove server -

i have problem when add sql job c# code mssql server. if set serverinstance domain name exmaple: "s2n18p9s7" job created done, if use ip server adress "10.1.1.202" connection expection: microsoft.sqlserver.management.smo.failedoperationexception: apply target server failed job 'job1'. ---> microsoft.sqlserver.management.common.executionfailureexception: exception occurred while executing transact-sql statement or batch. ---> system.data.sqlclient.sqlexception: specified @server_name ('10.1.1.202') not exist. code used created task: server server = null; microsoft.sqlserver.management.common.serverconnection sc = new microsoft.sqlserver.management.common.serverconnection("10.1.1.202,1433", "removed", "removed"); server = new server(sc); server.loginmode = serverloginmode.normal; job job = null; jobserver jobserver = server.jobserver; jobschedule schedule = null; schedule = new jobschedule(jobserver, str

Why am I getting the Kafka Error Failed to initialize SASL authentication: SASL handshake failed when using Node.js client for Message Hub service ? -

i getting error failed initialize sasl authentication: sasl handshake failed (start (-4)): sasl(-4): no mechanism available: no worthy mechs found when trying use message hub bluemix service node-rdkafka why happening? this error indicates librdkafka (the library node-rdkafka wraps) has not been compiled sasl support. please ensure have required dependencies installed on system , reinstall node-rdkafka via npm for linux: libsasl2-dev libsasl2-modules for macos , more details, see our documentation librdkafka: https://github.com/ibm-messaging/message-hub-samples/blob/master/docs/librdkafka.md

vue.js - Vue Router beforeRouteLeave doesn't stop subcomponents -

i have simple question. want cancel sub-component when route changed. here sample. there home component parent. , has subcomponent. want stop interval function when route changes in subcomponent mounted import home "./components/home.vue"; import "./components/another.vue"; const routes = [ { path: '', component: home }, { path: '/another', component: } ]; const router = new vuerouter({ routes }); const app = new vue({ router }).$mount('#app'); and home component. home.vue <template> <sub-component></sub-component> </template> <script type="text/babel"> import subcomponent "./components/subcomponent.vue"; export default { components:{ 'sub-component':subcomponent } } </script> and subcomponent. subcomponent.vue <template> <div> sub component run interval </div> </template> <script t

jquery - how to make navbar collapse after click one link in one page -

so have navbar dropdown link pages , in page (link 1 page), why collapse function on navbar cant work? this code: <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <button type="button" data-target="#navbarcollapse" data-toggle="collapse" class="navbar-toggle"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <!-- collection of nav links , other content toggling --> <div id="navbarcollapse" class="collapse navbar-collapse"> <ul class="nav

c# - Passing an Object to InstallUtil as a parameter -

i have management application calls installutil.exe service installation. i have custom settings want give directly service. have chance xml file want give parameter. so have instance custom class , serialized xml , want give parameter , then, service deserialize setting instance. i see installutil has more 8000 length character limit ok me. tried pass parameter servicedescription takes 34 letters, not more. dont know mistake string args = xmlsettingshelper.serializeobject(serviceinstaller,false); var args =$"{serviceinstaller.serviceexepath} /i /servicename=\" {serviceinstaller.servicename}\" /servicedisplayname=\" {serviceinstaller.servicedisplayname}\" /servicedescription=\"{args}\""; var process = new process { startinfo = { windowstyle = processwindowstyle.normal, filename = installutilpath, arguments = args,

android - Headless fragment with arguments, how to use Fragment.newInstance? -

i've been working through 3 different tutorials headless fragment open sockets , stay open through lifecycle changes. think i'm close there 1 final element escapes me. guts of fragment opening sockets , threads based on class works i'm not concerned part, @ least now. here relevant parts of fragment, rest left out make less torturous read. i'm trying pass in p2p group owner's ip , port. (no problems that) public class connectionfragment extends fragment { private inetaddress mgoaddress; private int mgoport; private client mclient; private static final string tag = "connection"; private static final string client_tag = "client"; private server mserver; private socket msocket; private connectionfragmentlistener mlistener; public static connectionfragment newinstance(inetaddress address, int port){ bundle bundle = new bundle(); bundle.putserializable("goaddress", address);

java - Selenium PageFactory: initelements once per class? -

this more of java question selenium, since new java don't know answer. writing selenium tests using page object model. have pages in 1 class, , tests in another. however, trying execute pagefactory.initelements once per test class don't have add line in each test (in class, anyways, want this: import com.company.pages.loginpage public class logintests { loginpage login = pagefactory.initelements(driver, loginpage.class ); @test public void test1() { login.method(); } @test public void test2() { login.methodtwo(); } } but keep getting nullpointerexception on object defined in loginpage class. tells me page never initialized. since relatively new java, don't know how initialize it. help! try this: loginpage login; @before public void beforetest() { login = pagefactory.initelements(driver, loginpage.class ); } according this : annotating public void method @before causes method run befor

.htaccess - apache httpd disable directory browser -

i have configured apache add options -indexes disable directory browser how can access resources website: in html file (website host1) has image take 1 server apache (host2), if set options -indexes in apache (host2) prevent directory browser image in html can't access,too. how solve this? thanks! why web page, or else other human, need access directory listing? options -indexes stops directory listing being generated, not prevent access of resources.

angularjs - Cordova delete files after sqlite delete it -

i have app take picture or select gallery move file-system , save imgpath image sqlite db , display it, works great far , when delete imgpath sqlite db , want delete file-system @ same time . $scope.deleteimg = function(imgpath) { if (!imgpath) { console.error("no filename specified. file not deleted."); return false; } else { $cordovafile.checkfile(cordova.file.externalrootdirectory, imgpath.id).then(function() { $cordovafile.removefile(cordova.file.externalrootdirectory, imgpath.id).then(function(result) { console.log("image '" + imgpath + "' deleted", json.stringify(result)); }, function(err) { console.error("failed delete file '" + imgpath.id + "'", json.stringify(err)); }); }, function(err) { console.log("image '" + imgpath.id + "' not exist", json.stringify(e

javascript - Passing image back with Ajax call -

i trying pass image rest of ajax call. using facebook marketing api , using foreach() go through array's. works fine besides image. when try work out display image_url but, want actual image. there 3 files home.php data displayed (duh). fbdata.php date range data sent , api code is. , third file fbdwdrp.php , have date range picker , ajax call. need figure out how display actual image , not image_url. <?php require_once __dir__ . '/vendor/autoload.php'; use facebookads\api; use facebookads\object\aduser; use facebook\facebook; use facebook\exceptions\facebookresponseexception; use facebook\exceptions\facebooksdkexception; use facebookads\object\campaign; use facebookads\object\fields\adsinsightsfields; use facebookads\object\ad; use facebookads\object\fields\adsetfields; use facebookads\object\adcampaign; use facebookads\object\fields\adfields; use facebookads\o

Running a single node Elasticsearch on a remote computer for development -

i trying run elasticsearch in development mode on remote machine. possible pass bootstrap checks , have run in development mode on remote computer accessible other computers? in documentation, said should set discovery.type single-node don't know add that. i tried adding config file gave me error saying discovery.type: single-node invalid configuration org.elasticsearch.bootstrap.startupexception: java.lang.illegalargumentexception: unknown discovery type [single-node] for future reference, make changes: transport.host: localhost network.host: _site_

How to pass click event from custom action bar to current page of android ViewPager? -

i have activity android.support.v4.view.viewpager , custom actionbar . there three(0,1,2) pages in viewpager page 1 set default page , user can slide left , right. 1 fragment class used show ui each of pages,which has webview shows html data can collapsed , viewed on button click in webview . there button in action, , i'm required collapse , show these data on webview on click of button in actionbar . i've done problem items on viewing page of viewpager not toggling on click of button in actionbar, while page on left or right of working well. how can solve problem? correct method of doing this? you need write 3 interfaces in 3 fragments. you need register 3 fragments pager adapter/activity. whenever click on actionbar button check active/current page in viewpager. perform click operation on registered interface on basis of active/current page/fragment.

android - GoogleApiClient is not working in marshmallow and above devices? -

am using googleapi client getting user location working fine below marshmallow devices on marshmallow devices application getting crashed don't know reason can me out let me post code activity trying location: import android.app.activity; import android.content.context; import android.content.intent; import android.content.intentsender; import android.location.location; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.widget.textview; import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.googleapiavailability; import com.google.android.gms.common.api.googleapiclient; import com.google.android.gms.common.api.pendingresult; import com.google.android.gms.common.api.resultcallback; import com.google.android.gms.common.api.status; import com.google.android.gms.gcm.gcmnetworkmanager; import com.google.android.gms.gcm.periodictask; import com.google.android.gms.location.lo

python - Is ther a way to get port names from a mwavepy network created form a touchstone -

i'm trying use mwavepy parse touchstone files. it common add port names in touchstone format (s-parameters) under comment e.g.: ! touchstone file project b1 ! exported hfss 3d layout design 2015.2.0 ! terminal data exported ! port_u4d2_10::m_b_dqs_dn[1] ! port_u4d2_11::m_b_dqs_dp[1] ! port_u4d2_12::m_b_dq[10] ! port_u4d2_13::m_b_dq[11] ! port_u4d2_14::m_b_dq[12] # ghz s ma r 50.000000 is possible port names form mwavepy network? or data ignored when parsing (being comment). thanks, avihai

html - Inline block in a flexbox in the column direction -

how make c, d, e have display: inline-block occupy space need fit text inside of them , can appear next each (side side in row) in flexbox has flex-direction set column ? please note not want wrap c, d, e in container desired result body { padding: 0; margin: 0; } .container { display: flex; flex-direction: column; } .a,.b,.c,.d,.e { height: 50px; line-height: 50px; border: 1px solid; text-align: center; } .c,.d,.e { display: inline-block; } .a { background: cyan; } .b { background: yellow; } .c { background: orange; } .d { background: gray; } .e { background: pink; } <div class="container"> <div class="a">a</div> <div class="b">b</div> <div class="c">c</div> <div class="d">d</div> <div class="e">e</div> </div> i think best way go lines w

json - Type "Any" has no subscript members in Swift 3 during pulling array of data from server -

Image
this question has answer here: correctly parsing json in swift 3 4 answers i'm trying update project swift 3.0 , codes pulling data server give me error in following picture. i tried lot of solutions available here no useful result problem in case ? { let json = try jsonserialization.jsonobject(with: data, options: .allowfragments) if let countries = json["countries"] as? [string: anyobject] { country in countries { if let couname = country["countryname"] as? [anyobject] { country_names.append(couname) } if let coucode = country["code"] as? [anyobject] { country_codes.append(coucode) } } } } catch { print("error serializing json: \(error)") }

html - Staircase effect (jagged edges) on angled background linear-gradient only in OS X -

Image
this question has answer here: background image, linear gradient jagged edged result needs smooth edged 2 answers this screen part stage of this live page . all make background linear-gradient, angle , 2 colors (mostly second color transparent) no gradient @ all. the issue doesn't occur on windows. seems occur on mac os x browers. (chrome 53, safari 9.1.2, firefox 49 on mac os x 10.11.6, mbpr 15'' late 2013) background: linear-gradient(7deg, @color1 50%, transparent 50%); i not looking different approach implement angled lines i curious if there can rid of linear-gradient stair cases in mac os x browsers. use .myclass { background: @color; /* browsers not support gradients / background: -webkit-linear-gradient(7deg, @color1 50%, transparent 50%); / safari 5.1 6.0 / background: -o-linear-gradient(7deg, @color1 50%, tra

user accounts - How to check the physical existence of new members in a database? -

i'm sorry if stackoverflow not place discuss matter. also, not programmer. this i'm trying learn about: how legally check registration of new member on app or website, corresponds real physical person, pretty high level of accuracy / security. example, many gambling websites have kind of technology. there public database (maybe provided governments?) can used match new members verified physical people? know facebook having hard time doing that. i looking suggestions, , out of box thinking, on reliable way insure 1 account = 1 physical person only. links on subject appreciated. thank much.

c# - Wix bootstrapper How to prevent rollback -

i know if there way prevent rollback when package fail. like in case have .bat package sets user name , password services. , if fails, want show message @ end of installation telling user need set credential manually. when check credential before installation, , reason failed tell user credential wrong , ask him if wants continue. (else wouldn't want prevent rollback) i know there <exitcode/> in <exepackage/> can use prevent rollback, can't detect error value in bootstrapper. i tried read status in bootstrapper when package complete , return 1 of following: e.result = result.continue; e.result = result.ignore; e.result = result.ok; exemple of reading status: if (e.status == -2147024895) { e.result = result.continue; } but still rollsback. i got answer here: http://lists.wixtoolset.org/pipermail/wix-users-wixtoolset.org/ basically, need set package want handle return code vital='no' , in executepackagecomplete handler us