Posts

Showing posts from March, 2013

spark Container killed by YARN for exceeding memory limits -

i'm running spark in aws emr. it's simple computation of pagerank, dataset 8gb i use 6 m3.xlarge cluster,each 16gb memory here configuration spark.executor.instances 4 spark.executor.cores 8 spark.driver.memory 10473m spark.executor.memory 9658m i'm new spark, have no common sense how memory-consuming it's......is cluster small? , memory hard limit? or , small memory ok computing slow.... here code (in our homework we're not allowed use graphx, use plain function) import org.apache.spark.sparkconf; import org.apache.spark.sparkcontext; import org.apache.spark.rdd.rdd; object pagerank { def main(args: array[string]): unit = { val conf = new sparkconf().setappname("pagerank") val sc = new sparkcontext(conf) val iternum = 10 val file = sc.textfile("hdfs:///input") val = file.flatmap { line => line.split("\t") }.distinct() val contributor = file.map ( line => line.split(...

javascript - POST Request not returning array from API - ngresource -

Image
i'm trying learn angularjs , on ngresource part. what i'm trying post request api return me array information in console log after button click. /*---------service----------*/ app.factory('gettablegriddataservice', function ($resource) { return $resource('api-url-adress', {}, { 'save': { method: 'post' } }) }); /*---------controller--------*/ $scope.fillrealtable = function () { alert('getting data...'); var arraybody = {}; var query = gettablegriddataservice.save({}, arraybody); query.$promise.then(function (data) { var loggitemlist = data; alert('done!'); $scope.loggitems = loggitemlist console.log($scope.loggitems); alert('console log displayed!') }) } <!--button--> <button type="button" class="btn btn-default pull-right" style="mar...

How can I connect to Apache Subversion Repository C++ with Qt4 -

i want gui application shows project table in subversion repository folder. i want display tables in following address https://atlas/svn/prjsvn/trunk/common/master_table/master how can connect svn repository qt4 , extract tables. how display gui in folder form. gui application using linux qtcreator in qtsdk. thanks help.

java - saaj client program getting response as wsdl file code -

i not getting proper response, getting response wsdl file code. please tell me how resolve problem proper response public class saajclientdemo { private static soapmessage createsoaprequest() throws exception { messagefactory messagefactory = messagefactory.newinstance(); soapmessage soapmessage = messagefactory.createmessage(); string loginpassword = "xx:xx"; soapmessage.getmimeheaders().addheader("authorization", "basic " + new string(base64.encode(loginpassword.getbytes()))); // creating soap part soappart soappart = soapmessage.getsoappart(); soapenvelope soapenvelope = soappart.getenvelope(); soapenvelope.addnamespacedeclaration("urn", "urn:sap-com:document:sap:soap:functions:mc-style"); soapbody soapbody = soapenvelope.getbody(); soapelement soapelement = soapbody.addchildelement("zfmaddrole", "urn"); soapelement e...

angular - Angular2: implementing the tabs -

i want implement tabs on page , therefore went through tutorial https://dzone.com/articles/learning-angular-2-creating-a-tabs-component somehow not working me plunker: http://plnkr.co/edit/jwbb7jd8kdxmndgbz4zn?p=preview import { component, oninit,input } '@angular/core'; @component({ selector: 'tab', template: '<div [hidden]="!active" class="pane"> <ng-content></ng-content> </div>', styleurls: ['./tab.component.css'] }) export class tab{ @input('tabtitle') title: string; @input() active = false; } and tabs component: import { component, oninit,contentchildren,querylist ,aftercontentinit} '@angular/core'; import { tab } './tab.component.ts'; @component({ selector: 'tabs', template: `<ul class="nav nav-tabs"> <li *ngfor="let tab of tabs" [hidden]='true' (click)="selecttab(tab)" [...

Google cloud pub/sub to Datastax Cassandra( In google cloud) -

i have deployed 9-node datastax cluster on google cloud. now i've been given requirement read data queue's , load datastax on google cloud( continues streaming). i know pub/sub can read data queue not sure whether can directly load datastax. is possible pub/sub load data datastax on google cloud ? i new pub/sub not sure start or how start. thanks, there no automatic way load data google cloud pub/sub datastax. have create subscription , write subscriber code gets messages subscription , writes them datastax. quickstart guide place start steps necessary.

clojure - Slow Braintree API Requests from Travis CI -

i have written server-side clojure service makes use of braintree java sdk. makes requests create payment tokens, create customers, handle notifications etc etc. have suite of tests written test making calls braintree sandbox. works well, until try run tests on travis. on travis, @ least 50% of time, build fails because times out, , have narrowed down call first call made braintree sdk (which in case find customer, doesn't seem matter call first). code sits there minutes waiting call complete. can happen quickly, other times 10 minutes can pass , travis job gives up. never happens locally. does have idea what's going on? since seems affect first call braintree, perhaps handshaking process? has else seen issue? while shot in dark, might issue build platform lacking entropy source, , part of code and/or dependencies blocking on reading random device. if lack of entropy source case, resolved installing haveged. in order install , start haveged , use of apt addon...

javascript - Why is DOM copied when I press enter key on the end of content in ContentEditable? -

while i'm making web editor contenteditable, met strange action. if press enter key in contenteditable element, current line's dom copied next line. , press enter key again, dom copied again. situation occur when caret end of content. text content not occur way. produced situation on latest chrome browser. <div id="editor" contenteditable="true" style="border:1px solid #000; width:500px; height:200px;"> <p><span class="name">content</span></p> </div> <div id="before" style="border:1px solid blue; width:500px; height:100px;"></div> <div id="afterenterkeypressed" style="border:1px solid red; width:500px; height:100px;"></div> $('#editor').on('keyup', function(e) { var keycode = e.keycode; if (keycode === 13) { $('#afterenterkeypressed').text($('#editor').html()); } }); $...

c# - Can read file from local computer, but not from IIS server -

i've got mvc site i've published remote server running iis, i've got problem site can upload documents folder (on server, within site header folder) via site, "access denied" error whenever try read same document. at first thought may have been simple permissions problem, checked security on folder , it's showing full control domain users on it, , when run project locally through visual studio can open without problems. i assumed may context of site running under iis, don't know if changes need made in iis or on folder permissions themselves. can help? edit i'm opening file using process.start like: system.diagnostics.process.start("filepath"); edit 2 i've edited app pool site running on , set allow process interact desktop, has not worked. have tried setting app pool load user profile based on suggestions found elsewhere has not worked either. other suggestion i've found set app pool identity "local system...

swift - How to add custom data to overlay in Google Maps for iOS? -

how can add custom data gmsgroundoverlay images in google maps ios? passing data on markers when clicked built-in "marker.userdata" ground overlays dont have property? okay figured out if it's helpful else. not sure if best way this, works. 1.) extended gmsgroundoverlay class in map's main .swift file extension gmsgroundoverlay { private struct customdata { static var userdata:any? = nil } var userdata:any? { { return customdata.userdata } set { customdata.userdata = newvalue } } } 2.) pass data on overlay before overlays added map let overlaydata:[string:any] = ["id":id,"html":html,"picture":picture,"photos":photos] overlay.userdata = overlaydata 3.) receive data when overlays clicked func mapview(_ mapview: gmsmapview, didtapoverlay overlay: gmsgroundoverlay) -> bool { print...

c# - logical error while comparing "-" with any record existing into the table -

what trying compare "-" in textbox record in table , code is: string cusph = txt_phone.text; tbl_custumer findcustumer = _objdb.tbl_custumer.where(obj => obj.cus_ph == cusph).firstordefault(); if (findcustumer != null) { strcusid = findcustumer.cus_id.tostring().trimend(); response.write("<script language='javascript'>alert('custumer registered ')</script> "); } the problem when want compare (obj.cus_ph == cusph) when value of cusph "-", if condition becomes true , should not happen.

bash - Using local variables from "child" functions -

consider following code: function child() { echo $var } function parent() { local var=5 child } i've tested on machine , seems work wasn't able find definitive describing such usage of local variables. namely, when declare local variable in 1 function , function call other function, can use variable in latter (and nest deeper)? legal in bash , standard versions? bash uses dynamic scoping. value of var in child not determined child defined, called . if there no local definition in body of child , next place shell looks in body of function child called, , forth. local modifier creates variable in function local call, not affect value of variable enclosing scopes. is, though, visible enclosed scope. a () { echo "$var"; } b () { local var="local value"; a; } var="global value" # outputs "global value" b # outputs "local value"

javascript - Cordova Media Plugin Record audio Error -

i built android application record audio using cordova media plugin. when press record button, creates audio file. once recoding complete: if press button audio file empty. if go location pressing home key audio file ok , playable. how can fix behaviour when using button? .controller('mycontroller', function($scope, $ionicplatform, $cordovamedia,$cordovadevice , $timeout, $interval) { $scope.timerwithinterval = 0; //$ionicplatform.ready(function() { try { $scope.timerwithinterval = 0; var mediarec; $scope.startrecord = function() { $scope.timerwithinterval = 0; if($scope.myinterval){ $interval.cancel($scope.myinterval); } $scope.oninterval = function(){ $scope.timerwithinterval++; } $scope.circle = "outer-circle-active"; $scope.myinterval = $interval($scope.oninterval,1000); var random = math.floor((math.random() * 100000) + 1); ...

API to retrieve subscribers with statistics from journey in Marketing Cloud (former ExactTarget) -

we have following task: in marketing cloud there few journeys created journey builder. assigned different data extensions via event source. i'm going receive data extension rows participate in specific journey. need retrieve basic statistics participants shows actual status of participant (data extension row in journey) like: current place in journey participant (received first email, received sms in line after first email etc.). to retrieve participants suspect have use: get /interaction/v1/eventdefinitions/{eventdefinitionid} eventdefinitionid id /interaction/v1/interactions/{journeyid} please correct me if i'm wrong. the question if there api allows retrieve statistic data described below. thanks, roman

ios - Swift prepopulate modal content before opening -

i unable find answer of in swift 3 there way pre-populate modal view controller data before opening it? i'm thinking not believe modal view controller won't exist @ point. here i'm trying achieve. have modal contains table view bound data used filter content on parent controller. parent controller has pass data modal used in it's table view (i having init in modal controller). have delegate going parent modal content in modal same looking way set modal table view data don't have rebind every time opened how following done. func presentmodal(){ let modalvc = roadwaysviewcontroller(roadways: roadways) modalvc.modalpresentationstyle = .popover modalvc.preferredcontentsize = cgsize(width: 300, height: 350) modalvc.delegate = self self.present(modalvc, animated: true) } the problem roadways same, binding same data on , over. there way around this? give modally presented view controller variable hold data, var data: [mystruct]? ...

twitter bootstrap - PHP loop not working inside of modal -

i have button opens modal , button inside of function. function gallery_full() { ///some code above $lisos='<button type="button" class="btn-red btn-xs btn btn-default" data-toggle="modal" data-target="#lisos'.$number.'" style="background-color:#cf000f; color:white; margin-right:-10px; "><span class="glyphicon glyphicon-info-sign"></span>&nbsp; cores lisas</button>'; ///some code below } as can see in data-target have variable called $number , defined in function. i created modal inside of function, working content of modal should looping , displaying products,but not. showing wrong product, each product in db has row called number_ , contains number 1-0, 1-1, 1-2, 2-0 , on. my modal inside of loop need other loop inside of it. because want products contains same number_ value of $number can pass $number variable first function function? this first function my mod...

mongodb - Python 2.x - How to work correctly with text in UNICODE -

okay, i'm trying manipulate list of texts obtained through mongodb. here how can create list , iterate on attribute contains messages: client = mongoclient('localhost:27017') db = client['...'] query = {'message': {'$exists': 1}, 'id': {'$exists': 1}, 'created_time': {'$exists': 1}} projection = {'_id': 0, 'message': 1} db_messages = db['dadoscoletados1'].find(query, projection) message_list=[] id_list=[] time_list = [] document in db_messages: key, value in document.iteritems(): if key == 'message': message_list.append(value) #print value word_final = status_processing(message_list) else: id_list.append(value) time_list.append(value) pair_up = zip(id_list, message_list, time_list) what happens following, if give find in mongo shel...

ssl - .NET reading cryptographic files from AWS S3 - some files fail on prod, succeed on dev -

i running certificate store off of s3 asp.net cloud application. class s3certificatestore reads .pfx files , password files s3, , creates certificates in memory. private void loadprivatecerts(x509certificate2collection certificates) { var s3files = s3facade.listobjects(config.bucket, config.privatepath).tolist(); foreach (var filepath in s3files) { if (filepath.endswith(".pass") || filepath.endswith("/")) { continue; } try { var certbytes = s3facade.getobject(config.bucket, filepath); var pwdbytes = s3facade.getobject(config.bucket, filepath + ".pass"); var pwd = encoding.utf8.getstring(pwdbytes); var cert = new x509certificate2(certbytes, pwd, x509keystorageflags.exportable); // needs exportable! certific...

How to add custom filter for Kendo ComboBox -

i have used combobox displays user name(first name last name). need filter these record statrswith filter either first name or last name. if use startswith, considering first name searching criteria. since there many names, has more 3 words can not split name in firstname, lastname. can use below ? myjavascriptcode return true or false based on custom logic $("#abc").datasource.filter({ field: "name", operator: "myjavascriptcode", value: value1 });

Building an embedded framework for WatchOS and iOS in XCode 8 with Swift 3 -

i in process of porting ios + watchos 1 app written in swift 1, latest xcode 8, watchos 3, swift 3. my app has embedded framework common functionality used compile , run file both watchkit extension target , ios app target. with xcode 8 can no longer seem work. when try import framework in watchkit extension code, module not found error. is still possible compile , use 1 single embedded framework package on both target ios , watchkit extension targets? in framework have target platforms set watchos, watchsimulator, iphoneos, iphonesimulator . my gut says it's not possible anymore. code ran on phone itself, not codes runs on actual watch , phone, you'd need compile embedded framework each.

Trigger Email Send After Cron Job Finished -

i have cron file contain # edit file introduce tasks run cron. # # each task run has defined through single line # indicating different fields when task run # , command run task # # define time can provide concrete values # minute (m), hour (h), day of month (dom), month (mon), # , day of week (dow) or use '*' in these fields (for 'any').# # notice tasks started based on cron's system # daemon's notion of time , timezones. # # output of crontab jobs (including errors) sent through # email user crontab file belongs (unless redirected). # # example, can run backup of user accounts # @ 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # more information see manual pages of crontab(5) , cron(8) # # m h dom mon dow command mailto="myemail@gmail.com" * * * * * php /home/forge/biossantibodies/artisan products:exportdiff --env=development * * * * * php /home/forge/biossantibodies/artisan images:exportdiff --env=development *...

javascript - Changing pictures on servlet with websocket -

i have small website each times user cliks on image, changes. made on html5, js, java , wildfly. know how update image others users browsers well? mean, each time clicks on image, changes, , want change on other users on website moment well. made connection of javascript , java json, how can send message java javascript? json again? thanks in advance i can think of 2 options: client side, poll server periodically, asking if should new image; if yes, it connect websocket , , send notification server client telling new image option 1 pretty easy implement. create endpoint on backend keeps track of "current" image. clients can hit endpoint, , update image if determine necessary. disadvantage polling server of clients. option 2 bit more robust. websocket allows bidirectional communication. so, on server side still track current image. when client clicks image, send message (client->server) notifies backend change image. then, server can send out ...

mysql - How to get data from two tables from database? -

can explain me, why code not working? select sum(`cash`) `cash`,count(*) `rows` `table_1` `login` = 'test' union select count(*) `rows2` `table_2` `login` = 'test'; in phpmyadmin see message: 1222 - used select statements have different number of columns and not solve problem. a union takes results of multiple select statements , presents them single result set. in order this, number of columns in individual select statements has same. to understand this, may format query bit: select sum(`cash`) `cash`, count(*) `rows` `table_1` `login` = 'test' union select count(*) `rows2` `table_2` `login` = 'test' your first query selecting 2 columns, cash , rows . second query selects 1 column, rows2 . note since union concatenating results, may call corresponding columns in each query same name. if don't have values want select second table, can substitute default value missing...

android Facebook SDK cannot share image -

i developing app can share image facebook. can share image, other people cannot share. have fab , calling activity on onclick() method. don't know do, app live when click on app name on shared photo get "misconfigured app sorry, myapp hasn't been approved display in app centre." what reason others cannot share images? need answer. thanks. public class shareactivity extends appcompatactivity { private callbackmanager callbackmanager; private loginmanager manager; @override protected void oncreate(bundle savedinstancestate) { { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); facebooksdk.sdkinitialize(getapplicationcontext()); callbackmanager = callbackmanager.factory.create(); list<string> permissionneeds = arrays.aslist("publish_actions"); //this loginmanager helps eliminate adding loginbutton ui manager = loginmanager.getinstance(); mana...

xpages - @Name within repeat -

Image
i have app build allow users enter approvers each document manually. wanted put in repeat control instead of hard coding fields in xpage. working want, except names stored in document in canonical format. don't want present user, want show abbreviated name. can't seem working. below repeat. want put , @name around value of approvername_# thanks in advance walt <xp:repeat id="repeat4" var="rowitem" indexvar="indexvar"> <xp:this.value><![cdata[#{javascript:["1", "2", "3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18"]}]]></xp:this.value> <xp:panel> <xp:repeat id="repeat3" var="fieldname"> <xp:label id="label3...

algorithm - Printing data according to weights or ratios from different data source or collection or array -

i have requirement have data stored in arrays(it not language specific). lets assume have 3 arrays name array1 has values 1,2,5,6,7,9,10. array2 hello,how,are,you. , array3 @,#. want logic when print it. should distributed upon weight. array1 has maximum elements , array3 has minimum.so output should like: 1 hello 2 how 7 @ 5 6 9 # 10 so there should equal distance between elements of array1(1,2,5,6,7,9,10) please me guys,been wasting days on this. in advance

r - Speed up multi-threaded sparse-matrix multiplication -

i have 2 large sparse matrices ([700 x 400000] %*% [400000 x 700]; 98% sparse) use following code multiply, takes 8 hours, can stop calculation @ time, write existing values, , start again stopped, require. i've looked @ other prepackaged solutions (blas, native r matrix stuff), can't wrap head around them. code work's i'm trying optimize it. i'm willing go outside r if gains sufficient. i'm sure other packages can them , faster, don't know current progress or expected run-time. what should focus on decrease run-time? how of decrease looking at? would sparse matrix library speed up? code: library(dosnow) library(foreach) library(data.table) cl <- makecluster(7, outfile ="") registerdosnow(cl) xtw <- as.matrix(fread('net_xtw.csv', header = f, sep=',')) net_players <- as.matrix(fread('net_players_filtered.csv', header = f, sep=',')) num_column=ncol(net_players) num_row=nrow(net_players) xt...

java - List<WebElement> for only first 3 columns of the table -

where says findelements(by.xpath("td[]")) , how td[1] , td[2] , td[3] elements in list ? webelement webtable = driver.findelement(by.xpath("")); list<webelement> totalrowcount = webtable.findelements(by.xpath("")); int rowindex = 1; (webelement rowelement : totalrowcount) { list<webelement> totalcolumncount = rowelement.findelements(by.xpath("td[]")); int columnindex = 1; (webelement colelement : totalcolumncount) { columnindex = columnindex +1; } rowindex = rowindex + 1; } you should try using position() function of xpath below select first 3 columns each row :- list<webelement> totalcolumncount = rowelement.findelements(by.xpath("td[position() <= 3]"));

python - why does some functions need () but some don't? -

my apologies if stupid question but if have x=3+5j then x.imag give imaginary part x.conjugate() give complex conjugate. why need put () call conjugate function? i thinking whether x can thought struct in c++ imag public attribute of x , conjugate member function. way of thinking correct? apologise if makes no sense. admittedly, knowledge of c++ , python both quite limited. x not struct , object of type complex (although helps think of object s struct s methods bound them). >>> type(x) <class 'complex'> >>> x = 3+5j >>> type(x) <class 'complex'> x.imag not function, it's attribute of object x float object. attribute not have called parentheses () in order retrieve value. value 5 in example. can test if it's function calling callable on it. float objects not callable. >>> x.imag 5.0 >>> type(x.imag) <class 'float'> >>> callable(x.imag...

php - Google Plus Client API Share Post Result Forbidden -

i use google api post on google plus profile (me). i have code on laravel 5.3 : $client = new google_client(); $client->setaccesstoken([ 'access_token' => 'token...', 'expires_in' => 3600, ]); $plusdomains = new google_service_plusdomains($client); $activityobject = new google_service_plusdomains_activityobject(); $activityobject->setcontent("somethings's not importance"); $activityaccess = new google_service_plusdomains_acl(); $activityaccess->setdomainrestricted(true); $resource = new google_service_plusdomains_plusdomainsaclentryresource(); $resource->settype("public"); $resources = array(); $resources[] = $resource; $activityaccess->setitems($resources); $activity = new google_service_plusdomains_activity(); $activity->setobject($activityobject); $activity->setaccess($activityaccess); $result = $plusdomains->activities->insert("me", $activity); dd($result); but hav...

javascript - Crop video on canvas -

i getting video user's camera, , displaying on 1:1 square. have button takes picture , draws 1:1 canvas, issue isn't drawn in same location on canvas. how can achieve this? here running example: https://jsfiddle.net/90d3ar1m/ here html: <!doctype html> <html> <head> <title>camera</title> <meta http-equiv="content-security-policy" content="default-src * data: gap: https://ssl.gstatic.com 'unsafe-inline'; style-src * 'unsafe-eval'; media-src 'self' blob:"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/camera.css"> </head> <body> <div class="container"> <div class="camera"> <video id="monitor" autoplay></video> </div> <canvas id="photo">...

c# - Count the number of words within an Array or List -

i need count number of words within array or list. reason array or list because not sure best use in situation. data static , in .txt file (it's book). able create array , break down words array life of me can not count! have tried many different ways , i'm thinking since string unable count. have teetered on edge of printing whole book listbox , counting listbox but, that's ridiculous. public partial class mainform : form { //------------------------ //global variables: //------------------------ list<string> countwords; string[] filewords; string[] filelines; char[] delim = new char[] { ' ', ',','.','?','!' }; string path; public mainform() { initializecomponent(); } private void booktitle() // titleandauthor method pull book title , display it. { (int = 0; < 1; i++) { booktitlelabel.text = filelines[i]; } } pr...

javascript - Fetching an ID on onclick of a button -

i trying create button dynamically inside loop. onclick of button want fetch id of button. below code not working. can please me. for(int i=1;i<5;i++) { var btn = document.createelement("button"); btn.innertext = "button"+i; btn.setattribute("id", i); btn.onclick = function(this){ alert(this.id); } } thanks in advance you had append child . , cannot use int here . use var for(var i=1;i<5;i++) { var btn = document.createelement("button"); btn.innertext = ("button"+i); btn.setattribute("id", i); document.body.appendchild(btn); // add line btn.onclick = function(){ alert(this.id); } }

r - Issue with as.POSIXct values on timeseries plot -

i having issue x axis on time series graph trying put together. have 4 separate data sets 2000 observations in each one. how of data sets formatted: > str(w) 'data.frame': 2116 obs. of 6 variables: $ time.stamp : factor w/ 2116 levels "11/11/2016\t00:00:00 am",..: 1 2 3 4 5 6 7 8 9 10 ... $ date : date, format: "2016-11-11" "2016-11-11" ... $ time : factor w/ 727 levels "00:00:00","00:02:00",..: 1 2 3 4 5 6 8 11 12 13 ... $ value : num 1.4 1.39 1.41 1.4 1.41 1.4 1.39 1.4 1.37 1.39 ... $ state.of.value: factor w/ 1 level "200 (unchecked)": 1 1 1 1 1 1 1 1 1 1 ... $ datetime : posixct, format: "2016-11-11 00:00:00" "2016-11-11 00:02:00" and here code using graph 4 parameters on same graph: w <- read.csv("w.csv") x <- read.csv("x.csv") y <- read.csv("y.csv") z <- read.csv("z.csv") #creating...

javascript - Security Error in IE11 -

i have highchart(svg) trying covert image base64 format. in chrome working fine in ie11(throwing security error) highchartsexport.nativesvgtoimage($("#highchartcontainer").find("svg")[0],function(uri){ var data = $.param({'dataurl': uri, 'emailcontent': $scope.content}); var config = {headers: {'content-type': 'application/pdf;'}} in highchartsexport: exp.nativesvgtoimage = function(domobject,callback,format){ if(!domobject.nodename){ throw new error("se requiere un objeto dom de tipo svg. obtener con document.getelementbyid o un selector de jquery $(contenedor).find('svg')[0]"); } var svgdata = new xmlserializer().serializetostring(domobject); var canvas = document.createelement("canvas"); canvas.width = $(domobject).width(); canvas.height = $(domobject).height(); ...

javascript - Django- jQuery and tags? -

i'm using app stores/manages forms. i've been wanting list forms in page, , if user clicks on form name, form fetched (via jquery?) , presented in same page, beneath form list, user can fill , submit! the person made app left template html specific form, example {% render_built_form slug=form_instance.slug %} i'm confused correct way go @ this. possible/correct use scheme like: (the list of forms presented, using javascript make button each of them) when user clicks on button, corresponding form (html string) fetched, somehow using tag (with form's slug in there) 'inside' jquery the html form displayed beneath list , user can fill it. is correct/feasible idea, or confusing these concepts? if so, pointers on how use jquery tag super helpful. meanwhile i've confirmed idea doable, i've implemented , runs ok. there's thing i've implemented didn't mention, of asynchronous posting of filled forms. thx.

oop - PHP: Is there no way to use a global variable inside an object constructor? -

i have php script intended user-editable, options set right @ beginning, including allowable extensions image files. later on, want use in object constructor set whether file image or not. $extensions = ["jpg", "jpeg", "gif", "png"]; class directory_entry { function __construct($name) { $this->name = $name; $extension = pathinfo($name, pathinfo_extension); $this->is_image = in_array(strtoupper($extension), $extensions); // throws error $this->image = $this->is_image($name); } } this doesn't work because can't call $extensions inside class(?). there way without including $extensions in every object of class? seems nuts declare objects $files[] = new directory_entry($value, $extensions); and have every instance of class have copy of same array? why not create classe this? class extensionsenum { const images = ["jpg", "jpeg", "gif", "png...

javascript - Polyfill for TextDecoder -

i'm using fetch , have included whatwg-fetch polyfill in application. i employ textdecoder described in jake archibald's blog that's fetch! decode response, i'm not sure polyfill use. (currently safari complains referenceerror: can't find variable: textdecoder ) i'm guessing there's polyfill textdecoder , i'm not finding it... i able solve problem using text-encoding library npm install text-encoding --save along import encoding 'text-encoding'; const decoder = new encoding.textdecoder();

Add custom error highlighting in PhpStorm when single equals in php if condition -

Image
yes, using single equals in php if condition desired, how can set custom error in phpstorm on below code prevent me doing so? mark error when: if (a = b) { //crap reassigned when wanted check if == b } there inspection -- use it. settings/preferences | editor | inspections | php | probable bugs -> assignment in condition it works fine: severity can changed "warning" "error" if needed. note: obviously, highlight such assignments .. not particular place. can create custom scope , turn on or off files in scopes. for particular place can suppressed via special comment: /** @noinspection phpassignmentinconditioninspection */ if ($a = $b) { echo 'hello!'; }

data binding - How to set databinding property to textblock in wpf usercontrol? -

<textblock margin="0,109,20,0" verticalalignment="top" height="auto" textwrapping="wrap" fontweight="bold" fontsize="14" horizontalalignment="right" foreground="#ff575757" rendertransformorigin="-3.611,3.696" cliptobounds="true" text="---------------------" width="213"/> this xaml textblock code part of usercontrol ui element. how databinding this? when try put text="{binding clickcount1, elementname=myusercontrol, mode=default} the xaml giving errors , design view become invisible. pls help. i think want usercontrol example <usercontrol x:class="wpfapplication1.myusercontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats....

dependency injection - GUICE: Listening to objects created by Provider -

i have requirement inspect objects being created guice. i've tried binding typelistener , on seeing right type register injectionlistener. seems work fine except typelistener not notified objects bound provider. i have tried using provisionlistener. notification provider class again not object provider providing. is there way around it?

Redirect to log in page if session does not exist in PHP -

so have page can accessed if user logged in. if not, redirected home page (if user visits page directly). want do, redirect user login page, , if login successful, redirected page. basically , in simplified way, concepts are: first, start session inside pages using sessions: session_start(); then, check in pages: if(!isset($_session['is-user-logged'])){ header("location: login.php"); exit; } in login in page: if($_post){ // .. process form here , check if user submitted valid credentials. $_session['is-user-logged'] = 1; header("location: home.php"); exit; } on logout page: session_destroy(); header("location: login.php"); exit;

RegEx for maximum length with dot and replace function in JavaScript -

how can limit length of string replace function. i need allow stings pattern: 11.11, 99.99, 100.00 1-3 numbers before dot, 1 dot , 2 numbers after dot. i have this: value = value.replace(/[^\d.]/, ""); using alternation | operator test both sides of . : var str="11.11, 99.99, 100.00, 1333.05, 44.999" console.log(str.replace(/([, ]*\d{4,}\.\d*|\d*\.\d{3,})[, ]*/g, "")); explanation: [, ]* : number of , or space \d{4,}\.\d* : 4 or more digits followed dot , number of digits(match numbers more 4 digits before dot) \d*\.\d{3,} : number of digits followed dot , 3 or more digits(match numbers more 3 digits after dot) if 1 of last 2 patterns found followed optional , or space, replace empty string ""

jQuery/CSS transitions are having a strange effect on font-smoothing in Chrome -

this 1 of little bugs has taken afternoon pinpoint, , although i've found seems causing it, can't work out why it's happening. i can't recreate in jsfiddle annoying. i'm using several jquery , css transitions on wordpress website, , reason when transition between opacity:0 , opacity:1 using toggleclass , font-smoothing seems temporarily stop working , starts working again when transition has finished. on website, have @ page – http://www.lucieaverillphotography.co.uk/contact if drag browser width below 980px , press menu button @ top left, push menu open hyperlinks in bold font. watch opacity changes 0 1 – text heavier supposed be, , seems thin out animation finishes. thing can think webkit-font-smoothing value being interfered somehow. initially had opacity values set on nav menu rather hyperlinks, worse. text didn't correct when animation had finished.. became stuck until resized window width little. again, chrome that's doing this. ha...

c - Difference between 2 vs "\2" -

while trying implement ike session key generation algorithms came across following code snippets following algorithm implementation algorithm generating session key skeyid_e = hmac (skeyid, skeyid_a || gxy || cky-i || cky-r || 2) implementation last concatenation hmac of digit 2 hmac_update(ctx, (unsigned char *) "\2", 1) here hmac_update api used concatenate buffer hmac before finalizing digest , ctx hmac context "\2" adding digit 2 , 1 size of buffer. my question difference between , escaped unsigned char * "\2" , char / uint8_t value 2 the difference char numeric value 2 , string "\2" former char , second literal representing character array containing char numeric value 2 , char numeric value 0. in other words: (char)2 single character. type char . value 2. "\2" array of characters. type decays const char* . first entry 2 , second entry 0. since hmac_update expects second argument pointer by...

apache - RewriteEngine is causing Error 500 -

i have been having trouble .htaccess file. below can see i'm trying do redirect incoming traffic http://hyperthunder.net/ disable viewing .htaccess file disable listing directories custom error pages the domains own on web host hyperthunder.net hyperthunder.com and .htaccess file // //domains //hyperthunder.net //hyperthunder.com //both domains on same webhosting // // //redirect // http://www.hyperthunder.net/ ---> http://hyperthunder.net/ // http://hyperthunder.com/ ---> http://hyperthunder.net/ // http://www.hyperthunder.com,/ ---> http://hyperthunder.net/ // options +followsymlinks rewriteengine on rewritecond %{http_host} ^www.hyperthunder.net[nc] rewritecond %{http_host} ^hyperthunder.com[nc] rewritecond %{http_host} ^www.hyperthunder.com rewriterule ^(.*)$ http://hyperthunder.net/$1 [r=301,nc] // //custom errors // errordocument 400 /customerrors/400.html errordocument 401 /customerrors/401.html errordocument 403 /customerrors/403.html errord...

javascript - Node.js and SQL to check a database for results -

i have challenge had done php, wanted see how done via node.js , sql. i beginner this, , not sure @ if did legal, wanting learn in node; challenge this: we function takes in useragent of browser string, , compares list of approved browsers , versions the database structure looks this: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | bigintpkid | varchar(50) browsername | varchar(50) versionnumber | bitgreaterversions | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |         1       |     ...

mongodb - How do run Mongo on Ubuntu Server, getting error -

Image
i have been trying install mongodb , have been following instructions on mongo docs, trying start mongo , error it appears if says "addr in use"? restarted server , still comes unsure next. stop active mongod server , try again: sudo service mongod stop sudo mongod

javascript - PHP show textbox on radiobutton click -

hi attaching part of code should hide textbox , when female selected should show it. not working $(document).ready(function() { $('input[name="gender"]').click(function() { var value = $(this).val(); if( $value == "male") { $('#address').hide(); } else{ $('#address').show(); } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <style> .error {color: #ff0000;} </style> gender: <input type="radio" name="gender" value="female">female <input type="radio" name="gender" value="male">male <div name="address" id="address"> <textarea name="address" id="address" rows="5" cols="40"></textarea> </div> <br><br> plea...

asp.net mvc - Generate html in body with RazorEngine email template -

i'm using razorengine generate email template. the issue i'm having cannot add line break in email body. var model = new emailmodel { destination = "anon@gmail.com", subject = "some subject", body = "hello <br> break <br> <br> up" }; var service = templatemanager.razorservice; var htmlbody = service.runcompile("emailtemplate.cshtml", model.gettype(), model); await emailservice.sendemail(model.destination, model.subject, htmlbody); i tried doing following in template: @html.raw(model.body) but still won't decode html, ideas? your <br> tag in body incorrect. replace <br> <br />

javascript - Parsing formatted date with moment js -

i'm formatting incoming date 2016-11-10t21:59:53.000+0000 moment js as: myservice.getdate(id) .then(function (data) { data.occureddate = moment.utc(new date(data.occureddate)).format('dd mmm yyyy h:mm a'); }; the output result looks like: 10 nov 2016 10:00 pm now i'm trying parse date string, unfortunately attempts unsuccessful console.log(new date(obj.occureddate)) console.log(new date(obj.occureddate).tostring()) console.log(date.parse(obj.occureddate)) console.log(new date(date.parse(obj.occureddate))) console.log(new date(date.parse(obj.occureddate)).tostring()) invalid date invalid date nan invalid date invalid date could explain me i'm doing wrong? thanks in advance. as parsing non standard format, specify format. use moment's todate() method plain js date object: moment.utc(obj.occureddate, 'dd mmm yyyy h:mm a').todate(); sidenode using moment.utc(new date(data.occur...

xml - Web Scraping with xpathSApply (R) - Only no class text -

i'm trying extract text following structure: <p class="id1"> title or </p> <p> text text text </p> <p> more text </p> <p class="id2"> else </p> when use: text_info <- xpathsapply(parsed, "//p", xmlvalue) the result is: [1] 'title or something' [2] 'text text text' [3] 'more text' [4] 'something else' i want text inside <p> no class: [1] 'text text text' [2] 'more text' i'm using following code takes long time , have many texts: text_info <- setdiff(xpathsapply(parsed, "//p", xmlvalue), xpathsapply(parsed, "//p[@class]", xmlvalue)) is there way extract have no class using 1 xpathsapply? you can use not() in xpath. xpathsapply(doc, "//p[not(@class)]", xmlvalue, trim = true) # [1] "text text text" "more text" this chooses elements without class attr...

angularjs - how to restore ionic backbutton after override? - breaking backbutton on other tabs -

currently backbutton override on particular page working on particular tab-subtab (a) applying - on subtaba, button takes me taba, $scope.$on('$destroy...) doesn't seem working. because if tab-subtab(a) , navigate directly tab-subtab (c) page - button on tab-subtab (c) takes me directly taba instead of tabc. furthermore, if go tabc - takes me directly tab-subtabc (because thats last left off) , can never tabc. below controller particular page/tab on: $scope.$on('$ionicview.beforeenter', function(){ // none related stuff here. }) ; // custom button send user master rides tab no matter how many subviews navigate // // var docustomback = function() { $state.transitionto('tab.rides'); }; // override soft // framework calls $rootscope.$ionicgoback when soft button pressed var oldsoftback = $rootscope.$ionicgoback; $rootscope.$ionicgoback = function() { docustomback(); }; var deregistersoftback = function() { ...

php - Can I import certain tables from a remote database over SSH into the main database for a Wordpress install? -

i able sync tables remotely hosted database wordpress database, these tables not containing related wordpress content. these tables contain simple warranty lookup info returns simple yes/no if specific serial number of product past warranty date. have ssh , privileges set , ip whitelisted. on management side, user enters data internal system pushes information server hosting database. my goal not disrupt system using , use form on site access lookup feature imported data external database. hope makes sense. i appreciate or guidance in this.

sqlite - How to get table.colname dataframe results using SQL Achemy / Pandas? -

i have join sql request output of 2 tables produced : ss= 'select t.*, p.* table1 t, table1 p t.table2_id=p.table1_id' df = pd.read_sql_query(ss, self.db_con) however, columns have same name since table stripped. (ex: id, id ...) how table.colname in dataframe ? thanks you have rename conflicting columns as : select t.id t_id, p.id p_id, table1 t, table2 p t.id = p.id

jquery - CSS transition not working on image -

i have created working transition div element, however, when tried apply exact same method image class, not work. instead of smoothly moving left jumps left. rotation transform animation work, not left transition. .firstimg{ width: 5%; cursor: pointer; position: absolute; -webkit-transition: 0.4s ease; -moz-transition: 0.4s ease; -ms-transition: 0.4s ease; -o-transition: 0.4s ease; transition: 0.4s ease; } .turnedimg{ width: 5%; cursor: pointer; /*left: 12% !important;*/ position: absolute; -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -ms-transform: rotate(90deg); -o-transform: rotate(90deg); transform: rotate(90deg); -webkit-transition: 0.4s ease; -moz-transition: 0.4s ease; -ms-transition: 0.4s ease; -o-transition: 0.4s ease; transition: 0.4s ease; } i not understand why rotation works transition not. how can make animations work? if interested, calling through jquery $(".firstim...