Posts

Showing posts from July, 2010

javascript - How to transfer html between two liferay input editors? -

i have 2 liferay input editors in form. on button click need transfer html first input editor second. i have tried javascript , names attribute cant work. how proper way of doing this? <liferay-ui:input-editor name="firsteditor"/> <liferay-ui:input-editor name="secondeditor"/> <button onclick="moveinfo()"></button> <script> function <portlet:namespace />initeditor() { return ''; } function moveinfo(){ //code missing } </script> correct answer be: var value = ckeditor.instances.<portlet:namespace />firsteditor.getdata(); ckeditor.instances.<portlet:namespace />secondeditor.setdata(value);

javascript - How to set a type to Kendo Grid Filter? -

how set type filter on columns, while being generated? 'string', 'int', 'date' etc? possible? if type of our column 'date', not show 'starts with', 'contains' etc... if it's integer, show 'greater then' etc... columns: { title: "test", field: "test2", width: "120px", hidden: false, type: "number",

SecItemAdd always returns error -34018 in Xcode 8 in iOS 10 simulator -

Image
update : issue has been fixed in xcode 8.2. keychain works in simulator without enabling keychain sharing. why always receiving error -34018 when calling secitemadd function in xcode 8 / ios 10 simulator ? steps reproduce create new single page ios app project in xcode 8. run following code in viewdidload (or open this xcode project). let itemkey = "my key" let itemvalue = "my secretive bee 🐝" // remove keychain // ---------------- let querydelete: [string: anyobject] = [ ksecclass string: ksecclassgenericpassword, ksecattraccount string: itemkey anyobject ] let resultcodedelete = secitemdelete(querydelete cfdictionary) if resultcodedelete != noerr { print("error deleting keychain: \(resultcodedelete)") } // add keychain // ---------------- guard let valuedata = itemvalue.data(using: string.encoding.utf8) else { print("🐣🐣🐣🐣🐣🐣🐣🐣🐣🐣 error saving text keychain") return } let queryadd: [string: anyobject] =

image processing - How can i close polyline object in Delphi? -

Image
i using code listed below: hobj:= imageenvect1.addnewobject(iekpolyline, blob.boundingbox, clgreen); imageenvect1.polylineclosingmode:=iecmonnearfinish; imageenvect1.setobjpolylinepoints(hobj,pplist); and these not connected polygons: how can connect last points , first points of these polygons? from documentation http://www.imageen.com/help/imageen/timageenvect.polylineclosingmode.html iecmalways means closes. with iecmonnearfinish close if end position of polyline close start.

javascript - Meteor WebSockets (via DDP?) -

i'm working on simple game, needs use web sockets. have read ddp should way go, it's meteor uses. i can't find documentation regarding tho, except note on meteor.com . should use sock js instead, or how can use ddp package? ddp protocol can run on top of sockets. it's not socket library in itself. if need own socket communication, use socket.io or packages on atmosphere. there have been attempts made (e.g., http://arunoda.github.io/meteor-streams/ ), i'm not sure latest on that. might work you: https://github.com/joncursi/socket-io-client

ios - Why Google login does not work on a device? -

when use code in simulator - works perfectly: // present view prompts user sign in google func signin(signin: gidsignin!, presentviewcontroller viewcontroller: uiviewcontroller!) { self.presentviewcontroller(viewcontroller, animated: true, completion: nil) } // dismiss "sign in google" view func signin(signin: gidsignin!, dismissviewcontroller viewcontroller: uiviewcontroller!) { self.dismissviewcontrolleranimated(true, completion: nil) } func signin(signin: gidsignin!, didsigninforuser user: gidgoogleuser!, witherror error: nserror!) { if (error == nil) { // perform operations on signed in user here. let accesstoken = user.serverauthcode // safe send server print("aaa \(accesstoken)") } else { print("\(error.localizeddescription)") } } but not work in real device. when tap "allow" button, refreshes page , forwards me google.com website. what prob

javascript - Google Maps Directions Appearing Twice? -

i'm trying create page which, on load, show user's current position on google map. there select list of various possible destinations. when select list changes map show route current position destination. far good! where goes wrong when try add in driving directions. reason appear twice, can't see why. code: var latitude = 0; var longitude = 0; $( document ).ready(function() { if (navigator.geolocation) { navigator.geolocation.getcurrentposition(initmap); } else { document.getelementbyid("feedback").innerhtml = "geolocation not supported browser."; } }); function initmap(position) { latitude = position.coords.latitude; longitude = position.coords.longitude; latlong = latitude + "," + longitude; var mycentre = new google.maps.latlng(latitude,longitude); var directionsservice = new google.maps.directionsservice; var directionsdisplay = new google.maps.directionsrenderer; var map = n

Running multiple pipelines and/or jobs on single HDinsight cluster in Azure data Factory -

what recommended way use hdinsight cluster running pipeline custom activity in azure data factory. can use single hdinsght cluster multiple azure data factory jobs , multiple pipelines running simultaneously? if referring running custom .net activity using azure data factory, run hdinsight activity, labeling custom activity , linking .net dll zip file in blob storage. running azure batch option, .net work , azure batch cheaper (if custom activity reason having hdinsight cluster). you able use single hdinsight cluster run multiple data factory jobs, including multiple parallel pipelines. however, keep in mind depending on parallel jobs (number, size, etc.) , configuration of cluster may overload cluster's resources.

header - Jquery Mobile not displaying data-icons (correctly) -

so, i'm adding popup menu off header , works... works quite except 1 small thing. life of me can't display icons way want them! in first <li> brute force data-icon <li> , shows not positioned left. in others, left data-icon i'm accustomed leaving them (where work correctly everywhere else) , don't display @ all. any suggestions? <div id="header" data-role="header" data-theme="b"> <h1>myapp</h1> <a href="#popupmenu" data-rel="popup" data-transition="slide" data-icon="bars" class="ui-btn-right"> menu </a> <div data-role="popup" id="popupmenu" data-theme="b"> <ul data-role="listview" data-inset="true"> <li data-icon="gear" data-iconpos="left"><a href="#">settings</a></li> <li><a href="#"

multithreading - OpenMP's mechanism for spreading threads out evenly -

openmp tries spread out threads across cores evenly possible, how work? ultimately, os deciding how spread them. openmp recommend os (similar using likely macro or register keyword in c). if we're running job num_threads threads on machine num_cores cores, none of in use, fair assume threads spread out across cores evenly (and assuming num_threads <= num_cores , have pure parallelism), since os should working in our best interest , spreading load nicely. i see graphs of strong scaling x axis # cores. assume maximum number of threads used run job <= number of cores , cores relatively idle? or of moot point. the scheduling of openmp threads on cores and/or hardware threads of machine responsibility of operating system. decide based on own heuristics , when start / stop / migrate them... however, openmp gives tools direct / restrict span of choices os has taking decisions. example, have access to: the number of openmp threads launch on parallel regi

javascript - Find n logarithmic intervals between two end points -

i trying find n logarithmic intervals between 2 numbers. eg: function logdiv (10, 10000, 3) 10 starting point, 10000 ending point, , 3 number of intervals, following output: (* {10, 100, 1000, 10000} *) what have tried: function loginterval(total_intervals, start, end) { var index, interval, result = []; (index = 0; index < total_intervals; index++) { interval = (index/total_intervals * math.log((end - start) + 1) - 1 + start); result.push(interval); } return result; } var intervals = loginterval(5, 1, 500); https://jsfiddle.net/qxqxwo3z/ this based on (poor) understanding of following solution found in stack exchange mathematica: logspace [increments_, start_, end_] := module[{a}, ( = range[0, increments]; exp[a/increments*log[(end - start) + 1]] - 1 + start )] https://mathematica.stackexchange.com/questions/13226/how-can-i-get-exactly-5-logarithmic-divisions-of-an-interval please can me this? not necessary follow of above att

angular - Is it possible to get Angular2 and D3.js working together? -

by working mean can place angular bindings in d3.js code, perhaps .attr("bind-attr.fill", "acolorvar") where acolorvar variable can bound color control in angular way. i can similar things in angular1, unfortunately using $compile. can bind svg attributes when svg used component template. i believe in angular 2 can setup bindings in templates, not in code, can't think of way work. the best can think of put d3 code component or directive, can use component/directive properties: .attr("fill", this.somecomponentproperty) however, not setup kind of binding. if update property somecomponentproperty , need execute line of code again.

How can I get a intermediate URL from a redirect chain from Selenium using Python? -

i'm using selenium python api , firefox automatic stuff, , here's problem: click link on original page, let's on page a.com i'm redirected b.com/some/path?arg=value and i'm redirected again final address c.com so there way intermediate redirect url b.com/some/path?arg=value selenium python api? tried driver.current_url when browser on b.com , seems browser still under loading , result returned if final address c.com loaded. another question is there way add event handlers selenium url-change? phantomjs has capacity i'm not sure selenium. you can redirects performance logs. according docs , github answer here i've done in c#, should possible port in python: var options = new chromeoptions(); var cap = desiredcapabilities.chrome(); var perflogprefs = new chromeperformanceloggingpreferences(); perflogprefs.addtracingcategories(new string[] { "devtools.network" }); options.performanceloggingpreferences = perflogprefs; opt

html - CSS: Responsive 3x3 grid messing up on window resize -

i'm trying make responsive 3x3 grid put noughts , crosses game on. it's working me when have maximized screen make window smaller check responsiveness messes up. what's going on? should use other vh's? http://codepen.io/apswak/pen/dxdjvw <h3>noughts , crosses</h3> <div class="gamegrid"> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> </div> style.css body { background-color: wheat; margin: 0; padding: 0; } .gamegrid { margin: 0 auto; padding: 0; width: 62vh; height: 62vh; } .cell { margin-bottom: -5px; display: inline-blo

web services - What's wrong with Yahoo finance webservice v1? API changed? -

i used type in browser : http://finance.yahoo.com/webservice/v1/symbols/yhoo,aapl/quote?bypass=true&format=json&view=detail , parse answer... it's not working anymore, see: has yahoo finance web service disappeared? api changed? down temporarily? the command curl -a "mozilla/5.0 (linux; android 6.0.1; motog3 build/mpi24.107-55) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.81 mobile safari/537.36" http://finance.yahoo.com/webservice/v1/symbols/yhoo,aapl/quote?bypass=true&format=json&view=detail gives not valid parameter. any idea what's wrong in request? any idea on way send http request directly works in desktop browser? if use headers below in request, work... "user-agent":"mozilla/5.0 (iphone; cpu iphone os 9_3 mac os x) applewebkit/601.1.46 (khtml, gecko) version/9.0 mobile/13e230 safari/601.1"

ios - Trying to convert objective-c to swift and couldnt solve an issue -

i trying convert objective-c project swift2 typedef void (^pdfcmapparserhandler)(nsarray *lines); can help? whenever want convert set of codes objc swift, use link easier banging head. to answer question: var pdfcmapparserhandler or var pdfcmapparserhandler = nsarray()

css - How to get both curved corners in a SVG clippath? -

for few days struggle problem: i've made svg clip-path , add curved corners it. when add 'c' of 'curvetto' code, curved corner on right. this code: <svg width="0" height="0"> <defs> <clippath id="myclip" clippathunits="objectboundingbox"> <path d="m0.23,0.1 c 0.77,0.1 0.77,0.1, 1,0, 1,1, 0,1,0.0,0.0z"/> </clippath> </defs> </svg> image of clip path how both corners curved?

c# - JSON to List<class> & List<class> to JSON? -

hi guys how work? searched in , promissing doesnt work either. errormessage: the deserialized type should normal .net type (i.e. not primitive type integer, not collection type array or list) or dictionary type (i.e. dictionary). so how split individual objects json? list<class> = jsonconvert.deserializeobject<list<class>>(json_string) the json string: { "spalten": [{ "nummer": 1, "name": "breite", "typ": "double", "laenge": 0, "einheit": "m", "editierbar": true, "optional": true, "layer": null, "layer_spalte": null, "d_spal_name": null, "d_spal_min": 0, "d_spal_max": null, "d_spal_val": null }, { "nummer": 2, "name": "kommentar", "typ": "string", "laenge&q

c# - Why can't I put this grid on my button? -

i need buttons have several pieces of text on them in specific layout, i'm trying put grid on button organize info. my problem while can unmodified button appear, grid never appears in or on top of it. here's .xaml code: <!-- ...other code above... --> <itemscontrol x:name="btnlist"> <itemscontrol.itemtemplate> <datatemplate> <grid background="green"> <grid.rowdefinitions> <rowdefinition height="3*" /> <rowdefinition height="2*" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="1*" /> <columndefinition width="1*" /> <columndefinition width="1*" /> </grid.columndefinitions> <textblock gri

html - Fixed navbar content to the right -

i'm working on project run through small issue can't find solution for. so idea is: have nav bar fixed. need scroll inside , when click on button content in middle goes right small part outside navbar. at first thought add overflow-y: auto; to navbar apprently doesn't work , clips content. i have created codepen show problem. http://codepen.io/denniswegereef/pen/vjqbxa looks it's because you're trying set height match window, have padding. can use box-sizing:border-box make padding included in specified height. var $item = $('.item'), $button = $('.button'); (i = 0; < 200; i++) { $item.append(i + '<br>') } $button.on("click", function() { $item.toggleclass('addmargin'); }); .sidenav { width: 300px; background-color: grey; position: fixed; padding: 20px; height: 100vh; overflow-y: auto; box-sizing: border-box; } .addmargin { margin-left: 6

javascript - issue in rendering jquery datetimepicker into a modal -

i trying show jquery datetimepicker bootstrap modal.. html: <div class="modal fade" id="availability_modal" role="dialog"> <div class="modal-dialog"> <!-- modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> &times; </button> <h4 class="modal-title">view availability of %supp_name%</h4> </div> <div class="modal-body"> <div id="availability_calender"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal"> close </button> </div>

bash - passing arguments to an interactive program non interactively -

i have bash script employs read command read arguments commands interactively, example yes/no options. there way call script in non-interactive script passing default option values arguments? it's not 1 option have pass interactive script. for more complex tasks there expect ( http://en.wikipedia.org/wiki/expect ). simulates user, can code script how react specific program outputs , related stuff. this works in cases ssh prohibits piping passwords it.

Infinispan Cluster Programmatically -

i need form inifinispan cluster programmatically. have done using cluster.xml , works many documentations state can done programmatically too. hint on how can done. my code uses hot-rod client , infinispan 7.2.5 it depends mean. let me describe of options: you might form infinispan cluster programmatically using tcpping jgroups protocol , putting list of hosts there. you may write own discovery protocol , whatever do. since mentioned hot rod client - may specify multiple hosts connect there . as can see there multiple options, please explain - trying do?

javascript - Print Out Jquery object to table -

i got script count td same value's in table. output need. but goes wrong when want print data html. when console.log get object {eandis - rc grond 2014-2018: 11, aswebo - farys: 7, vdv cleaning - rioolkolkenslib: 1} i have tried print out with: document.getelementbyid("write").innerhtml = bytechnology; output objectobject. what doing wrong? or way it? here find script. hope can me! <script> var bytechnology = {}; $("#test tbody td:nth-child(6)").each(function() { var tech = $.trim($(this).text()); if (!(bytechnology.hasownproperty(tech))) { bytechnology[tech] = 0; } bytechnology[tech]++; }); console.log(bytechnology); document.getelementbyid("test").innerhtml = bytechnology; </script> try: document.getelementbyid("write").innerhtml = json.stringify(bytechnology); the json.stringify() method converts javascript object json string.

java - Spring Cloud Config Encryption API ignores special characters at the end -

we have externalised our application config using spring cloud config. use encryption api encrypt plain text passwords before go in yaml property file. i struggling encrypting password downstream system has special character @ end. somehow that’s been ignored cloud config encryption api. when decrypt cipher using decryption api plain text without special character @ end. i using curl invoke api - curl 10.102.82.1:11901/encrypt -d axizfdh4xza= for reason special characters in middle of plain text works fine, if have @ end ignored. password hashed, still curious find out how deal this. set explicit content-type: text/plain make sure curl encodes data correctly when there special characters curl -h "content-type: text/plain" 10.102.82.1:11901/encrypt -d axizfdh4xza= this specified in cloud config documentation, tip on page - http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_encryption_and_decryption

android - How to use custom image for edittext password like axis bank app -

Image
how use custom image instead of '*' in edittext password field? see image: any answer or hint appreciated. the answer comes this tutorial , covers behaviour when user: enters login screen, keyboard open automatically. tries enter value in textbox background changes textbox star background. tries cancel/delete input value using key on keyboard textbox background change textbox without star background. first of have create 2 drawables : then, according approach, have implement addtextchangedlistener method on edittext . after that, parameter, create new instance of textwatcher class , implement methods: etxtpin1.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { // todo auto-generated method stub } @override public void beforetextchanged(charsequence s, int start, int count, int after) { // todo auto

Self JOIN query with Symfony entity -

Image
here's table : my category entity (without getter/setter): /** * @var int * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ private $id; /** * @var string * * @orm\column(name="name", type="string", length=255) */ private $name; /** * @var string * * @orm\column(name="slug", type="string", length=255, nullable=true) */ private $slug; /** * @var int * @gedmo\treeleft * @orm\column(name="lft", type="integer") */ private $lft; /** * @var int * @gedmo\treelevel * @orm\column(name="lvl", type="integer") */ private $lvl; /** * @var int * @gedmo\treeright * @orm\column(name="rgt", type="integer") */ private $rgt; /** * @gedmo\treeroot * @orm\manytoone(targetentity="category") * @orm\joincolumn(name="root", referencedcolumnname="id", ondele

ios - Save a PHAsset in Core Data? -

i have custom image picker load images in photo library. wanting save image locations in coredata. have gotten file path, when try load permission issue. how store phasset core data in such way not saving actual image? if there code should show let me know. thanks in advance. ok, able solve problem. instead of trying access image path, saved local identifier, , used fetchassetswithlocalidentifiers everything seems work desired now.

ember.js - Ember return length of a model created today -

i trying this: have model called 'trip', , inside trip, attribute called 'createdtoday', returns date when trip created. want return list of trips made today. here trip model: import ds 'ember-data'; export default ds.model.extend({ driver: ds.belongsto('driver', { async: true, inverse: 'trip' }), ..... etc ....... createdat: ds.attr('string', { defaultvalue() { return new date(); } }), isbookedtoday: function(trip) { var today = new date().todatestring(); return (today === trip.get('createdat').todatestring); }, gettripstoday: ember.computed('trip.@each.createdat', function() { var tripstoday = this.get('trip'); return tripstoday.filterby('isbookedtoday', true).get('length'); }) }); in isbookedtoday, i'm trying see if individual trip's created time same todays time

javascript - How to to addClass() to the active link of two different navs based on scroll position in jQuery? -

i have 2 navs, both class of .fixed-nav , add class active link of each nav (i.e. .menu__item--current #main-nav , .is-selected #cd-vertical-nav ), based on scroll position (snippet below). this part seems wrong: updatemainnavigation(), updateverticalnavigation(); $(window).on('scroll', function() { updatemainnavigation(), updateverticalnavigation(); }); my first try doesn't work: updatemainnavigation(); $(window).on('scroll', function() { updatemainnavigation(); }); updateverticalnavigation() $(window).on('scroll', function() { updateverticalnavigation(); }); here snippet you can add function listen scrolling. calculate div @ , select element , change css. can tweak number calculation if want change earlier. add class vertical-navs . in case, class="vert-nav" . function changedots(distancefromtop) { var number = math.ceil(distancefromtop / 400); $('.cd-dot').css({background: "#ff

javascript - Adding class active to a known tab -

is possible add class active known tab in different page. when navigate page 2 page 1 have make tab 2 active. have tab id me. can 1 tell me should do? my code <div ng-repeat="t in data" class="time-tab-adspace" ng-class="{'tab-align-center':data.length==2}"> <a class="nav-people-tab text-hover" data-toggle="tab" ng-class="{'nav-people-tab-hover in':seltab=='ticket'+t.id}" ng-click="selecttab(t)"></a> </div> in above code selected tab , css nav-people-tab-hover in gets applied when click on it. when click on continue below controller button gets executed. $scope.seltab= tselected; // here selected tab in page 2 $('#?????').addclass("active").show(); window.location.replace("page1"); in above code should write in ????? or piece of code inorder me work this?

excel - Get min from parts of the row that the possition of the row corresponds to a cell in another row -

i new in excel , want have min cell g1613: untill cell in same row(g) position wrote in row like(g1617) in case 1617 written in row m1.i stuck in it.could please me solve it.or how can have min(g1613:g1617) in form: min(g1613:g(1613+4)) 4 written in possition m1?

c++ - Crash after QGraphicsScene::removeItem() with custom item class -

i populating qgraphicsscene instances of custom item class (inherting qgraphicspathitem ). @ point during runtime, try remove item (plus children) scene calling: delete pitem; this automatically calls qgraphicsscene::removeitem() , leads crash in class qgraphicsscenefinditembsptreevisitor during next repaint. tl;dr: solution ensure qgraphicsitem::preparegeometrychange() gets called before item's removal scene. the problem during item removal scene, scene internal index not updated, resulting in crash upon next attempt of drawing scene. since in case, use custom subclass qgraphicspathitem , put call qgraphicsitem::preparegeometrychange() destructor since not manually removing item scene (via qgraphicsscene::removeitem() ), instead call delete pitem; in return triggers item's destructor removeitem() later on.

salesforce - How to get the previous selected value for select list in visaulforce page -

<apex:selectoption itemvalue="reports" itemlabel="select report" /> <apex:selectoption itemvalue="1" itemlabel="test1"/> <apex:selectoption itemvalue="2" itemlabel="test2"/> </apex:selectlist> select value 1 first, how retrieve value of 1 after choose 2 in visualforce page you can use onfocus attribute of selectlist component storing current value of picklist before choosing new 1 in js variable , onselect or onchange attributes of selectlist processing of new , old values. <apex:selectlist value="{!test}" onfocus="storeoldvalue(this.value)"> <apex:selectoptions value="{!testoptions}"/> </apex:selectlist> <script type="text/javascript"> function storeoldvalue(oldvalue){ oldval = oldvalue; } </script>

javascript - How to properly design a reliable acknowledgment mechanism using Parse Server? -

i working on app scenario occur parse server sends silent push notification tell app wake , pull new data app sends server request new data , server responds server doesn't know if data received app..... how solve last step? how make sure app gets chance acknowledge receipt of data? thank you i in way: when app send server request of new data, send id code too server store id when app ends data receiving, send server receive ok message id. when server receive "receive ok" message app, delete list id of app. in way server knows how many app ask data transfer how many app receive data successfully. the app id, data transfer, can change between transfer session .

swift - Tableview works on sim but not on test device -

i have no idea whats wrong function. i'm calling in viewdidload , prints array blank when load on phone. when in simulator fills array though. using objectmapper if helps @ all. func getdata() { let myurlstring = "http://meetup.x10host.com/api/get_event.php?radius=15" let myurl = nsurl(string: myurlstring)! var mycardsarray = [card]() let mysession = nsurlsession(configuration: nsurlsessionconfiguration.defaultsessionconfiguration()) let mydatatask = mysession.datataskwithurl(myurl) { (data, response, error) in guard error == nil else { let alertcontroller = uialertcontroller(title: "no connection", message: "can't connect database, perhaps turn on wifi?", preferredstyle: uialertcontrollerstyle.alert) alertcontroller.addaction(uialertaction(title: "okay", style: uialertactionstyle.default,handler: nil)) self.presentviewcontroller(alertcontroller, a

http - What is the correct placement, in an url, of a #bookmark and ?parameters? -

is url?params#bookmark, e.g. google.com?search=blahblah#bookmark or url#bookmark?params have tried both , work, i'm wondering if there "correct" way this? why need ask find on first result returned google ? check wikipedia article url : scheme:[//[user:password@]host[:port]][/]path[?query][#fragment] or rfc 3986 - uniform resource identifier (uri): generic syntax : uri = scheme ":" hier-part [ "?" query ] [ "#" fragment ] foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose

php - Retrieving & displaying images from a post with preg_match -

basically piece of code grab first image of post , display @ page. if no images, show default image. how modify make display max 4 images ? <?php $imagesrc = c('plugin.indexpostimage.image','/images/default.png'); preg_match( '#\<img.+?src="([^"]*).+?\>#s', $sender->eventarguments['post']->body, $images ); if ($images[1]) { $imagesrc = $images[1]; } $thumbs ='<a class="indeximg" href="'. $sender->eventarguments['post']->url .'">'. img($imagesrc, array('title'=>$sline,'class'=>"indeximg")).'</a>'; echo "$thumbs"; your found images in array $images according to preg_match manual: int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] ) $matches[1] have text matched first captured parenthesized subp

tkinter - Is is possible to search a listbox and return an index location? -

im having trouble finding answer this. is possible search tk listbox exact entry or string , return location or index in list? thank you. you can use get() method 1 or more items list. in first step, use get(0, end) list of items in list ; in second step use finding index of item given list containing in python forwards index() method: import tkinter tk master = tk.tk() listbox = tk.listbox(master) listbox.pack() # insert few elements in listbox: item in ["zero", "one", "two", "three", "four", "five", "six", "seven"]: listbox.insert(tk.end, item) # return index of desired element seek def check_index(element): try: index = listbox.get(0, "end").index(element) return index except valueerror: print'item can not found in list!' index = -1 # or whatever value want assign default return index print check_index('thre

javascript - How to get typescript to recognize a custom action on the angular $resource? -

Image
this sample use of angular $resource in typescript. in example i'm attempting create update action on resource i've defined, it's done in https://docs.angularjs.org/api/ngresource/service/ $resource. i'm returning instance ng.resource.iresourceclass<ivenueresource> module app.common { interface ivenueservice{ } export interface ivenueresource extends ng.resource.iresource<app.domain.ivenue>{ update(ivenue: app.domain.ivenue) : app.domain.ivenue; } export class venueservice implements ivenueservice{ static $inject = ["$resource", "url"]; constructor(private $resource: ng.resource.iresourceservice, private url: url_constants){ } getvenueresource(): ng.resource.iresourceclass<ivenueresource>{ // define custom action iactiondescriptor var updateaction : ng.resource.iactiondescriptor = { method: 'put', isarray: false }; return &l

datatables read language option from cookie -

i'm using angular-datatables(based on jquery-datatables), reading language json files. it's not hard switch datatables language through $scope.dtoptions.language.url = '../locales/dt/'+ lng +'.json'; once page refreshes, go default language. there way save language.url in cookie, , tell datatables read language option cookie? you better use localstorage that. has 2 benefits - 1) size not limited 4kb, starts 5mb; 2) not being sent on wire server , every request. more on comparison here local storage vs cookies browser api straightforward: localstorage.setitem('datatableslang', 'en'); localstorage.getitem('datatableslang'); // =='en' more details on browser api here: https://developer.mozilla.org/en-us/docs/web/api/storage/localstorage besides there's angular module: angular-local-storage can more.

inno setup - Pascal (Script) and exception control flow -

i'm working pascalscript innosetup installer, , fail see control of following block flowing. function foo(): string; begin result := 'foo'; raiseexception('...'); end; procedure test(); var z : string; begin z := ''; try z := foo(); except log(z); end end; my installer seems indicate z being set result of foo function. understanding of exceptions in 'most' programming languages tells me assignment z := foo() should not happen in case of exception. when foo function raises, should z still assigned to? probably handles result values reference implicit first argument. can happen. considered legal of codegeneration/optimization, since quite common way of handling return values. however defined in object pascal outside testing delphi murky territory, since there x86 , x86_64 implementation. , delphi return value in eax, if follow logic illegal. added later: i tested delphi structured types, , while

MIPS Assembly Language (Power2) -

Image
i looking best method performing n power2 function. in short, code in mips should calculate 2n. n being positive number stored in $a0 . however, of right results coming 1 power less. my attempt main: # initialize la $a0,3 #n counter li $s0,2 #base number li $s1,0 #calculated value while: beq $a0,$zero,exit #checks if n zero, if yes exit program sllv $s1,$s0,$a0 #shift left logical n, should math 2^n exit: "failed" isn't informative statement. anyway, correct syntax beg $a0,$zero,j exit beq $a0, $zero, exit don't need check. should load $s0 1 not 0 since 2^0 1 , sll $s0, 2, $a0 should sllv $s0, $s0, $a0 .

React-Native 0.20 - setInterval not working as expected -

has been able setinterval working expected react-native? having inconsistent results where: 1) delay before execution not match ms delay set 2) further executions after initial 1 do not always occur, do. my interval code in component, shown: componentdidmount() { this.syncfunc = setinterval(() => { this.props.actions.syncstate() }, 5000) } componentwillunmount() { clearinterval(this.syncfunc) } i've tried timermixin included in react-native, don't think it's supported @ point. code similar: componentdidmount() { this.syncfunc = timermixin.settimeout(() => { this.props.actions.syncstate() , 5000) } componentwillunmount() { timermixin.cleartimeout(this.syncfunc) } appreciate advice others who've tinkered this. thanks!

node.js - Sequelize bulk synchronization does nothing -

i'm unable sequelize.sync() work. calling sync() on each model definition works flawlessly calling sequelize instance appears nothing, if model manager had no registered models in it. consider following: function syncall() { console.log('retrieving exported models...') let models = require('./models') for(var modelname in models) { let model = models[modelname] // define() wraps regular sequelize.define() call // model.define().sync() works! model.define() } console.log('all exported models have been defined! syncing database...') sequelize.sync({ logging: true }).then(function() { // operation completes no command executed in db console.log('database synchronization complete!') }).catch(function(error) { console.log("database synchronization error:\n\t${error}") }) } just trying understand i'm missing, why bulk synchronizati

linux - Pearson Correlation between two columns -

good morning. here problem: have several files 1 below: 104 0.1697 12.3513214 15.9136214 112 -0.3146 12.0517303 14.8027303 122 0.2718 10.881109 13.259109 123 -0.4185 11.2880142 14.0237142 128 0.0205 13.0585763 15.4365763 132 0.1562 13.3956582 16.9579582 136 -0.4602 12.2567041 14.6347041 157 0.8142 13.6455927 17.2078927 158 -0.9244 8.0012967 11.5635967 approximately 10000 files, each file several rows. , need make pearson correlation between column 2 , 4 each file. later, need make average of these correlations. , linux commands. can me, please? thanks try script. need bash , bc (to operate on floating point numbers). give access execute chmod +x /path/to/pearson.sh change files directory files stored call script no parameters bash /path/to/pearson.sh . it should produce mean of pearson correlation coefficients calculated on data files. #! /bin/bash files=/path/to/files/ function add { echo $1 + $2 | bc } function sub { echo $1 - $2 | bc } functio

javascript - Adding to html elements from jade script -

i new jade , trying make website context changing regarding data on server. since need add unknown amount of div figured should this: html head title match support body script(type='text/javascript' src='http://code.jquery.com/jquery.min.js') h1 same h3 games: #container script. //var matches = json.parse(!{match}); var matches = !{matchlist}; (var = 0; < matches.length; i++){ // how add #container here? } i have tried jquery couldn't make work. any appreciated! if data asynchronously server, not question jade, jquery add elements dom, example matchlist.foreach(function(match) { var = "<a class='ui label'>" + match.property + "</a>"; $('#container').append(a); } if render *.jade page passing data there can use for-loop in jade .ui.segment#container each match in matchlist a.ui.label |

Powershell - Filter results of varaible in pipeline -

i want limit results of $groups variable below return members of specific group. code retrieves groups computer belongs to. interested in members of ad group contains "sccm". i tried line 5 doesn't work. correct method this? thanks. $samaccountnames = (get-adcomputer computer).samaccountname $osinfo = get-wmiobject -class win32_operatingsystem -computername computer $servergroupmembershiplist = get-adprincipalgroupmembership $samaccountnames | sort samaccountname $groups = $servergroupmembershiplist.name #$groups = $servergroupmembershiplist.name | select {$servergroupmembershiplist.name -like "sccm"} write-host " " write-host "checking software updates compliance on" $computer.toupper() -foregroundcolor yellow -nonewline write-host $osinfo.caption $groups rather using select-object cmdlet, try using where-object cmdlet filtering or ? short. $_ variable current object being processed

css transforms - Three.js cube face rotation vector in relation to camera -

i have rotating sphere on have div attached example can viewed here: https://jsfiddle.net/ao5wdm04/ calculate x , y values , place div using translate3d transform , works quite well. my question how can values rotatex , rotatey , rotatez or rotate3d transforms div "tangents" sphere surface. know cube mesh faces sphere center assume rotation vector of outward facing normal vector in relation camera contain values need. i'm not quite sure how obtain these. update by using euler angles i'm achieving desired effect, shown here: https://jsfiddle.net/ao5wdm04/1/ rotation not large enough. disclaimer: know nothing three.js . i've done bit of opengl. your euler angles coming model-view-projected origin (lines 74-80). can't see logic behind this. if div on sphere surface, should oriented normal of sphere @ location of div. fortunately, have these angles. named rotation . if replace euler angles in lines 82-84 rotation angles used positio

scala - Play Framework / Twirl Dynamically include templates -

use case: have route handling requests @ host:port/p route looks following: get /p/*path controllers.application.p(path: string) the p method gets data , passes right through view p : return ok(p.render(currentsession)); in view want import template if there exists 1 matches string in passed data. in case string represents model object name such "user" , if there matching template views/custompages/user.scala.html . if there no matching template, use generic 1 such views/generic.scala.html . i have 2 parts question: part 1 : see can check template existence doing following: @if(custompages.user != null) { <p>it exists!</p> } but if change custompages.usera (a non existent template) compilation error ( object usera not member of package ). how can check? part 2 : how can check using string have representing model class? concatenating in place of hard coded "user" in answer part 1? am going wrong way? doing suppo

stream - Delphi Write TResourceStream into TStream -

i have embedded exe file in resorce file. when use stream.savetofile('test.exe'); works fine,produced exe file works no error. when try stream.savetostream(stin); , error " stream write error " . what's wrong code ? var list: tstringlist; stream: tresourcestream; stin, stout: tstream; memstream: tmemorystream; begin stream := tresourcestream.create(hinstance, 'phprogram' , rt_rcdata); try stin := tstream.create; stout := tstream.create; stream.position := 0; stream.savetostream(stin); endecryptstream(stin, stout, 2913); memstream.loadfromstream(stout); memstream.savetofile('test.exe'); //stream.savetofile('test.exe'); stream.free; end; end; edited : thanks david ... changed code , worked fine : var stream: tresourcestream; memstream: tmemorystream; begin stream := tresourcestream.create(hinstance, 'testres' , rt_rcdata); memstream := tmemorystream.create; try endecryptstream(s

How to control mouse movement and be able to move the ILNumerics ILColorbar at the same time -

the ilcolorbar has property called movable. if set false can't move colorbar on surface. if set true , have written custom events mouse movement (mousedown, mouseup, mouseleave, mousemove) these don't fire. fire if moveable set false. i want able move colorbar if mouse hovering on left 50% of width of colorbar , have mouse interact colorbar if hovering on right 50% of colorbar. do leave moveable false , manually move colorbar based on mousedown , mousemove events , state? or toggle moveable property? or there better way or possible?

java - How can I make sure I am not going to get an integer cast when doing division? -

i find confusing try figure out when value computed double , when cast integer in java. example: system.out.println( 1 / 3 ); system.out.println( 1 / 3d ); system.out.println( 1d / 3 ); system.out.println( 1/ 1d / 3 ); produces: 0 0.3333333333333333 0.3333333333333333 0.3333333333333333 am safe in assuming if there 1 double anywhere in expression whole expression double , if each , every value integer treated integer division? to quote spec: 4.2.4. floating-point operations if @ least 1 of operands numerical operator of type double, operation carried out using 64-bit floating-point arithmetic, , result of numerical operator value of type double. if other operand not double, first widened (§5.1.5) type double numeric promotion (§5.6). 15.17. multiplicative operators the operators *, /, , % called multiplicative operators. ... the type of multiplicative expression promoted type of operands. if promoted type i

java - Implement html multiple select in jsp -

<select multiple> <option value="volvo">volvo</option> <option value="saab">saab</option> <option value="opel">opel</option> <option value="audi">audi</option> </select> i need implement multiple select list. how it? getting list backend size can vary.

c# - Load UserControl in TabItem programatically -

placing usercontrol inside tabitem pretty basic when using xaml. <tabcontrol> <tabitem> <local:myusercontrol/> </tabitem> </tabcontrol> but want load usercontrol using viewmodel. how go that? instance <tabcontrol itemssource="{binding tabcollection}"> <tabitem header="{binding header}" source="{binding myusercontrol}"> <!-- source not property of tabitem--> <!-- i'm using in context example. how 'frame' work --> </tabitem> </tabcontrol> assuming viewmodel has observablecollection use populate different tabs, headers, background colour , on, how populate view in tabitem programatically? for instance, below basic sample of viewmodel: public class tabviewmodel { // 'tabmodel' simple class acts model class (tabviewmodel) // store strings, integers, etc. properties /