Posts

Showing posts from August, 2010

c++ - Figuring out why Word Counter program output is 0 or 1 -

i need figure out bug program. when type hello world am , should count number of spaces, keep getting 0 or 1 . below full program: #include "windows.h" #include <iostream> #include <cctype> using namespace std; //global declarations. //function prototypes. void pause(); void numwords(string&); int numwords(char []); int main() { string userval; numwords(userval); char *constr= new char[userval.length()]; strcpy(constr, userval.c_str()); //string converted c-string. int fin= numwords(constr); cout<< "the number of words in sentence "<< fin<< "."<< endl; delete[] constr; constr= 0; pause(); return 0; } /***************************************functions**********************************************************************/ /*1st function pause program.*/ void pause() { cin.sync();

php - Saving a USER preference variable after logout -

Image
in project need save information user if has submitted form. doing saving in $_session[] variable when user submit form saved in session variable , writing if(!isset($_session['page'])) restrict user visiting page when logout whole session destroyed. once again able register user has register, how block user re-registering form when form submitted set $_session['personal_datas']=1; when user revisit form after submitting i check <?php if(!isset($_session['personal_datas'])): ?> //display form <?php else: ?> <div class="well"> have submitted form </div> <?php endif; ?> but when logout revisit page displays same unfilled form how block user re-registering after re-login? if there unique user enters form (such username or personal identification number) store in database , every time form submitted check username (or whatever) provided not in database. otherwise there no wa

ios - CollectionViewCell doesnt work properly with Pinch Gesture -

im using collectionview , pinch gesture connected cvcell. have image in cell , pinch gesture zoom in , out in image. problem pinch gesture works rows, not works odd rows. mean first cell cant zoom picture, can zoom in picture in second cell, , cant 3rd cell , can 4th cell, , goes on this. couldnt find logical explanation. maybe can see miss. in advice. code here: ` @ibaction func handlepinch(recognizer : uipinchgesturerecognizer) { if let view = recognizer.view { view.transform = cgaffinetransformscale(view.transform, recognizer.scale, recognizer.scale) recognizer.scale = 1 } } @iboutlet weak var collectionview: uicollectionview! override func viewdidload() { super.viewdidload() var b = uibarbuttonitem(barbuttonsystemitem: .bookmarks, target: self, action: "barbutton") self.navigationitem.rightbarbuttonitem = b var itemindex = nsindexpath(foritem: catchnumber, insection: 0) self.collectionview?.scrolltoitematin

c# - Pass values from plain-text to a method on button click -

i using below code login in using ldap authentication in asp.net. however, don't know how pass values plain-text code. want run through button click. public class ldapauthentication { private string _path; private string _filterattribute; public ldapauthentication(string path) { _path = path; } public bool isauthenticated(string domain, string username, string pwd) { string domainandusername = domain + @"\" + username; directoryentry entry = new directoryentry(_path, domainandusername, pwd); try { // bind native adsobject force authentication. object obj = entry.nativeobject; directorysearcher search = new directorysearcher(entry); search.filter = "(samaccountname=" + username + ")"; search.propertiestoload.add("cn"); search.propertiestoload.add("mail"); searchresult result =

sql - How to construct query which compares two sets in M:N relationship? -

i have 2 (three-the third binding table) tables user , feature. in many-to-many relationship. construct query finds users have similar features particular user. i know can use this: select user user user inner join user.feature feature feature in :features but works when looking 1 specific feature. there way how in way of comparing "two sets" "features in features" in sql? or have in business layer? you can use sql this. if understand, want rank other users how many features have in common given user. select uf.user, count(*) featuresincommon user_features uf join user_features uf2 on uf.feature = uf2.feature uf2.user = $user group uf.user order featuresincommon desc;

javascript - Use waitOn on separate blocks in Meteor -

i new meteor. using iron-router route on page. set waiton property, making page load until publications subscribed. but on many pages see load panels/cards separately, i.e. page loads elements on page load concurrently , finished loading on different times. is such behaviour possible in meteor, instead of waiting subscriptions load before page can shown? it's hard give concrete answer question, progressive loading default in meteor. if subscribe in ir , or globally, or your template , documents flow client server , templates should render data becomes available. note in many cases, you'll need add guards code in order fix race conditions. using waiton special use of subscriptions block rendering of template until initial set of documents has arrived on client. should used in cases ui doesn't make sense progressive load (you need see of data @ once). i hope helps give general overview. if have specific questions, leave comment , i'll best add mor

regex - Continue with newline in perl -

i have perl script this: elsif ($url =~ m/^(http|https):\/\/(banner(s?)|advertising|iklan|adsbox|adserver|adservice(s?))\.(.*)/) { print "http:\/\/ip\.mdm\-lo\-00\.willsz\.net/null\.png\n"; } that working redirect squid (one line), if change multiline this, absolutely not working. elsif ($url =~ m/^(http|https):\/\/(banner(s?) \ |advertising \ |iklan \ |adsbox \ |adserver \ |adservice(s?))\.(.*)/) { print "http:\/\/ip\.mdm\-lo\-00\.willsz\.net/null\.png\n"; } any suggestion? - thank you you getting little carried away escapes , parentheses! , simpler change delimiter { ... } isn't in body of pattern; don't have escape slashes unless use /x modifier, whitespace significant in regex pattern, including newlines, , escaping them makes no difference @ all. isn't c! you should use non-capturing parentheses (?:...) unless need capture substrings of matched pattern and there no need throw-away .* match tail of stri

C++ access private member in composition of two classes from base class -

since i'm newbie in c++, here goes! i have base class (i'm not using inheritance anywhere) 2 objects 2 other classes. need have access private member other in class. class base { private: myclass1 m1; myclass2 m2; public: base() {}; ~base() {}; }; class myclass1 { private: int m_member1; public: myclass1() {}; ~myclass1() {}; }; class myclass2 { private: int m_member2; public: myclass2() {}; ~myclass2() {}; int sum_members_because_yes(void) { return (myclass1::m_member1 + m_member2); //how can this??? } }; how can have access of m_member1 myclass1 in myclass2? :) (i want avoid inheritance, because on code myclass1 , 2 not base class...) thanks there many ways it. to allow access m_member1 @ all, make m_member1 public. or declare friend of myclass1 , this: class myclass1 { private: int m_member1; ... friend class base; }; or this: class myclass1 { private: int m_member1;

wordpress options page update meta date on submit -

i trying make plugin, prints posts of type attachment, , enables quick edit of title , alt text. i know how print posts get_posts, , know how update alt text update_post_meta. the problem having running update_post_meta on form submission in admin options page. can find how submit settings. so need know how execute code on submit. add_action('admin_menu', 'plugin_create_menu'); function plugin_create_menu() { add_menu_page('my cool plugin settings', 'cool settings', 'administrator', __file__, 'plugin_settings_page') ); } function plugin_settings_page() { ?> <div class="wrap"> <h2>plugin</h2> <form method="post" action="options.php"> <input type="submit" value="submit"> </form> </div> <?php } ?>

java - Obtaining underlying class from org.eclipse.jdt.core.IClassFile -

i have list of org.eclipse.jdt.core.iclassfile , simple way actual class file (for reflection)? the option see, in case it's jar file , load jar jarfile (i can jar , package iclassfile parents) iterate on entries in jarfile , ,u sing classloader load class. but maybe there better way...

java - Gem Fire 6 to Gem Fire 8 Upgrade -

we have gem fire 6 data, want migrate gem fire 8 data. possible options this? need our customers may not happy loose data in gem fire 6 servers. please advise. see pivotal gemfire user guide here more details... http://gemfire.docs.pivotal.io/latest/userguide/index.html#getting_started/upgrade_from.html . in particular, pay close attention bullet #5. also keep in mind... http://gemfire.docs.pivotal.io/latest/userguide/index.html#getting_started/version_compatiblity.html . disclaimer: not experienced, or expert in upgrading gemfire, but... i thinking there maybe more few ways accomplish feat depending on customer's ucs/requirements. 1 option big bang conversion , stream data between older gemfire cluster (e.g. 6.x) , newer gemfire cluster (e.g. 8.1) using spring xd. another option "incrementally" migrate data old gemfire cluster new gemfire cluster on cache misses setting cacheloader in new gemfire cluster cache region(s) serve "cache clients&q

android - Increase height of linear layout by animation -

i want increase height of linear layout after 2 seconds. when activity loaded app should wait 2 seconds height of linear layout should increase 200dp 300dp. xml code shown below. <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fffafaf9" android:clipchildren="false" tools:context=".mainactivity"> <textview android:text="@string/hello_world" android:id="@+id/top" android:layout_width="wrap_content" android:layout_height="60dp" android:paddingtop="30dp" android:paddingleft="20dp" /> <view android:layout_width="fill_parent" android:layout_height="2dp" android:layout_below="@id/top" android:background=&q

angularjs - Angular JS directive with JQuery Datepicker -

Image
i'm totally new angular js. somehow managed integrate jquery ui datepicker in angular js project. want format date picked jquery datepicker iso date format i'm not being able do. here code. html <input type="text" ng-model="event.when.start" datetime-picker> angular controller myapp.directive('datetimepicker', function() { return { require : 'ngmodel', link : function (scope, element, attrs, ngmodel) { $(function(){ element.datetimepicker({ dateformat:'yy-mm-dd', mindate: 0, yearrange: '1920:2012', minute: 0, stepminute: 15, onselect:function (datetext, inst) { var dt = new date(datetext); alert(dt.toisostring()); ngmodel.$setviewvalue(dt.toisostring());

javascript - What's the best option using cryptojs, have the key stored in client and server sides, or generate the key and pass it some way to the other side? -

i want encrypt , decrypt data passed between client , server using cryptojs. decrypt data necessary know key used, imhave 2 options: use fixed key stored in both sides. generate randomly key , pass other side data. in both cases, if petition captured, can resend server , access page. if use fixed key, if key, can decrypt messages, except if change key. if pass key data, key data (i pass in no clear way, have know part key , part data). key changes every petition. anyway, think attacker see client side code , discover procedure used encrypt data , opposite procedure. what's best option? pd: know https way, want tp too. option: 1 assuming want use cryptojs , want use http, , don't want attacker know secret key, can use pbkdf2 . pbkdf2 password-based key derivation function you can generate key user's password on browser , use encrypt data encryption key. on server side, assuming have access user's password user database, can re-g

SQL query execution speed -

is better, in terms of execution speed in sql, have 2 different tables names 'image' , 'video' or 1 table name 'media' , column name 'type'. will execution speed same 2 querys? 'select * image id=x'; 'select * media id=x , type="image"' it makes little difference. performance, tables should have index (the first image(id) ; second media(id, type) ). there slight inefficiency media table, because records larger: type information stored on each row. results in corresponding tables have few more data pages, effect important when start having millions of records. balancing (potential) advantages of storing content in single table. if have foreign key relationships can either images or video, single mediaid can be used relationship. if have queries combining 2 (how many "media" user have?), having them in same table advantage. if have other common attributes (such creation time, byte size, form

Facebook GraphAPI - Get a list of groups a user belongs -

i list groups user belong facebook graph api. according documentation, tried : get /me/groups ( https://developers.facebook.com/docs/graph-api/reference/user/groups/ ) it requires user_managed_groups privillege, shows groups user manage. groups user belongs. is possible ? thanks. you need use user_groups permission that, permission deprecated , removed soon: https://developers.facebook.com/docs/apps/changelog#v2_4 meaning, not possible, i´m afraid.

postgresql - PostGIS Windows - legacy.sql missing -

i have installed postgis 2.1 on top of postgresql using stackbuilder. working correctly, need add support legacy function postgis 1.5 imports. file legacy.sql missing in installation , folder /share/contrib/ empty. can find file?

python - Using PyGal, how can I embed a label on the pie chart itself on hover? -

Image
using code below, can generate pie chart . when hover on slice of pie, shows percentage slice occupies. import pygal results = [ (15232,'value 1'), (947,'value 2'), (246,'value 3'), (117,'value 4'), (50,'value 5'), (50,'value 6'), (50,'value 7'), (50,'value 8'), ] pie_chart = pygal.pie() pie_chart.title = 'title!' r in results: pie_chart.add(r[1], r[0]) pie_chart.value_formatter = lambda x: "%.15f" % x pie_chart.render_to_file('piechart.svg') this produces pie chart looks (if hover on "value 2"): the problem have small slices. it's hard see hovering over. in example above, obvious values 5 through 8, on value 4, it's hard tell 1 being hovered above. there way include label in tool tip well? the closest i've found value_formater , seems ignored in pie charts (as evidenced example above having 2 decimal places in tooltip, despi

amazon web services - How to restrict CloudFront access to my website only? -

i have looked below answer talks origin access identity private content , signed urls. content not private, open public dont want other websites hotlink images. in other words, images on site should access via urls under domain. simple example restrict access cloudfront(s3) files users not others i've followed below document create oai on cloudfront distribution. http://docs.aws.amazon.com/amazoncloudfront/latest/developerguide/private-content-restricting-access-to-s3.html after apply oai on distribution, weird happened. access images, , not. , when working localhost not access cloudfront images. is there way can specify domains have access resources , ones not? this? { "sid": "allowpublicread", "effect": "allow", "principal": { "aws": "*" }, "action": "s3:getobject", "resource":

spring mvc - One jsp for both add and update functionality -

this might basic question , still want know better approach in terms of performance , maintainability. i have page need add , update functionality, , have handled in same jsp for eg:- managecouriers.jsp , here have write more code check whether update or add action , in controller (i using spring mvc). if use separate jsp eg:- addcourier.jsp , updatecourier.jsp , here me straight forward, dont want check condition, here need less coding, , see both page have same attribute cases, hit in maintaining both pages if there future changes. i feel both scenarios seems better ways, in state of confusion 1 choose, better performance , maintainability. valuable inputs start least common denominator supports current , future forseable use-cases, , refactor when/if new requirements force to. that said, you've described, easiest @ least maintenence point of view have single form, 2 buttons name attribute can distinguish server methods based on param a

Service Registry in Hibernate -

i see since hibernate 4 in order session factory configuration need make use of serviceregistry. configuration configuration = new configuration().configure(); serviceregistry serviceregistry = new standardserviceregistrybuilder().applysettings(configuration.getproperties()).build(); sessionfactory factory = configuration.buildsessionfactory(serviceregistry); what's purpose of serviceregistry. why required? they have redesigned sessionfactory pass argument serviceregistry object. explanation there in jira ticket. currently sessionfactory built throwing bunch of stuff configuration object, stirring it, letting come boil, , pulling out sessionfactory. in seriousness, there few problems way operate within configuration , how use build sessionfactory: the general issue there no "lifecycle" when various pieces of information available. important omission in number of ways: 1) consider schema generation. cannot know dialect when l

How do I rename multiple files after sorting by creation date? -

i want number files based on creation date rather based on old file names. example: assume following files listed in descending order of creation date. a.jpg d.jpg b.jpg c.jpg i want rename these files such that a.jpg becomes 4.jpg d.jpg becomes 3.jpg b.jpg becomes 2.jpg c.jpg becomes 1.jpg i using windows 8 , have sorted files in folder based on creation date. however, when try rename files, dos ignores sorting , proceeds rename files based on old file names. thus, a.jpg becomes 1.jpg d.jpg becomes 4.jpg b.jpg becomes 2.jpg c.jpg becomes 3.jpg i using following code (.bat file) got different post in website. @echo off setlocal enabledelayedexpansion set oldext=jpg set newext=jpg set index=0 %%f in (*.%oldext%) ( set /a index+=1 set index=!index! ren "%%f" "!index!.%newext%" ) i not have scripting tools installed , creating basic .bat files using notepad. thanks help. in fat file systems files not ordered, placed includ

mysql - How to use paste function and quotes, in a for loop and insert statement -

through for loop r language , i'm trying use insert statement save rows in table: 1 row example looks : numpat name firstnam birthdate sex datprel adicap1 idpat numerorum 1 eloste james 2003-09-27 1 2008-03-24 bhote4p1 468 2 what i've tried write is: info<- paste("insert tab_anapath_std1 values (",matop[i,1],", \",matop[i,2],\",\",matop[i,3], \",",matop[i,4],",",matop[i,5],",",matop[i,6],",\",matop[i,7],\",",matop[i,8],",",matop[i,9],")") sql_update_tbl_ds <- fn$dbsendquery(dbconn, info) and output got : numpat name firstnam birthdate sex datprel adicap1 idpat numerorum 1 ,matop[i,2], ,matop[i,3], 0000-00-00 1 0000-00-00 ,matop[i,7], 468 2 i have real problem manage quotes ; i've tried change without success; how may w

rest assured - Received fatal alert: bad_certificate RestAssured -

i using restassured library make calls rest api's these https endpoints , tried using "relaxedhttpsvalidation()" method provided in restassured bypass ssl validation my request looks like requestspecification req = restassured.given().relaxedhttpsvalidation().body().post(); i keep getting error javax.net.ssl.sslhandshakeexception: received fatal alert: bad_certificate @ sun.security.ssl.alerts.getsslexception(alerts.java:192) @ sun.security.ssl.alerts.getsslexception(alerts.java:154) @ sun.security.ssl.sslsocketimpl.recvalert(sslsocketimpl.java:1959) @ sun.security.ssl.sslsocketimpl.readrecord(sslsocketimpl.java:1077) @ sun.security.ssl.sslsocketimpl.performinitialhandshake(sslsocketimpl.java:1312) doeas have idea why happening ? which version using? had same issue before version. after updating latest problem solved.

android - Using Swipe view in drawer navigation -

i'm made navigation drawer , listview have complete , decided main content right of it. had , i'm gonna replace swipe view. i can't find swipe-view-in-drawer-navigation tutorial anywhere. seen on bland activity extends fragmentactivity ive extends else due navigation actionbaractivity . don't know now. please give me hint so need tutorial explaining viewpager implementation here 1 tutorial its similar listview , adapter implementation. going have view pager in layout file have listview. <android.support.v4.view.viewpager android:id="@+id/my_viewpager" android:layout_width="match_parent" android:layout_height="match_parent"/> then need adapter , views fill in adapter. fragmentpageradapter trick you. how implement this list<viewpageradapter.fragmenttabitem> fragmentlist = new arraylist<>(); fragmentlist.add(new viewpageradapter.fragmenttabitem(myfragmentone.newins

git - Jenkins: running build does not provision docker slave -

Image
i'm running jenkins 1.609.1 docker-plugin 0.10.0 provision jenkins docker slave. docker 1.0.1 running on ubuntu 14.04. i've created customized docker images based on evarga/jenkins-slave per instruction on https://wiki.jenkins-ci.org/display/jenkins/docker+plugin ("shortcut : pulling docker image"). in jenkins configuration i've: added "docker" "cloud" area pointed local docker url http://localhost:4243/ , configured docker appropriately (i can run "test connection" , reports "1.0.1") created custom docker ( my/jenkins:0.1 ) image using supervisord run ssh, mysql, postgres, elasticsearch, php , nodejs inside manually running container, can ssh inside user jenkins/jenkins i've given jenkins user inside container password-less sudo rights i've added docker image "docker template" (as above: my/jenkins:0.1 ) , provided launch method via "docker ssh launcher" in job configurati

c# - Ninject: GetAll instances that inherit from the same abstract class -

is possible ninject instances inherit specific abstract class? example, have following abstract class. public abstract class myabstractclass { } then have following 2 derived classes both inherit same abstract class. public class myderivedclass1 : myabstractclass { } public class myderivedclass2 : myabstractclass { } now going bind both derived classes kernel because want them in singleton scope. _kernel = new standardkernel(); _kernel.bind<myderivedclass1>().toself().insingletonscope(); _kernel.bind<myderivedclass2>().toself().insingletonscope(); i know kernel can return me instance following. _kernel.get<myderivedclass1>(); is there way of classes inherit myabstractclass? tried following without success. ienumerable<myabstractclass> items = kernel.getall<myabstractclass>(); the hope above getall() method return list of 2 instances, 1 myderivedclass1 , second myderivedclass2. instead of creating 2 bindings, second 1 "

C++ difference between [ ] and ( ) when declaring an array -

can tell me difference between these 2 lines of c++ code? int *p = new int (7); and int *p = new int [7]; i can't spot difference except in first 1 put number 7 in p[0] , there other difference? , in case when there char instead of int happen? thanks in advance. one array of 7 items new int [7] the other initialising pointer int value of 7

using jQuery to find div that has class which contains this text -

i using find info , append elsewhere $(data).find('.two_column_layout').has('b.warning').each(function (index, element) but need narrow down search specific text resides in b.warning area , example , have 50 tables , , need find ones have b.warning contains "this" or "this text" if needs match text ? <table class="two_column_layout"> <tbody> <tr><td><b class="warning">this text</b></td></tr> <tbody> </table> <table class="two_column_layout"> <tbody> <tr><td><b class="warning">not append info here</b></td></tr> <tbody> </table> i tried , didn't work , when remove :contains(this) , script finds b.warning again $(data).find('.two_column_layout').has('b.warning:contains(this)').each(function (index, element) there no need include single quotes. include :

jquery - bootstrap-tags-input adding a class to the generated input -

i add class or other attributes input generated bootstrap <input type="text" value=""> $('input').tags-input(); generates: <div class="bootstrap-tagsinput"> <input type="text" placeholder="add tags" style="width: 8em !important;"> </div> i add class with: http://timschlechter.github.io/bootstrap-tagsinput/examples/#methods input returns tagsinput's internal , used adding tags. use add own typeahead behaviour example. var $elt = $('input').tagsinput('input'); i don't seem understand how class added thank you firstly, tagsinput initialized $("input").tagsinput(); the method tagsinput('input') returns input element other jquery methods can used var $input = $("input").tagsinput('input'); $input.addclass('custom-class');

jquery - Add active and current state class -

how can give each , active , current class style css , onclick active state , , onload current class added. each set @ same time both have current class added div.toggle loaded , , active class added when tab another jsfiddle - http://jsfiddle.net/zm9dl/534/ i tried , add active class , shows active 1 set of tabs viewing , , removes active class of other set var selector = '.tabbed-reports li'; $(selector).on('click', function(){ $(selector).removeclass('active'); $(this).addclass('active'); }); here html <ul class="tabbed-reports"> <li class="toggle1">one</li> <li class="toggle2">two</li> <li class="toggle3">three</li> <li class="toggle4">four</li> <li class="toggle5">five</li> </ul> <div class="reports-content"> <div class="toggle1"><li clas

reactjs - Does react have a "null element"? -

i have piece of component looks this c.props.results.totalcount > c.props.searchoptions.perpage ? createelement(reactpaginate, { previouslabel: "<", nextlabel: ">", pagenum: math.ceil(c.props.results.totalcount / c.props.searchoptions.perpage), marginpagesdisplayed: 2, pageranedisplayed: 5, containerclassname: "pagination", activeclass: "active", forceselected: c.props.searchoptions.page, clickcallback: noop }) : null basically, if there page, include pager widget, otherwise don't. i'd encapsulate logic in own component. createelement(optionalpager, c.props) the problem render function can't return null , i'd prefer not insert intermediate element here. there sort of rea

c++ - why is adding try block causing compiler error -

i have working code, error handling crude @ moment - sends error string standard error , exits. throw exception , allow user deal choose typical handler. however, having added try catch block code giving me compiler error don't understand @ all. my code looks this: // ------------------------------------------------------------------------- sockets::tcpsocket::tcpsocket(const char* address, const int port) { this->address = address; this->port = port; this->buffersize = sockets::tcpsocket::def_buffer; sockets::tcpsocket::init(); } // ------------------------------------------------------------------------- sockets::tcpsocket::~tcpsocket() { freeaddrinfo(this->addressinfolist); close(this->filedes); } // ------------------------------------------------------------------------- void sockets::tcpsocket::init() { memset(&(this->addressinfo), 0, sizeof this->addressinfo); addressinfo.ai_family = af_unspec;

ruby on rails - How to get rid of uninitialized constant Omniauth (NameError)? -

i have fresh rails-composer omniauth application. when running tests rspec gives error: $ rspec /home/grzegorz/programing/integra/spec/support/helpers.rb:5:in `block in <top (required)>': uninitialized constant omniauth (nameerror) /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core.rb:97:in `configure' /home/grzegorz/programing/integra/spec/support/helpers.rb:4:in `<top (required)>' /home/grzegorz/programing/integra/spec/rails_helper.rb:23:in `block in <top (required)>' /home/grzegorz/programing/integra/spec/rails_helper.rb:23:in `each' /home/grzegorz/programing/integra/spec/rails_helper.rb:23:in `<top (required)>' /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1280:in `require' /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1280:in `block in requires=' /home/grzegorz/.rvm/gems/ruby-2.2.2@integr

angularjs - How to put $last ngRepeat result out of href? -

is there option put $last ng-repeat result <li class="active">four</li> instead of <li><a href="#">four</a></li> ? have been trying ng-if unfortunately did not give solution yet :( demo: http://codepen.io/anon/pen/bdvvre var app = angular.module('myapp', []); app.controller('testcontroller', function($scope) { $scope.mymenu = ["one", "two", "three", "four"]; }); <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myapp"> <div ng-controller="testcontroller" class="container"> <strong>expecting</strong> <br /> <ol class="breadcrumb"> <li><a href

SQL Server DATEPART() function -

today wrote 2 queries on datepart() , different returns below query #1: select datepart(day,'2015-07-05') returns '5', expected. query #2: select datepart(day, 2015-07-05) returns '27', little bit funny, , don't understand how 27 being returned. the difference between these 2 queries 1 date inside ' ', , other without. anybody can me out here? 2015-07-05 mathematical expression adds integer 2003. (subtracting 7 2015 gives 2008 subtract 5) 2003 evaluates '1905-06-27' when implicitly cast datetime casting int datetime works same adding number of days base date of 1 jan 1900 (i.e. equals dateadd(day, 2003,'19000101') ). so 27 comes from. the correct way denote date literals in sql server string '2015-07-05' (iso format - unambiguous newer datetime datetypes) or '20150705' (unambiguous legacy datatypes) or using odbc format { d '2015-07-05' } .

json - Angular Route vs $Resource -

so have few rest urls load , bind html when requested. when user searches first name , if first name found html gets populated json. works fine (initial url). initial url var url = http://localhost:8080/usersearch/name/find?firstname='+enteredvalue.firstname+'&lastname=& $http.get(url).success(function(data){ $scope.dataitems= data; now using ng-click on first name want request address , location based on these urls //urls var url = http://localhost:8080/usersearch/addr/find?address=&address var url = http://localhost:8080/usersearch/loca/find?location=&location so started looking ui-router , $resource. first thought use $resource seems if others have had problems ports. could use router solve problem or should stick resource? ui-router , $resource different things. ui-router used provide navigation between different states in app while $resource used make calling server side apis more convenient. if need retrieve dat

Exception in thread "main" java.util.NoSuchElementException in my tokenizer class -

whenever run program gives me following error: exception in thread "main" java.util.nosuchelementexception @ java.util.stringtokenizer.nexttoken(stringtokenizer.java:349) @ runcar.main(runcar.java:40) assignment says need close file, unsure on how so, , haven't found answers online. here current code: import java.io.ioexception; import java.util.stringtokenizer; import java.io.*; public class runcar { public static void main(string[] args) throws ioexception{ stringtokenizer tokenizer; string line, code, file="car.txt"; double dealercost, price; int idnumber, day, year, modelyear; string makemodel, month, customer; date datearrived, datesold; car[] items = new car[13]; car[] placeholder = new car[1]; filereader fr = new filereader(file); bufferedreader infile = new bufferedreader(fr); int = 0; line= infile.readline();

javascript - HTML or CSS navigation bar issue -

basically, have created navigation bar has underline when hovered , when active. have line spanning page. when cursor hovered on list, 4px line appears under word pushed line spanning page down 4 pixels. can please. here's html: <!doctype html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>home</title> <link rel="stylesheet" href="new1.css"> </head> <body> <nav id="ddmenu"> <div class="menu-icon"></div> <ul> <li class='top-heading'><a href='#'><span>new in</span></a> </li> <li class='top-heading'><a href='#'><span>homeware</span></a> </li> <li class='top-heading'><a href='#'><span>d

Android gradle build Error "finished with non-zero exit value 42" , what does it mean and how do i fix it? -

Image
i trying run older project on think latest version of android studio. when attempt run or debug app 2 error messages. have google , found no viable solution. error 1 error:error: com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'e:\android studio\android\sdk\build-tools\21.1.2\aapt.exe'' finished non-zero exit value 42 error 2 error:execution failed task ':app:mergedebugresources'. e:\tuts\developing android apps {am}\exercise files\ex_files_developandroidapp_esst\ex_files_developandroidapp_esst\exercise files\solutions\04_layouts\registrationsolution\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\drawable-mdpi\abc_btn_switch_to_on_mtrl_00012.9.png: error: com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'e:\android studio\android\sdk\build-tools\21.1.2\aapt.exe'' finished non-

upload image to database using PHP class PDO, jquery, -

am having bug in script; trying upload image mysql , using php pdo, classes , jquery. sure script seeing image name. firstly getting error message of undefined variable 'img' not declared, fixed using isset(function), still no image inserted, , empty alert message. sorry say, new here. here code. form.php // html inputs <form action="" method="post" enctype="multipart/form-data"> <input type="file" name ="myimage" id="image"> <input type="submit" id="imagesend" > </form> image.js // image script $("#imagesend").click(function(){ var postimg = $("#image").attr("name");// image name var datastring = 'img='+postimg; $.ajax({ type:"post", url:"postimage.php", data:datastring, success: function(html){ alert(html); }, }); }); postimage.php // script post image //class script included her

java - Why does invoking a method on a null reference compile successfully? -

trying execute piece of code public class main { public static void main(string... args) { new main(); } main() { a = null; a.foo(); } } class { void foo() {} } i get, obviously, nullpointerexception since has been initialized null . code compiles because (the coder) know variable a can null @ location, while (the compiler)... well, knows too, point warning message null pointer access: variable can null @ location my question is, given both me , know exception going thrown, why code allowed compile? there chance not exception there? edit: put in way, why compiler error in someting this try { throw new exception(); int x = 0; } catch (exception e) { } and not in this try { if(true)throw new exception(); int x = 0; } catch (exception e) { } put poorly: how compiler discriminates between blocking or not blocking "obvious errors"? it's allow

javascript - Aurelia: accessing Custom Element's custom functions or custom attributes -

i'm playing around custom element functionality in aurelia , tried create 'progress bar' element. progress-bar.js import {customelement, bindable} 'aurelia-framework'; @customelement('progress-bar') export class progressbar { //do stuff// } progress-bar.html <template> <link rel="stylesheet" type="text/css" href="src/components/progress-bar.css"> <div class='progress-bar' tabindex=0 ref="bar">bloo</div> </template> test.html (relevant portion) <require from="./components/progress-bar"></require> <progress-bar ref="pb">a</progress-bar> all of shows fine. i'm struggling on how main page can call function or change attribute on element, should in term on progress bar itself. i tried create function 'dosomething' inside progress-bar.js can't access in test.js. added progress-bar.js dosomething

memory leaks - Is there a way to suppress process id in valgrind output? -

i have 2 valgrind reports , want diff them. pid in each line, diff finds different. if can suppress pid in output, easier me diff. there way suppress process id in valgrind output ? background: my program simulator meant running forever (until manually killed). after initialization, can feed networking packets , processes them. using valgrind, i've narrowed down , fixed memory leaks occur during packet processing. however, still have small leak. trying figure out if there way me reset memory leak count in valgrind @ runtime. if could=> after sending 1 packet, i'd 0 out memory errors, , errors happening @ subsequent packet pass reported. couldn't figure out how this. so, thought of taking diff of 2 valgrind reports: 1 one packet , l10 packets. should me narrow down culprit. if there's better alternative solving without using diff, please let me know! i haven't seen option prevents pid being printed, looking way add time limit how long valgrind