Posts

Showing posts from 2013

javascript - Angularjs $http cant get data but can get from $jquery.ajax -

i tired data off api using jquery.ajax() , works fine here code that: $.ajax({ url: "http://api.somesite.com/api?format=json", type: "get", //it works post datatype: 'jsonp', }) .done(function( data ) { if ( console && console.log ) { console.log( "sample of data:", data ); } }); now wanted same angularjs did following first did this: var req = { method: 'get', url: "http://api.somesite.com/api?format=json", headers: { 'content-type': "application/json", }, } $http(req).then(function(response){ console.log(response.data); }); i in console: xmlhttprequest cannot load http://api.somesite.com/api?format=json. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8100' therefore not allowed access. then tried this: $http.jsonp('http://api.somesite.com/api?format=json',...

java - Connect two boxes with a line via drag and drop -

selenium rookie here question regarding drag , drop. i have 2 boxes , 1 of boxes can drag line , connect other box. i have tried various ways none of them seem work. actions action = new action(driver); action.draganddrop(box1 , box2).perform(); // did not work action.clickandhold(box1).movetoelement(box2).release().perform(); //did not work either action.clickandhold(box).movebyoffset(coordonates of box2).release().perform(); // did not work this knowledge of selenium stops , there other way can this? i know xpath because when perform element.click(); access not that. selenium's actions drag , drop not play nice html5, when trying move element frame , in several other situations. possibly can solve problem using jquery solution: [c#][selenium] how drag-hover-drop element

sql - Writing a query for multiple fields using IN -

select a.first_name,b.empid,c.phn name a,emp b,phone c b.emptype = 'new' , a.first_name,b.last_name,c.phn = (select a.first_name,b.last_name,c.phn name a,emp b,phone c b.emptype = 'old') basically, want search new customers have same details (first name, last name , phone) old customers. old customer can converted new customer details retained. hence, thing changes emptype. eg. (john mcenroe 47589876 old) when converted becomes (john mcenroe 475898876 new) [first_name,last_name,phone,emptype] dude, here's query uses exists. main difference between exists , in exists queries using index in goes lot of or toghether. select a.first_name ,b.empid ,c.phn name ,emp b ,phone c b.emptype = 'new' , exists (select top 1 1 name x ,emp y ,phone z x.first_name = a.first_name , y.last_name = b.last_name , z....

c++ - Inverse FFT in OpenCV gives different result than Matlab -

using opencv, want same result of matlab's ifft2 function. in matlab get: a = [1 2 0; 4 5 0; 7 8 9; 10 11 12]; inverse = ifft2(a); inverse = 5.7500 + 0.0000i -0.1250 + 0.3608i -0.1250 - 0.3608i -1.7500 - 2.0000i -0.3080 + 0.4665i 0.5580 + 0.0335i -1.2500 + 0.0000i -0.1250 - 0.2165i -0.1250 + 0.2165i -1.7500 + 2.0000i 0.5580 - 0.0335i -0.3080 - 0.4665i in opencv, when do: cv::mat paddeda; int m = cv::getoptimaldftsize(a.rows); int n = cv::getoptimaldftsize(a.cols); cv::copymakeborder(a, paddeda, 0, m - a.rows, 0, n - a.cols, cv::border_constant, cv::scalar::all(0)); cv::mat planes[] = { cv::mat_<float>(paddeda), cv::mat::zeros(paddeda.size(), cv_32f) }; cv::mat complexa; cv::merge(planes, 2, complexa); cv::mat inverse; cv::idft(complexa, inverse, cv::dft_scale | cv::dft_complex_output); this gives me: inverse = [1, -0, 2, -0, 0, -0; 4, -0, 5, -0, 0, -0; 7, -0, 8, -8, 9, 0; 10, -0, 11, -0, 12, -0] and type of a cv_32f . ho...

sql - sqlalchemy: select specific columns from multiple join using aliases -

this has stumped more day , examples find have not worked. new sqlalchemy , find documentation not enlightening. the query (so far): prey = alias(ensembl_genes, name='prey') bait = alias(ensembl_genes, name='bait') query = db.session.query(tap,prey,bait).\ join(prey, tap.c.tap_prey_ensembl_gene_id==prey.c.ensembl_gene_id).\ join(bait, tap.c.tap_bait_ensembl_gene_id==bait.c.ensembl_gene_id).\ filter(\ or_(\ tap.c.tap_prey_ensembl_gene_id=='ensg00000100360',\ tap.c.tap_bait_ensembl_gene_id=='ensg00000100360'\ )\ ).\ order_by(desc(tap.c.tap_unique_peptide_count)) tap refers table of interacting genes. 1 interactor designated 'bait' , other 'prey'. prey , bait aliases same table holds additional information on these genes. objective select interactions given gene 'ensg00000100360' either bait or prey. the problem: this query returns 20 or columns, need 6 specific ones, 2 ea...

java - One statement to select data from two MySQL tables. Show name instead of/by ID -

i have 2 tables the table .issues looks this: id tracker_id project_id 22 1 218 in second table .trackers: id name 1 error is possible make 1 select request receive result names of trackers instead of/with ids? need simplify java request. i want smth this: id (tracker_id) project_id tracker_name 22 (1) 218 error i tried this, know doesn't make sense: statement stmt1 = conn.createstatement(); resultset ticketsrows = stmt1.executequery("select * issues tracker_id in (select id trackers)"); join trackers table , select name column table instead tracker_id select i.id, t.name tracker_name, i.project_id issues join trackers t on i.tracker_id = t.id

angularjs - how to use element attribute value to show / hide div in angular js -

i want show div based value of div's attribute values. <div ng-show="" data-views="{{viewstate}}" id="question_id_{{questionid}}" >aaa</div> i want below <div ng-show="data-views" data-views="{{viewstate}}" id="question_id_{{questionid}}" > how pass data-views attribute value ng-show="" is possible better way show hide take scope variable in controller , use below if value boolean otherwise use conditions in ng-show. $scope.viewstate =true/false; <div ng-show="viewstate" data-views="{{viewstate}}" id="question_id_{{questionid}}" >

How to make simple string compare in C (Arduino)? -

i new c , i'm attempting writte simple code arduino (based on wiring language) this: void loop() { distance(cm); delay(200); } void distance(char[3] unit) { if (unit[] == "cm") serial.println("cm"); } could please advise me how writte correctly? in advance! there several ways. the "basic" 1 using strcmp function: void distance(char* unit) { if (strcmp(unit, "cm") == 0) serial.println("cm"); } note function returns 0 if strings equal. if have fixed-length strings maybe testing every single character faster , less resources-consuming: void distance(char* unit) { if ((unit[0] == 'c') && (unit[1] == 'm') && (unit[2] == '\0')) serial.println("cm"); } you can other things (such iterating through arrays if strings can have different length). bye

python - Appending a multi-indexed column to the index of a DataFrame -

i have generated initial dataframe called df , adjusted dataframe called df_new. i wish df df_new using set_index() operation. problem how negotiate hierarchical index on columns import pandas pd import numpy np df = pd.dataframe(np.ones((5,5))) col_idx = pd.multiindex.from_tuples([('x','a'),('x','b'),('y','c'),('y','d'),('y','e')]) row_idx = ['a1','a2','a3','a4','a5'] df.columns = col_idx df.index = row_idx idx = pd.indexslice df.loc[:,idx['y','d']] = 99 print df.head() x y b c d e a1 1 1 1 99 1 a2 1 1 1 99 1 a3 1 1 1 99 1 a4 1 1 1 99 1 a5 1 1 1 99 1 #------------------------------------------------------------------------------------------ df_new = pd.dataframe(np.ones((5,4))) col_idx = pd.multiindex.from_tuples([('x','a'),('x','b'),('y','c'...

javascript - Change displayed text returned by google Autocomplete API -

Image
currently i'm using google autocomplete enable users search cities. when typing ber shows following: which fine. when selecting element, e.g. first one, textbox-value switches berlin, deutschland can seen here: when hitting enter or clicking element, text stay same: what want show city's name berlin in textbox without nation @ end. there specific event should bind crop nation before set in textbox? the 'place_changed' event 1 should listening for

java - Security impact of access modifiers (public, private, internal, protected) -

do access modifiers of classes , properties or methods in c#, java , other programming languages have impact on security of application? protect against unauthorized access in way? or tool clear , propper programming? no, access modifiers don't offer security protection. merely there developer convenience, e.g. enforce coding practices , programming patterns. it's easy access otherwise inaccessible modifiers using reflection in java/c# , other languages.

excel - Updating a workbook and Saving using VBA -

i've created macro should refresh data sources. it's data sources sql servers, , such automatically pull password box required. if you've input password server since excel last opened doesn't ask password. i've managed following piece of code together, it's not behaving i'd expect sub bsr_refresher() 'refreshes spreadsheet , copies today's date 'clears filters on error resume next activeworkbook.showalldata 'refreshes spreadsheet each objconnection in thisworkbook.connections 'get current background-refresh value bbackground = objconnection.oledbconnection.backgroundquery 'temporarily disable background-refresh objconnection.oledbconnection.backgroundquery = false 'refresh connection objconnection.refresh 'set background-refresh value original value objconnection.oledbconnection.backgroundquery = bbackground next 'saves spreadsheet activeworkbook.saveas filename:=activ...

css - Broken HTML inside an HTML page -

i have page reading html email. sometimes, text comes email has html , css , changes page style completely. i don’t want page style impacted because of this. how read html , css strictly inside particular div (box) , not let page impacted this? you have write css using parent > child format. might have use !important.

c# - Handling CORS Preflight in Asp.net Web API -

i have 3 applications in architecture. on same server having different port numbers. a - token application (port 4444) - asp.net webapi b - api application (port 3333) - asp.net webapi c - ui application (port 2222) - angularjs app. the application flow below 1- ui project gets token token application (it requires windows auth.) ex : awxrsdsaweffs12da 2- ui application puts token custom header named "accesstoken" ex : accesstoken : awxrsdsaweffs12da 3- ui application sends request api application ex: http:myaddress:3333/api/therestservicehere ui application gets 401 error. sends options method. (i guess preflight issue) in web api project enabled cors below. public static void register(httpconfiguration config) { .... //cors var cors = new enablecorsattribute("*", "*", "*"); config.enablecors(cors); .... } config public static class webapiconfig ...

ios - Get file path from a NSBundle which is not the mainBundle -

i'm trying pathforresource plist file, when file in mainbundle easy, used: let path = nsbundle.mainbundle().pathforresource("settings", oftype: "plist") but moved settings file bundle , don't know how it. tried use forclass , allbundles i'm swift rookie , didn't managed make work. coulden't find solution on web. seems nsbundle usages examples mainbundle if don't know bundle has resource loop through of them: let bundles = nsbundle.allbundles() var path : string? var mybundle : nsbundle? bundle in bundles { if let resourcepath = (bundle as! nsbundle).pathforresource("settings", oftype: "plist") { path = resourcepath mybundle = bundle break } } on other hand, if have path or identifier of bundle use: let bundle = nsbundle(path: "the-bundle-path") or let bundle = nsbundle(identifier: "bundle-identifier") this has nothing level of swift pr...

enums - c# convert datagridview id to collection names -

i'm having problems datagridview. i'm trying export row selection of datagridview1 in array used in chart in same solution. need convert id's actual collection name. tried enum list convert id collection name, compiler gives me error in end used case switch. enum correct way go convert id collection name or should follow different road? e.graphics.drawline(pen, position1, position2(enum.getname(typeof(collectioname),idofcollectioname), positionx2, positiony2)); i not sure if got question but, i need convert id's actual collection name if mean id value can one of limited set of values, answer yes , can use enum . but if id else, answer no , can't use it.

RichText in Magnolia CMS is changing HTML text -

i ask how can block richtext changing html text under source view. i'm using blossom module , defined richtext @chris j advised me do: add source button magnolia cms richtext control whenever put html code in source code, switch normal view , source view code changed. example following part of code missing : <div class="components"> <div class="product col img-slider"> <div id="product-image" class="royalslider productimage rsdefault"> <div class="rscontent"> <div class="rstmb"><img src="/magnoliapublic/resources/xxx/products/product_7.jpg" alt=""> and replaced folowing <p><img alt="" src="/magnoliapublic/resources/xxx/products/product_7.jpg" /></p> i need provide possibility user put html code , next see in on web page. regards jan jan. i'd ask why using rich text area if entering html. not designed ...

netlogo - How do I properly use the 'random' function for multiple agents? -

in model have agents collecting agent bump @ random after move base. move drop off material defined random function. here's sample code to go ask searchers [ set energy energy - 1 fd 0.0125 if random-float 1 < (1 / 50) [ ifelse random 2 = 0 [ rt 45 ] [ lt 45 ] ] search ] end search if any? depots in-radius vision [color = yellow] [spread set energy 0] ;; makes them base end spread if random 10000 = 1 [hatch-rubbish 1 [ set color white set shape "circle" set size 0.5]] end if set visual radius enormous can see depot number of bits of rubbish works out. however if allow them move around radius of 1, count of rubbish higher 1 in 10,000. why make difference? thanks

google compute engine - How to allow HTTP requests from forwarding rule only -

i setting http load balancer compute engine instances. after basic setup works, want block external http access compute engine instances. http communication should go through forwarding rule. how configure network firewall achieve that? so far network firewall looks like: default-allow-http allow source (0.0.0.0/0) tcp:80 ; tcp:443 i tried change source filter 10.240.0.1/16 or forwarding rule ip (107.178.254.89). none of these works.

sql - Multi-level Group By clause is not allowed in a sub query -

the query running fine in query design when use tr.docno field in report. error msg pops : multi-level group clause not allowed in sub query. any ideas how can fix select t.traid, iif(t.trawrhidto,"purchase"," sales ") formsorp, t.tradocnoid, w.wrhname, ts.trsprice, ts.trsvatrate, ts.trsauxfield, wi.whiadjustment, w.wrhcountry, t.tradate tdate, ts.trssubtotalgross, c.cstname cname, tr.docno (select tbltransactionssc.tradocnoid docno tbltransactionssc (((tbltransactionssc.traid)=[forms]![frmreturns]![tratraid]))) tr tblwarehouse w inner join ((tbltransactionssc t left join tblcustomer c on t.tracstid = c.cstid) inner join (tbltransactionssubsc ts left join tblwarehouseitem wi on ts.trswhiid = wi.whiid) on t.traid = ts.trstraid) on w.wrhid = t.tra...

linux - php shell_exec casperJS -

i installed phantomjs , casperjs on linux machine , add symbolic links in /usr/local/bin/casperjs , /usr/local/bin/phantomjs. if login via ssh working perfect. but want call casperjs in php script shell_exec: shell_exec('/usr/local/bin/casperjs'); i added php include_path: .:/usr/local/bin/casperjs but "null" output exec command - how done? help? how can use casperjs within webhost directory in /var/www/?

asp.net - Get referring domain from HTML5 Audio Tag Streaming URL -

part of site working on @ moment requires audio/video previews. these server different server main site. the streaming url of form: www.myserver.com/preview.aspx?e=i_am_an_encrypted_key the key generated server hosts file, not site on previews displayed. it's kind of api. part of security stop these previews being played anywhere except website supposed check domain requesting this, seems httpcontext.current.request.urlreferrer null when requested html5 video/audio element. without posting domain along key api, there way can referring url on receiving server, server side? edit: to clarify: there website html5 elements directed url on different server, url , key provided server (not website) when api server receives request stream preview checks key (which tells play) , checks referring domain against list of allowed domains. figured out - in case cares... simply replace: referringdomain = httpcontext.current.request.urlreferrer with : ref...

java.io.IOException: The process cannot access the file because another process has locked a portion - when using IOUtils.copyLarge() in Windows -

the issue stemming specificied line of code in try block: try { finputstream = new fileinputstream(path); #thisline bytecount += ioutils.copylarge(finputstream, foutputstream); filecount++; } the stack-trace looks this: java.io.ioexception: process cannot access file because process has locked portion of file @ java.io.fileinputstream.readbytes(native method) @ java.io.fileinputstream.read(fileinputstream.java:233) @ org.apache.commons.io.ioutils.copylarge(ioutils.java:1719) @ org.apache.commons.io.ioutils.copylarge(ioutils.java:1696) this seems windows-specific issue. there file i/o best practice(s) specific windows might missing? check if process accessing same file. on windows follow post figure out -> https://superuser.com/questions/399659/how-can-i-identify-what-application-is-using-a-given-file it should work no other process accessing same file. to make sure can access file consider...

machine learning - Convolutional Neural Networks with Caffe and NEGATIVE IMAGES -

when training set of classes (let's #clases (number of classes) = n) on caffe deep learning (or cnn framework) , make query caffemodel , % of probability of image ok. so, let's take picture of similar class 1, , result: 1.- 90% 2.- 10% rest... 0% the problem is: when take random picture (for example of environment), i keep getting same result , 1 of class predominant (>90% probability) doesn't belong class. so i'd hear opinions/answers people has experienced , have solved how deal no-sense inputs neural network. my purposes are: train 1 more class negative images (like train_cascade ). train 1 more class positive images in train set, , negative on val set. but purposes don't have scientific base execute them, that's why ask question. what do? thank in advance. rafael.

javascript - back button - cookies -

i have search-page, , when results (100 results/page) use counter/cookie see how many times user clicked on page result. use counter "back button" go search page (and remember inserted search values). if user goes search-page, it's same result-page other results. two examples: 1. searchpage > result page (counter = 1) => button = window.history.go(-1); 2. searchpage > result page (counter = 1) > result page (counter = 2) > result page(counter = 3) => button = window.history.go(-3); this working fine, have problem. user can send result page user mail, if clicks on result page , clicks on button, can't use window.history.go(x); i tried window.location.href("[url of searchpage]");, how can check in code if user came search page or link in mail? i can use document.referrer.indexof("[url of searchpage]"). ok first page, not if user goes page-result. because document.referrer.indexof check fal...

html - Joomla make module full width -

i want module in joomla 3.4.3 full width. for example, have picture, should on page. if set width="100%" it takes space used article, there white spaces on both sides, left , right. other modules, example slideshows, use whole width. how can use space these modules do? edit: added <div style="margin-left:0px";"padding-left:0px";"margin-right:0px";"padding-right:0px"> <img src="images/slides/1.jpg" style="width:100%"/> </div> which doesn't change anything. image placeholder, later there going google-map why put div in. index.php: <?php /** * @version $id: index.php 26163 2015-01-27 17:11:55z james $ * @author rockettheme http://www.rockettheme.com * @copyright copyright (c) 2007 - 2015 rockettheme, llc * @license http://www.gnu.org/licenses/gpl-2.0.html gnu/gplv2 * * gantry uses joomla framework (http://www.joomla.org), gnu/gplv2 content management system * ...

python - "ImproperlyConfigured: Error loading psycopg2 module" after migrate -

i'm getting error traceback (most recent call last): file "manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 440, in execute self.check() file "/library/frameworks/python.framework/versions/2.7/lib/pyt...

r - Get the (t-1) data within groups -

apologies if has been asked before, couldn't find question answers exactly. have data this: project date price 30/3/2013 2082 b 19/3/2013 1567 b 22/2/2013 1642 c 12/4/2013 1575 c 5/6/2013 1582 i want have column last-instance prices group. example, row 2, last instance price same group 1642. final data this: project date price lastprice 30/3/2013 2082 0 b 19/3/2013 1567 1642 b 22/2/2013 1642 0 c 12/4/2013 1575 0 c 5/6/2013 1582 1575 how this? main issue i'm facing data may not ordered date not if can take last cell. here's option. i'd recommend use na s instead if 0 because 0 actual price. library(dplyr) df %>% arrange(as.date(date, format = "%d/%m/%y")) %>% group_by(project) %>% mutate(lastprice = lag(price)) # source: local data frame [5 x 4] ...

android - Use margin on an include layout -

this follow question question: margin not impact in "include" i trying add margin include layout. have added layout_width , layout_height include element, margin still ignored. furthermore, when try auto complete word "margin" in layout xml file, attribute not recognized. so how can add margin include tag? the layout: <!-- drawerlayout intended used top-level content view using match_parent both width , height consume full space available. --> <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/main_status" /> <!-- ma...

How to provide Authorization & Authentication using Asp.net, C#? -

Image
i have asp.net application in c#. i have provide page authorization specific user/usergroup. i have created 2 tables in database: 1) pagename 2)permissions[insert, update, view, delete] but i'm unable match tables , permissions assigning... can 1 please me, how created tables in database , how coding. please me. you can below explanation. configure access specific file , folder, set forms-based authentication. request page in application redirected logon.aspx automatically. in web.config file, type or paste following code. this code grants users access default1.aspx page , subdir1 folder . <configuration> <system.web> <authentication mode="forms" > <forms loginurl="login.aspx" name=".aspnetauth" protection="none" path="/" timeout="20" > </forms> </authentication> <!-- section denies access files in...

Exposing authenticated data from Azure Mobile App via an ASP.NET MVC 5 application -

i'm trying access authenticated data mobile apps via asp.net mvc5. backend .net (not node.js) , i'm using c# sdk (not javascript). since custom auth (user\pwd) not yet available mobile apps i'm trying connect facebook. i've found this post outdated now. if trying both mobile app clients , mvc client, might need specify list of oauth urls valid per: https://developers.facebook.com/docs/facebook-login/security#surfacearea you can set list of valid callback urls on settings -> advanced tab in facebook app management.

Finding an error in Android Studio -

Image
i have error in logcat: 07-08 18:41:35.397 29820-30298/com.boolbalabs.petlinx e/syncexception﹕ java.lang.classcastexception: java.lang.long cannot cast java.lang.integer am able locate occurring in code information? if double click error, android studio jump relevant file, , highlight line on error occurs.

sql - Column to be filled based on condition -

i have following data prod_no prod_cat prod_description x23 pens n/a x23 pencil in warehouse x23 ink " x30 books " x30 drawings not in warehouse x30 erasers " what achieve if prod_description having n/a or ", rows filled comments exist prod_no. e.g. x23 in warehouse filled rows. x30 not in warehouse filled rows. prod_no prod_cat prod_description x23 pens in warehouse x23 pencil in warehouse x23 ink in warehouse x30 books not in warehouse x30 drawings not in warehouse x30 erasers not in warehouse how can this? there many prod_no , prod_description varies each prod_no you should make join table maximum prod_description each prod_no , use decode output value null,'' or 'n/a': select t.prod_no, t.prod_cat, decode (t.prod_descrip...

Jekyll includes and YAML frontmatter -

is possible offload frontmatter include in manner? jekyll site uses frontmatter variable page title, have pages share include due code repetition. putting frontmatter page title in include treats raw html. there way simulate , set variables in include? you can pass parameter include. try: {% include name.html var={{page.title}} %} then in include, access parameter using include.var . see "pass parameters includes" @ https://jekyllrb.com/docs/includes/

ios - How to release a `Hidden` UIView from memory? -

i'm used setting views in storyboard , set inactivated views hidden , don't want them take unnecessary memory. how release uiview when hidden or inactive? by way i'm programming in swift. in advance. if want inactivate views forever , need remove them superviews ( view.removefromsuperview() job here). otherwise wouldn't make sense release memory since you'll have reinstantiate same view later on again in opinion unnecessary overhead compared hiding , unhiding it.

action - Selenium: Mouse cursor (pointer) not changing its position -

i have move mouse cursor (pointer) specific element , have click on element. have written below code not helping. although can see cursor type (image) changing not changing position. please help. below code: utilities.waitfor(2000); objactions.movetoelement(questionlist.get(i)).build().perform(); utilities.waitfor(500); objactions.click().perform(); utilities.waitfor(500); following worked: utilities.waitfor(2000); objactions.movetoelement(questionlist.get(i)).build().perform(); utilities.waitfor(500); objactions.click().build().perform(); utilities.waitfor(500);

python 2.7 remove brackets -

i have string opening { , closing } . brackets @ first , @ last , must appear, can not appear in middle. following: {-4,10746,.....,205} {-3,105756} what efficient way remove brackets receive: -4,10746,.....,205 -3,105756 s[1:-1] # skip first , last character

Token error on getting started tutorial with Node.js and Google Cloud datastore -

i'm building webapp google appengine, node.js , socket.io, , i'm trying set google compute instance use google cloud datastore api following tutorial . far, i've completed steps 1 , 2, when running downloaded adams.js file locally, this: error: no access or refresh token set. stuff i've tried: gcloud auth login (this logs me in google, doesn't set token locally) changing way i'm exporting datastore_service_account , datastore_private_key_file values, strings, plain text, etc. logging credentials on line before error (i'm missing token) creating new service account , going through key creation steps again ran curl " http://metadata/computemetadata/v1/instance/service-accounts/default/token " -d "metadata-flavor: google" more info. that command gives me this: <html> <head><title>301 moved permanently</title></head> <body bgcolor="white"> <center><h1>301 moved per...

java - Set custom property in Tomcat7 -

we running our application using tomcat-7 in windows environment. using shibboleth idp our application, due need set system property @ container level identify 1 new property called "idp.home". found property can set in "catalina.properties". set , running using "idp.home" property problem if use same compiled war file in machine, property "idp.home" not working. cataline.properties idp.home=../../idp structure: build --> idp --> tomcat-->conf-->catalina.properties queries: 1) custom property "idp.home" cached in tomcat where? 2) need set "idp.home" property in file along "catalina.properties" in tomcat. 3) there other way inform tomcat "idp.home"? thanks in advance. we can pass system properties -d parameter vm arguments tomcat, example "-dmy.prop.name=value" or place system properties in property file , specify path of property file in vm argum...

Date conversion in JSP via JSTL from XMLCalendar to util date -

i trying convert xmlcalendar date normal date format rendering on jsp page. while using below tag getting exception: <fmt:formatdate value="${xmlcalendardate}" pattern="dd/mm/yyyy" /> with tag getting exception as java.lang.illegalargumentexception: cannot convert 2015-07-02t21:33:35z of type class org.eclipse.emf.ecore.xml.type.internal.xmlcalendar class java.util.date is there other tag or other approach render date on jsp page. thanks in advance. that's subclass of xmlgregoriancalendar . can java.util.date out of first obtaining java.util.calendar via xmlgregoriancalendar#togregoriancalendar() , calling calendar#gettime() on it. so, assuming el 2.2 capable environment, should do: <fmt:formatdate value="${xmlcalendardate.togregoriancalendar().time}" pattern="dd/mm/yyyy" /> if you're not on el 2.2 yet (which standard part of servlet 3.0 / java ee 6), you'd need perform xmlgregoriancalenda...

javascript - binding string array to navigation bar -

updated code: have string array in controller below, var app = angular.module('myapp', []); app.controller('mycontroller', function($scope) { $scope.menuitems =['home','about']; }; }); i need display in navigation pane (navigation should on leftside) below html code. <body class="container-fluid"> <div class="col-md-2"> <ul class="nav nav-pills nav-stacked" ng-repeat="x in menuitems track $index"> <li>{{x}}</li> </ul> </div> </body> i did string values bound navigation pane. showing text {{x}}. kindly help in javascript code }; unnecessary. you haven't attached controller div . code. javascript: var app = angular.module('myapp', []); app.controller('mycontroller', function($scope) { $scope.menuitems = ['home', 'about']; //}; // remove }); html: <...

forms - Change color of text while typing in HTML textbox? -

i have set of text input boxes , right while typing in them, text being typed doesn't show up. once different part of page clicked, text shows up, not while user typing. know might causing this? <form method="post" action="/contact" > <ul class="contact"> <li> <label for="name">name</label> {{ contact | contact_input: 'name' }} </li> <li> <label for="email">email</label> {{ contact | contact_input: 'email' }} </li> <li> <label for="subject">subject</label> {{ contact | contact_input: 'subject' }} </li> <li> <label for="message">message</label> {{ contact | contact_input: 'message' }} </li> <li> <label for="captcha">spam ...

matplotlib - ImportError with Python 3 -

i trying run example thinkstats2 code. copied github - file structure same given on github. chap01soln.py __future__ import print_function import numpy np import sys import nsfg import thinkstats2 def readfemresp(dct_file='2002femresp.dct', dat_file='2002femresp.dat.gz', nrows=none): """reads nsfg respondent data. dct_file: string file name dat_file: string file name returns: dataframe """ dct = thinkstats2.readstatadct(dct_file) df = dct.readfixedwidth(dat_file, compression='gzip', nrows=nrows) cleanfemresp(df) return df def cleanfemresp(df): """recodes variables respondent frame. df: dataframe """ pass def validatepregnum(resp): """validate pregnum in respondent file. resp: respondent dataframe """ # read pregnancy frame preg = nsfg.readfempreg() ...

Debug Protractor tests using Nodeclipse -

i using nodeclipse create test automation framework using protractor . however, i'm not able debug (step through code). able using webstorm . frustrating debug tests using protractor's browser.pause(); , browser.debugger(); statements. can please on ? there particular configuration needs done on nodeclipse on webstorm shown here: https://github.com/angular/protractor/blob/master/docs/debugging.md

jquery - DRY JS - How to Combine Identical JavaScript Functions into One? -

i have js function loads same re-size function based on button id. js fidle demo i'm trying simplify code keep dry , clean. since can have 100+ of these buttons on single page, need somehow make code more dynamic. var = $('.a').popover(); a.on("show.bs.popover", function(e) { a.data()["bs.popover"].$tip.css("max-width", "630px"); }); var b = $('.b').popover(); b.on("show.bs.popover", function(e) { b.data()["bs.popover"].$tip.css("max-width", "630px"); }); var c = $('.c').popover(); c.on("show.bs.popover", function(e) { c.data()["bs.popover"].$tip.css("max-width", "630px"); }); var d = $('.d').popover(); d.on("show.bs.popover", function(e) { d.data()["bs.popover"].$tip.css("max-width", "630px"); }); i tried works first button: var = $('.a, .b, .c, .d,')....

mocking - what is a good mockwebserver for angularjs? -

i looking module can mock httpbackend service when apiendpoint not ready yet. did quick search , found stubby. other options available? try using synthjs.source , reference you'll find here:reference synthjs angular firebase method mock web server.reference: angular firebase quick start

html - display: inline block and vertically centred -

i have 3 divs , want them display beside each other , centred. goes image, 1px divider text. want them vertically centred compared ones beside them. html <div class="sub-logo-wrap"> <div class="sub-logo"><img src="..." width="auto" height="30px" /></div> <div class="divider"></div> <div class="sub-logo-text"><p>text ... can more 1 line ... </p></div> </div> css .sub-logo-wrap > div { display: inline-block; } .divider { width: 1px; height: 20px; } .sub-logo-text { width: 150px; } the problem when text goes more 1 line centering of text no longer works that can done easily. .sub-logo-wrap > div { display: inline-block; vertical-align: middle; } jsfiddle demo also add if need accuracy. .sub-logo img { display: block; } or .sub-logo img { ver...

javascript - Three.js - Trying to use WebGL - Skinned Mesh Avatar -

i have been trying display avatar (skinned mesh) on safari using webgl (three.js r71). code below (i have set camera, lighting, scene , renderer): loader = new three.jsonloader(); loader.load( 'models/avatar.json', addmodel ); guicontrols = new function() { this.mpelvis = 0.0; this.mtorso = 0.0; this.mchest = 0.0; this.mneck = 0.0; this.mhead = 0.0; this.mskull = 0.0; this.meyeright = 0.0; this.meyeleft = 0.0; this.mcollarleft = 0.0; this.mshoulderleft = 0.0; this.melbowleft = 0.0; this.mwristleft = 0.0; this.mcollarright = 0.0; this.mshoulderright = 0.0; this.melbowright = 0.0; this.mwristright = 0.0; this.mhipright = 0.0; this.mkneeright = 0.0; ...

python - Can't install pg_config for flask app -

i running following command pip install -r .\requirements.txt in project directory , following error using cached psycopg2-2.5.3.tar.gz complete output command python setup.py egg_info: running egg_info creating pip-egg-info\psycopg2.egg-info writing pip-egg-info\psycopg2.egg-info\pkg-info writing top-level names pip-egg-info\psycopg2.egg-info\top_level.txt writing dependency_links pip-egg-info\psycopg2.egg-info\dependency_links.txt writing manifest file 'pip-egg-info\psycopg2.egg-info\sources.txt' warning: manifest_maker: standard file '-c' not found error: pg_config executable not found. please add directory containing pg_config path or specify full executable path option: python setup.py build_ext --pg-config /path/to/pg_config build ... or pg_config option in 'setup.cfg'. ---------------------------------------- command "python setup.py egg_info" failed error code 1 in c:\users\eugene~1\appdata\local\temp\pip-build-mil943\p...

Does Javascript RegExp support POSIX expressions? -

i have password <input> box in <form> element html body when user click on submit button in sign form, i can javascript determine whether string user typed in password box combination of alphabet and/ or numbers using following code $("#password1").val().match(new regexp(/[a-za-z1-9]{1,}/)); however when tried using expression below, returns "null" gives me impression posix expressions not supported in javascript... or somewhere along line missing something? $("#password1").val().match(new regexp(/[[:alnum:]]{1,}/)); posix expressions such :alnum: are not supported , though other backslash-escaped character classes (like \w word characters including alphanumeric characters , underscore) allowed.