Posts

Showing posts from June, 2015

python - How to replace ndarray with a number? -

i have following code: arr = zip(*people2) in range(len(arr)): j in range(len(arr[i])): k in range(len(arr[i][j])): if(arr[i][j][k] == 1): arr[i][j] = k break there array of arrays of arrays. need replace these last arrays numbers. this: [ [[1, 0, 0], [2, 0, 0]], [[3, 0, 0], [4, 0, 0]], ] -> [ [1, 2], [3, 4] ] numbers here example. how can this? tried use numpy.resize() , doesn't work.

vba - Visual Basic Run-time error '91' when setting new Object -

i'm relatively new vba, not programming. i'm trying set shared instance of class, , keep running run-time error 91, complains variable not being set. 'a module acts singleton loader option explicit private instance grocerydatabase public function sharedinstance() grocerydatabase if instance nothing set instance = new grocerydatabase 'run-time error 91 thrown here end if set sharedinstance = instance end function obviously variable isn't set yet, why i'm assigning new grocerydatabase. i've seen lot of answers question boil down attempting use nothing object, can't understand why being thrown when try instantiate it. the error not due line object instantiated, instead because of issue in constructor there in fact variable being assigned not set. this discovered putting breakpoint in constructor grocerydatabase. future, i've enabled "break in class modules", found in path tools>options>general. no

html - Using margins vs absolute positioning when positioning elements? -

let's have simple table on site <table class="table table-striped table-bordered"> <tr> <th>name</th> <th>version</th> <th>edition</th> <th>expire date</th> <th>owner</th> </tr> <tr> <td style="color:red;">homex</td> <td>1.83</td> <td>basic</td> <td>13.07</td> <td>all</td> </tr> </table> and want move 20px top. should use margins margin-top:20px; or better use absolute positioning position:absolute; top:20px; which way better practice? to answer question, let's consider there multiple tables similar 1 have 1 after other. in case of using position:absolute style along top wouldn't fulfill task. because in case have calculate manually how top px want each table, whereas if use mar

android - How can I get the IMEI numbers for a dual SIM phone -

the dual sim phones have 2 imei numbers. when use getdeviceid() , can gets 1 of imei numbers. while can imei numbers using *#06# code. there way imei numbers in dual sim phones in android?

android - makeSceneTransitionAnimation between two recyclerViews working only in reverse -

in short : creating shared element activity transition between fragment recyclerview onclick opening activity recylcerview not trigger transition. however, using supportfinishaftertransition(); close opened activity does trigger animation correctly (it goes backwards previous activity). also, creating shared elements outside recyclerview cause animation work @ every case (both forwards , backwards on finish) - therefore code must correct. viewholder onclicklistener opens activity - simplified reduce useless code. public class statsviewholder extends webstatsviewholder implements view.onclicklistener{ protected textview vtitle; protected imageview vpicture; public statsviewholder (view itemview) { super(itemview); vtitle = (textview) itemview.findviewbyid(r.id.stats_title); vpicture = (imageview) itemview.findviewbyid(r.id.stats_picture); vtitle.setclickable(true); vtitle.setonclickli

php - joomla 3x insert a string into sql database -

i'm running joomla 3x portal , need insert string mysql database, have had no success far (sadly, i'm not programmer). so added new field users table called "ok1" , want insert string (actually hyperlink) , overwrite every time current 1 on page executed code last. this code used, "blows" portal... $query = $db->getquery(true); $columns = "ok1"; $values = "my hyperlink"; $query ->insert($db->quotename('#__users')) ->columns($db->quotename($columns)) ->values($db->quotename($values)); $db->setquery($query); $db->execute(); $query = $db->getquery(true); $db->setquery($query); $db->execute(); hopefully can me out one, in advance. second attempt: $content ="test" $query = $db->getquery(true); update `x__users` set `ok1`=$content `user` = $user->id; $db->setquery($query); $result = $db->execute(); what want this $columns = "ok1&q

javascript - Understanding of hash tables and collision detection -

below implementation of hash table using "buckets" collision detection. i'm trying make sure can understand logic behind hash tables , visualize it. hash table looks in case: [[[]<----tuple]<---bucket, []<----bucket]<--storage the key value pairs in tuples placed in bucket based upon hashing function's output, i.e. , bucket index. once @ hashed bucket index, place key value pair there, inside bucket. if matches exact key (once inside bucket) gets overwritten in implementation. collision detection takes place when find same key before, overwrite value. could have done different—perhaps added key different value end of tuple (instead of overwriting value) or must keys unique? there ever case when values need unique? var makehashtable = function() { var max = 4; return { _storage: [], retrieve: function(key) { //when retrieve, want access bucket in same way insert, don't need set storage since taken /

css - How can I center align a Bootstrap dropdown properly? -

i know can center bootstrap dropdown element using text-align: center css style. centers dropdown menu desired. however, when click menu activate it, , list of items appears, instead aligned left of parent div . i'd make left edge of dropdown menu flush left edge of button click activate (like if dropdown aligned left default). possible? this jsfiddle demonstrates issue i'm having. you can change dropdown class follows .dropdown{ margin: 0 auto; display: table; } if not wish set specific width element.

Can we force Javascript/jQuery to load fresh (unmodified) version of page from anchor link in modified page? -

i have jquery function clones elements on page , appends them list, replacing prior content. for background, items wordpress comments of type - posted since datetime "n" - have been isolated within nested comment structure. nested comment thread hidden, , list of selected comments take place. if seems... peculiar... note since comments cannot shown/hidden siblings, getting them meant cloning, re-formatting, , appending them in list page element. prior nested structure hidden, , new list of selected comments appears in former space. so far, good. toggling prior version works fine. works fine except last problem: when clicked, links of type (those linking elements within same page, identified id/hash) behave in less desirable manner. these internal links, when clicked, appear in browser address bar - .e.g.: ourhome/page/#itemid . if linked item happens displayed in cloned list, function normal anchors: jump location within list. (that's ok, if not ideal possib

imagelist - icons is grayed in c# program -

Image
i use png icons in program written in c#. have strange problem them. color of icons grayed on time , run program. in below picture picture @ first inserted (right image) , after 200 times program run (left image) shown. whats idea? problem coming from? how can prevent effect?

php - Data retrieval Issue -

i haven't found common sense way retrieve value column has space in it. example medal of honor column name , value number 0-15. yet moment write if($medal of honor >= 1) { the $medal read value , not $medal of honor duh right i tried add [] {} '' "" possible around variable no success any great. try fetch_assoc column names white space keep array keys. may access them $row['medal of honor'] .

c++ - Brace initialization for class with virtual function -

there code: struct { int x; void f() {} }; struct b { int y; virtual void f() {} }; a = {2}; //b b = {3}; error: no matching constructor initialization of 'b' int main() { return 0; } why initialization variable a works not variable b ? a aggregate, , can have brace initialization, , b isn't, since has virtual method. 8.5.1 aggregates an aggregate array or class (clause 9) no user-provided constructors (12.1), no brace-or-equal- initializers non-static data members (9.2), no private or protected non-static data members (clause 11), no base classes (clause 10), , no virtual functions (10.3).

Instagram realtime api https -

i'm coding app in php , i've had issues starting tag subscription when don't use https, i've tested both ways , prefer use http if possible. has else run , know of solution? their documentation doesn't show need https. when use http error unable reach callback url "http://... my issue wasn't https vs http. function curls post data. rebuilt , works now. a note future people trying use realtime api returns 0 data instagram post find odd, why note include post id @ least. ping server data subscription effected. worth noting see data have use command in php $igdata = file_get_contents("php://input");

javascript - jQuery - Ajax POST seems to does not work -

here html code: <div class="form-horizontal row-border"> <div class="form-group"> <label class="col-md-2 control-label">title:</label> <div class="col-md-10"><input class="form-control" id="title" name="title" type="text"></div> </div> <div class="form-group"> <label class="col-md-2 control-label">article:</label> <div class="col-md-10"> <textarea name="editor1" id="editor" rows="10" cols="80"> let's go... </textarea> </div> </div> <div class="form-group"> <label class="col-md-2 control-l

jquery - Unresponsive button in Laravel 5 yajra datatable -

i'm displaying table of usertypes. last column action column button opens modal edit usertype. for reason button nothing. controller : public function usertype_getall(){ $usertype = usertype::select(['id','name','price','tv','created_at','updated_at']); return datatables::of($usertype) ->addcolumn('action',function($usertype){ return '<button class="btn btn-sm yellow edit" onclick="edit_usertype('.$usertype->id .')"><i class="fa fa-cog"></i></button>'; }) ->setrowid('id') ->editcolumn('tv',function($usertype){ if($usertype->tv == 1){ return 'ja'; }else{ return 'nee'; } }) ->editcolumn('price','eur {{$price}}') ->removecolumn('id')

selenium - browse a file from my PC with selenuim -

i want write selenium program on site need part of process browse file operating system. how can that? if mean use selenium open html file on local, it's easy do. 1. open html file on browser 2. copy url in browser address, should like: file:///c:/workspace/js-projects/tey/protractor-cucumber-tey/reports/cucumber_report.html 3. put above url in browser.get() better way it's caclcute html file absolute path in scritp dynamically (rather hard code), prefix file://// on path, possible need replace '\' '/' in path.

java - How to print duplicates in string array only once -

i have string array index of 25. have entered 25 elements, , i'm trying display them, however, want elements listed once, number of occurrences. far, number of occurrences correct, each iteration of array still printing multiple times. using brute force method since cannot use arraylist, map, etc. there give me hints logic of printing elements once? here method below: private void displayflowers(string flowerpack[]) { // todo: display unique flowers along count of duplicates /* * example should * roses - 7 * daffodils - 3 * violets - 5 */ for(int = 0; < flowerpack.length; i++) { int count = 0; for(int j = 0; j < flowerpack.length; j++) { if(flowerpack[i].equals(flowerpack[j])) { count++; } } system.out.println(flowerpack[i] + " - " + count); } and here output see i'm talking about: rose - 6 daffodil - 2 rose - 6

css - Black Tint on Image Without Overlay - Firefox -

i have been able tint images in safari using following code: -webkit-filter: grayscale; /*sepia, hue-rotate, invert....*/ -webkit-filter: brightness(50%); however, doesn't work in firefox. understand how image grayscale in firefox, don't want grayscale -- instead black tint able achieve above code in safari. thank <3 use img { filter: grayscale(.5); filter: brightness(.5); } in firefox for more examples see mozilla guide filters

javascript - Ionic Scroll to Element -

i have with: <span id="quote-{{quote.id}}" ng-repeat="quote in quotes">{{quote.text}}</span> i'm trying have index scroll part of scroller using: $scope.jumptoquote = function (quote) { $scope.quoteselected = quote; var quoteposition = $ionicposition.position(angular.element(document.getelementbyid('quote-'+quote))); $ionicscrolldelegate.$getbyhandle('quotes-box').scrollto(quoteposition.left, quoteposition.top, true); } however value of quoteposition.top equals 10 top-offset of <ion-scroll> . as far see, need replace document.getelementbyid('quote-'+quote) document.getelementbyid('quote-'+quote.id) , concatenating whole quote object instead of it's id .

node.js odata-server mongodb unable to post related entity -

i have been working on node.js odata server based on example: how set nodejs odata endpoint odata-server i have working... can read, update, insert, delete. trying associate journal tasks , having problems. i have tried several different ways outlined here: operations (odata version 2.0) here code: /* global $data */ require('odata-server'); $data.class.define("task", $data.entity, null, { id: { type: "id", key: true, computed: true, nullable: false }, title: { type: "string", required: true, maxlength: 200 }, journals: { type: "array", elementtype: "journal" , inverseproperty: "task" } }); $data.class.define("journal", $data.entity, null, { id: { type: "id", key: true, computed: true, nullable: false }, entry: { type: "string" }, dateinserted: { type: "string" }, task: { type: "object", elementtype: "task" , i

Swift: Recursively cycle through all subviews to find a specific class and append to an array -

having devil of time trying figure out. asked similar question here: swift: subviews of specific type , add array while works, realized there many subviews , sub-sub views, , need function starts @ main uiview, cycles through subviews (and subviews until there aren't left) , adds array custom button class have named checkcircle. essentially i'd end array of checkcircles constitute checkcircles added view programmatically. any ideas? here's i've been working on. doesn't seem appending checkcircles array: func getsubviewsofview(v:uiview) -> [checkcircle] { var circlearray = [checkcircle]() // subviews of view var subviews = v.subviews if subviews.count == 0 { return circlearray } subview : anyobject in subviews{ if let viewtoappend = subview as? checkcircle { circlearray.append(viewtoappend checkcircle) } getsubviewsofview(subview as! uiview) }

Calculating an em value -1px in CSS/SASS without assuming the user's default font size -

i setting rwd breakpoints variables in sass, e.g. $bp-medium: 48em; (equivalent 768px when 1em = 16px). able set variable 1px less that, , have variable's value set in ems breakpoint continues respect user's base size preferences. sass provides calculation tools, certainly, every way i've tried relies on me having make assumption regarding how many pixels user has browser's default font size set to. example: $bp-medium-1: ($bp-medium/1em)*16px-1px; …gives $bp-medium-1 value of 767px (worst of options result in px), or $bp-medium-1: $bp-medium - (1em/16); …which gives $bp-medium-1 value of 47.9375em — better, since @ least result in ems now, i've had use assumed '16' in calculation again. to recap then: want work out 48em - 1px , end result being in ems , without having assume 16px/em base size. can done? no, cannot. way can perform arithmetic operations incompatible units em , px via calc() in css (not sass), , that not allowe

How can I make the same function work for different arrays? -

what want execute function when want push positions of vertices of 3d geometry array. want use same code on again when want push positions array. possible use function when want push in array? can me please? this code: function sphereposition() { sphere.position.x + sphere.geometry.vertices[i].clone().x * 1; sphere.position.y + sphere.geometry.vertices[i].clone().y * 1; sphere.position.z +sphere.geometry.vertices[i].clone().z * 1; } ( var = 0; < particles; i++ ) { positions.push( sphereposition(); ); } this not three.js question more of programming question how organize data ? you have several options (not exhaustive list). add position cone2. data world space position + vertices position use 2 arrays. 1 object world space position , 1 vertices position premultiply vertices object matrix , store result. using option 1: function getobjectdata (object) { var world_position = object.position; var vertices_posit

java - Strange type of password in mysql workbench -

i have problem password when password inputed in jpasswordfield . kasirlozinka = new jpasswordfield("lozinka"); final string lozinka = new string(kasirlozinka.getpassword().tostring()); and when write password "lozinka" in mysql workbench "[c@3f528528" , questions are, how fix , user input in string, , type of password this, how decrypt it? the call jpasswordfield.getpassword() returns char[] (and don't want call tostring() on that, because array doesn't override object.tostring ). can use string.valueof(char[]) make string . like, char[] pass = kasirlozinka.getpassword(); string pw = string.valueof(pass);

utf 8 - Thin/Hair space in FPDF -

i wondering if it's possible add thin/hair space pdf generated fpdf? i tried iconv('utf-8', 'iso-8859-1', html_entity_decode('bla&thinsp;blub')) but gives me: php notice: iconv(): detected illegal character in input string (my font generated iso-8859-1 ) any idea? okay, answering own question: found addon allows fit text in cell reducing space width and/or character spacing. writing raw pdf source. in case helped out, doesn't answer question...

ios - frame changes are discarded -

i trying reposition when resizing using changes on these views' frames changes made problem these changes discarded (undone) , views old frames back. changing frames code bellow viewholder.frame = cgrectmake(viewholder.frame.origin.x,viewholder.frame.origin.y, viewholder.frame.size.width, viewholder.frame.size.height + 30); cgrect frame3 = cgrectmake(belowview.frame.origin.x, belowview.frame.origin.y + 30, belowview.frame.size.width, belowview.frame.size.height); belowview.frame = frame3; so can tell me why happening here?

python - Function cannot open file after py2exe compile -

i'm using rdkit . after build using py2exe , when call draw.moltoimage method there error: warning: unable load font metrics dir c:\pythonapp\dist\library.zip\rd kit\sping\pil\pilfonts traceback (most recent call last): file "app.py", line 470, in <module> img=draw.moltoimage(part[i]) file "rdkit\chem\draw\__init__.pyc", line 124, in moltoimage file "rdkit\chem\draw\moldrawing.pyc", line 536, in addmol file "rdkit\chem\draw\moldrawing.pyc", line 351, in _drawlabel file "rdkit\chem\draw\spingcanvas.pyc", line 74, in addcanvastext file "rdkit\sping\pil\pidpil.pyc", line 333, in drawstring valueerror: bad font: font(12,0,0,0,'helvetica')` there no difference if put these files library.zip (to \rdkit\sping\pil\pilfonts ) or dist folder , change paths in pidpil.py valid; application still cannot open metrics.dat . without py2exe conversion, works perfectly. ar

ios - Create empty array of struct gives me an error -

i'm trying create empty array of struct . here's code: struct item { var prop1 : nsdate var prop2 : nsdate } var myitem = [item()] but error: missing argument parameter 'prop1' in call. what doing wrong, , how can fix it? item() trying create item empty, that's not possible since neither prop1 nor prop2 have default values. automatically generated initializer requires 2 arguments. to create empty array, can use 1 of these: var myitem: [item] = [] var myitem = [item]() var myitem = [] [item]

Subquery's with limit in Doctrine/Symfony using DQL -

i know how can set limit on 1 query , query based on selected results. for example want select last 100 posts , operation. $first_query= $this->getentitymanager() ->createquery( 'select p testbundle:post p order p.date desc' ) ->setmaxresults(5); how use result select in next query? return $this->getentitymanager() ->createquery( "select u.username , max(p.date),d.points,l.name $first_query join p.location l join p.user u join u.deeds d l.name = :location group u.id order d.points desc , p.date desc " ) ->setparameter('location' , $location) ->getresult(); i found out dql doesn't support limits went native sql. $stmt = $this->getentitymanager()->getconnection()->prepare($query); $stmt->execute(); return $stmt->fetchall(); this way can whatever want $query varaible can set limit

Haskell class functions: very confusing error -

i have confusing error in piece of code. using data.aeson package. don't think bug of package. class toarrayformat getobjects :: (tojson b) => -> b toarrayformat :: -> value toarrayformat = tojson $ getobjects this piece of code fail compile error message : not deduce (tojson s0) arising use of ‘tojson’ context (toarrayformat a) bound class declaration ‘toarrayformat’ @ <interactive>:(103,1)-(108,43) type variable ‘s0’ ambiguous in expression: tojson in expression: tojson $ getobjects in equation ‘toarrayformat’: toarrayformat = tojson $ getobjects i'm confused now. getobjects returns tojson b instance can consumed tojson in toarrayformat . can't deduce instance of b getobjects definition? why tojson s0 ambiguous? the key part: the type variable ‘s0’ ambiguous note tojson has type: tojson :: tojson b => b -> value also, declaration: getobjects :: (tojson b) => -> b says getobjects

JSX and Typescript in the same file with Visual Studio 2015 -

in visual studio 2015 : i can change file extension .jsx , start writing jsx code inside. i can change file extension .ts , start writing typescript code inside. but how can jsx , typescript in visual studio 2015 inside 1 single file ? someting .jsx.ts ? intelissense working both @ same time... i found wich works atom ide. http://blog.mgechev.com/2015/07/05/using-jsx-react-with-typescript/ as far understand need have typescript 1.6 support. if visual studio 2015 doesn't come typescrip 1.6 support, there way use nightly builds wich allready have implementation ? now typescript 1.6 beta out. download tools as provided in announcement .

php - How to get individual xml subnodes when using $xpathvar->query? -

i try value of name, previewurl, description, etc when country name (e.g. <country name="us"> ) matches country of user xml results 1 below: <offers> <offer id="656"> <name>the hobbit android</name> <platform>android smartphone & tablet</platform> <dailycap>63</dailycap> <previewurl>https://play.google.com/store/apps/details?id=com.kabam.fortress</previewurl> <trackingurl>http://ads.ad4game.com/www/delivery/dck.php?offerid=656&zoneid=7711</trackingurl> <description>the battle middle-earth has begun! play free , join thousands worldwide drive ..</description> <restrictedtraffic> social traffic (facebook, etc), social traffic (facebook, etc) email marketingm, brand bidding</restrictedtraffic> <countries> <country name="us"> <optin>soi</optin><rate>$3.75&l

Loadmore Script Php / Javascript? -

i try code loadmore script.. connected database means onpage load showing first 20 posts... @ page complete scrolling down or clicking loadmore button after @ bottom of page loading next 20 posts. but @ moment showing everytime same posts , working button onclick. so right way ? or must change ? thanks hints. i use atm simple ajax request. <script type="text/javascript"> $(document).ready(function(){ $( ".readmore_home_posts" ).click(function() { $('div#loadmoreajaxloader').show(); $.ajax({ url: "./ajax/loadmore_homenews.php", success: function(html){ if(html){ $("#lastpostsloader").append(html); } else{ $('#lastpostsloader').html('<center>no more posts show.</center>'); } }

ios - Koloda delegate : fatal error: unexpectedly found nil while unwrapping an Optional value -

i using koloda in project , whenever try load 1 view controller in particular error "fatal error: unexpectedly found nil while unwrapping optional value" on kolodaview.datasource = self , if commented out same error on kolodaview.delegate = self . new ios , swift not sure going on. following code in koloda viewcontroller showing error: override func viewdidload() { super.viewdidload() kolodaview.datasource = self kolodaview.delegate = self self.modaltransitionstyle = uimodaltransitionstyle.fliphorizontal } the following code uiviewcontroller trying load. not linked via segues. import foundation import uikit class genderselection1: viewcontroller, uitableviewdelegate, uitableviewdatasource{ @iboutlet weak var tableview: uitableview! override func viewdidload() { super.viewdidload() self.tableview.delegate = self self.tableview.datasource = self } override func didreceivememorywarning() { super.didreceivememorywarning()

html - Bootstrap Nav Tabs Showing All Body -

trying make nav tabs section not show body of each tab photo below. here code relevant section: <div class="widget-content padding"> <a href="consultants.html" style= "float:right" button type="button" class="btn btn-danger" data-dismiss="modal">back</button></a> <h1>sales provisioning - (daniel ince)</h1> </div> <br> <div class="additional-btn"> </div> </div> <div class="widget-content padding"> <h3><i>refer faq if stuck whilst provisioning</i></h3> <br> <ul id="demo1" class="nav nav-tab

Parsing specific field in XML file in Python -

i have xml file looks this: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <feed xml:base="http://data.treasury.gov:8001/feed.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/atom"> <title type="text">dailytreasuryyieldcurveratedata</title> <id>http://data.treasury.gov:8001/feed.svc/dailytreasuryyieldcurveratedata</id> <updated>2015-08-30t15:17:09z</updated> <link rel="self" title="dailytreasuryyieldcurveratedata" href="dailytreasuryyieldcurveratedata" /> <entry> <id>http://data.treasury.gov:8001/feed.svc/dailytreasuryyieldcurveratedata(6404)</id> <title type="text"></title> <updated>2015-08-30t15:17:09z</updated>

When building release apk using android studio, i get a error "Keystore was tampered with, or password was incorrect" -

it's strange, have created keystore using android studio before. , studio canary channel(1.4), keep studio updated. last day error, downgraded studio stable channel(1.3). but when build using gradle in command line , fine. sure password right. full error : error:execution failed task ':app:packagedevrelease'. failed read key ** store "d:\work\app_proj\android\jxj\trunk\jxj\app\szyx.keystore": keystore tampered with, or password incorrect i fixed it! (for me @ least) i found issue somehow related gradle plugin. when changed dependencies { classpath 'com.android.tools.build:gradle:1.4.0-beta6' } to dependencies { classpath 'com.android.tools.build:gradle:1.3.1' } in project's build.gradle , fixed problem. just op, able sign builds created using ide's play button, not ones created through generate signed apk... menu option. after searching, found open issue .

c# - VS 2015 Community - Not checking errors until build, errors do not go away -

intellisense still give suggestions, visual studio not highlight errors until click "start". can write absolute gibberish , no red squiggles appear. however, when click "start", error list populate , build fail. (it check errors after click "rebuild" or "clean solution"). however, when edit errors, red squiggles remain. when remove entire line, 2 space long red squiggle remain. clicking "start", "rebuild", or "clean solution" not make these old error highlights disappear , error list not change. closing , restarting vs 2015 community clear them. rebooting computer did not re-enable error checking function. system details: fresh install of windows 7 pro 64bit on macbook pro bootcamp. first project have made since installing vs 2015 community yesterday. writing windows forms app using c#. best of knowledge, working fine few hours morning. have tried resetting settings. have tried rebooting , deleting bin/obj fo

javascript - listening for click event for an href by classname -

there page basic html cannot touch looks this: <a class="continue-shopping" href="https://someurl">continue shopping</a> what want send user different link when click on someurl text link. user can come page containing html many other pages. i have tried many hours cannot js recognize click event class associated hyperlinked text. use here. js code wrote not work window.onload = function() { prepeventhandler(); } function prepeventhandler () { var myclass = document.getelementsbyclassname("continue-shopping"); myclass[0].onclick=window.open(document.referrer,"_self"); /* make pages go haywire or -- not work */ myclass[0].addeventlistener("click", function() { window.open(document.referrer,"_self"); } ) } it keeps ignoring second function, , sure doing basic wrong. again, help! apart preventdefault() use return false window.onload = function () { var myclass = documen

php - Symfony on Synology -

i use latest dsm on synology (ds415+), dsm 6.1.3-15152 update 4, , try install new symfony application, doesn't work. i tried: symfony new projectname but ends with: ✕ symfony 3.3.9 installed system doesn't meet technical requirements! fix following issues before executing symfony application: token_get_all() must available install , enable tokenizer extension. then tried: composer create-project symfony/framework-standard-edition projectname the install process ends fine, after running command: php bin/symfony_requirements it's same tokenizer extension issue i tried: php56 symfony.phar new projectname same previous install command. well, i'm having own issues symfony on dsm6, frustrating! synology decided build own php packet source. choose remove capabilities , extensions (including tokenizer) build. that's why can't run symfony php version doesn't meet symfony requirem

Calculating the Letter Frequency in Python -

i need define function slice string according character, sum indices, divide number of times character occurs in string , divide length of text. here's have far: def ave_index(char): passage = "string" if char in passage: word = passage.split(char) words = len(word) number = passage.count(char) answer = word / number / len(passage) return(answer) elif char not in passage: return false so far, answers i've gotten when running have been quite off mark edit: passage given use string - 'call me ishmael. years ago - never mind how long precisely - having little or no money in purse, , nothing particular interest me on shore, thought sail little , see watery part of world. way have of driving off spleen , regulating circulation. whenever find myself growing grim mouth; whenever damp, drizzly november in soul; whenever find myself involuntarily pausing before coffin warehouses, , bringing rear of every funeral meet; , whene

azure - Xamarin forms - authentication with AAD, tried and failed -

i've been trying days xamarin forms app token aad i've tried countless different ways of doing , have problems, bugs, haven't been able figure out this link 1 of simplest examples i've come across, yet fails because says there's no client secret http://www.cloudidentity.com/blog/2015/07/22/using-adal-3-x-with-xamarin-forms/ when add client secret, modifying authenticationcontext so authenticationcontext ac = new authenticationcontext("https://login.microsoftonline.com/common"); clientcredential cc = new clientcredential("------4ba8-4136-ad1c-f36be878af8a", "-----sddg4/wzcyyu="); authenticationresult result = await ac.acquiretokenasync("https://graph.windows.net", cc); i new error saying there no application matching graph.windows.net in directory any help? please make sure type of azure ad application register native client application , type application meant run on device ,

php - trying to simplify the update code -

i want update following words in identifier_flag field, there simpler way currenty have? $temp_query = "select * faq"; $sql = mysqli_query($connection, $temp_query); while($row = mysqli_fetch_assoc($sql)){ if(preg_match("/price/", $row['question'])){ $update = "update faq set identifier_flag = 'price' id = '".$row['id']."'"; mysqli_query($connection, $update); } if(preg_match("/colours/", $row['question'])){ $update = "update faq set identifier_flag = 'colours' id = '".$row['id']."'"; mysqli_query($connection, $update); } if(preg_match("/versions/", $row['question'])){ $update = "update faq set identifier_flag = 'versions' id = '".$row['id']."'"; mysqli_query($connection, $update); } if(preg_match("/oil/&q

c++ - Possible data race condition using openMP, corrupted data -

i have code works fine when running on 1 thread. have been using open mp parralellize code. problem when use more 1 thread start corrupted results. best guess have data race condition somewhere in code cannot find it. thoughts or advice appreciated. in advance. omp_set_num_threads( 12 ); double average = 0; int x; #pragma omp parallel schedule(static) reduction(+:average) for(x = 0; x<k_folds_folds; x++) //need paralellize loop { double result = logistic_regression_test(xtraining[x], xtest[x], ytraining[x], ytest[x]); average += result; } the code works fine when comment out omp_set_num_threads. k_folds_folds = 15 , logistic_regression_test function bunch of stuff , returns double. possible problem somewhere within function? function create local variables @ same memory location every time, if multiple threads executing function? explain corrupted data if each function called in parallel changing same memory addresses.

excel - Custom row labels in PivotTable -

i have excel spreadsheet full of customer data including few single letter categorical variables. for example: property type can (i investment, o owner occupier, or r renter). possible replace single letter descriptive title in rows on pivottable? not have descriptive names anywhere in spreadsheet , prefer not add them. you can give nicknames fields checking populate pivot table. if go pivot table data , right click can change value field settings give custom name row/series not know individual data points. path: pivot table data => right click => select field settings => edit custom name. it not modifies raw data (before pivot table). adds name chart well. make sure chart looks okay. knowledge best tool mess around with. answers question. coming experimenting on excel 2013.

java - Scrape eBay Product Description -

i'm using selenium + java scrape ebay product descriptions. currently, easiest way description using xpath: .//*[@id='ds_div'] . scrapes everything—including sellers template images, shipping information , details directly related seller's policy—which don't want or need. i need scrape details of product (such features , product description) without extraneous details. the problem there no single xpath/css can use this—as xpath/css varies seller seller. what best approach obtain information? thanks

java - How to check if android.hardware.Camera is released? -

i got exception while releasing camera object "java.lang.runtimeexception: method called after release" following code , exception stack trace. if (camera != null) { camera.stoppreview(); camera.release(); camera = null; } exception stack trace - java.lang.runtimeexception: method called after release() thread[main,5,main] android.hardware.camera._stoppreview(native method) android.hardware.camera.stoppreview(camera.java:626) com.s5.selfiemonkey1.activity.preview.surfacedestroyed(preview.java:152) android.view.surfaceview.updatewindow(surfaceview.java:601) android.view.surfaceview.access$000(surfaceview.java:88) android.view.surfaceview$3.onpredraw(surfaceview.java:183) android.view.viewtreeobserver.dispatchonpredraw(viewtreeobserver.java:680) android.view.viewrootimpl.performtraversals(viewrootimpl.java:2123) android.view.viewrootimpl.dotraversal(viewrootimpl.java:1139) android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.jav

Ruby on Rails mysql migrate use Timezone instead of Datetime -

i keeping in mysql table column called starts_at my column can different timezone each time. i have tried creating migration: def self.up create_table :meetings, id: false, force: true |t| t.string :id t.timestamp :starts_at end end but end datetime column type i want force rails use timestamp , , tried of these with no success : def change_column :meetings, :starts_at, :timestamp end this: def change_column :meetings, :starts_at, 'timestamp' end and this: def self.up create_table :meetings, id: false, force: true |t| t.string :id t.column :starts_at, 'timestamp' end end any ideas? update: i want save timezone on database record , not on application configuration rails makes of decisions you. both :timestamp , :datetime default datetime , while :date , :time corresponds date , time , respectively. using rails, have decide wh

angularjs - How to extend angular-material components? -

i want apply angular-material in recent project, afraid difficult find other components not available currently. treeview, date/time picker, carousel , on... how can deal these things? opinions? i've tried use angular-material in site existing style, , found number of issues wasn't able resolve: - site ui feeling sluggish - there paralax script became extremely slow , lagged when there quick scroll. - odd behavior fonts when loaded (when re-sized screen , again working again) in chrome. this became real issue - part doesn't feel complete. hoping material-ui, appears rely on react. however, have come across https://fezvrasta.github.io/bootstrap-material-design/bootstrap-elements.html appears suitable , works bootstrap. there's answer : using bootstrap angular , material design angular together of issues face when using material bootstrap. also, tested on mobile phone , site terrible (in performance), you'd never want site type of performanc

Creating Object List in Java class - better approach -

a have question related creating object list in java class. can tell me solution better? pros , cons of it? 1) first version of class: public class productrepositoryimpl implements productrepository { private list<product> listofproducts = new arraylist<product>(); public productrepositoryimpl() { addproducts(1, "silnik", "ferrari", 1000, listofproducts); addproducts(2, "sprzęgło", "opel", 500, listofproducts); addproducts(3, "kierownica", "fiat", 100, listofproducts); addproducts(4, "panewka", "maluch", 250.00, listofproducts); addproducts(5, "akumulator", "autosan", 1700.00, listofproducts); addproducts(6, "zakrętka", "maseratii", 100.00, listofproducts); } private void addproducts(int idproduct, string name, string brand, double price, list list) { product product = new

php - Display JSON data from external API -

i'm trying sort out knowledge jsonp. dont know how make callback external api class myclass { private $_id = $_post['id']; public get_name() { $id = $this->_id; $request = 'http://external.sever.com/api.php?operation=get_name&id='.$id.'&callback=?'; } } let's assume, api works properly, , callback like: {name:'kamil'} or this. and comes javascript code $.ajax({ url: get_request_from_myclass, datatype: 'jsonp' }).done(function(data) {send_data_as_$_post_or_another_php_var}); how put php variable in javascript , output $.ajax send server post variable?

Exclude folders from indexing in Intellij maven project using wildcard -

is possible exclude folders indexing using wildcard? in project impossible mark /target folders excluded. there of them. leads freezes during project rebuild. edit (thanks @arham) progress tracked issues: https://youtrack.jetbrains.com/issue/idea-127753 https://youtrack.jetbrains.com/issue/idea-150784 for simpler things, ignoring target folders in project can use: settings|editor|filetypes|ignore files , folders i found way exclude files of extensions. i have configured project on windows in sync linux box. i use sftp tool provided intellijidea sync files , folders . to configure sftp deployment goto tools-> deployment -> configuration to exclude files goto tools- > deployment -> options -> exclude items name this helps me in excluding files getting synced linux box windows. i guess if structure not same mine, create dummy deployment configuration existing project , should work.

java - Cannot refer to the non-final local variable button defined in an enclosing scope, Random method error -

i getting error in project eclipse: cannot refer non-final local variable button defined in enclosing scope this class: import android.app.activity; import android.content.context; import android.graphics.point; import android.os.bundle; import android.support.annotation.nonnull; import android.widget.button; import android.view.menu; import android.view.menuitem; import android.view.windowmanager; import java.util.random; import java.util.timer; import java.util.timertask; public class mainactivity extends activity { button buttonblack; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); buttonblack = (button)findviewbyid(r.id.button01); startrandombutton(buttonblack); } public static point getdisplaysize(@nonnull context context) { point point = new point(); windowmanager manager = (windowmanager) context.getsystemservice(context.window_service); ma

ruby on rails - How to make the "update" function -

i new ror. started make registration of user login, showing , deleting, cant make edit/update function. going post register function , html form used register , want same use edit/update. the register function def register @name = params[:name] @surname = params[:surname] @username = params[:username] @password = params[:password] @email = params[:email] @tel = params[:tel] @role_id = params[:role_id] user = user.create_with_password(@name,@surname,@username,@email,@password,@tel,@role_id) if user #session[:signed_in] = true session[:username] = user.username redirect_to "/menaxhimi_pushimit/index" else redirect_to "/menaxhimi_pushimit/index" end end user model def self.create_with_password(name, surname, username, email, password, tel, role_id) salt = securerandom.hex password_hash = self.generate_hash(password, salt) self.create( name: name, surname: surname, username: username, email: email,