Rectangle 27 0

Linux - How to run multiple command in a single line?

Use define command to define your own command:

(gdb) define mycommand
Type commands for definition of "mycommand".
End with a line saying just "end".
>info threads
(gdb) mycommand

For detailed information, you can refer:

Note Linux lldb
Rectangle 27 0

how to pass javascript variable to the jstl code?

First, you need the following concept right: Java/JSP runs at the server machine and produces a HTML/CSS/JS page. The server machine sends HTML/CSS/JS page over network (HTTP) to the client machine. Client machine retrieves HTML/CSS/JS and starts to interpret HTML to display a markup structure, apply CSS to style and position the structure and execute JS on the resulting the HTML/CSS.

More background information and code examples can be found in this article.

There is no means of any line of Java/JSP code at the client machine. Rightclick page and view source. The only way to pass Java/JSP variables to Javascript is to just output them as if it's a Javascript variable so that it has instant access to it once it runs at the client machine. The only way to pass Javascript variables to Java/JSP is to just send a HTTP request with that variable as parameter and have Java/JSP to listen on that specific request.

Rectangle 27 0

node.js Accessing Express.js local variables in client side JavaScript?

!!! 5
    var local_data =!{JSON.stringify(data)}

include ../www/index.html
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');

app.get('/', ensureAuthenticated, function(request, response){
    response.render('index', { data: {currentUser:} });

app.use(express.static(__dirname + '/www'));

If you are inserting @Amberlamps snippet of code above an included static HTML file, remember to specify !!! 5 at the top, to avoid having your styling broken, in views/index.jade:

This will pass in your local_data variable before the actual static HTML page loads, so that the variable is available globally from the start.

Rectangle 27 0

android downloading multiple files one by one using asynctask?

package com.example.androidhive;


import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class AndroidDownloadFileByProgressBarActivity extends Activity {

    // button to show progress dialog
    Button btnShowProgress;

    // Progress Dialog
    private ProgressDialog pDialog;
    ImageView my_image;
    // Progress dialog type (0 - for Horizontal progress bar)
    public static final int progress_bar_type = 0;

    // File url to download
    String[] ur = {
            "" };

    public void onCreate(Bundle savedInstanceState) {

        // show progress bar button
        btnShowProgress = (Button) findViewById(;
        // Image view to show image after downloading
        my_image = (ImageView) findViewById(;
         * Show Progress bar click event
         * */
        btnShowProgress.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // starting new Async Task
                new DownloadFileFromURL().execute(ur);

     * Showing Dialog
     * */
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case progress_bar_type:
            pDialog = new ProgressDialog(this);
            pDialog.setMessage("Downloading file. Please wait...");
            return pDialog;
            return null;

     * Background Async Task to download file
     * */
    class DownloadFileFromURL extends AsyncTask<String, String, String> {

         * Before starting background thread Show Progress Bar Dialog
         * */
        protected void onPreExecute() {

         * Downloading file in background thread
         * */
        protected String doInBackground(String... f_url) {
            int count;
            try {

                for (int i = 0; i < f_url.length; i++) {
                    URL url = new URL(f_url[i]);
                    URLConnection conection = url.openConnection();
                    // getting file length
                    int lenghtOfFile = conection.getContentLength();

                    // input stream to read file - with 8k buffer
                    InputStream input = new BufferedInputStream(
                            url.openStream(), 8192);
                    System.out.println("Data::" + f_url[i]);
                    // Output stream to write file
                    OutputStream output = new FileOutputStream(
                            "/sdcard/downloaded" + i + ".jpg");

                    byte data[] = new byte[1024];

                    long total = 0;

                    while ((count = != -1) {
                        total += count;
                        // publishing the progress....
                        // After this onProgressUpdate will be called
                                + (int) ((total * 100) / lenghtOfFile));

                        // writing data to file
                        output.write(data, 0, count);

                    // flushing output

                    // closing streams
            } catch (Exception e) {
                Log.e("Error: ", e.getMessage());

            return null;

         * Updating progress bar
         * */
        protected void onProgressUpdate(String... progress) {
            // setting progress percentage

         * After completing background task Dismiss the progress dialog
         * **/
        protected void onPostExecute(String file_url) {
            // dismiss the dialog after the file was downloaded

            // Displaying downloaded image into image view
            // Reading image path from sdcard
            String imagePath = Environment.getExternalStorageDirectory()
                    .toString() + "/downloaded.jpg";
            // setting downloaded into image view
            // my_image.setImageDrawable(Drawable.createFromPath(imagePath));

Rectangle 27 0

if else conditions in mysql query php?

FROM user
where usertype =1 group by jobid
FROM user
where usertype =2 group by experienceId

You can try like this..

Rectangle 27 0

excel vba: adding distinct values in a range to a new range?

Dim dic As Dictionary
Set dic = New Dictionary
Dim srcRng As Range
Dim lastRow As Integer

Dim ws As Worksheet
Set ws = Sheets("Sheet1")

lastRow = ws.Cells(1, 1).End(xlDown).Row
Set srcRng = ws.Range(ws.Cells(1, 1), ws.Cells(lastRow, 1))

Dim cell As Range

For Each cell In srcRng
    If Not dic.Exists(cell.Value) Then
        dic.Add cell.Value, cell.Value   'key, value
    End If
Next cell

Set ws = Sheets("Sheet2")    

Dim destRow As Integer
destRow = 1
Dim entry As Variant

'the Transpose function is essential otherwise the first key is repeated in the vertically oriented range
ws.Range(ws.Cells(destRow, 1), ws.Cells(dic.Count, 1)) = Application.Transpose(dic.Items)

I really like the dictionary object in VBA. It's not natively available but it's very capable. You need to add a reference to Microsoft Scripting Runtime then you can do something like this:

You can transpose the array of dictionary keys to the range in one step using dic.keys. Try it out :)

Rectangle 27 0

encoding url parameter in ruby, and correctly decoding it with php?

url_encoded_string = CGI::escape("'Stop!' said Fred")
   # => "%27Stop%21%27+said+Fred"
Rectangle 27 0

how to mock localstorage in javascript unit tests?

beforeEach(function () {
  var store = {};

  spyOn(localStorage, 'getItem').andCallFake(function (key) {
    return store[key];
  spyOn(localStorage, 'setItem').andCallFake(function (key, value) {
    return store[key] = value + '';
  spyOn(localStorage, 'clear').andCallFake(function () {
      store = {};

you could do this with sinon as well. The key is why bother tying to mock the entire localStorage object, just mock the methods (getItem and/or setItem) you are interested in.

If you want to mock the local storage in all your tests, declare the beforeEach() function shown above in the global scope of your tests (the usual place is a specHelper.js script).

Note local storage unittest JavaScript
Rectangle 27 0

java api to convert jpeg to tiff?

The javax.imageio package has built-in writers for most of the popular image types, including jpg and tiff. Here's Sun's page on imageio.

javax.imageio does not support TIF.

Rectangle 27 0

java javafx tabpane change one tab, update the others?

The easiest way would be to hold the categories in an ObservableList at some top level (say in your Application sub class) and have all the tables share a reference to that list (table.setItems(yourList)). Whenever a change is made in the categories tab, the other tabs will automatically reflect the change.