How to call Javascript function from server side asp.net

I have a Textbox in GridView I want to change the Label.Text if the text in Textbox is changed. But I am not able call javascript function written in .cs page. Is there any mistake in TbUnitCost_TextChanged method.

This is my aspx page

<ItemTemplate>
  <asp:TextBox Style="text-align: right" ID="TbUnitCost" runat="server" Width="80px" Text='<%#Bind("Unit_Cost")%>' AutoPostBack="true" OnTextChanged="TbUnitCost_TextChanged"  TextMode="Number"></asp:TextBox>
 </ItemTemplate>

Code behind Page is as follows

 protected void TbUnitCost_TextChanged (object sender, EventArgs e)
    {
        GridViewRow currentRow = (GridViewRow)((TextBox)sender).Parent.Parent;
        int rowNo = currentRow.RowIndex;
        string gridName = "GridWorkExpenses";
        TextBox tbunitCost = (TextBox)currentRow.FindControl("TbUnitCost");
        int row = Convert.ToInt32(tbunitCost.Text);

        tbunitCost.Attributes.Add("onchange","javascript:calculateTotalCost('"+rowNo+"','"+gridName+"');");

    }

and javascript Function is:

<script type ="text/javascript">
    function calculateTotalCost(rowNo, GridName) {                        

        if (GridName== 'GridWorkExpenses') {
            var rowscount = document.getElementById('<%=GridWorkExpensesSheet.ClientID%>').rows.length;
            return calculateTotalUnitCost("GridWorkExpensesSheet", rowscount,rowNo);
        }
   }
 </script>     


Click here view more answers http://ift.tt/21bxQUO

Writing a test case for a Java program which takes user input in iterations to get to a final value

Below is the java program to guess the number of Apples Tom has. Tom would type higher if he has higher number of apples than the guessed number and lower if it is lower. He will respond with none when the number guessed is correct. My task is to write a JUnit test case for this program. Since based on the user input the guessed number is either decremented or incremented until we reach the actual value it confuses me as to how to write a JUnit test case for this program

  public static void main(String args[]){
      System.out.println("Guess the number of Apples Tom has");
      Scanner sc= new Scanner(System.in);
      int number=sc.nextInt();
      System.out.println("Tom, is it higher or lower?")
      String higherOrLower=sc.nextLine();

      while(true){
          number= getValue(higherOrLower,number);
          System.out.println("Tom, is it higher or lower?")
          higherOrLower=sc.nextLine();
          if(higherOrLower.equalsIgnoreCase("none")) {
                break;
          }
      }
  }

  public static int getValue(String i,int j){

        if(i.equalsIgnoreCase("lower") {
            j--;
            return j;
        } else if(i.equalsIgnoreCase("higher")) {
            j++;
            return j;
        } else {
            return j;
        }
    }


Click here view more answers http://ift.tt/1QuZSPQ

How to query Where Datetime many time?

I want query datetime many time. but i try query it's not work.

Example

Table cus_bill

Number       Period
A-20160101   01/2015
A-20160410   04/2015
A-20160912   09/2015
A-20161020   10/2015
A-20161102   11/2015
A-20161219   12/2015

SQL

SELECT v.*
FROM cus_bill v
WHERE TO_DATE('01/'||V.PERIOD,'DD/MM/YYYY') >= TO_DATE('01/'|| '10/2015','DD/MM/YYYY') 
and TO_DATE('01/'||V.PERIOD,'DD/MM/YYYY') <= TO_DATE('01/'|| '12/2015','DD/MM/YYYY')
and V.PERIOD IN ('01/2015','09/2015')  

But it's not work (0 Rows).

Desired output:

Number       Period
A-20160101   01/2015
A-20160912   09/2015
A-20161020   10/2015
A-20161102   11/2015
A-20161219   12/2015


Click here view more answers http://ift.tt/1UjFqr5

Writing with Server in C++

I am programming a server-client service, the client is in Java and the Server is in C++, but when I try to write by the Server to the Client, he does not sends the message, only when i close the socket, the server sends the message and the client reads it. Here is the Server Code:

#include<stdio.h>
#include<stdlib.h>
#include<sstream>
#include<string>
#include<netdb.h>
#include<netinet/in.h>
#include<string.h>
#include<iostream>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<unistd.h>


using namespace std;

void doprocessing (int sock, int cliente);
void sendM(int socket,int client);

int main(int argc, char *argv[]) {
   int sockfd, newsockfd, portno,cliente;
   char buffer[256];
   struct sockaddr_in serv_addr, cli_addr;
   int n, pid;
   socklen_t clilen;


   sockfd = socket(AF_INET, SOCK_STREAM, 0);

   if (sockfd < 0) {
      perror("ERROR opening socket");
      exit(1);
   }

   bzero((char *) &serv_addr, sizeof(serv_addr));
   portno = 8080;

   serv_addr.sin_family = AF_INET;
   serv_addr.sin_addr.s_addr = INADDR_ANY;
   serv_addr.sin_port = htons(portno);

   if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
      perror("ERROR on binding");
      exit(1);
   }


   listen(sockfd,5);
   clilen = sizeof(cli_addr);
   cout<<"Servidor Iniciado1..."<<endl;

   while (1) {
      newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
      cliente=cliente+1;
      if (newsockfd < 0) {
         perror("ERROR aceptando conexion");
         exit(1);
      }
      /* Create child process */
           pid = fork();

           if (pid < 0) {
              perror("ERROR on fork");
              exit(1);
           }

           if (pid == 0) {

             cout<<"Nueva conexion "<<cliente<<endl;
              close(sockfd);
              doprocessing(newsockfd,cliente);
              exit(0);
           }
           else {
              close(newsockfd);
           }

   }
}

void doprocessing (int sock, int cliente1) {
   int n;
   char buffer1[256];
   bzero(buffer1,256);
   n = read(sock,buffer1,255);
   n=1;
   if (n < 0) {
      perror("ERROR leyendo el socket");
      exit(1);
   }
   cout<<"Mensaje de cliente "<<cliente1<<":"<<buffer1<<endl;
   sendM(sock,cliente1);
   if (n < 0) {
      perror("ERROR escribiendo al socket");
      exit(1);
   }

}

void sendM(int socket, int client){
    std :: string buff;
    int n;
    cout << "\nServidor: ";
    cin >> buff;
    n=send(socket, buff.data(), buff.length(),0);
    cout<<buff.data()<<"\n";
    cout<<n<<endl;
    if(n<0){
            cout<<"Error enviando respuesta"<<endl;
        }
    doprocessing(socket,client);
}


Click here view more answers http://ift.tt/1L7Se1F

Javascript is unable to stop page loading

I have a sign-up page having proper validation's every place. But whenever i click "Sign-Up" on a blank form. It shows the validation, but gets loaded. I want to stop the loading. How's that possible.

I am primarily checking on chrome, where i checked on settings, whether javascript is disabled or not, but it is enabled.

it's happening in an .cshtml page.

Feel free to ask any question


Click here view more answers http://ift.tt/1PUkVhE

Insert Array To Database With Angular JS

I getting problem to insert array with php to database, php code:

$name = mysql_real_escape_string($data->name);
$address = mysql_real_escape_string($data->address);
$school = mysql_real_escape_string($data->school);
$year = mysql_real_escape_string($data->year);

$qry = 'INSERT INTO users (name,address,school,year) values ("' . $name . '","' . $address . '","' . $school . '","' . $year . '")';

angular js code:

$http({
    method : 'POST',
    url    : 'post.php',
    data   : {
              name   : $scope.name,
              address: $scope.address,
              users  : $scope.users
    }
})

how to explanation php code and combine with angular js? Anybody have idea? for more details here is preview


Click here view more answers http://ift.tt/1PUkVhs

How to split a string, iterate over it, and output a joined version

I'm working on a code for caesar_cipher. I am writing a method for encryption without making a Caesar class and defining other methods inside of it. The code I wrote is below:

def caesar(string, shift = 0)
  alphabet = ("a".."z").to_a
  letters = string.split("")
  blank = []
  letters.map do |letter|
    blank << alphabet[(alphabet.index(letter) + shift) % alphabet.length]   
  end       
  puts blank.join
end

I get this error when putting in a string consisting of more than one word:

block in `caesar_cipher': undefined method `+' for nil:NilClass (NoMethodError)

I understand tr can solve my problem if I were to create the class. I have an independent method that works on every angle of caesar_cipher except sentences. I cannot get the words to be split, iterate, and then join. Any input will help me avoid this.


Click here view more answers http://ift.tt/1UjFozv

htaccess to manually redirect to renamed "Main Page"

Our site has something like this as our .htaccess

RewriteEngine On
RewriteRule ^/wiki/Main_Page$ /wiki/Welcome_to_Our_Site [R]
RewriteRule ^/?wiki/?$ / [R]

RewriteRule ^/?$ %{DOCUMENT_ROOT}/index.php?title=Welcome_to_Our_Site [L,QSA]
RewriteRule ^/?wiki(/.+)$ %{DOCUMENT_ROOT}/index.php [L]
RewriteRule ^/?w(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

I have also used MediaWiki:Mainpage to point to Welcome_to_Our_Site.

For the sake of users who may have bookmarked the old page, I would also like Main_Page to manually redirect to Welcome_to_Our_Site--without a redirect notice--but it is not happening.

I originally moved the Main Page to Welcome_to_Our_Site, creating a redirect within the Mediawiki software, but even when I delete the Main Page or add text into it without a redirect, my htaccess rule does not override Mediawiki's own redirecting as I think it should and redirect Main Page to Welcome_to_Our_Site, changing the URL, but without the Mediawiki "(Redirected from Main Page)" redirect text showing up. What is wrong with the line I expect should do the trick RewriteRule ^/wiki/Main_Page$ /wiki/Welcome_to_Our_Site [R] or the cascading after it?


Click here view more answers http://ift.tt/1QuZSPM

how to cross scripting on this html?

</div>
        </div>
                    </div>
    </div>
        <div class="col2-set addressbook">
    <div class="box">
        <div class="box-title">
            <h3>Address Book</h3>
            <a href="http://ift.tt/1UjFqaH">Manage Addresses</a>
        </div>
        <div class="box-content">
            <div class="col-1">
                <h4>Default Billing Address</h4>
                                <a href="http://ift.tt/1QuZSPG">Edit</a>
                <address>
                    You have not set a default billing address.<br />
                    
                </address>
            </div>
            <div class="col-2">
                <h4>Default Shipping Address</h4>
                                  <a href="http://ift.tt/1QuZSPG">Edit</a>
                <address>
                    You have not set a default shipping address.<br />
                  
                </address>
            </div>
        </div>
    </div>
</div>
    </div>
        </div></div>                                        </div>
                </div>
                <div class="col-left sidebar"><div class="block block-account">
    <div class="block-title">
        <strong><span>My Account</span></strong>
    </div>
    <div class="block-content">
        <ul>

i have this html code. I want the word :'root anonymous' in this html become a hyperlink for xss cross site scripting. can anyone tell me how to do this thing? i am not a program developer, this is just my exam. please write for me that code. Thanks.

<div class="page-title">
        <h1>My Dashboard</h1>
    </div>
        <div class="welcome-msg">
    <p class="hello"><strong>Hello, root anonymous!</strong></p>
    <p>From your My Account Dashboard you have the ability to view a snapshot of your recent account activity and update your account information. Select a link below to view or edit information.</p>
</div>
        <div class="box-account box-info">
        <div class="box-head">
            <h2>Account Information</h2>
        </div>
                        <div class="col2-set">
    <div class="col-1">
        <div class="box">
            <div class="box-title">
                <h3>Contact Information</h3>
                <a href="http://ift.tt/1UjFqaJ">Edit</a>
            </div>
            <div class="box-content">
                <p>
                    root anonymous<br />
                    example@gmail.com<br />
                    <a href="http://ift.tt/1QuZSPI">Change Password</a>
                </p>
            </div>
        </div>
    </div>
        <div class="col-2">
        <div class="box">
            <div class="box-title">
                <h3>Newsletters</h3>
                <a href="http://ift.tt/1UjFqaL">Edit</a>
            </div>
            <div class="box-content">
                <p>
                                            You are currently not subscribed to any newsletter.

Click here view more answers http://ift.tt/21bxQUS

how to draw() the Form table....?

when I submitting my form the data is stored, but I need to draw my formtable also..that data should update there...

this is my code..

$('#AttributeSettingsForm').submitAjax({
  success: function(response) {
    try {
      if (response.error) {
        notifyError(response.error, '@ViewBag.Title');
        return;
      } else {
        Formtable.draw();
        notifySuccess(response.msg, '@ViewBag.Title');
      }
    } catch (e) {
      if (window.console)
        console.error(e);

      notifyError('@G("InternalError")', '@ViewBag.Title');
    }
  },
  error: function(xhr) {
    notifyError(xhr.statusText, '@ViewBag.Title');
  }
});

Click here view more answers http://ift.tt/1PUjhfP

how to Debugging app using phone?

My become unfortunately stopped when i am lunching on my android device and navigate to another page. so i want to debug myapp using my device.

Here is my code

public void onClick(View v) { BackgroundTask task=new BackgroundTask(Login.this); task.execute(); if(ss_deals != null) { Intent i_A = new Intent(this,Dashboard.class); i_A.putExtra("MESSAGE",msg ); startActivity(i_A); } }

private class BackgroundTask extends AsyncTask {

    public BackgroundTask(Login activity) {
        dialog = new ProgressDialog(activity);            
            objMS = new MyService();
            ss_deals = (SoapObject) objMS.getWebServiceResult("CheckLogin","",txtid.getText().toString(),txtPwd.getText().toString());

    }

    @Override
    protected void onPreExecute() {
        dialog.setMessage("Loading...");
        dialog.show();
    }

    @Override
    protected void onPostExecute(Void result) {
        if (dialog.isShowing()) {
            dialog.dismiss();

        }
    }

    @Override
    protected Void doInBackground(Void... params) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return null;
    }

}


Click here view more answers http://ift.tt/1KG77Zh

Difference between : and :: in CSS [duplicate]

This question already has an answer here:

Hi just want to clear up my mind to use colon / pseudo class in css.

If I use

div:before {
    // some css styles
}

OR

div::before {
    // some css styles
}

Both works same. So what is the difference between single colon : or double colon ::?


Click here view more answers http://ift.tt/1OrGHFo

Polymorphic inheritance

I have a question about how to define a method from a subclass or a parent class. For example:

public class Thought
{
   //-----------------------------------------------------------------
   //  Prints a message.
   //-----------------------------------------------------------------
   public void message()
   {
      System.out.println ("I feel like I'm diagonally parked in a " +
                          "parallel universe.");

      System.out.println();
   }
}

And the child class is:

public class Advice extends Thought
{
   //-----------------------------------------------------------------
   //  Prints a message. This method overrides the parent's version.
   //-----------------------------------------------------------------
   public void message()
   {
      System.out.println ("Warning: Dates in calendar are closer " +
                          "than they appear.");

      System.out.println();

      super.message();  // explicitly invokes the parent's version
   }
}

If I wanted to invoke method message from the main method, would I have to use Thought.message, or Advice.message since I used the super invoker. Does super.(method)() technically just copy and paste the parent method into the child method, allowing you to create an object of only the child?


Click here view more answers http://ift.tt/1WFroPo

Python split() method not working properly

I want to use split() method for separating rupees and paise. In paise part it is showing 6 paise for 60 paise, 7 for 70 and so on.But if the paise is 44 it will show correctly.Is it not considering zero if it is at the end? [rupees and paise are Indian currency]

from num2words import num2words

pre=405068.60
text1 = ''
text2 = ''
result1 = ''
result2 = ''
entire_num = int((str(pre).split('.'))[0])
decimal_num = int((str(pre).split('.'))[1])
print "Decimal number=%d" %decimal_num
text1=num2words(entire_num, lang='en_IN').capitalize()
text2=num2words(decimal_num, lang='en_IN')
result1=text1+' '+'rupees'
if(decimal_num>0):
    result2 = ' and '+text2+' paise'
print result1+result2


Click here view more answers http://ift.tt/1KG77Zd

SQL Update Multi Row At One Time

mysql> SELECT * FROM options;
+----+------+---------+
| id | name | value   |
+----+------+---------+
|  1 | aa   | a value |
|  2 | bb   | b value |
|  3 | cc   | c value |
|  4 | dd   | d value |
|  5 | ee   | e value |
+----+------+---------+

I have a options table.

I want to Update multi row in same query (with where case name).

suppose i update options.name aa and bb at one time. It's update like

+----+------+---------+
| id | name | value   |
+----+------+---------+
|  1 | aa   |aa value |
|  2 | bb   |bb value |
+----+------+---------+

I try to solve this problem by googling but i can't.

Please Help me and little bit explain for the query.


Click here view more answers http://ift.tt/1OrGIck

unable to do http call

I am trying to make a http call in mobile app using ionic framework.

Below is my UI:

<ion-view title="Register">
    <ion-content overflow-scroll="true" padding="true" scroll="false" class="has-header has-footer" ng-controller="registerCtrl">
        <form class="list" name="regform" novalidate>
            <ion-list>
                <label class="item item-input" name="Number">
                    <span class="input-label">Number</span>
                    <input type="tel" name="num" placeholder="" ng-model="user.ph_no" ng-minlength="10" ng-maxlength="10" required>
                </label>
                <label class="item item-input" name="Email">
                    <span class="input-label">Email</span>
                    <input type="email" name="email" placeholder="" ng-model="user.email" ng-minlength="6" required>
                </label>
                <label class="item item-input" name="Password">
                    <span class="input-label">Password</span>
                    <input type="password" name="password" placeholder="" ng-model="user.password" ng-minlength="6" required>
                </label>
            </ion-list>
            <div class="padding">
                <p ng-show="regform.num.$error.required">* Phone Number is required</p>
                <p ng-show="regform.num.$error.minlength">* Phone Number should be 10 digits</p>
                <p ng-show="regform.num.$error.maxlength">* Phone Number should be 10 digits</p>
                <p ng-show="regform.email.$error.required">* Email is required</p>
                <p ng-show="regform.email.$error.minlength">* Email must be longer than 5 letters</p>
                <p ng-show="regform.password.$error.required">* Password is required</p>
                <p ng-show="regform.password.$error.minlength">* Password must be longer than 6 characters</p>
            </div>
            <ion-checkbox name="checkbox" ng-model="checked">I Agree with T&amp;C</ion-checkbox>
            <a ng-click="proceed()" class="button  button-block button-positive" ng-disabled="!checked || regform.$invalid">Proceed</a>
        </form>
    </ion-content>
</ion-view>

I registered a HttpService service in app.js file.

angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

.service('HttpService', function($http) {
 return {
   getPost: function() {
     // $http returns a promise, which has a then function, which also returns a promise.
     return $http.get('http://ift.tt/17vsUzp')
       .then(function (response) {
         // In the response, resp.data contains the result. Check the console to see all of the data returned.
         console.log('Get Post', response);
         return response.data;
       });
   }
 };
});

In controller i.e. controllers.js, I am using in ng-click event:

angular.module('app.controllers', ['ionic'])

.controller('registerCtrl', function($scope,backcallFactory, HttpService, $ionicLoading) {

    backcallFactory.backcallfun();
    $scope.user = {};

    $scope.proceed = function() {
        $ionicLoading.show({
            template: 'Loading...'
        });

        HttpService.getPost()
            .then(function(response) {
                $scope.user.ph_no = response;
                $ionicLoading.hide();
            });

    };
})

.factory('backcallFactory', ['$state','$ionicPlatform','$ionicHistory','$timeout',function($state,$ionicPlatform,$ionicHistory,$timeout){

        var obj={}
        obj.backcallfun=function(){
        var backbutton=0;

            $ionicPlatform.registerBackButtonAction(function () {
                if ($state.current.name == "register") {
                    /*var action= confirm("Do you want to Exit?");
                    if(action){
                        navigator.app.exitApp();
                    }//no else here just if*/

                     if(backbutton==0){
                        backbutton++;
                        window.plugins.toast.showShortCenter('Press again to exit');
                        $timeout(function(){backbutton=0;},5000);
                    }else{
                        navigator.app.exitApp();
                    }

                }
                else{

                        $ionicHistory.goBack();
                        /*$ionicHistory.nextViewOptions({
                        disableBack: true
                        });
                        $state.go('app.home');*/
                        //go to home page
                    }
            }, 100);//registerBackButton
        }//backcallfun
        return obj;
    }])

The problem is, when i click the proceed button it is stucked at ionic Loading screen.

enter image description here

I am literally using tutorial http://ift.tt/21mO1eF but with in button click event.

Can someone tell what I am missing.


Click here view more answers http://ift.tt/1oEjknm

Trying to loop a switch with an invalid input (C#)

Anyway I don't know how I'm supposed to go about doing this... in my application I need to have the switch repeat itself if there's an invalid input. All the application does is exit as soon as I enter a different result. Here's my code:

string str = Console.ReadLine(); 
char option = char.Parse(str);
//Need to repeat this switch:
switch (option)
{
    case 'N':
        Console.WriteLine("Creating New App...");
        break;
    case 'L':
        Console.WriteLine("Loading App...");
        break;
    case 'O':
        Console.WriteLine("Loading Options...");
        break;
    case 'Q':
        Console.WriteLine("Exiting Application...");
        System.Environment.Exit(1);
        break;
    default:
        Console.WriteLine("Invalid input.");
        break;
}
Console.ReadLine();


Click here view more answers http://ift.tt/1KG7aEd

what is the meaning of "int *(&arry)[10] = ptrs" and how to read it?

I'm new to C++ and is trying to learn the concept of arrays. I know

int *ptrs[10]; 

has the meaning of ptrs is an array of ten pointers to int. So how about

int *(&arry)[10] = ptrs;

I'm very confused by its many syntax so could someone please explain it to me what is its meaning and how to read it? It would be great someone can break it down and explain it in smaller parts. Thanks in advance for any help!


Click here view more answers http://ift.tt/1OrGHF8

JQuery button click not registering

I have created a mock twitter website that is supposed to generate more tweets once a button is clicked. I have created the button which is appended to the main section of the site but it seems that once it is clicked absolutely nothing happens. I have looked this over and over again making sure that my code is correct but I am afraid that I am just missing something. below is a my JQuery and CSS.

JQuery:

  $(document).ready(function(){
    var $body = $('body');
    var $section = $('.main');

    $section.html('');

    //Returns a div with a time stamp for the tweet
    var createdTime = function(tweet){

        return $('<div>', {text: tweet.created_at, id: 'dT'}).prop('outerHTML');

    };
    //Returns the @handle as a link of the user who tweeted
    var userName = function(tweet){
        return $('<a>', {text: tweet.user, href: '#'}).prop('outerHTML') + '<br />' + '@' + tweet.user; 
    };

    // simply returns the users tweeted message
    var tweetContent = function(tweet){
        return tweet.message;
    };

    var index = streams.home.length - 1;
    // A function that generates new tweets
    var newTweets = function(index){
    while(index >= 0){
            var tweet = streams.home[index];
            var $tweet = $('<div class=tweet></div>');
            //call to outside function to populate tweets
            $tweet.html(userName(tweet) + ': ' + tweetContent(tweet) + createdTime(tweet));
            $tweet.appendTo($section);
            index -= 1;

        }
    }
    newTweets(index);
    //Adds a user image to tweet  
   $('.tweet').prepend('<img id=tweetImg src=images/blank-user.jpg />');

    //button created to generate more tweets after page has loaded
   var $button = $('<button />', {
       type: 'button',
       'class':'tweetButton',
       id: 'mT',
       text: 'More Tweets',
       click: function(){
          index = streams.home.length-1;
           newTweets(index);
           alert('I work!');
       }
   });
      $button.appendTo($section);

  });

CSS:

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, caption {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-size: 100%;
    vertical-align: baseline;
    background: transparent;
}

body{
    background-color: #D7DADB;
    font-family: 'Asar', serif;
    position: relative;
}

/*
  ========================================
  Header
  ========================================
*/
nav{
    display: inline-block;
    height: 28px;
    top: 0px;
    width: 100%;
    position: fixed;
    background-color: #6DBCDB;
    border-bottom: 2px solid #F1433F;
    
}
a,
nav{
    padding: 15px;
    color: #FFFFFF;
}

/*
  ========================================
  Typography
  ========================================
*/

/*
  ========================================
  Button
  ========================================
*/
button{
    width: 300px;
    height: 60px;
    margin: 10px auto 100px auto;
    background-color: #F1433F;
    border: none;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    font-family: 'Asar', serif;
    font-size: large;
    font-style: oblique;
    font-weight: 700;
    color: #FFFFFF;
}
.tweetButton{
    
}
.search{
    position: relative;
    float: right;
    right: 20px;
    
}
#srchFrm{
    height: 20px;
    width:170px;
    padding-left: 10px; 
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
    background-color: #D7DADB;
    font-family: 'Asar', serif;
}

#srchBtn{
    height: 25px;
    width: 80px;
    position: relative;
    right: 4px;
    border: none;
    border-bottom-right-radius: 30px;
    border-top-right-radius: 30px;
    background-color: #F1433F;
    font-family: 'Asar', serif;
    color: #FFFFFF;   
}

/*
  ========================================
  Imgages
  ========================================
*/
#network{
    position: relative;
    height: 60px;
    width: 60px;
    left: 50%;
    transform: translateX(-50%);
    transform: translateY(-70%);
}


/*
  ========================================
  User
  ========================================
*/

aside{
    position: fixed;
    clear: both;
    float: left;
    height: inherit;
    width:300px;
    margin: 0 0 0 10px;
    background: linear-gradient(#2C3E50,#415B75,#6DBCDB, #EEEEEE);
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    text-align: center;
}
a{
    text-decoration: none;
    margin-bottom: 0;
}
a:hover{
    text-decoration: none;
    background-color: #F1433F; 
}
#user-pic{
    clear:both;
    border-radius: 50%;
    height: 150px;
    width: 150px;
    padding: 20px;
}
#trend{
    color: #FFFFFF;
    text-align: center;
    height: 400px;
    width: 270px;
    margin-top: 15px;
    padding: 15px;
    border-top: 1px solid #F1433F;
}
/*
  ========================================
  Main
  ========================================
*/
.container{
    margin-top: 80px;
}

/*
  ========================================
  Middle Content
  ========================================
*/

section{
    position: relative;
    margin: auto;
    width: 400px;
    z-index: -1;
    
    
}
.main{
    background-color: #D7DADB;
}
/*
  ========================================
  Tweet Box
  ========================================
*/
#tweetImg{
    height: 75px;
    width: 75px;
    border-radius: 5px;
}
.tweet a{
    font-size: large;
    text-decoration: none;
    color: black;
}
.tweet a:hover{
    text-decoration: underline;
    background-color: transparent;
    color: gray;
}
.tweet{
    position: relative;
    width: 450px;
    height: 225px;
    background-color: #FFFFFF;
    border: 4px solid #F1433F;
    border-top-left-radius: 20px;
    border-bottom-right-radius: 20px;
    margin-bottom: 15px;
    padding: 25px 15px 0px 15px;
}
.tweetContent{
    width: inherit;
    height: inherit;
    margin: 5px 5px 0 5px;
    border-bottom: 1px solid #EEEEEE;
    border-top: 1px solid #EEEEEE;
}

#dT{
    width:inherit;
    position: absolute;
    bottom: 0px;
    border-top: 1px solid gray;
    background-color: #FFFFFF;
    font-size: small;
}

Click here view more answers http://ift.tt/1VAVi7c

When to Encapsulate in javascript?

I have been developing websites using jQuery for 3 years now and I've recently gained interest in OOP in Javascript and I'm still starting to get my hands on OOP.

I read from this article, and it says:

Encapsulation ...(its methods and properties) are hidden from the rest of the application.

but why would you wanna take the extra time to do that? When you are the programmer and you know you aren't gonna use that on another object anyway. Am I missing something imoportant here? I don't really see any need to do this on my current experiences. So when exactly to Encapsulate in Javascript?


Click here view more answers http://ift.tt/1oEilDS

mysql count from two tables and give combined count of string

I have two tables where common column is location,i am looking for the count of the locations from both the tables and display a combined count.

    Table-1 
+-------------+
|  Location   |
+-------------+
|    USA      |
|   INDIA     |
|    UK       |
|   INDIA     |
+-------------+

   Table -2
+-------------+
|  Location   |
+-------------+
|   INDIA     |
|   INDIA     |
|    USA      |
+-------------+

Here the count from table one is :

+-------------+--------+
|  Location   | COUNT  |
+-------------+--------+
|    USA      |   1    |
|   INDIA     |   2    |
|    UK       |   1    |
+-------------+--------+

Count from table 2 is :

+-------------+--------+
|  Location   | COUNT  |
+-------------+--------+
|    USA      |   1    |
|   INDIA     |   2    |
+-------------+--------+

This count am getting by :

SELECT Location, COUNT(*) AS COUNT FROM Table-1 GROUP BY Location;
SELECT Location, COUNT(*) AS COUNT FROM Table-2 GROUP BY Location;

But i want the combined count from the two tables which looks like:

+-------------+--------+
|  Location   | COUNT  |
+-------------+--------+
|    USA      |   2    |
|   INDIA     |   4    |
|    UK       |   1    |
+-------------+--------+

Thank you in advance.


Click here view more answers http://ift.tt/1OrGIca

Removing duplicates from one column only

So I would have something like this. Its the outcome a query into two tables.

+------------------+------------------------------------+
| character_name   | title                              |
+------------------+------------------------------------+
| derp             | a                                  |
| derp             | b                                  |
| derp             | c                                  | 
| herp             | a                                  |
| herp             | b                                  |
| herp             | c                                  |
+-------------------------------------------------------+

and I want this

+------------------+------------------------------------+
| character_name   | title                              |
+------------------+------------------------------------+
| derp             | a                                  |
|                  | b                                  |
|                  | c                                  | 
| herp             | a                                  |
|                  | b                                  |
|                  | c                                  |
+-------------------------------------------------------+

Is this possible?


Click here view more answers http://ift.tt/1KG7anL

Implementing simple upvote downvote program

I am using express.js and jQuery to create a basic upvote downvote program. Basically the voting buttons increment/decrement by one whenever pressed and the result of each button click is displayed below. Nothing happens when the buttons are clicked, not even a Cannot POST /. I am not sure what is causing the error. This is what my main.js file looks like:

$(document).ready(function(){
$("#up").click(function(){
    var up = $.post("/upvote", {changeBy: 1}, function(dataBack){

        $("#upvote").text(dataBack);
    });

});
$("#down").click(function(){
    var down = $.post("/downvote", {changeBy: 1},
    function(dataBack){
        $("#downvote").text(dataBack);
    });

  });
});

and then on the server side server.js, I have this:

var express = require("express");
var app = express();
var bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static("public"));

var inc = 0;
var dec = 0;

app.post("/upvote", function(req, res){
   res.setHeader("Content-Type", "application/json");
   inc += parseFloat(req.body.changeBy);
   res.write(JSON.stringify(inc));
   res.end();

});
app.post("/downvote", function(req, res){
   res.setHeader("Content-Type", "application/json");
   dec -= parseFloat(req.body.changeBy);
   res.write(JSON.stringify(dec));
   res.end();

 });


var server = app.listen(8081, function () {

    var host = server.address().address
    var port = server.address().port

    console.log("Example app listening at http://%s:%s", host, port)

})

A bit of HTML:

<div class="buttons">
<button id="down">Downvote</button>
    <p id="downvote"></p>
<button id="up">Upvote</button>
    <p id="upvote"></p>
</div>


Click here view more answers http://ift.tt/1oEijvv

In Javascript, why are \b characters dropped in a .join()?

In Javascript, why does this statement not equal '\b,\b'?

['\b', '\b'].join()
//=> ","

According to MDN docs on join:

If an element is undefined or null, it is converted to the empty string.

So why is \b being evaluated as undefined/null?

Additionally, the\b is dropped from any string prepended with it, e.g:

['\btest', '\btest2'].join()
//=> "test,test2"

Something crazy is going on.


Click here view more answers http://ift.tt/1VAVgfo

Change Position of div in javascript

I want to Change Positioning of HTML div Via Javascript in my existing Script

Currently This My Existing Javascript is generating in front end.

<div class="navbar navbar-inverse affix" id="SubMenu" style="top: 72px;"> 

But i want to make positioning to top:8px

JavaScript is as Below.

// Sub-navbar affix on scroll
// ------------------------------------------------------------------------
if ($('#SubMenu').length) {
    $('#SubMenu').affix({
        offset: {

            top: function() {
                return $('#SubMenu').parent().offset().top - $('#navbar-main-container').outerHeight();
            },
        }
    }).css('top', $('#navbar-main-container').outerHeight());
    // Update values on window resize
    $(window).resize(function() {
        theTop = $('#SubMenu').parent().offset().top - $('#navbar-main-container').outerHeight();
        $('#SubMenu').data('bs.affix').options.offset = {
            top: theTop
        };
    });

    $('#SubMenu').on('affixed.bs.affix', function() {
        $('a.navbar-brand.scrollTop span').text($('#destination-the-title').val());
    });
    $('#SubMenu').on('affixed-top.bs.affix', function() {
        setTimeout(function() {
            $('a.navbar-brand.scrollTop span').text('');
        }, 600)
    });
}


Click here view more answers http://ift.tt/1VAUuPJ

Place a view over another view

I have a custom toolbar in a separate file called include_toolbar.xml.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://ift.tt/nIICcg"
    xmlns:app="http://ift.tt/GEGVYd"
    android:id="@+id/include_toolbar"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

enter image description here

In a layout for an activity, I want to display this toolbar at the top, a camera preview view and an image button on top of that.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://ift.tt/nIICcg"
    xmlns:app="http://ift.tt/GEGVYd"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/include_toolbar" />

    <com.journeyapps.barcodescanner.CompoundBarcodeView
        app:zxing_result_view="@color/zxing_custom_result_view"
        android:id="@+id/activity_scan_barcodeView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </com.journeyapps.barcodescanner.CompoundBarcodeView>

    <ImageButton
        android:id="@+id/activity_scan_flashlight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignLeft="@id/activity_scan_barcodeView"
        android:src="@drawable/btn_flashOn"/>

</LinearLayout>

enter image description here

The CompoundBarcodeView is a component from this library.

The problem with the LinearLayout is that the image button is not displayed.

If I change it to RelativeLayout, the image button is displayed but now the toolbar is gone.

enter image description here

How do I get both of them to display?


Click here view more answers http://ift.tt/1WFoji4

Layout_weight does not work properly

I have the followin xml where I want imageview and then two textview and then imageview again, but it does not work properly.

Here is what I planned to have:

enter image description here

Here is what I am getting:

enter image description here

<LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_gravity="center_horizontal"
     android:orientation="horizontal"
     android:clickable="true"
     android:onClick="userProfileDetailAction"
     android:id="@+id/userProfileDetail"
     android:paddingTop="5dp"
     android:paddingBottom="5dp">

            <com.example.eyeniaras.satdostum.CircleImageView
                xmlns:app="http://ift.tt/GEGVYd"
                android:layout_weight="0.3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:background="@drawable/circle_shape"
                app:civ_border_width="0.2dp"
                app:civ_border_color="@color/dark"
                android:id="@+id/userImage"
                android:scaleType="centerCrop"/>

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.6">

                <TextView
                    android:id="@+id/userName"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_gravity="center"
                    android:textColor="@android:color/black"
                    android:background="#ffffff"
                    android:textSize="18sp"
                    android:layout_weight="1"/>

                <TextView
                    android:id="@+id/userRegistrationDate"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_gravity="center"
                    android:textColor="@android:color/black"
                    android:background="#ffffff"
                    android:textSize="18sp"
                    android:text = "45 days ago"
                    android:layout_weight="1"/>
            </LinearLayout>

            <ImageView
                android:id="@+id/userClick"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_weight="0.1"
                android:background="@drawable/list_arrow" />

 </LinearLayout>


Click here view more answers http://ift.tt/1UjAJ0n

How can i convert .outerHTML to .text()

I want to convert item.outerHTML to .text(), Actually I want to convert the html to text, now what do I do ?

$(imgAttr).each(function(index,item) {
 var valImg = $(item).attr("alt");
 if (typeof valImg == typeof undefined || valImg == "") {           
     $(".url-res").append(item.outerHTML.text());
 }

});


Click here view more answers http://ift.tt/1Qdwu4X

How to add display:inline-block to jQuery fadeIn

I'm running into an issue where I am attempting to get inline-block elements to display: none on page load, but then I want them to fadeIn one by one in their original inline-block form. However, when I do a normal jQuery fadeIn the elements display as block.

My jQuery is like this right now:

function blueBoxDelays(){
    $('.fadeBlock1').delay(200).fadeIn(500);
    $('.fadeBlock2').delay(400).fadeIn(500);
};

CSS

.dark-blue-box, .light-blue-box {
    height: 50%;
    width: 25%;
    display: inline-block;
    /*display: none;   ********I replaced the inline-block with this.
    vertical-align: top;
    padding: 0;
    margin: 0;
    transition: all .8s ease-in-out;
}

Is there something I can do to the jQuery to get these to fadeIn as inline-block elements?


Click here view more answers http://ift.tt/1RjSpX0

Opening and Reading files fails

I am currently trying to read a file and count the number of instances of a user-specified string in an input file and output them to another file,.

However when I try to open the file, fopen returns NULL. Here's what I have so far:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(int argc, char **argv)
{
    char in[50];
    char out[50];
    char target[50];

    getIns(in,out,target);
    Search(in, out, target);
    //printf("string entered: %s\n%s\n%s", in, out, target);



    return 0;
}

int getIns(char *i, char *o, char *t)
{
    printf("please enter name of input file you wish to search: \n -i ");
    fgets(i, 50, stdin);

    printf("please enter name of output file you wish to write to: \n -o ");
    fgets(o,50,stdin);

    printf("Please enter the string you wish to search for \n -c ");
    fgets(t, 50, stdin);

    return 1;
}


int Search(char *i, char *o, char *t)
{
    char*p;
    int c = 0;
    int start;
    char *data = NULL;
    FILE*f;

    f = fopen(i, "r");

    if (f == NULL)
    {
        printf("file not found \n Quitting...");
        exit(1);
    }   

    while(!feof(f))
    {
        fgets(data, sizeof(data), f);
        p = strstr(data,t);
        while (p != NULL)
        {
            c++;
            p = strstr(p , t);
        }
    }

    if (c == 0)
    {
        printf("String not in file\n");
    }
    if (c > 0)
    {
        printf("word: %s found: %d times\n", t, c);
    }

    fclose(f);

    return 1;
}


Edit:

I've made some changes to the code following the responses and now, my program crashes on reading the file. New code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int Search(char *i, char *o, char *t)
{
    char*p;
    int c = 0;
    int start;
    char data[1024];
    FILE*f;

    f = fopen(i, "r");

    if (f == NULL)
    {
        printf("file not found \n Quitting...");
        exit(1);
    }   

    while(fgets(data, sizeof(data), f))
    {
        fgets(data, sizeof(data), f);
        p = strstr(data,t);

        while (p != NULL)
            c++; p = strstr(p+1 , t);
    }

    if (c == 0)
    {
        printf("String not in file\n");
    }
    if (c > 0)
    {
        printf("word: %s found: %d times\n", t, c);
    }

    fclose(f);

    return 1;
}

int getIns(char *i, char *o, char *t)
{
    printf("please enter name of input file you wish to search: \n -i ");
    fgets(i, 50, stdin); i[strcspn(i, "\n")] = 0;

    printf("please enter name of output file you wish to write to: \n -o ");
    fgets(o, 50, stdin); o[strcspn(o, "\n")] = 0;

    printf("Please enter the string you wish to search for \n -c ");
    fgets(t, 50, stdin); t[strcspn(t, "\n")] = 0;

    return 1;
}

int main(int argc, char **argv)
{
    char in[50];
    char out[50];
    char target[50];

    getIns(in,out,target);
    Search(in, out, target);

    return 0;
}


Click here view more answers http://ift.tt/1KG77s9

How to get logo & Title on same line via bootstrap

I am using Bootstrap & want to get the logo on the left & title in the center. I have used the following code but not able to get the desired result. Please Guide.

<div class="panel-heading"><a href="#">
<img src="Logo.png" width="10%" height="10%" alt="">
</a>
<h1 align="center">Title</h1></div>


Click here view more answers http://ift.tt/1oZxsYn

What regex pattern will get me separately all letters in an array from the below file?

What regex pattern will get me separately all strings in an array from the below file?

Table_name_1 {
   Columns {
     Name : col_1
     Type: varchar(20)
     Description : to store stuff
   }
   Index {
     Name : Index1
     Column: col_1
   }
}

O/P:

[Table_name_1,Columns,Name:col_1,Type: varchar(20),Description : to store stuff,Index,Name : Index1,Column: col_1]


Click here view more answers http://ift.tt/1LDz2Us

Javascript return function issue returning object

I'm using google npm package to return some search results in an angular service. I guess I don't understand anything because I can't seem to pass back the results from the google search function to my service to return it to my controller.

I'm trying to set the var results = google function return. That way I can parse the search into a json object and return it to my service and then return it to my controller for display.

the var results is always undefined

Console Output

RESULTS
search-service.js:43 undefined
controller.js:88 undefined
annyang-service.js:32 End undefined
search-service.js:22 [Object, Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object, Object]
search-service.js:38 Object {0: Object, 1: Object, 2: Object, 3: Object, 4: Object}
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:38 Object {0: Object, 1: Object, 2: Object, 3: Object}
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:38 Object {0: Object, 1: Object, 2: Object, 3: Object}
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:38 Object {0: Object, 1: Object, 2: Object, 3: Object}
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:22 [Object, Object, Object, Object]
search-service.js:38 Object {0: Object, 1: Object, 2: Object, 3: Object}
2annyang-service.js:32 End undefined

CODE

(function() {
  'use strict';

  function SearchService($window, $http, $rootScope, $q) {
      var service = {};
      service.events = [];
      var google = require('google');
      google.resultsPerPage = 4;
      var nextCounter = 0;
      var results = {}; 
      service.Search = function(searchString) {

          console.log(searchString);

          results = google(searchString, function (err, next, links){
            var json_return = {};
            var json_search_string = "{";

            for (var i = 0; i <= links.length - 1; ++i) {
                var description_fixed = links[i].description.toString().replace(/(\r\n|\n|\r)/gm,'');

                description_fixed = description_fixed.replace(/"/g, ""); 

                console.log(links);

                if(i != links.length - 1){  
                     json_search_string +='"'+i.toString() + '":{ "title":" ' + links[i].title  + '" , "link":"' + links[i].link  + '" , "description":"' + description_fixed + '" },';     
                }else{          
                     json_search_string +='"'+i.toString() + '":{ "title":" ' + links[i].title  + '" , "link":"' + links[i].link  + '" , "description":"' + description_fixed + '" }';
                }       
            } 

            json_search_string += "}";

                if (nextCounter < 4) {
                          nextCounter += 1;
                          if (next) next()
                }

            json_return = JSON.parse(json_search_string); 
            console.log(json_return);
            return json_return  

          });
        console.log("RESULTS");
        console.log(results);
    }
    return service
}
    angular.module('Diddo')
        .factory('SearchService', SearchService);

}());

My controller directive

        AnnyangService.addCommand('Google *term', function(term) {
                console.log("executing search");
                $rootScope.search_string = term.toString();
                var results = SearchService.Search($rootScope.search_string);
                console.log(results);
        });


Click here view more answers http://ift.tt/1oZxvmY

Read Access Violation (this->headPtr was 0xCDCDCDCD)

Remove (T &item) is supposed to remove the headPtr and store that "item value" in "item" and return true, otherwise return false if no elements are in the queue. I get a "read access violation error" in this function. Here is the class and function definitions:

class SharedQueue {
public:
    SharedQueue();
    ~SharedQueue();

    //Return true if the queue is empty
    bool IsEmpty() const;

    //Enqueue the next item at the tail of the queue.
    void Add(T value);

    //Dequeue the next queue element and store it in "item" variable.  The function returns false if the queue is empty and no item can be retrieved.
    bool Remove(T &item);
    void Print();
private:
    struct QueueItem {
        T item;
        QueueItem *next;
    };
    //Fill in the The private data members.
    QueueItem *headPtr;
    QueueItem *tailPtr;
};

template <typename T> SharedQueue<T>::SharedQueue() {
    headPtr = NULL;
    tailPtr = NULL;
}

template <typename T>SharedQueue<T>::~SharedQueue() {
    QueueItem *temp;
    while (headPtr != NULL) {
        temp = headPtr;
        headPtr = headPtr->next;
        delete temp;
    }
}

template <typename T> bool SharedQueue<T>::IsEmpty() const {
    if (headPtr == NULL && tailPtr == NULL) {
        return true;
    }
    return false;
}

template <typename T> void SharedQueue<T>::Add(T aValue) {
    if (headPtr == NULL) {
        QueueItem *newItem = new QueueItem;
        newItem->item = aValue;
        tailPtr = headPtr = newItem;
    }
    else {
        QueueItem *newItem = new QueueItem;
        newItem->item = aValue;
        tailPtr->next = newItem;
        tailPtr = tailPtr->next;
    }
}

template <typename T> bool SharedQueue<T>::Remove(T &item) {
    if (headPtr == NULL) {
        return false;
    }
    else {
        QueueItem temp = *headPtr;
        item = headPtr->item;
        delete headPtr;
        headPtr = temp.next;
        return true;
    }
}

template <typename T> void SharedQueue<T>::Print() {
    QueueItem *temp = headPtr;
    while (temp != NULL) {
        std::cout << temp->item << "\n";
        temp = temp->next;
    }
}


Click here view more answers http://ift.tt/1OrGH8j

C# MVC get .Distinct() data

I have some data in SQL Server:

[
  {
    "code": 1,
    "name": "qweee",
    "IDNO": "ff2222"
  },
  {
    "code": 2,
    "name": "test2",
    "IDNO": "ff2222211"
  },
  {
    "code": 3,
    "name": "fsdfasdf",
    "IDNO": "ddaaa"
  },
  {
    "code": 4,
    "name": "qweee",
    "IDNO": "ff2222"
  },
  {
    "code": 5,
    "name": "123",
    "IDNO": "U120000005"
  }
]

I need to use the following SQL in C # MVC

SELECT DISTINCT  
    A1.IDNO , A1.name ,
    (SELECT COUNT(cnt_tab.IDNO) 
     FROM Postpartum_AccountsManagement AS cnt_tab
     WHERE cnt_tab.IDNO = A1.IDNO) AS data_cnt
FROM 
    Postpartum_AccountsManagement AS A1

Then I will get

[
      {
        "name": "test2",
        "IDNO": "ff2222211",
        "data_cnt": 1
      },
      {
        "name": "qweee",
        "IDNO": "ff2222",
        "data_cnt": 2
      },
      {
        "name": "fsdfasdf",
        "IDNO": "ddaaa",
        "data_cnt": 1
      },
      {
        "name": "123",
        "IDNO": "U120000005",
        "data_cnt": 1
      }
]

I need to get the same data in C# MVC.


Click here view more answers http://ift.tt/1KG77bK

If two objects are declared in a single line, in what order are they constructed?

May be this is a basic question, but I couldn't find any relevant posts regarding it.

Let's say a class has been defined as

class A {
//.....
}

and now I am creating two objects as

A a,b;

I have the following query

In what order a and b created? Is it defined by the standard?


Click here view more answers http://ift.tt/1OrGF06

CSS: How to remove white space

I am designing a responsive web page. Actually what's happening is though i am setting the width of my header and wrapper with the screen size still I guess it is taking more space due to which a horizontal scroll bar appears down the screen and also the position of buttons are varying from display to display though i am taking the screen size px Here is the code

$(document).ready(function(){
    var a=window.screen.availWidth;
    var b=(0.20 * window.screen.availHeight);
    var c=(0.60 * window.screen.availHeight);
 $("#header").css("background-color","#009acd");
 $("#header").css("height",b);
 $("#header").css("width",a);
 $("#header").css("position","relative");

 $("#wrapper").css("background-color","#FFFFFF");
 $("#wrapper").css("width",a);
 $("#wrapper").css("height",c);
 $("#wrapper").css("position","relative");

 $("#logo1").css("position", "absolute");
 $('#logo1').css("top","5%");

 $('#d11').css("position","absolute");
 $('#d11').css("top","75px");
 $('#d11').css("left","310px");
 $('#d11').css("color","#FFFFFF");

 $('#marquee').css("position","absolute");
 $('#marquee').css("top","-15px");
 $('#marquee').css("left","300px");
 $('#marquee').css("color","#FFFFFF");

 $('h1').css("color","#FFFFFF");
 $('h3').css("position","absolute");
 $('h3').css("top","90px");
 $('h3').css("left","1000px");
 $('h3').css("color","#FFFFFF");
 $('h2').css("position","absolute");
 $('h2').css("top","60px");
 $('h2').css("left","1075px");
 $('h2').css("color","#FFFFFF");

/* $('#d12').css("position","absolute");
 $('#d12').css("top","65px");
 $('#d12').css("left","950px");
 $('#d12').css("color","#FFFFFF");*/

 $('#css3menu1').css("position", "absolute");
 $('#css3menu1').css("bottom","17px");
 $('#css3menu1').css("left","310px");

 $('#videos').css("position", "absolute");
 $('#videos').css("top","0px");
 $('#videos').css("left","22px");

 $('#studymaterial1').css("position", "absolute");
 $('#studymaterial1').css("top","148px");
 $('#studymaterial1').css("left","32px");

 $('#downloads').css("position", "absolute");
 $('#downloads').css("top","315px");
 $('#downloads').css("left","22px");

 $('#wowslider-container1').css("left","233px");
 $('#wowslider-container1').css("top","1000px");

 $('.formoid-solid-blue').css("position","absolute");
 $('.formoid-solid-blue').css("left","912px");
 $('.formoid-solid-blue').css("top","12px");


});
HTML code
<body>
    <div id="header">

        <div id="logo1">
            <img src="images/logo.jpg" alt="logo"></img>
        </div>
        <div>
            <ul id="css3menu1" class="topmenu">
                <li class="topfirst"><a href="#"
                    style="height: 18px; line-height: 18px;">Home</a></li>
                <li class="topfirst"><a href="#"
                    style="height: 18px; line-height: 18px;"><span>FAQs </span></a></li>
                <li class="topfirst"><a href="#"
                    style="height: 18px; line-height: 18px;"><span>Videos </span></a></li>
                <li class="topfirst"><a href="#"
                    style="height: 18px; line-height: 18px;"><span>Study
                            Materials</span></a></li>
                <li class="topfirst"><a href="#"
                    style="height: 18px; line-height: 18px;"><span>Downloads</span></a></li>

            </ul>
        </div>

        <div id="marquee">
            <marquee>
                <a href="#" ><h1>I have a QUERY?????&nbsp;I have a QUERY?????&nbsp;I have a QUERY?????</h1></a>
            </marquee>
        </div>

        <div id="d11">
            <h1>WELCOME TO ULLASUCHIL.COM</h1>
        </div>
        <div id="d12">
            <h2 align="right">
                ULLAS UCHIL</h2><h3 align="right">DEVELOPMENT OFFICER<br>+91 98195 63458<br>ullasuchil@licindia.com</h3>

        </div>
    </div>
    <div id="wrapper">
        <div id="videos">
            <img src="images/videos.png" alt="videos"></img>
        </div>
        <div id="studymaterial1">
            <img src="images/studymaterial1.png" alt="studymaterials"></img>
        </div>
        <div id="downloads">
            <img src="images/downloads.png" alt="downloads"></img>
        </div>

        <div id="wowslider-container1">
            <div class="ws_images">
                <ul>
                    <li><img src="data1/images/photo_20160218_183940.jpg"
                        alt="photo_2016-02-18_18-39-40" title="photo_2016-02-18_18-39-40"
                        id="wows1_0" /></li>
                    <li><img src="data1/images/photo_20160218_183950.jpg"
                        alt="photo_2016-02-18_18-39-50" title="photo_2016-02-18_18-39-50"
                        id="wows1_1" /></li>
                    <li><img src="data1/images/photo_20160218_183956.jpg"
                        alt="photo_2016-02-18_18-39-56" title="photo_2016-02-18_18-39-56"
                        id="wows1_2" /></li>
                    <li><img src="data1/images/photo_20160218_184006.jpg"
                        alt="photo_2016-02-18_18-40-06" title="photo_2016-02-18_18-40-06"
                        id="wows1_3" /></li>
                    <li><img src="data1/images/photo_20160218_184014.jpg"
                        alt="photo_2016-02-18_18-40-14" title="photo_2016-02-18_18-40-14"
                        id="wows1_4" /></li>
                    <li><img src="data1/images/photo_20160218_184020.jpg"
                        alt="photo_2016-02-18_18-40-20" title="photo_2016-02-18_18-40-20"
                        id="wows1_5" /></li>
                    <li><img src="data1/images/photo_20160218_184028.jpg"
                        alt="photo_2016-02-18_18-40-28" title="photo_2016-02-18_18-40-28"
                        id="wows1_6" /></li>
                    <li><img src="data1/images/photo_20160218_184035.jpg"
                        alt="photo_2016-02-18_18-40-35" title="photo_2016-02-18_18-40-35"
                        id="wows1_7" /></li>
                    <li><img src="data1/images/photo_20160218_184045.jpg"
                        alt="photo_2016-02-18_18-40-45" title="photo_2016-02-18_18-40-45"
                        id="wows1_8" /></li>
                    <li><img src="data1/images/photo_20160218_184054.jpg"
                        alt="photo_2016-02-18_18-40-54" title="photo_2016-02-18_18-40-54"
                        id="wows1_9" /></li>
                    <li><img src="data1/images/photo_20160218_184059.jpg"
                        alt="photo_2016-02-18_18-40-59" title="photo_2016-02-18_18-40-59"
                        id="wows1_10" /></li>
                    <li><img src="data1/images/photo_20160218_184113.jpg"
                        alt="photo_2016-02-18_18-41-13" title="photo_2016-02-18_18-41-13"
                        id="wows1_11" /></li>
                    <li><img src="data1/images/photo_20160218_184121.jpg"
                        alt="photo_2016-02-18_18-41-21" title="photo_2016-02-18_18-41-21"
                        id="wows1_12" /></li>
                    <li><a href="http://wowslider.com/vf"><img
                            src="data1/images/photo_20160218_184129.jpg"
                            alt="full screen slider" title="photo_2016-02-18_18-41-29"
                            id="wows1_13" /></a></li>
                    <li><img src="data1/images/photo_20160218_184140.jpg"
                        alt="photo_2016-02-18_18-41-40" title="photo_2016-02-18_18-41-40"
                        id="wows1_14" /></li>
                </ul>
            </div>
            <div class="ws_bullets">
                <div>
                    <a href="#" title="photo_2016-02-18_18-39-40"><img
                        src="data1/tooltips/photo_20160218_183940.jpg"
                        alt="photo_2016-02-18_18-39-40" />1</a> <a href="#"
                        title="photo_2016-02-18_18-39-50"><img
                        src="data1/tooltips/photo_20160218_183950.jpg"
                        alt="photo_2016-02-18_18-39-50" />2</a> <a href="#"
                        title="photo_2016-02-18_18-39-56"><img
                        src="data1/tooltips/photo_20160218_183956.jpg"
                        alt="photo_2016-02-18_18-39-56" />3</a> <a href="#"
                        title="photo_2016-02-18_18-40-06"><img
                        src="data1/tooltips/photo_20160218_184006.jpg"
                        alt="photo_2016-02-18_18-40-06" />4</a> <a href="#"
                        title="photo_2016-02-18_18-40-14"><img
                        src="data1/tooltips/photo_20160218_184014.jpg"
                        alt="photo_2016-02-18_18-40-14" />5</a> <a href="#"
                        title="photo_2016-02-18_18-40-20"><img
                        src="data1/tooltips/photo_20160218_184020.jpg"
                        alt="photo_2016-02-18_18-40-20" />6</a> <a href="#"
                        title="photo_2016-02-18_18-40-28"><img
                        src="data1/tooltips/photo_20160218_184028.jpg"
                        alt="photo_2016-02-18_18-40-28" />7</a> <a href="#"
                        title="photo_2016-02-18_18-40-35"><img
                        src="data1/tooltips/photo_20160218_184035.jpg"
                        alt="photo_2016-02-18_18-40-35" />8</a> <a href="#"
                        title="photo_2016-02-18_18-40-45"><img
                        src="data1/tooltips/photo_20160218_184045.jpg"
                        alt="photo_2016-02-18_18-40-45" />9</a> <a href="#"
                        title="photo_2016-02-18_18-40-54"><img
                        src="data1/tooltips/photo_20160218_184054.jpg"
                        alt="photo_2016-02-18_18-40-54" />10</a> <a href="#"
                        title="photo_2016-02-18_18-40-59"><img
                        src="data1/tooltips/photo_20160218_184059.jpg"
                        alt="photo_2016-02-18_18-40-59" />11</a> <a href="#"
                        title="photo_2016-02-18_18-41-13"><img
                        src="data1/tooltips/photo_20160218_184113.jpg"
                        alt="photo_2016-02-18_18-41-13" />12</a> <a href="#"
                        title="photo_2016-02-18_18-41-21"><img
                        src="data1/tooltips/photo_20160218_184121.jpg"
                        alt="photo_2016-02-18_18-41-21" />13</a> <a href="#"
                        title="photo_2016-02-18_18-41-29"><img
                        src="data1/tooltips/photo_20160218_184129.jpg"
                        alt="photo_2016-02-18_18-41-29" />14</a> <a href="#"
                        title="photo_2016-02-18_18-41-40"><img
                        src="data1/tooltips/photo_20160218_184140.jpg"
                        alt="photo_2016-02-18_18-41-40" />15</a>
                </div>
            </div>
            <div class="ws_shadow"></div>
            <script type="text/javascript" src="engine1/wowslider.js"></script>
            <script type="text/javascript" src="engine1/script.js"></script>
        </div>

        <div>

            <script type="text/javascript"
                src="formoid_files/formoid1/jquery.min.js"></script>
            <form class="formoid-solid-blue"
                style="background-color: #FFFFFF; font-size: 14px; font-family: 'Roboto', Arial, Helvetica, sans- serif; color: #34495E; max-width: 980px; min-width: 335px; max-height: 600px; min-height: 440px"
                method="post">
                <div class="title">
                    <h2>Register</h2>
                </div>
                <div class="element-input">
                    <label class="title"><span class="required"></span></label>
                    <div class="">
                        <b><font color="black">Name</font></b><input class="large"
                            type="text" name="input" required="required" placeholder="Name" /><span
                            class=""></span>
                    </div>
                </div>


                <div class="">
                    <label class="title"><span class="required"></span></label>
                    <div class="">
                        <b><font color="black">Contact</font></b><input class="large"
                            type="text" name="input1" required="required"
                            placeholder="Contact" /><span class="icon-place"></span>
                    </div>
                </div>
                <div class="">
                    <label class="title"><span class="required"></span></label>
                    <div class="item-cont">
                        <b><font color="black">Email</font></b><input class="large"
                            type="text" name="input2" required="required" placeholder="Email" /><span
                            class=""></span>
                    </div>
                </div>
                <div class="element-select">
                    <label class="title"><span class="required"></span></label>
                    <div class="item-cont">
                        <div class="large">
                            <b><font color="black">Location</font></b><span><select
                                name="select" required="required">

                                    <option value="Mumbai">Mumbai</option>
                                    <option value="Navi Mumbai">Navi Mumbai</option>
                                    <option value="Thane">Thane</option>
                                    <option value="Kalyan">Kalyan-Dombivali</option>
                                    <option value="Dahisar">Mira Road-Virar</option>
                                    <option value="Rest of India">Rest of India</option>
                            </select><i></i><span class="icon-place"></span></span>
                        </div>
                    </div>
                </div>
                <div class="submit">
                    <input type="submit" value="Submit" />
                </div>
            </form>
            <script type="text/javascript"
                src="formoid_files/formoid1/formoid-solid-blue.js"></script>
        </div>
    </div>


Click here view more answers http://ift.tt/20RXBEd

HTML text input field with currency symbol selector on left

I would like to have a text input field containing currency sign selector as input addon, when user clicks on currency sign, drop down will open it will show list of available currencies UOM's and after selecting it from drop down currency symbol will change.


Click here view more answers http://ift.tt/1QyXPk7

Is it possible to make a div position relative to a non parent div or is there a better way?

I am working on a FAQ page for a rustic home furnishings company. The questions are buttons that, when clicked, expand to show the answer. As of right now, I either have to put the footer way down so it never overlaps which looks awful, or let it overlap, which also looks awful.

The problem is, the buttons (and text they reveal) need to be centered in a secondary background, but the footer needs to span 100% width of the page. If I make the footer a child of the questions div width=100% makes it only span the questions div.

I need the footer's vertical position to be relative to the questions div.

<div id="questions" class="auto-style22" style="position: absolute; width: 591px; height: 466px; z-index: 8; left: 395px; top: 323px">
<script type="text/javascript">
function toggleMe(a){
 //Collapse all answers
   var elements=document.getElementsByClassName("button");
   for (var i=0;i<elements.length;i+=1){
    elements[i].style.display = 'none';
   }
 //Toggle a particular answer
 var e=document.getElementById(a);
 if(!e) return true;
 if(e.style.display=="none"){
  e.style.display="block"
 }
 else{
  e.style.display="none"
 }
 return true;   
}</script>

<input type="button"  onclick="return toggleMe('para1');" value="What is Buffalo Ranch?" class="buttonClass"><br>
<div class="button" id="para1" style="display:none" >

    <br>Buffalo Ranch Rustic Home Furnishings is a locally owned and operated retail store featuring a unique collection of ranch and lodge décor, western art, fine antiques, and collectibles. We have a variety of taxidermy mounts, hair on hide leather furniture and other leather goods (bags, wallets, coasters, etc). We also carry beautiful western inspired jewelry, bedding and gifts. We have everything you need to accessorize yourself and your rustic home, except the fresh country air, that is!
</div>
<br>
<input type="button" onclick="return toggleMe('para2')" value="Where are you located?" class="buttonClass"><br>
<div class="button" id="para2" style="display:none" >
<br>
We are located at 123 Main Street in the quaint and historic little town of Nowhere.
</div>
</div>
div id="footer" style="position: relative; width: 100%; height: 125px; top: 966px; left: 0px;">
    <img class="footer" height=475 src="Graphics/Blue%20Footer.png" width="100%"></div>

Obviously there are a lot more questions but I only included 2 to keep it short.


Click here view more answers http://ift.tt/1L7MTrb

Frames vs Bounds and autolayout constraints?

I recently read a wonderful question regarding frames & bounds property of views over here - UIView frame, bounds and center. I tried to experiment on that a bit more with autolayout as well and now I find myself in a very conflicting scenario. Please be patient as it may take a bit long.

I will highlight them one by one & so please help me to get over all these -

What I have? -

A view hierachy with constraints as follows - (The designing was done on the default ViewController size of 600*600)

enter image description here

enter image description here

I tried to print out the frames and bounds of these views -

contentView

 print(contentView.frame)// o/p - (0.0, 64.0, 600.0, 536.0) 
  print(contentView.bounds)//o/p- (0.0, 0.0, 600.0, 536.0)

Q) **a)**Why is the frame size showing 600*536 whichever screen I may run it. eg. It prints the same if I run it on a 4s screen or else in an iPad screen?

**b)**And it always infers the size of my VC in my storyboard!!. eg. If i design the screen in a 3.5 inch VC,the frame size becomes 320.0*416.0.

**c)**Since it is pinned to all sides of the view it should be same to the view size, and also it always remains pinned to edges. So why is it not of the same size of self.view.frame.width*self.view.frame.height

sideView

print(sideView.frame)//o/p - (520.0, 86.0, 80.0, 128.0) 
   print(sideView.bounds)//o/p - (0,0, 80.0, 128.0)

Q) If I design a custom UIView programmatically as

let TestView = UIView(frame: CGRectMake(520.0, 86.0, 80.0, 128.0))//Mark:its frame is exactly same as sideView.frame
        TestView.backgroundColor = UIColor.redColor()
        self.contentView.addSubview(TestView)

So here the sideView(subview of contentView) should be replaced by the TestView but isn't & the o/p screen comes the same as in previous case. Why?

Thanks.


Click here view more answers http://ift.tt/20RXoB0

Passing by reference how to call the method

I've readed a few articles on stackoverflow but i couldn't figure out how to do it. I've made a small code for reading mixed\binary files (making a new one, with separated methods, the older one was messed) - but i'm in doubt on how to call the method on the program's main.

I figured out i should instantiate each variable before using them on the method's call - but how do i do that with string ? I know this is a newbie question but i'm new to c# - also i've searched over stackoverflow and other places and couldn't find an suitable answer.

Thanks.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;

namespace ConsoleApplication2
{
    class Program
    {
        public void FileOpen(ref OpenFileDialog of, ref string filename, ref int nfiles)
        {
            of.Filter = "PPF Files | *.ppf";
            of.Multiselect = true;
            of.ShowDialog();
            filename = of.FileName;
            nfiles = of.FileNames.Count();
        }
        public void FileRead(ref OpenFileDialog of, ref string filename, ref List<string> freaded, ref int nfiles, ref string filecontents)
        {
            string aux;
            List<string> filesreaded = new List<string>();
            if (string.IsNullOrEmpty(of.FileName) == false)
            {
                for(int i=0; i<nfiles; i++)
                {
                    // Read the file into <bits>
                    using (var fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
                    {
                        var len = (int)fs.Length;
                        var bits = new byte[len];
                        fs.Read(bits, 0, len);
                        // Dump 16 bytes per line
                        for (int ix = 0; ix < len; ix += 16)
                        {
                            var cnt = Math.Min(16, len - ix);
                            var line = new byte[cnt];
                            Array.Copy(bits, ix, line, 0, cnt);
                            // Convert non - ascii characters to .
                        for (int jx = 0; jx < cnt; ++jx)
                            { 
                                if (line[jx] < 0x20 || line[jx] > 0x7f)
                                    line[jx] = (byte)'.';
                            }
                            aux = Encoding.ASCII.GetString(line);
                            filecontents += aux;
                        }



                    }//Closing FileStream
                }//Closing files loop (operations for each file)
            }//Closing IF Statement
        }//Closing FileRead function

        [STAThread]
        static void Main(string[] args)
        {
            Program a = new Program();
            OpenFileDialog openf = new OpenFileDialog();
            int filenumber = new int();
            string fullfilename //What to do here? 
//How can i instantiate a new string so i can use it when calling the method ?


            a.FileOpen(ref openf , ref fullfilename , ref filenumber);
        }
    }
}


Click here view more answers http://ift.tt/20RXDf7

Select subset of objects from javascript object array

I've got a long array of objects:

var myObj = {
  a: "aaa",
  b: "bbb",
  c: "ccc",
  d: "ddd",
  ...
}

I'd like to create a new object array that consists of every object except the first two:

var myObj2 = {
  c: "ccc",
  d: "ddd",
  ...
}

Obviously myObj.slice(2) doesn't work (as much as I'd like it to), and I can't select them all by name (myObj.c, myObj.d, etc) because there are more than 100 objects, and potentially more to be added.

What's the best way to select a range of objects in a object array?


Click here view more answers http://ift.tt/1L7MR2y

Endless recyclerview on load more scrolls to start of the list

i have got onload more functionality in my app, but when i reach the end of list new items are loaded but the list automatically scrolls to the start of the list.

this is the onload function:

         recyclerView.addOnScrollListener(new EndlessRecyclerOnScrollListener(mLayoutManager) {
            @Override
            public void onLoadMore(int current_page, int position) {
                // do something...
                Log.d("Yaeye!", "HElloyoyo");
                SuperHeroes superHero = listSuperHeroes.get(position);

                Log.d("we want url", superHero.getImageUrl());
                imgoffset = superHero.getImageUrl();
                // Do something
                getData(0);

            }
        });

here is the parsing of the data received from the server :

           JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(url,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        //Dismissing progress dialog
                        // loading.dismiss();

                        //calling method to parse json array
                        parseData(response);

                            adapter.notifyDataSetChanged();



                    }

                },

                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                });



        //Creating request queue
        RequestQueue requestQueue = Volley.newRequestQueue(this);

        //Adding request to the queue
        requestQueue.add(jsonArrayRequest);


    }
    public int z;
    //This method will parse json data
    private int parseData(JSONArray array){
        for(int i = 0; i<array.length(); i++) {
            SuperHeroes superHero = new SuperHeroes();
            CardAdapter car = new CardAdapter();
            JSONObject json = null;
            try {
                json = array.getJSONObject(i);
                superHero.setImageUrl(json.getString(Config.TAG_IMAGE_URL));
                superHero.setProUrl(json.getString("pro_pic"));
                Img =json.getString(Config.TAG_IMAGE_URL);
                superHero.setName(json.getString(Config.TAG_NAME));
                superHero.setRank(json.getInt(Config.TAG_RANK));
                superHero.setstat(false);

                Log.d("test",Img);
                car.setImageUrl(Img);


            } catch (JSONException e) {
                e.printStackTrace();
            }

             adapter.notifyItemInserted(listSuperHeroes.size());
                listSuperHeroes.add(superHero);

             //   adapter.notifyDataSetChanged();
                loading=false;
      }

please help, its urgent and i have spent alot of time on this app already.


Click here view more answers http://ift.tt/20RWC6S

how to convert? C-string format of toStirng()

Here is the function:

string toString(){
    string tmp;

    char buf[80];
    if (*d != 1)
        sprintf_s(buf, "%d/%d", *n, *d);
    else sprintf_s(buf, "%d", *n);
    tmp = string(buf);

    return tmp;
}

need a c-string format of toString(), don't know how to do; plz help.. char *str();


Click here view more answers http://ift.tt/20RXAjx

JAVA: Program not detecting key presses using KeyListener

I'm making a space shooter game in Java. I have it set to move up when I press the up key, but it is currently not working at all. I am using the KeyPressed method in the KeyListener interface. Here is my code. It is in 2 classes.

Game.java

package main;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class Game extends Canvas implements Runnable, KeyListener {

    private static final long serialVersionUID = 1L;
    public static final int WIDTH = 800;
    public static final int HEIGHT = 600;
    public static final String TITLE = "Space Shooter";

    private boolean running = false;
    private Thread thread;

    private Player player;

    private BufferedImage playerImage;

    int playerx;
    int playery;

    public Game() {
        player = new Player((WIDTH/2)-32, 400); 
        try {
            playerImage = ImageIO.read(this.getClass().getResourceAsStream("/res/player.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }

        addKeyListener(this);
    }

    private synchronized void start() {
        if (running)
            return;

        running = true;
        thread = new Thread(this);
        thread.start();
    }

    private synchronized void stop() {
        if (!running)
            return;

        running = false;
        try {
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.exit(1);
    }

    @Override
    public void run() {     
        long lastTime = System.nanoTime();
        final double amountOfTicks = 60.0;
        double ns  = 1000000000 / amountOfTicks;
        double delta = 0;
        int updates = 0;
        int frames = 0;
        long timer = System.currentTimeMillis();
        while (running) {
            long now = System.nanoTime();
            delta += (now - lastTime) / ns;
            lastTime = now;
            if (delta > 1) {
                tick();
                updates++;
                delta--;
            }
            render();
            frames++;

            if (System.currentTimeMillis() - timer > 1000) {
                timer += 1000;
                System.out.println(updates + " TICKS, " + frames + " FPS");
                updates = 0;
                frames = 0;
            }
        }
        stop(); 
    }

    public void tick() {
        playerx = player.getX();
        playery = player.getY(); 
    }

    public void render() {
        BufferStrategy bs = this.getBufferStrategy();
        if (bs == null) {
            createBufferStrategy(3);
            return;
        }
        Graphics g  = bs.getDrawGraphics();

        g.drawImage(playerImage, playerx, playery, this); 

        g.dispose();
        bs.show();
    }

    @Override
    public void keyPressed(KeyEvent e) {
        int key = e.getKeyCode();
        if (key == KeyEvent.VK_UP) {
            player.setY(playery -= 5);
        }
    }

    public void keyReleased(KeyEvent e) {}
    public void keyTyped(KeyEvent e) {}

    public static void main(String[] args) {

        Game game = new Game();
        JFrame frame = new JFrame(TITLE);

        frame.setSize(WIDTH, HEIGHT);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setResizable(false);
        frame.add(game);
        frame.getContentPane().setBackground(Color.BLACK);
        frame.setVisible(true); 

        game.start();

    }

}

Player.java

package main;

public class Player {

    int x, y; 

    public Player(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

}


Click here view more answers http://ift.tt/1Twj6dd

Assignment help on arrays

The Java assignment is to Prompt user for ten integers which are stored in an array, call a method passing the array and the method will display the values in both the original and reverse order.

I have tried every which way I know (from reading my class book and watching the lecture videos...) but I can not figure out how to write this code.


Click here view more answers http://ift.tt/1Q7xeoA

How to unify various date format?

I need to accept either DateTime or Date information from a text file. The challenge is, this date information comes in any format each time. It can be in any format below.

20160131 23:30:15
31032016 23:30:15
2016/01/31 23:30:15
01/31/2016 23:30:15
31/01/2016 23:30:15
31.01.2016 23:30:15
31/01/2016 23:30
// ... more formats come with '-' separators as well and some similar format

How can I unify these random formats into a string or even straight into DateTime ? Or is there any 3rd party library that can handle this scenario?


Click here view more answers http://ift.tt/1L7MTaK

Compiling errors on homework

I'm writing a program for my class and i'm getting compiling errors and I'm not sure why. I think it has something to do with my Test method.

public class Test1 {

    public static void main(String[] args) {

        String test;

    public void Test(String s){
        text = s;
        }

        Test test = new Test("ABC");
        System.out.println(test);

    }
}


Click here view more answers http://ift.tt/1UjwVMS

How std::transform and std::plus work together?

I was reading C++ reference and came across std::plus function with an example. Which is pretty straight forward, its simply adds lhs and rhs. The code was:

#include <functional>
#include <iostream>

int main()
{
   std::string a = "Hello ";
   const char* b = "world";
   std::cout << std::plus<>{}(a, b) << '\n';
}

output: Hello world

I changed it to

#include <functional>
#include <iostream>

int main()
{
   int a = 5;
   int b = 1;
   std::cout << std::plus<int>{}(a, b) << '\n';
}

output : 6

Now I made

foo vector = 10 20 30 40 50
bar vector = 11 21 31 41 51

I called:

std::transform (foo.begin(), foo.end(), bar.begin(), foo.begin(), std::plus<int>());

and it gave 21 41 61 81 101 which I understand it is adding up both foo and bar. But how it was passed to std::plus function?


Click here view more answers http://ift.tt/20RXA31