Compare 2 files and remove any lines in file2 when they match values found in file1

I have two files. i am trying to remove any lines in file2 when they match values found in file1. One file has a listing like so:

File1

ZNI008
ZNI009
ZNI010
ZNI011
ZNI012

... over 19463 lines

The second file includes lines that match the items listed in first:
File2

copy /Y \\server\foldername\version\20050001_ZNI008_162635.xml \\server\foldername\version\folder\
copy /Y \\server\foldername\version\20050001_ZNI010_162635.xml \\server\foldername\version\folder\
copy /Y \\server\foldername\version\20050001_ZNI012_162635.xml \\server\foldername\version\folder\
copy /Y \\server\foldername\version\20050001_ZNI009_162635.xml \\server\foldername\version\folder\

... continues listing until line 51360

What I've tried so far:

grep -v -i -f file1.txt file2.txt > f3.txt

does not produce any output to f3.txt or remove any lines. I verified by running

wc -l file2.txt

and the result is

51360 file2.txt

I believe the reason is that there are no exact matches. When I run the following it shows nothing

comm -1 -2 file1.txt file2.txt

Running

( tr '\0' '\n' < file1.txt; tr '\0' '\n' < file2.txt ) | sort | uniq -c | egrep -v '^ +1'

shows only one match, even though I can clearly see there is more than one match.

Alternatively putting all the data into one file and running the following:

grep -Ev "$(cat file1.txt)" 1>LinesRemoved.log

says argument has too many lines to process.

I need to remove lines matching the items in file1 from file2.

i am also trying this in python:
 `

    #!/usr/bin/python
s = set()

# load each line of file1 into memory as elements of a set, 's'
f1 = open("file1.txt", "r")
for line in f1:
    s.add(line.strip())
f1.close()

# open file2 and split each line on "_" separator,
# second field contains the value ZNIxxx
f2 = open("file2.txt", "r")
for line in f2:
    if line[0:4] == "copy":
        fields = line.split("_")
        # check if the field exists in the set 's'
        if fields[1] not in s:
            match = line
        else:
            match = 0
    else:
        if match:
            print match, line,

`

it is not working well.. as im getting
'Traceback (most recent call last):
  File "./test.py", line 14, in ?
    if fields[1] not in s:
IndexError: list index out of range'


Wake up a QThread that is in sleep?

How can I wake up a QThread when it is sleeping?

I have a thread that is running in the background and now and then wakes up and does some small stuff, however if I would like to stop that thread in a controlled manner I have to wait for him to wake up by him self in order to make him quit. And since he is sleeping quite long this can be quite annoying.

Here is a little example code that show the basic problem.

Let's start with the thread that in this example sleeps for 5 seconds and then just prints a dot.

#include <QDebug>
#include "TestThread.h"

void TestThread::run()
{
    running = true;
    while(running == true)
    {
        qDebug() << ".";
        QThread::sleep(5);
    }
    qDebug() << "Exit";
}

void TestThread::stop()
{
    running = false;
}

Then we have the main that starts the thread and then kills him.

#include <QDebug>
#include "TestThread.h"

int main(int argc, char *argv[])
{
    qDebug() << "Start test:";
    TestThread *tt = new TestThread();

    tt->start();
    sleep(2);
    tt->stop();
    tt->wait();

    delete tt;
}

The problem is that the tt->wait(); must wait the 5s that the thread is sleeping.
Can I just call something like a "wakeup from sleep" so he can continue.

Or is there a better way to do this?

/Thanks

Update I got it working with a QMutex and the tryLock:

#include <QDebug>
#include "TestThread.h"

QMutex sleepMutex;

void TestThread::run()
{
    qDebug() << "Begin";
    //1. Start to lock
    sleepMutex.lock();
    //2. Then since it is locked, we can't lock it again
    //   so we timeout now and then.
    while( !sleepMutex.tryLock(5000) )
    {
        qDebug() << ".";
    }
    //4. And then we cleanup and unlock the lock from tryLock.
    sleepMutex.unlock();
    qDebug() << "Exit";
}

void TestThread::stop()
{
    //3. Then we unlock and allow the tryLock
    //   to lock it and doing so return true to the while
    //   so it stops.
    sleepMutex.unlock();
}

But would it be better to use the QWaitCondition? Or is it the same?

Update: The QMutex breaks if it is not the same tread that starts and stop him,
so here is a try with QWaitCondition.

#include <QDebug>
#include <QWaitCondition>
#include "TestThread.h"

QMutex sleepMutex;

void TestThread::run()
{
    qDebug() << "Begin";

    running = true;
    sleepMutex.lock();
    while( !waitcondition.wait(&sleepMutex, 5000) && running == true )
    {
        qDebug() << ".";
    }
    qDebug() << "Exit";
}

void TestThread::stop()
{
    running = false;
    waitcondition.wakeAll();
}


Secrecy of Firebase Cloud Messaging Server Key

I'm developing a smart home app that communicates with the smart home system on the local network (or via VPN). I would like to integrate with Firebase Cloud Messaging and would need a server. It's a free app that I don't make any money off, so I don't want to have a server to maintain and keep an eye on.

I'm thinking that the I could make the server available open-source on GitHub. I want the setup of the server to be as easy as doing a clone and running a single command. That leads me to the question: Can I leave my server key for the project in a public repos for others to use or what kind of abuse would that open for?

I see they (naturally) tell you to keep the server key a secret at https://firebase.google.com/docs/cloud-messaging/server#role , but I'm wondering if  that would be the case for me when it's okay for others to have their own instance of the server on their LAN where their own devices registers.


How to verify a login using MySqli

I'm trying to create a simple login with php and mysqli but keep receiving the error:
Fatal error: Call to a member function prepare() on a non-object in C:\wamp\www\web2\database.php on line 107

database.php

 <?php
class Database
{
 public $server = "localhost";
 public $database = "database";
 public $user = "root";
 public $password = "";
 public $row;
 public $result;
 public $sqlExtra = " ORDER BY firstname ASC";
 public $dbLocalHost;

 //call connection method upon constructing
 public function __construct(){
  $this->createConnection();
 }

 //connection to the database
 public function createConnection()
    {
     $this->dbLocalhost = new mysqli($this->server, $this->user, $this->password, $this->database)
                or die("could not connect:");

      //mysql_select_db($this->database)
       //
       //  or die("Could not find the database: ".mysql_error());

 }

    function verifyLogin($email, $password) {

        $query = "SELECT *
                FROM admint
                WHERE email = ?
                AND password = ?
                LIMIT 1";

 107.               $statement = $this->dbLocalHost->prepare($query);
        if($statement) {
            $statement->bind_param('ss', $email, $password);
            $statement->execute();

            if($statement->fetch()) {
                $statement->close();
                return true;
            }
            else {
                return false;
            }
        }

    }

    function addElement($table, $firstName, $lastName, $email, $mobile, $password,
                            $faculty, $campus) {

        $query = "INSERT INTO $table (first_name, last_name, email, mobile, password, faculty, campus_location)
                VALUES('$firstName', '$lastName','$email','$mobile',
                '$password','$faculty','$campus');";

        if($this->connection->query($query)) {
            header('location: regConfirm.php');
        }

    }

}

?>

login.php

 <?php
session_start();

require_once 'admin.php';
$admin = new Admin();

if(isset($_GET['status']) && $_GET['status'] == 'loggedout') {
    $admin->logOut();
}

if($_POST && !empty($_POST['email']) && !empty($_POST['password'])) {

    $valid = $admin->validateUser($_POST['email'], $_POST['password']);

    if($valid) {
        header("location: index.php");
    }
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
</head>

<body>
<div id="login">
    <form method="post" action="">
    <h1>Admin Login</h1>
    <p>
        Email:
        <input type="email" name="email" />
    </p>

    <p>
        Password:
        <input type="password" name="password" />
    </p>

    <p>
        <input type="submit" value="Login" name="Submit" />
    </p>

    </form>

</div>

</body>
</html>

admin.php

    <?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of admin
 *
 * @author Matt
 */
require 'database.php';
class admin {

   function logOut() {
        if(isset($_SESSION['status'])) {
            unset($_SESSION['status']);

            if(isset($_COOKIE[session_name()])) {
                setcookie(session_name(), '', time() - 1000);
                session_destroy();
            }
        }
    }

    function validateUser($email, $password) {
        $db = new Database();

        $verified = $db->verifyLogin($email, $password);

        if($verified) {
            $_SESSION['status'] = 'authorised';
            //header("location: index.php");
            return true;
        }
        else {
            return false;
        }
    }

    function confirmAdmin() {
        session_start();
        if($_SESSION['status'] != 'authorised')
            header("location: login.php");
    }
}

?>

sorry to be a bother, thanks.


Z3 Output of get-value

I have a problem with the generation of model values through get-value.
If I try to get the value of an array, I will get a value
containing internal z3 constants which are not printed. I know that
get-model would print those constants but I would like to stick
to using get-value.

Here is an example (I tried it on rise4fun):

(declare-const b (Array Int Int))
(declare-const a (Array Int Int))
(assert (= (store a 1 2) b))
(check-sat)
(get-value (b a))

returns:

sat ((b (_ as-array k!1)) (a (_ as-array k!0)))

The output with get-model is the following:

sat (model (define-fun b () (Array Int Int) (_ as-array k!1)) (define-fun a () (Array Int Int) (_ as-array k!0)) (define-fun k!0 ((x!1 Int)) Int 0) (define-fun k!1 ((x!1 Int)) Int (ite (= x!1 1) 2 0)) )

It contains the value of k!0 and k!1. Is it possible to substitute these in the values for a and b ?


need Help dokan and c# creating virtual disk

I want to create virtual disk using c# and dokan and I need code hint or api for  or I want to know how to work with them because when I search on google I didn,t to find and result


ModX: Resource alias not automatically inserting slash in URL

A weird one: I have a site using ModX and this morning when I went to preview a page after editing a got and error. It seems that ModX is no longer placing the / before the Resource Alias.

Thus my URL becomes mysite.comabout-us instead of mysite.com/about-us and doesnt work

Putting in the slash manually has no effect as ModX removes it on save.

Im running Revo 2.1.3

Would anyone know how to fix this? Thanks

EDIT:
Did some more testing and discovered this also occurs when I turn FURLs off


memcpy + pointers + java

I have seen there is no question that specifically reply to this combination of parameters:

Java + memcpy + pointers.

My background of C/C++ is probably biasing me.
In C++ I can do this:

memcpy (Destination, Source, length_data);

and Destination and Source can be just two memory locations.
Is there a way to do it in Java with arrays of primitive types?

All the realizations of

Arrays.copyOf
Arrays.copyOfRange

are basically doing half the job. In the sense that, you can specify the amount of data or a given range, but all of them give back one Array, they do not modify an existing one.

Thanks in advance.


jQuery UI slider doesn't show

I have installed the jQuery UI slider, but it doesn't show in my code. I don't see what I'm doing wrong.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Home Page</title>
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-ui-1.8.18.min.js" type="text/javascript"></script>
    <script src="/Scripts/modernizr-2.5.3.js" type="text/javascript"></script>

</head>
<body>
    <div class="page">
        <section id="main">
            <link href="/Content/themes/base/jquery.ui.slider.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">

    $(function () {
            ...
            $("#bwvolume").slider({
                value: 0,
                min: 0,
                max: 2500,
                step: 100,
                slide: function (event, ui) {
                    $("#spanbwvolume").val("$" + ui.value);
                }
            });
            $("#spanbwvolume").val("$" + $("#bwvolume").slider("value"));
        });
    </script>
   ...
        <tr class="format">
            <td width="150" valign="top" class="tdlabelNoSize">Volumes monochrome:</td>
            <td>
                <div id="bwvolume"></div>(<span id="spanbwvolume"></span>)
            </td>
        </tr>

     ...
</body>
</html>

There is some space allocated in the browser. But the slider doesn't show. My code is based on http://jqueryui.com/demos/slider/#steps.

This is what I see in FireBug:

<tr class="format">
<td class="tdlabelNoSize" width="150" valign="top">Volumes monochrome:</td>
<td>
<div id="bwvolume" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all">slider=Object { element={...}, options={...}, _keySliding=false, meer...}
<a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="left: 0%;"></a>index.uiSliderHandle=0
</div>
(
<span id="spanbwvolume"></span>
)
</td>
</tr>

FireBug doesn't report any errors.

Do I miss something like images or something? On the same page I'm using also jQuery UI Selectable (not shown in code) and this is working fine.


Create histogram of count frequencies in ggplot2

Let's say I have the following data frame:

d = data.frame(letter = c(
    'a', 'a', 'a',
    'b', 'b', 'b',
    'c',
    'd', 'd', 'd', 'd',
    'e', 'e',
    'f', 'f', 'f', 'f', 'f', 'f', 'f',
    'g'))

How can I use ggplot2 to make a histogram that does not count how many times a given letter occurs, but rather counts the number of times a given letter frequency occurs? In this example:

table(d$letter)

a b c d e f g
3 3 1 4 2 7 1

two letters (c and g) occur once, one letter (e) occurs twice, two letters occur three times, etc. Such that you can make a figure equivalent to the base plot:

hist(table(d$letter), right = F, breaks = 6)


I am getting rendering error in the latest android studio when trying to view the preview of an activity

Rendering Problems The following classes could not be instantiated:

android.support.v7.internal.widget.ActionBarOverlayLayout (Open
  Class, Show Exception, Clear Cache)

What can be done to solve this? I can't get any preview for my XML coding.


How can I push a div inside the profoundgrid "responsive fluid" style to the right?

I'm using the profound grid framework to build responsive fluid grid layout. Basically what I want to achieve is to create a layout containing 6 colums of which the menu container is on the left with 1 column width and the content is on the right with 5 columns width. Inside the content I have a nested grid that is also fluid.

I have the grid working as the responsive fluid example which can be found here: http://www.profoundgrid.com/examples/fluidresponsive.html

The scss code I have looks like this:

#row{
    div{@include column(6);}
    .col1{@include column(2);}
    .col5{@include column(10);}
    @include generate_grid_positions(div, 1);
}

The HTML looks like this:

<article id="row">
        <div id="menuContainer" class="col1">Menu <br />menu <br />menu</div>
        <div id="contentContainer" class="col5">
            <div id="projectContainer">
                <div class="project">project1</div>
                <div class="project">project2</div>
                <div class="project">project3</div>
                <div class="project">project1</div>
                <div class="project">project2</div>
                <div class="project">project3</div>
            </div>
            <div id="socialContainer">sadfgsdfg</div>
        </div>
    </article>

What I have right now is a fluid responsive grid, but both divs get stacked upon eachother. I would like to know how to push the content 2 columns to the right.


How to know the classes of a package in java?

Possible Duplicate:

  Can you find all classes in a package using reflection?

suppose I've a package name as string:

String pkgName = "com.forat.web.servlets";

How to know the types in this package?


Disabling specific interrupts on an ATtiny84a programmed using Arduino as an ISP?

I am programming an ATtiny84a using Arduino as the in-serial programmer. I am currently using two interrupt vectors: INT0_vect and TIM1_OVF_vect.

During my void loop() code, I would like to disable the 16-bit timer overflow interrupt. Would the following be the correct way of doing it?

void setup() {
  ...
  bitSet(TIMSK1, TOIE1);
  ...
}

void loop() {
  ...
  bitClear(TIMSK1, TOIE1);
  ...
}

If I am not mistaken, the mask register TIMSK1 bit 0 toggles the on/off status of the timer overflow interrupt, so simply clearing the respective bit will disable the interrupt, right? If not, is there a way to do it?

Datasheet for reference: http://ww1.microchip.com/downloads/en/DeviceDoc/doc8006.pdf


Editing a Perforce label's description through a script

I want to modify an existing Perforce label using a script that I can invoke automatically. Currently I know how to do it using the text editor option:

p4 label <label-name>

This opens up a temporary file in my default text editor, I can then enter a description, save the file and close - updates the label successfully.

However, I want to be able to do this automatically using a script. I will have variables that can be used to form my description.

I can use either a shell script or a bat script (on Windows but have Cygwin).

Perforce command line documentation on labels can be found here, but it's not helping me.

Any ideas?


How do I get the workbench window to open a modal dialog in an Eclipse based project?

In order to open a modal dialog, you need to pass a parent window, and pass the necessary flags for the dialog to be modal of course.

Depending on where you are in the eclipse infrastructure, finding this parent window is not always easy.

How can the parent window be accessed?


jQuery: Animate Knob inside FineUploader callback

I'm using jQuery libs FineUploader & Knob for a faux circular loading effect.

My current code is:

    $('.dial').val(0).trigger('change').delay(2000);
    var myKnob = $(".dial").knob({
        'min': 0,
        'max': 100,
        'readOnly': true,
        'width': 90,
        'height': 90,
        'fgColor': "47CBFF",
        'dynamicDraw': true,
        'thickness': 0.3,
        'tickColorizeValues': true,
        'skin': 'tron'
    })
     $('.dial').knob();
    $('#uploader-div').fineUploader({
        request: {
            endpoint: "/updateavatar",
            paramsInBody: true
        },
        debug: true,
        template: '<div class="qq-uploader">' + '<pre class="qq-upload-drop-area"><span>{dragZoneText}</span></pre>' + '<div class="qq-upload-button btn btn-success">{uploadButtonText}</div>' + '<span class="qq-drop-processing"><span>{dropProcessingText}</span><span class="qq-drop-processing-spinner"></span></span>' + '<ul class="qq-upload-list"></ul>' + '</div>',
    }).on('submit', function (event, id, name, responseJSON) {
        $('.qq-uploader').css({
            'background': 'rgba(0,0,0,.3'
        });
        $('canvas').fadeIn();
        $({
            value: 0
        }).animate({
            value: 75
        }, {
            duration: 3000,
            easing: 'swing',
            step: function () {
                $('.dial').val(Math.ceil(this.value)).trigger('change');
            }
        });
    }).on('complete', function (event, id, name, responseJSON) {
        $({
            value: 75
        }).animate({
            value: 100
        }, {
            duration: 1000,
            easing: 'swing',
            step: function () {
                $('.dial').val(Math.ceil(this.value)).trigger('change');
            }
        });
        $('canvas').fadeOut();
        var image = $('#profile-pic img').attr('src');
        $('#profile-pic img').fadeOut(function () {
            $(this).attr('src', image).fadeIn('slow')
        });
    });

The problem is that the "complete" function will run before the 'loader' is finished animating the 75%.

I want the "complete" callback to wait until the animation finishes...

As a bonus, I would like the animation to actually take the correct valums fineuploader percentage so I don't have to fake it!

Can I help you understand better? Let me know!


MVC 4 Error 404 on Created View

I have this controller:

[Authorize]
public class CheckoutController : Controller
{

    ShoppingCartContext storeDB = new ShoppingCartContext();
    const string PromoCode = "FREE";

    [HttpPost]
    public ActionResult AddressAndPayment(FormCollection values)
    {
        var order = new Order();
        TryUpdateModel(order);

        try
        {
            if (string.Equals(values["PromoCode"], PromoCode,
                StringComparison.OrdinalIgnoreCase) == false)
            {
                return View(order);
            }
            else
            {
                order.Username = User.Identity.Name;
                order.OrderDate = DateTime.Now;

                //Save Order
                storeDB.Orders.Add(order);
                storeDB.SaveChanges();
                //Process the order
                var cart = Models.ShoppingCart.GetCart(this.HttpContext);
                cart.CreateOrder(order);

                return RedirectToAction("Complete",
                    new { id = order.OrderId });
            }
        }
        catch
        {
            //Invalid - redisplay with errors
            return View(order);
        }
    }

    public ActionResult Complete(int id)
    {
        // Validate customer owns this order
        bool isValid = storeDB.Orders.Any(
            o => o.OrderId == id &&
            o.Username == User.Identity.Name);

        if (isValid)
        {
            return View(id);
        }
        else
        {
            return View("Error");
        }
    }

}

And I have created a View called AddressAndPayment under Checkout, so it goes to localhost/Checkout/AddressAndPayment but I only get a 404 error, even if I right click on the View and click on view in Page Inspector. I don't know why its not even showing the view when it is created.


Capitalize the first letter of every word in a filename or directory in Shell

I'm trying to write a shell command where I can specify a directory, and then every file and directory inside will have the first letter of every word capitalized. So

/doCumenTS/tesT.txt

should change to

/DoCumenTS/TesT.txt

I'm thinking it should start like

for i in directory do
tr something_goes_here
done

The problem I can't figure out is how to only do the first letter. I've made a script that uppercase the whole file name, but I can't figure out how to only get the first letter of every word.

Thanks!


Nesting SAX ContentHandlers

I would like to parse a document using SAX, and create a subdocument from some of the elements, while processing others purely with SAX.  So, given this document:

  <DOC>
    <small>
      <element />
    </small>
    <entries>
      <!-- thousands here -->
    </entries>
  </DOC>

I would like to parse the DOC and DOC/entries elements using the SAX ContentHandler, but when I hit <small> I want to create a new document containing just the <small> and its children.

Is there an easy way to do this, or do I have to build the DOM myself, by hand?


double free or corruption(fasttop)

Hello guys I have an array resizing function like this

int
add_time_element (time_t *array, time_t element, size_t *size)
{
    if (NULL == array)
    {
        return STATUS_FAIL;
    }

    int status = STATUS_SUCCESS;
    time_t *tmp = NULL;
    size_t local_size;

    (*size)++;
    local_size = *size;

    printf ("Local size %lu\n", local_size);

    tmp = realloc (array, local_size * sizeof (time_t));
    if (NULL == tmp)
    {
        status = STATUS_FAIL;
    }
    else
    {
        array = tmp;
    }

    if (STATUS_FAIL == status)
    {
        (*size)--;
    }
    else
    {
        array[local_size - ONE] = element;
    }

    return status;
}

I am calling this function like this..

  time_t *dates = NULL;
    dates = malloc (ONE);
    for (slot_index = ZERO; slot_index < data_provider->n_slots; slot_index++)
    {
        printf ("Testing\n");
        /*slot = data_provider->slots[slot_index];
        date = get_date (slot->start_time);*/
        date += ONE;
        if (STATUS_FAIL ==  add_unique_time_element (dates, date, &n_dates))
        {
            free (dates);
            dates = NULL;
            return STATUS_FAIL;
        }
    }

I am getting the double free(fasttop) error in realloc function..

And valgrind analysis report says

Invalid free() / delete / delete[] / realloc()
==22491==    at 0x4C2DD9F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22491==    by 0x402BA3: add_time_element (array_util.c:353)
==22491==    by 0x402C6C: add_unique_time_element (array_util.c:399)
==22491==    by 0x401F92: create_dates (data_provider.c:283)
==22491==    by 0x401D7D: create_data_provider_file (data_provider.c:174)
==22491==    by 0x4075CC: main (data_provider_test.c:13)
==22491==  Address 0x5b63170 is 0 bytes inside a block of size 1 free'd
==22491==    at 0x4C2DD9F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22491==    by 0x402BA3: add_time_element (array_util.c:353)

Please help.


Javascript Variable Scope

I'm having issues with a javascript global variable (called TimeStamp) not being defined onload...at least I think that's the problem.

I start with this, defining TimeStamp.

        $(document).ready(function(){
        // AddTest();
        var TimeStamp = null;
        waitForMsg();
    });

...waitForMsg then runs using TimeStamp and updated it on successful completion of the ajax call. At least that's the idea, but at the moment nothing runs because "TimeStamp is not defined"...even though I defined it earlier! (urgh).

If I re-define Timestamp within waitForMsg it just gets reset instead of using the updated value from the successfull ajax function.

    function waitForMsg(){

    $.ajax({
        type: "POST",
        url: "backend.php",
        async: true,
        cache: false,
        timeout:50000, /* Timeout in ms */
        data: "TimeStamp=" + TimeStamp,
        success: function(data){

            var json = eval('(' + data + ')');

            $('#TextHistory :last-child').after('<p>' + json['msg'] + '</p>');

            TimeStamp = json['timestamp'];

            setTimeout(
                'waitForMsg()', /* Request next message */
                1000            /* ..after 1 seconds */
            );
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){

            $('#TextHistory :last-child').after('<p>' + errorThrown + '</p>');

            setTimeout(
                'waitForMsg()', /* Try again after.. */
                "15000");       /* milliseconds (15seconds) */
        },
    });
};

As always any help is greatly appreciated.

Dan.


I want to convert vb this code

I want to convert vb this code

<?php
// Where the file is going to be placed
$target_path = "uploads/";

/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']).
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
    echo "filename: " .  basename( $_FILES['uploadedfile']['name']);
    echo "target_path: " .$target_path;
}
?>

please explain your scenario more clearly.


waypoints between one terminal to another terminal required

hi i am writing a google map api code by which i am getting waypoints between origin to destination,code works fine it's give only those waypoints which has terminal (in below image marked as ire ,re , ice, cnl)  .As you see there is lots of distance between 'cnl' and point 'B'. so i want more waypoints between 'CNL' and 'B'. can anybody tell me how i can get this?

i am using this request

  var request = {
  origin: start,
  destination: end,
  travelMode: google.maps.TravelMode.TRANSIT
   };

and this thing for showing waypoints.

          for (var j = 0; j < myRoute.legs.length; j++) {
      for (var i = 0; i < myRoute.legs[j].steps.length; i++) {
          path=path+myRoute.legs[j].steps[i].start_point+"|";
      }
      }


Configure Group Policy

I'm a programmer, which to write my first program, i already write it... and now I'm providing user interface and the side things which i wish to do automatically instead of making user to do all of them manually...

The problem i have is to Configure Group Policy, i find some of codes but I'm unable to understand them...

what i now looking for is any class library or code i can use them to do these changes...

http://www.watchdirectory.net/wdhelp/plugins/wdopAuditInfoConf.html

...through C#

please if you reference to a code, provide a sample usage, because i also find many codes, which i didn't know how to use, and mostly i didn't know what kinda value i should pass to them... :|

Thank you,
Hassan F.


How to create general lists / template lists in C#

I have one main class with several inherited members who all overload the same Draw method of the parent class, but have different Initialize methods. Is it somehow possible to use the same list type for every inherited class, and thus be able to iterate through the Draw-methods? I am pretty sure you can do this with templates in C++, but can't seem to find a way to do it in C#. Here is an example:

class MainMenu : ExpandingWindow{
   Init(A,B)
   Draw(D)
}

class SideMenu : ExpandingWindow{
   Init(A,B,C)
   Draw(D)
}

I want to be able to do:

 WindowList List<ExpandingWindow>

 WindowList.Add(new MainMenu)
 WindowList.Add(new SideMenu)

 WindowList[0].Initialize(A,B)
 WindowLIst[1].Initialize(A,B,C)

And:

 for each window in WindowList{
   window.Draw(D)
 }

I am pretty sure I'm missing something here. I do not have to do it in this exact manner, I am rather looking for general way of handling these situations well.

Thanks!


Chrome extenssion: Getting URL domain name

I am new to chrome-extension development and just read a sample "hello world" example.
Advancing, I would like to create a chrome-extension, which gets and pops the URL name to be accessed, on a pop-up window. How will I do this? I think this is more related to javascript coding, but still, how will I accomplish this?

Thanks in advance!


Getting error while sorting records in descending order by Id with orderby clause in Angular js

I am trying to display my records in descending order of my Id property.

But getting error below in browser console:

[orderBy:notarray] Expected array but received:
  {"name":"Abc","EmailId":"Abc@yahoo.com","Salary":4000}

This is my code:

 <table>
       <tr>
          <td ng-repeat="item in User " ng-if="$odd" >
          </td>
       </tr>
    </table>

    <table>
       <tr>
          <td ng-repeat="item in User " ng-if="$even" >
          </td>
       </tr>
    </table>

             <tr ng-repeat="item in User | orderBy: '-Id'    ">
             </td>

 function Displaydata() {
        MyService.getList().then(
        function (data) {
            $scope.User = data
           }, function (reason) {
      })
    }

Json Output:

    [
            {
              "Id":5,
             "name": "Abc",
             "EmailId": "Abc@yaoo.com",
             "Salary" : 4000
            },
            {
          "Id":11,
             "name": "YYY",
             "EmailId": "Abc@yaoo.com",
             "Salary" : 4000
            },
            {
              "Id":7,
             "name": "III",
             "EmailId": "Abc@yaoo.com",
             "Salary" : 4000
            },
            {'
              "Id":3,
             "name": "WWW",
             "EmailId":"Abc@yaoo.com",
             "Salary" : 4000
            }
           ]


Issue setting up the development environment for ProjectTango developemnt Device

I have a Project Tango development Kit. I am interested in working on the depth data from the sensors.
I have ADB setup on my machine. But the Eclipse android emulator doesn't detect the Tango Development tablet.

Can anyone suggest me how to set things up for the device!.

Thank you in advance.


Mongoose plugin to assign extra data to a field but not saving to database

I am trying to write a plugin that should return extra data by setting on a field tags already saved to model instead of saving set data on tags to database and return.
Here is plugin code.

module.exports = function samTagsPlugin(schema, options) {
    schema.post('init', function () {
        document.set('tags', ['a', 'b', 'c']);
    });
};

But, the tags field is saved to mongodb with the values ['a', 'b', 'c']. Is there any way I can just assign dynamic value to tags and mongoose do not save the provided value to database?
Mongoose version I am using is 3.8.x.


How to know if DB exists from within Rake task

How do i find out if the database exists from within a rake task?

that is, i'd like to do something like:

  task :drop_and_create => :environment do
    Rails.env = "development"
    if (db_exists?)
      Rake::Task["db:drop"].invoke
    end
    Rake::Task["db:create"].invoke
    #more stuff...
  end

how do i write the db_exists? condition?


SQL Server Mgmt Studio shows "invalid column name" when listing columns?

I'm used to scripting in Python or Matlab, and my first couple hours with SQL have been infuriating.  I would like to make a list of columns appear on the screen in any way, shape, or form; but when I use commands like

select *
from "2Second Log.dbo.TagTable.Columns"

I keep getting the error:

Invalid column name '[the first column in my table]'.

even though I never explicitly asked for [the first column in my table], it found it for me.  How can you correctly identify the first column name, and then still claim it's invalid!?  Babies will be strangled.

This db was generated by Allen Bradley's FactoryTalk software. What I would really like to do is produce an actual list of "TagName" strings...but I get the same error when I try that.  If there were a way to actually double click the table and open it up and look at it (like in Matlab), that would be ideal.


Xcode 4: Missing File's Owner with Storyboard?

I started a new project under Xcode 4.5. I accepted the default wizard settings, which included a storyboard.

I went to make connections and the File's Owner is missing.

I'm not sure what I did to end up in this configuration. As far as UI components, I added a scroll view in place of the original view. I had some trouble with Vertical Constraints, but I did not do anything drastic.

I tried to Google for the issue, but only got back two results: http://www.google.com/#q=xcode+4+%22missing+file+owner+%22.

How does one go about adding a file's owner to a storyboard.

UPDATE: For others who find this Stack Overflow article, its time to do Apple App's 101 again: Creating Your First iOS App. It looks like Hillegass and LeMarche have not yet caught up with the 6.0 SDK. There are no books on Amazon as of January, 2013.


Jquery Event Calendar with tool tip

Can somebody suggest me a good jquery calender with tooltip.


Fetch data from Google Analytics API

What I Want: The website should show the analytics data without Authorization.

What I Did: I have a app on google app engine and enabled API and created service account which gave a json file.

I tried to do same as: https://ga-dev-tools.appspot.com/embed-api/custom-components/ but didn't succeed.

Then I came across this issue: http://code.google.com/p/analytics-issues/issues/detail?id=496 and changed my code as this

<!DOCTYPE html>
<html>
<head>
  <title>Embed API Demo</title>
</head>
<body>

<!-- Step 1: Create the containing elements. -->

<section id="auth-button"></section>
<section id="view-selector"></section>
<section id="timeline"></section>

<!-- Step 2: Load the library. -->

<script>
(function(w,d,s,g,js,fjs){
  g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(cb){this.q.push(cb)}};
  js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];
  js.src='https://apis.google.com/js/platform.js';
  fjs.parentNode.insertBefore(js,fjs);js.onload=function(){g.load('analytics')};
}(window,document,'script'));
</script>

<script>
gapi.analytics.ready(function() {

  // Step 3: Authorize the user.

  gapi.analytics.auth.authorize({
    serverAuth: '<server auth key>'
  });

  // Step 4: Create the view selector.

  var viewSelector = new gapi.analytics.ViewSelector({
    container: 'view-selector'
  });

  // Step 5: Create the timeline chart.

  var timeline = new gapi.analytics.googleCharts.DataChart({
    reportType: 'ga',
    query: {
      'dimensions': 'ga:date',
      'metrics': 'ga:sessions',
      'start-date': '30daysAgo',
      'end-date': 'yesterday',
    },
    chart: {
      type: 'LINE',
      container: 'timeline'
    }
  });

  // YOU MUST CALL THIS MANUALLY HERE INSTEAD OF WAITING FOR CALLBACK
  viewSelector.execute();

  // Step 6: Hook up the components to work together.

  gapi.analytics.auth.on('success', function(response) {
    viewSelector.execute();
  });

  viewSelector.on('change', function(ids) {
    var newIds = {
      query: {
        ids: ids
      }
    }
    timeline.set(newIds).execute();
  });
});
</script>
</body>
</html>

I tried seeing couple of documents to get server auth key, but I failed getting it.

Can anyone help in setting the server auth key and by this will my purpose of displaying charts without authentication will resolved?

Thanks,
Sharad Soni


Error with bat file token or for loop: not recognized as an internal or external command, operable program or batch file

Need Windows .bat file tech support.
I am having trouble running Win 7 bat files which loop through tokens and variables. The script below works on my wifes PC, and should on all PCs, but does not on mine.

** I am running Windows 7 in VMWare off my Mac.

The file is located at the root of c:

This short little script, and any others like it with tokens gives me errors ( I copied the script below out of the .bat file ):

setLocal ENABLEDELAYEDEXPANSION
set SCHEMA_one= first
set SCHEMA_two= second
set SCHEMA_three= third

@ECHO ON
FOR /F "tokens=2* delims=_=" %%A IN ('set SCHEMA_') DO (
    echo "looping through " %%A
)
endLocal

I get the following error:

C:\>FOR /F "tokens=2* delims=_=" %A IN ('set SCHEMA_') DO (echo "looping through " %A )
'set SCHEMA_' is not recognized as an internal or external command, operable program or batch file.

Ideas???

Many thanks in advance. I have been stuck for hours and hours...


How to get an analyzed term from a TokenStream in Lucene.NET 4.8

I am using the following lines of code to extract an analyzed term from a TokenStream in Lucene.NET 4.8 but getting runtime errors.

var analyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);
TokenStream tokenStream = analyzer.TokenStream(null, new StringReader("myterm"));

tokenStream.Reset();
while (tokenStream.IncrementToken())
{
    var termAttr = tokenStream.GetAttribute<ITermAttribute>();
    var analyzedTerm = termAttr.Term;
}
tokenStream.End();
tokenStream.Dispose();

Exception thrown: An unhandled exception of type 'System.ArgumentException' occurred in Lucene.Net.dll and Additional information: this AttributeSource does not have the attribute 'ITermAttribute'

I´ve used the same approach in other versions of Lucene.NET which works fine.

Lucene.NET 3.0.3

var analyser = new StandardAnalyzer(Version.LUCENE_30);
var tokenStream = analyzer.TokenStream(null, new StringReader("myterm"));

tokenStream.Reset();
while (tokenStream.IncrementToken())
{
    var termAttr = tokenStream.GetAttribute<ITermAttribute>();
    var analyzedTerm = termAttr.Term;
}
tokenStream.End();
tokenStream.Dispose();

Lucene.NET 2.9.4.1

var analyser = new StandardAnalyzer(Version.LUCENE_29);
var tokenStream = analyser.TokenStream(null, new StringReader("myterm"));

tokenStream.Reset();
while (tokenStream.IncrementToken())
{
    var termAttr = tokenStream.GetAttribute(typeof(TermAttribute));
    var analyzedTerm = termAttr.ToString();
}
tokenStream.End();
tokenStream.Close();

Anyone who has done this in Lucene.NET 4.8?


QTP I want to split that number into 13

below number has length of 39, I want to divide that to length 13 and Want to get that values. So I should get 3 values like A =0001098600250, b = 0001098600602, c=0001098600763. Can you please help me regarding this.  000109860025000010986006020001098600763


SSRS / MDX - Extra row for reversal charge

I have a financial report in SSRS that runs off an MDX query. The report is run, exported to Excel, then loaded into a financial system, like SAP.

I need to include a "reversal" row, for charges that fall in a certain category. For example (below) for anything with a "Type" of "Product Freight", I also want to include an EXTRA row, with a NEGATIVE value, essentially reversing the charge in the report.

This:

| Charge           | Account | Type            | Invoice | GST |
|------------------|---------|-----------------|---------|-----|
| Apple            | 123     | Product         | $100    | $10 |
| Banana           | 123     | Product         | $200    | $20 |
| Orange           | 456     | Product         | $150    | $15 |
| Orange (Freight) | 456     | Product Freight | $50     | 0   |

Would become this:

| Charge           | Account | Type            | Invoice | GST |
|------------------|---------|-----------------|---------|-----|
| Apple            | 123     | Product         | $100    | $10 |
| Banana           | 123     | Product         | $200    | $20 |
| Orange           | 456     | Product         | $150    | $15 |
| Orange           | 456     | Product Freight | $50     | 0   |
| Orange (Freight) | 456     | Product Freight | ($50)   | 0   |

UPDATE

This is a simple version of the MDX query:

WITH MEMBER measures.[Charge] AS
  [Charge].[Charge All].CurrentMember .member_name

MEMBER measures.[Account] AS
  [Account].[Account All].CurrentMember .member_name

MEMBER measures.[ChargeType] AS
  [Charge Type].[Charge Type Group].CurrentMember .member_name

MEMBER measures.[GST] AS
  ( [Charge Type].[Charge Type Class].&[GST], measures.[value] )

MEMBER measures.[InvExcGST] AS
  measures.[Value] - measures.[GST]

SELECT
{
measures.[Charge],
measures.[Account],
measures.[ChargeType],
measures.[InvExcGST],
measures.[GST]
}
ON 0,

NON EMPTY
[Charge].[Charge All].[All].Children *
[Account].[Account all].[all].Children *
[Charge Type].[Charge Type Group].[All].Children
HAVING measures.[Value] <> 0
ON 1

FROM CubeName


How can validate either one of the textfields to be filled in Yii

I'm new to Yii framework. Now in my form I have two fields FirstName and LastName.
I want to validate such that either of the two is filled. i.e not both should be empty.
Suppose the user leaves both the fields empty it should not allow submit. The user should atleast enter any of these fields.

Rules

public function rules()
        {
                return array(

                        array('Firstname,Lastname, email, subject, body', 'required'),
                        array('email', 'email'),
                        array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
                );
        }

How can I do this?


the type or namespace name 'Management' does not exist in the namespace 'MicrosoftSqlServer' are you missing an assembly reference

I am using:

using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;

I am using the above namespaces for restore database from c# window form, but the compiler tell me

The type or namespace name 'Management' does not exist in the
  namespace 'MicrosoftSqlServer' are you missing an assembly reference

And I follow some advice from Google,  found the DLL in  C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies:

Microsoft.SqlServer.Smo.dll;
Microsoft.SqlServer.ConnectionInfo.dll

and I copy them and paste them to all the location in my project, but I still have error message from compiler.

Could anyone where I can put the reference to?


Different solutions while integrating stiff equation

I am trying to integrate Rosenzweig-MacArthur model (equations) using Backward Differentiation Method using CVODE in C for stiff equations. I have to specify tolerance value for integration. Depending on the tolerance value I give, I get different solutions. I am not able to see which one is the correct solution. Can you please tell me what should (criteria for choosing) the tolerance value be?


JavaScript: Displaying and updating text arrays

Trying to put a paragraph together on canvas with JavaScript from multiple user specified variables. I start off with...

function special01() {
    //clean slate
    ctxx.clearRect(0, 0, ctx.width, ctx.height);

    //navigations important
    drawNav();

   //lets begin

    var newSlate = "You're feeling colorChoice today!";
    document.getElementById("displayed").innerHTML =
        newSlate;
    if (user.color == 'blue') {
    var array = newSlate.replace("colorChoice", "blue")
    }
    else if (user.color == 'red') {
    etc..etc..
    };
}

I seem to be forgetting something, and being just a hobbyist, I'm not sure what.  Essentially I'm just trying to replace colorChoice with blue when blue has been selected by the user.  The selection and user.color is updating correctly when selected.


Send data to com port virtually

I'm writing a Mathlab programe for get input from a serial port.

serPort = serial('COM5','BaudRate', 57600);
fopen(serPort);
.....

Now i want to check this programe with virtual com port(COM5) and sent data to the port virtually.
Can someone suggest a software to do this.
(Everything is in the same computer)


Screen.Cursor in Firemonkey

In Delphi 6, I could change the Mouse Cursor for all forms using Screen.Cursor:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Screen.Cursor := crHourglass;
end;

I am searching the equivalent in Firemonkey.

Following function does not work:

procedure SetCursor(ACursor: TCursor);
var
  CS: IFMXCursorService;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXCursorService) then
  begin
    CS := TPlatformServices.Current.GetPlatformService(IFMXCursorService) as IFMXCursorService;
  end;
  if Assigned(CS) then
  begin
    CS.SetCursor(ACursor);
  end;
end;

When I insert a Sleep(2000); at the end of the procedure, I can see the cursor for 2 seconds. But the Interface probably gets freed and therefore, the cursor gets automatically resetted at the end of the procedure. I also tried to define CS as a global variable, and add CS._AddRef at the end of the procedure to prevent the Interface to be freed. But it did not help either.

Following code does work, but will only work for the main form:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Application.MainForm.Cursor := crHourGlass;
end;

Since I want to change the cursor for all forms, I would need to iterate through all forms, but then the rollback to the previous cursors is tricky, as I need to know the previous cursor for every form.

My intention:

procedure TForm1.Button1Click(Sender: TObject);
var
  prevCursor: TCursor;
begin
  prevCursor := GetCursor;
  SetCursor(crHourglass); // for all forms
  try
    Work;
  finally
    SetCursor(prevCursor);
  end;
end;


Comparing histograms without white color included OpenCV

Is there a way that compares histograms but for example white color to be excluded and so white color doesn't affect onto the comparison.


MongoDB extension is not working in Wamp

I want to use MongoDB in my Symfony2 project. I added in composer.json (required section)

    "doctrine/mongodb": "1.2.*@dev",
    "doctrine/mongodb-odm": "1.0.*@dev",
    "doctrine/mongodb-odm-bundle": "3.0.*@dev"

But when I updated composer, an error occurred

Problem 1
- Installation request for doctrine/mongodb 1.2.*@dev -> satisfiable by doctrine/mongodb[1.2.x-dev].
- doctrine/mongodb 1.2.x-dev requires ext-mongo >=1.2.12,<1.6-dev -> the requested PHP extension mongo is missing from your system.

I am using Wamp and I added (as indicated in this post) php_mongo.dll in the ext directory. phpinfo() function indicates that Mongo is available
When I press the Wamp button, "php_mongo" extension appears.
However, when I execute php -m, mongo extension isn't listed.

C:\wamp\www>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File:         C:\wamp\bin\php\php5.4.16\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

I don't have any file like php.ini in the C:\Windows directory.


How often to call DataContext.SubmitChanges() for a large number of inserts?

How many InsertOnSubmit should I call before calling SubmitChanges? I'm adding data from a web service that can return tens of thousands of records one record at a time. The wrapper class around the web service exposes the records a an IEnumberable collection to hide an elaborate chunking mechanism.

Are there guidelines on how many inserts I should accumulate before submitting them?


How to turn on the visibility of a <a> which is on the cluster manager page from code behind file?

Here is the snippet of the code inside my cluster manager page.

<section id="login">
    <asp:LoginView runat="server" ViewStateMode="Disabled">
        <AnonymousTemplate>
            <ul>
                <li><a id="loginLink" runat="server" href="~/Login.aspx">Log in</a></li>
                <li><a id="logoutLink" runat="server" href="#" visible="false">Logout</a></li>
            </ul>
        </AnonymousTemplate>
    </asp:LoginView>
</section>

I would like to turn on the visibility of hyperlink with the id of #logoutlink from one of my pages' code behind file. I tried this way but didn't work.

protected void Page_Load(object sender, EventArgs e)
{
    HyperLink x = (HyperLink)ClusterManager.FindControl("logoutLink");
    x.Visible = true;
}

Any help would be appreciated.


How do I combine these two tables so I have one which  displays both State and Zip code?

I have two queries that find both the Zip codes, and the States for all the respondents in our database. Here they are

For ZIP code:

select top 100  S.ID as SurveyID, S.SID, S.SurveyNumber, S.ABCSurveyName, SE.RespondentID, Q.name as QuestionName, rp.Condition as ZipCode
from Surveys S
    join Sessions SE
        on S.id = SE.SurveyID
    join RespondentProfiles rp
        on RP.RespondentID = SE.RespondentID
    join Questions Q
        on Q.ID = rp.QuestionID
where q.name = 'ZIP'
        and S.ID = 13900
        and Q.LK_RecordStatusID = 1

For state:

select VW.ID as SurveyID, VW.SID, SurveyNumber, ABCSurveyName, RespondentID, VW.Name as QuestionName, st.Code as State
from (
    select top 100 S.ID, S.SID, S.SurveyNumber, S.ABCSurveyName, SE.RespondentID, Q.name, rp.Condition
    from Surveys S
        join Sessions SE
            on S.id = SE.SurveyID
        join RespondentProfiles rp
            on RP.RespondentID = SE.RespondentID
        join Questions Q
            on Q.ID = rp.QuestionID
    where S.ID = 13900
            and q.name = 'STATE'
            and Q.LK_RecordStatusID = 1

) VW
    join LK_States st
        on st.ID = vw.Condition

This works, but I'd like to have them all in one table, i.e. Zip Code and State.

Thanks!

questions schema:

Column_name Type    Computed    Length  Prec    Scale   Nullable

TrimTrailingBlanks  FixedLenNullInSource    Collation
ID  int no  4   10      0       no  (n/a)   (n/a)   NULL
SID nvarchar    no  128                 yes (n/a)   (n/a)   SQL_Latin1_General_CP1_CI_AS
Name    nvarchar    no  64                  yes (n/a)   (n/a)   SQL_Latin1_General_CP1_CI_AS
QuestionIdentifier  nvarchar    no  128                 yes (n/a)   (n/a)   SQL_Latin1_General_CP1_CI_AS
ParentID    int no  4   10      0       yes (n/a)   (n/a)   NULL
LK_QuestionTypeID   int no  4   10      0       yes (n/a)   (n/a)   NULL
LK_QuestionCategoryID   int no  4   10      0       yes (n/a)   (n/a)   NULL
LK_IndustryID   int no  4   10      0       yes (n/a)   (n/a)   NULL
OptionMask  nvarchar    no  512                 yes (n/a)   (n/a)   SQL_Latin1_General_CP1_CI_AS
MetaTags    ntext   no  16                  yes (n/a)   (n/a)   SQL_Latin1_General_CP1_CI_AS
Order   int no  4   10      0       yes (n/a)   (n/a)   NULL
Rows    int no  4   10      0       yes (n/a)   (n/a)   NULL
Columns int no  4   10      0       yes (n/a)   (n/a)   NULL
IsDisplay   bit no  1                   yes (n/a)   (n/a)   NULL
AnswerLifespan  int no  4   10      0       yes (n/a)   (n/a)   NULL
CreateUserID    int no  4   10      0       yes (n/a)   (n/a)   NULL
CreateDate  datetime    no  8                   yes (n/a)   (n/a)   NULL
UpdateUserID    int no  4   10      0       yes (n/a)   (n/a)   NULL
UpdateDate  datetime    no  8                   yes (n/a)   (n/a)   NULL
LK_RecordStatusID   bit no  1                   yes (n/a)   (n/a)   NULL
LK_QuestionClassID  int no  4   10      0       yes (n/a)   (n/a)   NULL
LK_QuestionVisibilityID int no  4   10      0       yes (n/a)   (n/a)   NULL
DisplayLK_QuestionTypeID    int no  4   10      0       yes (n/a)   (n/a)   NULL


I am writing a script to embed Youtube or vimeo videos into magento product page

Youtube embed code has letters and vimeo embed code has numbers example v?cVxmbd5 and Vimeo is like Vimeo.com/6847539 . I am writing a script to pull the end of embed strings with letters to match it with top iframe and pull end of embed strings with no letters to match with bottom iframe.

This script is supposed to embed videos into a video tab on the product view page.

<?php
$_product = $this->getProduct();
if ($_product->getVideo())
$videos = explode(', ', $_product->getVideo());

foreach ($videos as $video) {

if (ctype_digit($video)) {
echo "<iframe width = '560' height = '315' style = 'max-width:100%;' src = 'https://player.vimeo.com/video/" . $video . "' frameborder = '0' allowfullscreen></iframe>";
} else {

  echo "<iframe width = '560' height = '315' style = 'max-width:100%;' src = 'http://www.youtube.com/embed/" . $video . "' frameborder = '0' allowfullscreen></iframe>";

}
}

?>


How do I show my database data into TableView?

I am trying to show my database data into TableView. I have a database named info and there is two columns 'fname' and 'lname' into the table 'data'. I am trying to show the data into tableview format. I've tried the following code-

package imran.jfx.application;

import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;

public class Controller implements Initializable {

    @FXML
    private TableView<?> dataView;

    @FXML
    private TableColumn<?, ?> english;

    @FXML
    private TableColumn<?, ?> bangla;

    @FXML
    private Button getData;

    ResultSet result;
    PreparedStatement doQuery;
    Connection conn;
    String query;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        try {
            Class.forName("org.sqlite.JDBC");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        String url = "jdbc:sqlite::resource:database/info.db";
        try {
            conn = DriverManager.getConnection(url);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @FXML
    void showData(ActionEvent event) throws SQLException {
        query="select fname,lname from data";

        ResultSet result = conn.createStatement().executeQuery(query);

        while (result.next())
        {
            //Can't understand how should I write here to show the data
        }
    }
}

How should I do it?


cPanel Cron Job Run PHP File

I am trying to get my cronjob to work in cPanel.

I want to run the PHP file located at http://www.mydomain.com/path/cron-job.php

But it have to include ?code=something

So it would be this: http://www.mydomain.com/path/cron-job.php?code=something

I tried using the following commands:
php -q /home/mydomain/public_html/path/cron-jpb.php?code=something >/dev/null

and

/usr/bin/php -q /home/mydomain/public_html/path/cron-jpb.php?code=something >/dev/null

But all without luck.. Any ideas what could be wrong?


Can I use a combo box to change the voice of my speech synthesizer to one of the system TTS voices?

I would like to have a combo box on my form which allows the user to select the voice which they would like to use. How can I implement such a feature?

Currently, my form consists of four buttons and a combo box. The code behind the buttons and the synthesizer is as follows:

private void button1_Click(object sender, EventArgs e)
        {
            reader.Dispose();
            if (Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text != "")
            {
                reader = new SpeechSynthesizer();
                reader.SpeakAsync(Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text)
                button2.Enabled = true;
                button4.Enabled = true;
                reader.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(reader_SpeakCompleted);
            }
            else
            {
                MessageBox.Show("Please insert text before launching Text to Speech.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        void reader_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
        {
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;
        }
 private void button2_Click(object sender, EventArgs e)
        {
            if (reader != null)
            {
                if (reader.State == SynthesizerState.Speaking)
                {
                    reader.Pause();
                    button3.Enabled = true;
                }
private void button3_Click(object sender, EventArgs e)
        {
            if (reader != null)
            {
                if (reader.State == SynthesizerState.Paused)
                {
                    reader.Resume();
                }
                button3.Enabled = false;
            }
            }

        private void button4_Click(object sender, EventArgs e)
        {
            if (reader != null)
            {
                reader.Dispose();
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
            }

I would like to populate a combo box with a list of currently installed voices, which, when the user clicks one, reads the text from richTextBoxPrintCtrl1 in the selected voice. Currently, the synthesizer works, but I would like to add this feature to my Text to Speech feature.

Thanks.


django admin registering dynamic model from action

I have strange problem. In admin.py I can say:

admin.site.register(MyModel)

and this is obviously fine. Now I want this model to be loaded automatically as an result of user action:

def user_action_from_admin_panel(......):
    .....
    admin.site.register(MyModel)

MyModel class gets shows up in the admin as plain text without links.
Any ideas to solve this?


No 'seek_preroll' and 'codec_delay' in audio header

When SB_API_VERSION is not less than SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER, 'codec private' for Opus has been passed to starboard.

But I am not very sure whether the audio sample was preprocessed with 'codec delay' and 'seek preroll', is it unnecessary for audio decoder to use those?

Thanks!


Using Intersect I'm getting a Local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains operator

I'm using a Linq to SQL query to provide a list of search term matches against a database field.  The search terms are an in memory string array. Specifically, I'm using an "intersect" within the Linq query, comparing the search terms with a database field "Description".  In the below code, the description field is iss.description.  The description field is separated into an array within the Linq query and the intersect is used to compare the search terms and description term to keep all of the comparing and conditions within the Linq query so that the database is not taxed. In my research, trying o overcome the problem, I have found that the use of an in-memory, or "local" sequence is not supported. I have also tried a few suggestions during my research, like using "AsEnumerable" or "AsQueryable" without success.

searchText = searchText.ToUpper();
var searchTerms = searchText.Split(' ');

var issuesList1 = (
    from iss in DatabaseConnection.CustomerIssues

    let desc = iss.Description.ToUpper().Split(' ')
    let count = desc.Intersect(searchTerms).Count()
    where desc.Intersect(searchTerms).Count() > 0

    join stoi in DatabaseConnection.SolutionToIssues on iss.IssueID equals stoi.IssueID into stoiToiss
    from stTois in stoiToiss.DefaultIfEmpty()
    join solJoin in DatabaseConnection.Solutions on stTois.SolutionID equals solJoin.SolutionID into solutionJoin
    from solution in solutionJoin.DefaultIfEmpty()
    select new IssuesAndSolutions
    {
        IssueID = iss.IssueID,
        IssueDesc = iss.Description,
        SearchHits = count,
        SolutionDesc = (solution.Description == null)? "No Solutions":solution.Description,
        SolutionID = (solution.SolutionID == null) ? 0 : solution.SolutionID,
        SolutionToIssueID = (stTois.SolutionToIssueID == null) ? 0 : stTois.SolutionToIssueID,
        Successful = (stTois.Successful == null)? false : stTois.Successful
    }).ToList();
    ...

The only way I have been successful is to create two queries and calling a method as shown below, but this requires the Linq Query to return all of the matching results (with the number of hits for search terms in the description) including the non-matched records and provide an in-memory List<> and then use another Linq Query to filter out the non-matched records.

public static int CountHits(string[] searchTerms, string Description)
    {
        int hits = 0;
        foreach (string item in searchTerms)
        {
            if (Description.ToUpper().Contains(item.Trim().ToUpper())) hits++;
        }
        return hits;
    }
    public static List<IssuesAndSolutions> SearchIssuesAndSolutions(string searchText)
    {
        using (BYCNCDatabaseDataContext DatabaseConnection = new BYCNCDatabaseDataContext())
        {
            searchText = searchText.ToUpper();
            var searchTerms = searchText.Split(' ');

            var issuesList1 = (
                from iss in DatabaseConnection.CustomerIssues
                join stoi in DatabaseConnection.SolutionToIssues on iss.IssueID equals stoi.IssueID into stoiToiss
                from stTois in stoiToiss.DefaultIfEmpty()
                join solJoin in DatabaseConnection.Solutions on stTois.SolutionID equals solJoin.SolutionID into solutionJoin
                from solution in solutionJoin.DefaultIfEmpty()
                select new IssuesAndSolutions
                {
                    IssueID = iss.IssueID,
                    IssueDesc = iss.Description,
                    SearchHits = CountHits(searchTerms, iss.Description),
                    SolutionDesc = (solution.Description == null)? "No Solutions":solution.Description,
                    SolutionID = (solution.SolutionID == null) ? 0 : solution.SolutionID,
                    SolutionToIssueID = (stTois.SolutionToIssueID == null) ? 0 : stTois.SolutionToIssueID,
                    Successful = (stTois.Successful == null)? false : stTois.Successful
                }).ToList();

            var issuesList = (
                from iss in issuesList1
                where iss.SearchHits > 0
                select iss).ToList();
                ...

I would be comfortable with two Linq Queries, but with the first Linq Query only returning the matched records and then maybe using a second, maybe lambda expression to order them, but my trials have not been successful.

Any help would be most appreciated.


"Edit profile" form is not populated using FOSUserBundle

I have User entity with properties like name, address, and I want these fields to be editable on "edit profile" page. Sounds easy, but I couldn't make it work following official documentation. My form is not populated with the User data, though I have configured services (form type, form handler).

I suppose that it might be because $this->form->getData() should get CheckPassword object, but I pass User entity to it (function process() in ProfileFormHandler.php). Or not ?

How to populate form with User data?

All related files are here - http://www.pastie.org/2604806


Explain structure of site.categories

Jekyll supplies a site.categories variable that is accessible to liquid templates.  In my site I currently have two categories with one post each.  From looking at the jekyll bootstrap categories.html I know:

{% for category in site.categories %}
    {{ category[0] }}

I know this renders to the category's name.  However if I also do:

    {% for item in category %}
        {{ item }}

It seems category has two items:  its name and the post.  This makes no sense to me.  category[0] is name and then an array of posts starts at index 1?  Why does this make sense?  I wonder if this comes from Ruby somehow, but I don't know Ruby.  (Since Jekyll is written in Ruby I'm adding this tag, since I suspect much of the syntax is derivative.)

How do I determine the structure of site.categories?  I don't know how to debug this and don't understand liquid syntax well enough to know why this behavior makes sense.


Multiple ids and an unique name

I am very new in Ruby and JavaScript, so I not sure about what I am doing. I have a dropdown box that I would like to show by unique name.

I use JavaScript(CoffeeScript) to get the results with JSON

I created a method to show by unique name (It is working)

My problem is how can I get both ids? When I select a object the value is the id, and the text method is the name. For example, if I have 3 objects with the same name, I need to get three ids. Now, I am getting just one.

Is there another way to do it? Thanks a lot!

TABLE OBJECTS

ID
NAME (I have duplicates in name)
MODEL

UNIQUE INDEX (NAME, MODEL)


Java Inheritance Query

Say I have two classes where SubClass inherits from (extends) SuperClass.

What is the difference between:

SuperClass obj1 = new SubClass();

and:

SubClass obj2 = new SubClass();

Both will look to the constructor of the Superclass and initialise it (the correct one, obviously). Both have access to the superclass implementations. But one is (as far as I am aware) a subclass wrapped in a superclass (the first example) and the other is a subclass object (the second example).

How will this effect the way code is run and interpreted?

What are the real world issues that a developer needs to be aware of regarding how these two objects differ?

Thanks in advance for any help!


how to enable and disable the button's one & another in oracle forms 10g

I have create,save,update and delete button's in a form. At  first only create button must be enabled and all other buttons disabled, once we create a record, then the save button is enabled.  The update and delete button is enabled after we click on save button.


Push failed in clion

I make c++ project and add it to GitHub but when I try to push I get that error what is the problem here?

**Note: I create the repo in GitHub first then push to it.

but if I choose share to GitHub at first everything works very well.


How is this program still taking method copy in the stack even after the StackOverflowError?

If in the try block, the recursive calling of main method gives StackOverflowError then how is the copies of method test still being put on the stack?

class CatchError
{
    static void test()
    {
        System.out.println("test");
    }
    public static void main(String[] args)
    {
        try
        {
            main(null);
        }
        catch(Throwable ex)
        {
            System.out.println("Stack Overflow Error");
            for(int i=0;i<10;i++)
            {
                test();
            }
        }
    }
}


How to alert vibrate loop with 10 seconds on Blackberry?

I have a screen. I want alert vibrate with 10th seconds, 20th seconds, 30th seconds....
How can I do that ?
Thanks for reading


JQuery change CSS property of two div's

I have two div's in my HTML modal-footer & modal-header and I want to change the background color of these by clicking a switch.

I got the switch from a ww3schools tutorial here and I want the background color to change, when I switch it.

HTML of the switch:

<label class="switch">
  <input type="checkbox">
  <div class="slider round"></div>
</label>

I already tried something like this but it didn't work.
Anyone have a solution for that?


Hive connectivity error in Pentaho DI

I am getting a below error while I am trying to do a test connection on hive localhost in pentaho di.

Error connecting to database [HiveConn] :
  org.pentaho.di.core.exception.KettleDatabaseException: Error occurred while > trying to connect to the database

Error connecting to database: (using class
  org.apache.hadoop.hive.jdbc.HiveDriver) loader constraint violation: loader > (instance of java/net/URLClassLoader) previously initiated loading for a
  different type with name "org/apache/thrift/protocol/TProtocol"

org.pentaho.di.core.exception.KettleDatabaseException:
  Error occurred while trying to connect to the database

Please let me know what could be the reason.


90th percentile latency of memcached

I'm running the memaslap client from libmemcached 1.0.16  to benchmark memcached-1.4.15 and I want to get the 90th percentile latency.

Is there a good way to get it from memaslap?

Or are there other benchmark tools that make it easier to extract the 90th percentile latency?


Magento - Fatal error: spl_autoload() after adding to cart.

I have just started experiencing this problem:
The site is fine until I add something to my cart at which point I start to receive the following error at the bottom of the page:

Fatal error: spl_autoload() [<a href=’function.spl-autoload’>function.spl-autoload</a>]: Class Mage could not be loaded in /blah/blah/app/code/core/Mage/Core/functions.php on line 244

The logged in user also gets logged out and they can not log back in again.

I’ve seen a couple of forum posts that talk about this possibly being a problem with memory but my hosts (Rackspace) assure me that the memory is fine (i’ve got 16GB of RAM).

So I’m stuck.

I don't think I've changed any code to cause this. But I'm not sure.

Thanks!


How to insert already displayed div in print function

How can I insert div that is already shown on web page in the print function.

This is the function:

function printHTML(input){
  var iframe = document.createElement("iframe");
    document.body.appendChild(iframe);

  iframe.contentWindow.document.write(input);
  iframe.contentWindow.print();
  document.body.removeChild(iframe);
}

printHTML('<h1>Test!</h1>');

But I need to put inside something that is already shown on the webpage


Why IDE-specific project files are ignored in Git?

I have seen that a number of projects posted on Github feature a .gitignore file explicitly excluding control files related to the IDE. These control files are widely used to define the project and its dependencies. These can be .sln for .NET or .project for Eclipse.

I want to ask why is this practice widely applied or considered a good practice, considering that I agree that achieving IDE-neutrality (don't bind developers to a specific IDE) is a good principle, in general.

On the contrary, these control files often dictate project dependencies, configuration or compilation variables in multiple configurations (this is the case of the .csproj files for example).

I have seen a large number of open source projects ignoring Eclipse files, however it has been impossible to me so far to set up a development environment without the project files (even if I create a project from existing code, or create a new project and import the code, I always get plenties of compilation errors).

If the project files were present in repositories it would be vry simple to set up a development environment with "download the code, import the project and voilà compile the source" but it would obviously bind developer to a specific IDE (and that's not funny).

Standardizing or migrating project files is out of the scope of the question.

So, from an external contributor's point of view, how does one build up a working and compiling project environment for a project of which he downloaded the source code from Github? (after cloning all submodules, if needed)

Just to pick one example project I would like to import into Eclipse, analyse and slightly modify, here it is.


Adaptive html layout using only CSS

I think this is my second post regarding Adaptive HTML/CSS layout. I got a helpful answer in my previous post where I implemented the adaptive layout, which was more straight where I need to remove the float and place the containers one below another.

This time I have got some what complex design. Let me show the designs how it should be looking in Landscape and Portrait modes.

Landscape Design:

In the portrait mode that is if the width is less than 1024px then the design should be looking like this

Portrait Design:!

Would be helpful if someone guides me how to approach this design. In case if some more information is required then please feel free to ask

Thanks
Raaks


How to select from unknown number of databases?

I want to show a customer a history of their total orders across multiple 'vendors'. Each vendor has a separate database in SQL server to store their own orders.

In my database I only know which vendors the user is signed up with. So my sequence needs to go like this:

Get all the VendorIDs that the user is signed up with.

Go to the Vendor table and get their server + database name

Perform a select statement that gets all orders from each Order table in each of the Vendor databases that the user is signed up to.

DECLARE @UserID int = 999

SELECT Count(OrderNumber) AS 'Orders'

FROM
--- Need some kind of loop here?
[VendorServer].[VendorDB].[OrderTable] o1

WHERE
o1.UserID = @UserID

How would I get the aggregate of the total number of orders this customer made when their orders are spread across multiple databases?

The User may be signed up to over 100 vendors. So it has to query across 100 databases. This is an extreme example but its possible.


LibGdx texture drawn as inverse of what #getTextureData gives

I've been trying to resolve this issue I have been having with displaying a texture correctly on my libgdx desktop program.

I have an Orthographic camera with which when I set as:

camera.setOrtho(false);

I get this image:

And when I set it as:

camera.setOrtho(true);

I get this image:

The red image is drawn with a SpriteBatch:

batch.draw(texture, x, y, width, height);

While the white image is drawn from individual points plotted based on if their alpha value was 1.

TextureData td = texture.getTextureData();
td.prepare;
Pixmap map = td.consumePixmap();
for (int i = 0; i < map.getWidth(); i++)
            for (int j = 0; j < map.getHeight(); j++)
                if (new Color(map.getPixel(i, j)).a == 1)
                    points.add(new Point(i, j));

Above is the code used to get all the non-transparent pixels.
They are displayed as the white image, and seem to be the inverse of the original texture.

However, the points plotted and the image itself is always an inverse of one another.

Is there any way of resolving this issue?

Thank you.

PS: I've tried multiple ways of trying to fix this:

Using Sprites and flipping them

Using TextureRegions and flipping them

Absolutely nothing seems to work.


Prompt width and height of image being uploaded

I am looking for some method to prompt the width and height of the image being uploaded using an asp file upload control. Following is the code I am using to prompt message for file size. I just want to add the width and height of the image being uploaded using that upload control. Please take a note that I can't use javascript DOM here like img.clientWidth as there is no such html object to call it.

Here's the JS Code

$(document).ready(function () {
    $("#<%= fupNewImage.ClientID %>").bind("change", function () {
        var fSize = ((this.files[0].size) / 1024).toFixed(2);
        if (fSize <= 200) {
            $("#fupSize").html('Good file size: ' + fSize + " kb  Width=? and Height=?" ); // ? denotes the actual value to be put.
        }
        //---------More cases
    });
});


My android app loads successfully but shuts downs immedaitely

I'm using the Android NDK to port my C++ game over to mobile. I've debugged all the code successfully using ndk-build. And I've all successfully run ant-debug. I then installed the app onto my android device and the compiler said it was a success. However when I press the icon on my android screen, the app loads a black surface onto the screen and then shuts down after about 1 second. Could anybody suggest what might be the problem here? Has anybody experienced anything similar? I would like to know which area to start looking for the bug.


PHP taking the value from only one key in an array

Hey guys so I have an array like

Array (
  [more] => 1
  [routingTable] => Array (
    [0] => Array (
      [ip] =>fcca:948b:3c04:f481:e678:8539:a57e:197a
      [link] => 90731030
      [path] => 0000.0000.271a.c907
      [isDct] => 1
    )
    [1] => Array (
      [ip] => fc1c:fc12:2735:0c17:c864:5273:c66e:558f
      [link] => 74624930
      [path] => 0000.0000.006e.c907
      [isDct] => 1
    )
    [2] => Array (
      [ip] => fcf3:2015:05f7:e2d8:39e8:51ca:1cd5:b29b
      [link] => 188709805
      [path] => 0000.0000.2ab6.c387
      [isDct] => 1
    )
    [3] => Array ( [ip] => fcf6:28f2:3522:8ad0:57ad:cc26:0a6e:27a3 [link] => 7331630 [path] => 0000.001c.4fca.4387 [isDct] => 1 ) [4] => Array ( [ip] => fc99:02f4:7795:c86c:36bd:63ae:cf49:d459 [link] => 188709805 [path] => 0000.0000.0006.4387 [isDct] => 1 ) [5] => Array ( [ip] => fcf3:ca3a:d5a9:3552:7e71:afa7:e87c:f1ce [link] => 188709805 [path] => 0000.0000.0006.c387 [isDct] => 1 ) [6] => Array ( [ip] => fc93:e5b5:7cde:7983:f50c:fe31:106b:1f88 [link] => 87509810 [path] => 0000.0000.004e.c387 [isDct] => 1 ) [7] => Array ( [ip] => fcd4:1dc1:cc08:c97d:85e2:6cad:eab8:0864 [link] => 188709805 [path] => 0000.0000.0056.c387 [isDct] => 1 ) [8] => Array ( [ip] => fce8:78b3:fa72:84a6:f737:e85f:7525:46a3 [link] => 188709805 [path] => 0000.0000.0076.c387 [isDct] => 1 ) [9] => Array ( [ip] => fc19:e2db:7977:6d2c:15ce:4363:19cc:6bd6 [link] => 127238194 [path] => 0000.0000.01e1.0387 [isDct] => 1 ) [10] => Array ( [ip] => fc1b:7538:824d:ccf2:f5da:96eb:a04a:f6e4 [link] => 188709805 [path] => 0000.0000.036a.4387 [isDct] => 1 ) [11] => Array ( [ip] => fc1f:8b91:f3e8:73b9:c46f:ed52:d09f:1c81 [link] => 188709805 [path] => 0000.0000.029a.4387 [isDct] => 1 ) [12] => Array ( [ip] => fcf6:28f2:3522:8ad0:57ad:cc26:0a6e:27a3 [link] => 188709805 [path] => 0000.0000.0000.4607 [isDct] => 1 ) [13] => Array ( [ip] => fcf6:28f2:3522:8ad0:57ad:cc26:0a6e:27a3 [link] => 279709270 [path] => 0000.0000.0000.43c3 [isDct] => 1 ) [14] => Array ( [ip] => fcc7:3fc5:d3f2:f66e:ec97:25e3:4a3d:948c [link] => 188709805 [path] => 0000.0000.0000.4387 [isDct] => 1 ) [15] => Array ( [ip] => fcca:948b:3c04:f481:e678:8539:a57e:197a [link] => 278098660 [path] => 0000.0138.cfe9.c383 [isDct] => 1 ) [16] => Array ( [ip] => fcf6:28f2:3522:8ad0:57ad:cc26:0a6e:27a3 [link] => 9158 [path] => 0000.0000.02f8.c087 [isDct] => 1 ) [17] => Array ( [ip] => fc3a:956e:4b69:1c1e:5ebc:11a5:3e71:3e7e [link] => 0 [path] => 0000.0000.0348.c087 [isDct] => 1 ) [18] => Array ( [ip] => fc93:e5b5:7cde:7983:f50c:fe31:106b:1f88 [link] => 107374000 [path] => 0000.0000.02ad.8087 [isDct] => 1 ) [19] => Array ( [ip] => fc76:582b:9762:fcb6:1459:9564:f934:e02d [link] => 177703971 [path] => 0000.0095.8ea9.c4c7 [isDct] => 1 ) [20] => Array ( [ip] => fc41:bcf4:4c13:5cc6:d96d:aadc:74c2:df2a [link] => 177703970 [path] => 0000.008b.8ea9.c4c7 [isDct] => 1 ) [21] => Array ( [ip] => fce9:df87:2170:6a3d:e0d4:67a5:c82d:1bc0 [link] => 177703970 [path] => 0000.008d.0ea9.c4c7 [isDct] => 1 ) [22] => Array ( [ip] => fc56:926d:c133:bc89:e6eb:640c:aa4e:0cb2 [link] => 774372 [path] => 0000.0092.0ea9.c4c7 [isDct] => 1 ) [23] => Array ( [ip] => fcd9:c8a0:c35c:ba2e:e3de:b497:8706:2aab [link] => 99320952 [path] => 0000.008e.0ea9.c4c7 [isDct] => 1 ) [24] => Array ( [ip] => fcac:541e:9c5c:9ddc:f648:962a:2892:e33e [link] => 0 [path] => 0000.0086.8ea9.c4c7 [isDct] => 1 ) [25] => Array ( [ip] => fcd4:1dc1:cc08:c97d:85e2:6cad:eab8:0864 [link] => 188709805 [path] => 0000.0083.8ea9.c4c7 [isDct] => 1 ) [26] => Array ( [ip] => fc36:4345:785d:cbe6:fc6d:5d61:507a:d721 [link] => 25769760 [path] => 0000.008f.0ea9.c4c7 [isDct] => 1 ) [27] => Array ( [ip] => fca5:372b:57be:78aa:e490:6b0f:da2a:c882 [link] => 43486470 [path] => 0000.0094.0ea9.c4c7 [isDct] => 1 ) [28] => Array ( [ip] => fc73:81dc:9b2e:3095:cd37:0214:114e:d27f [link] => 0 [path] => 0000.049c.46a4.8047 [isDct] => 1 ) [29] => Array ( [ip] => fc30:5b55:a53d:c456:3c3d:da26:4759:3cbc [link] => 132321905 [path] => 0000.0091.0ea9.c4c7 [isDct] => 1 ) [30] => Array ( [ip] => fccf:3418:31dd:4126:c23a:1d73:4a2c:15e5 [link] => 774372 [path] => 0000.0097.0ea9.c4c7 [isDct] => 1 ) [31] => Array ( [ip] => fc05:2d70:2146:9298:73b9:14fb:d7a9:633a [link] => 257697600 [path] => 0000.0000.0007.4483 [isDct] => 1 ) [32] => Array ( [ip] => fcf3:2015:05f7:e2d8:39e8:51ca:1cd5:b29b [link] => 257697600 [path] => 0000.0000.026b.4483 [isDct] => 1 ) [33] => Array ( [ip] => fcd6:b2a5:e3cc:d78d:fc69:a90f:4bf7:4a02 [link] => 264676910 [path] => 0000.0000.0006.c483 [isDct] => 1 ) [34] => Array ( [ip] => fccc:3ddb:f184:ee46:ae1a:f2a4:4f79:1ee7 [link] => 34930104 [path] => 0000.0000.02fa.c483 [isDct] => 1 ) [35] => Array ( [ip] => fc98:82c4:0fca:f53e:2132:426a:c879:083c [link] => 159987260 [path] => 0000.0000.039a.c483 [isDct] => 1 ) [36] => Array ( [ip] => fcf6:28f2:3522:8ad0:57ad:cc26:0a6e:27a3 [link] => 7046418 [path] => 0000.0000.038a.c483 [isDct] => 1 ) [37] => Array ( [ip] => fce8:78b3:fa72:84a6:f737:e85f:7525:46a3 [link] => 221190440 [path] => 0000.0000.02ca.c483 [isDct] => 1 ) [38] => Array ( [ip] => fcc7:3fc5:d3f2:f66e:ec97:25e3:4a3d:948c [link] => 190857286 [path] => 0000.0000.02ea.c483 [isDct] => 1 ) [39] => Array ( [ip] => fc5d:baa5:61fc:6ffd:9554:67f0:e290:7535 [link] => 190857285 [path] => 0000.0000.021a.c483 [isDct] => 1 ) [40] => Array ( [ip] => fcd9:c8a0:c35c:ba2e:e3de:b497:8706:2aab [link] => 190857285 [path] => 0000.0000.03ca.c483 [isDct] => 1 ) [41] => Array ( [ip] => fcd4:1dc1:cc08:c97d:85e2:6cad:eab8:0864 [link] => 264676910 [path] => 0000.0000.027a.c483 [isDct] => 1 ) [42] => Array ( [ip] => fc38:4c2c:1a8f:3981:f2e7:c2b9:6870:6e84 [link] => 4294960 [path] => 0000.0002.aa0b.c007 [isDct] => 1 ) [43] => Array ( [ip] => fcd9:6fcc:642c:c70d:5ff2:63c3:8ead:c9ad [link] => 0 [path] => 0000.0000.0c7b.c007 [isDct] => 1 ) [44] => Array ( [ip] => fc5b:0934:7fce:3885:7fe7:ab23:8743:3e14 [link] => 124285405 [path] => 0000.001a.df21.8047 [isDct] => 1 ) [45] => Array ( [ip] => fcf6:28f2:3522:8ad0:57ad:cc26:0a6e:27a3 [link] => 147102381 [path] => 0000.0000.30be.c907 [isDct] => 1 ) [46] => Array ( [ip] => fcf3:2015:05f7:e2d8:39e8:51ca:1cd5:b29b [link] => 32212200 [path] => 0000.0154.a496.c387 [isDct] => 1 ) [47] => Array ( [ip] => fc97:d627:b1b6:3021:7b55:1ea3:1b3b:75a5 [link] => 188709805 [path] => 0000.0000.02eb.c007 [isDct] => 1 ) [48] => Array ( [ip] => fccc:3ddb:f184:ee46:ae1a:f2a4:4f79:1ee7 [link] => 26843500 [path] => 0000.0000.0329.8007 [isDct] => 1 ) [49] => Array ( [ip] => fcca:948b:3c04:f481:e678:8539:a57e:197a [link] => 188709805 [path] => 0000.0000.03e9.8007 [isDct] => 1 ) [50] => Array ( [ip] => fce1:b388:04e8:c4ff:654a:3e62:2c68:77ee [link] => 44560210 [path] => 0000.0000.2ea9.8007 [isDct] => 1 ) [51] => Array ( [ip] => fc3a:2804:615a:b34f:abfe:c7d5:65d6:f50c [link] => 135291240 [path] => 0000.0000.36a9.8007 [isDct] => 1 ) [52] => Array ( [ip] => fcd5:c432:affb:7e77:a754:74e0:5e98:12d3 [link] => 148176120 [path] => 0000.0000.32a9.8007 [isDct] => 1 ) [53] => Array ( [ip] => fc37:acb2:544b:ed86:8b8d:9945:add7:b119 [link] => 142807420 [path] => 0000.0000.26a9.8007 [isDct] => 1 ) [54] => Array ( [ip] => fc38:4c2c:1a8f:3981:f2e7:c2b9:6870:6e84 [link] => 188709805 [path] => 0000.0000.2aa9.8007 [isDct] => 1 ) [55] => Array ( [ip] => fc93:e5b5:7cde:7983:f50c:fe31:106b:1f88 [link] => 18186471 [path] => 0000.0000.33e9.8007 [isDct] => 1 ) [56] => Array ( [ip] => fc09:c762:d144:4e53:bb79:372c:28dd:2cd6 [link] => 166966572 [path] => 0000.0000.1549.8007 [isDct] => 1 ) [57] => Array ( [ip] => fcbd:9678:6e2c:568e:ea0d:6cc0:69f1:9996 [link] => 123480101 [path] => 0000.0001.fde9.8007 [isDct] => 1 ) [58] => Array ( [ip] => fcef:c7a9:792a:45b3:741f:59aa:9adf:4081 [link] => 81335805 [path] => 0000.0000.18c7.8043 [isDct] => 1 ) [59] => Array ( [ip] => fcb4:baa6:ca46:5255:8514:53da:28dc:1337 [link] => 44560210 [path] => 0000.0000.2aa9.c787 [isDct] => 1 ) [60] => Array ( [ip] => fcef:c7a9:792a:45b3:741f:59aa:9adf:4081 [link] => 137438720 [path] => 0000.0001.8ca9.c787 [isDct] => 1 ) [61] => Array ( [ip] => fc74:b146:a580:2be9:6285:7af3:6a56:2b7b [link] => 0 [path] => 0000.000a.22c7.8043 [isDct] => 1 ) [62] => Array ( [ip] => fc00:9846:1c48:9a10:9c1b:3bbc:2322:face [link] => 52613260 [path] => 0000.0001.94a9.c787 [isDct] => 1 ) [63] => Array ( [ip] => fc13:6176:aaca:8c7f:9f55:924f:26b3:4b14 [link] => 1 [path] => 0000.0000.32b6.8043 [isDct] => 1 ) [64] => Array ( [ip] => fc2c:700f:63fa:2eb1:c360:059d:9b3e:1703 [link] => 188709805 [path] => 0000.0000.0034.81c7 [isDct] => 1 ) [65] => Array ( [ip] => fc85:f077:1447:a03e:bae3:30b2:1e87:63b3 [link] => 2147480 [path] => 0000.0037.2a0b.c007 [isDct] => 1 ) [66] => Array ( [ip] => fc2c:700f:63fa:2eb1:c360:059d:9b3e:1703 [link] => 188709805 [path] => 0000.0000.348e.c087 [isDct] => 1 ) [67] => Array ( [ip] => fcd4:1dc1:cc08:c97d:85e2:6cad:eab8:0864 [link] => 188709805 [path] => 0000.0000.004e.c087 [isDct] => 1 ) [68] => Array ( [ip] => fc7e:854a:b6fe:440b:965d:e487:58fb:5701 [link] => 185220150 [path] => 0000.0000.298e.c087 [isDct] => 1 ) [69] => Array ( [ip] => fc9a:8c7e:a05f:62c0:4872:a860:0610:2e4b [link] => 61203180 [path] => 0000.0000.318e.c087 [isDct] => 1 ) [70] => Array ( [ip] => fc99:02f4:7795:c86c:36bd:63ae:cf49:d459 [link] => 294649 [path] => 0000.0000.0056.c087 [isDct] => 1 ) [71] => Array ( [ip] => fcf1:b5d5:d0b4:c390:9db2:3f5e:d2d2:bff2 [link] => 294649 [path] => 0000.0000.2196.c087 [isDct] => 1 ) [72] => Array ( [ip] => fc58:7ce1:b011:920f:5ac7:98dd:e3c4:0c81 [link] => 294650 [path] => 0000.0000.3296.c087 [isDct] => 1 ) [73] => Array ( [ip] => fcac:541e:9c5c:9ddc:f648:962a:2892:e33e [link] => 0 [path] => 0000.0000.2b96.c087 [isDct] => 1 ) [74] => Array ( [ip] => fca6:83a5:de61:21da:9f57:b943:c039:ffde [link] => 188709805 [path] => 0000.0000.0005.ca47 [isDct] => 1 ) [75] => Array ( [ip] => fc2c:700f:63fa:2eb1:c360:059d:9b3e:1703 [link] => 0 [path] => 0000.0000.03b8.c087 [isDct] => 1 ) [76] => Array ( [ip] => fc99:02f4:7795:c86c:36bd:63ae:cf49:d459 [link] => 124553840 [path] => 0000.0001.7140.c707 [isDct] => 1 ) [77] => Array ( [ip] => fc3a:956e:4b69:1c1e:5ebc:11a5:3e71:3e7e [link] => 107374000 [path] => 0000.00d2.7140.c707 [isDct] => 1 ) [78] => Array ( [ip] => fc72:6c3b:8c74:68a7:d8c3:b4e0:6cbd:9588 [link] => 100394690 [path] => 0000.008a.7140.c707 [isDct] => 1 ) [79] => Array ( [ip] => fcf1:b5d5:d0b4:c390:9db2:3f5e:d2d2:bff2 [link] => 0 [path] => 0000.0086.7140.c707 [isDct] => 1 ) [80] => Array ( [ip] => fc58:7ce1:b011:920f:5ac7:98dd:e3c4:0c81 [link] => 124553841 [path] => 0000.00ca.7140.c707 [isDct] => 1 ) [81] => Array ( [ip] => fcac:541e:9c5c:9ddc:f648:962a:2892:e33e [link] => 0 [path] => 0000.00ae.7140.c707 [isDct] => 1 ) [82] => Array ( [ip] => fce1:3a9f:4546:e9e5:6646:88f9:1b18:8d18 [link] => 83214850 [path] => 0000.00aa.7140.c707 [isDct] => 1 ) [83] => Array ( [ip] => fcfc:89e0:da25:3e98:23be:bc9a:4114:48d5 [link] => 1 [path] => 0000.00c6.7140.c707 [isDct] => 1 ) [84] => Array ( [ip] => fc9a:62c1:75d2:b027:ca9d:9278:4a22:bc37 [link] => 120795750 [path] => 0000.00a2.7140.c707 [isDct] => 1 ) [85] => Array ( [ip] => fc90:8f10:9ca3:12a1:ab12:c98d:0680:d915 [link] => 122406360 [path] => 0000.00b6.7140.c707 [isDct] => 1 ) [86] => Array ( [ip] => fcc7:3fc5:d3f2:f66e:ec97:25e3:4a3d:948c [link] => 0 [path] => 0000.00ba.7140.c707 [isDct] => 1 ) [87] => Array ( [ip] => fc8f:aa30:3bba:8b3e:12fd:44a5:0322:77ff [link] => 79456760 [path] => 0000.000b.2071.4a03 [isDct] => 1 ) [88] => Array ( [ip] => fcf6:28f2:3522:8ad0:57ad:cc26:0a6e:27a3 [link] => 113816440 [path] => 0000.0001.c4fa.c907 [isDct] => 1 ) [89] => Array ( [ip] => fc74:b146:a580:2be9:62 [isDct] => 1 ) ) [isDct] => 1 )

And I need to just grab out all the ip's (the values of the key "ip") and place them into a normal array like ips[]

Ive tried a few things, but It's been so long since I've used php that it's not coming,
Any help is great!


Creating a normal class with injections from Spring

Well, I have a normal class (LovHelper) that is responsible for doing some utils tasks. When i say normal class is because LovHelper.java don't have @Component, @Service or @Repository annotation.

Inside of this "normal class" i wanna inject a bean from spring, but the bean is always null. Look my Class LovHelper.java bellow:

package br.com.odontonew.helper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import br.com.odontonew.bean.Lov;
import br.com.odontonew.dao.BasicDAO;

public class LovHelper {

    @Autowired
    private BasicDAO dao;

    private static LovHelper instance;

    private LovHelper(){

    }

    public static LovHelper getInstance(){
        if (instance == null)
            instance = new LovHelper();

        return instance;
    }

    public Lov getLovByCodigo(Class lovClass, String codigo){
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("codigo", codigo);
        List<Lov> lovs = (List<Lov>)dao.findByQuery("SELECT c FROM "+lovClass.getName()+" c WHERE c.codigo = :codigo", map);
        if (lovs.size() == 1)
            return lovs.get(0);
        else
            return null;
    }

    /*Getters and Setters*/
    public BasicDAO getDao() {
        return dao;
    }

    public void setDao(BasicDAO dao) {
        this.dao = dao;
    }

}

So, in another class i just call: LovHelper.getInstance().getLovByCodigo(param1, param2). But i always get a NullPointerException because the bean "dao" within LovHelper is NULL.

After think a little i decided to change my LovHelper.java (using singleton pattern) to a Bean for Spring inject, then I put @Component annotation and remove all singleton pattern the was developed.
And in another class i inject "lovHelper" and use like this: lovHelper.getLovByCodigo(param1, param2). This second solution works fine, but the first not.

Finally, my doubt is: Why the original code (as posted) don't works.


This is googles standard code for getting current location of user on map but on some PC it shows incorrect results. what could be the reason?

The code given below is the google's standard code for getting the current geolocation. This code works fine on my android mobile device but it shows my current location to Pune (841 kilometres from my current location), when I accessed the web page from my PC. On one of my friends pc it shows correct location while incorrect location on another friend's PC. Can any one tell why this code shows correct current location on some PC while incorrect on some other?

<!DOCTYPE html>
    <html>
        <head>
            <title>Geolocation</title>
            <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
        <meta charset="utf-8">
        <style>
          html, body, #map-canvas {
            height: 100%;
            margin: 0px;
            padding: 0px
          }
        </style>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>

        <script>
    // Note: This example requires that you consent to location sharing when
    // prompted by your browser. If you see a blank space instead of the map, this
    // is probably because you have denied permission for location sharing.

    var map;

    function initialize() {
      var mapOptions = {
        zoom: 6
      };
      map = new google.maps.Map(document.getElementById('map-canvas'),
          mapOptions);

      // Try HTML5 geolocation
      if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
          var pos = new google.maps.LatLng(position.coords.latitude,
                                           position.coords.longitude);

          var infowindow = new google.maps.InfoWindow({
            map: map,
            position: pos,
            content: 'Location found using HTML5.'
          });

          map.setCenter(pos);
        }, function() {
          handleNoGeolocation(true);
        });
      } else {
        // Browser doesn't support Geolocation
        handleNoGeolocation(false);
      }
    }

    function handleNoGeolocation(errorFlag) {
      if (errorFlag) {
        var content = 'Error: The Geolocation service failed.';
      } else {
        var content = 'Error: Your browser doesn\'t support geolocation.';
      }

      var options = {
        map: map,
        position: new google.maps.LatLng(60, 105),
        content: content
      };

      var infowindow = new google.maps.InfoWindow(options);
      map.setCenter(options.position);
    }

    google.maps.event.addDomListener(window, 'load', initialize);

        </script>
      </head>
      <body>
        <div id="map-canvas"></div>
      </body>
    </html>


WordPress query posts on scroll laggy/skips

I have a website that on the homepage contains images/sliders standard page content etc. Once the page loads, it scrolls nice and smoothly. But I have a section about half way down that queries and displays WordPress Posts (see code below). When I view it in Google Chrome, while scrolling in that section, the website becomes laggy/skips and doesn't smoothy scroll like the rest of the home page.

Is there a way or something to include that will have WordPress query the posts faster or better or is there another reason as to why scrolling in that section becomes laggy?

<?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('no_found_rows=true&showposts=6&post_status=publish' . '&paged='.$paged);
    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
        <div class="newspagearticle full">
            <div class="newsthumb">
                <?php the_post_thumbnail( 'category-thumb' ); ?>
            </div>
            <div class="homenewsheader">
                <div class="newsdate">
                    <div><?php the_time('M') ?></div>
                    <?php the_time('d'); ?>
                </div>
                <h2>
                    <a class="readmore" href="<?php the_permalink() ?>">
                        <?php
                            $thetitle = $post->post_title; /* or you can use get_the_title() */
                            $getlength = strlen($thetitle);
                            $thelength = 200;
                            echo substr($thetitle, 0, $thelength);
                            if ($getlength > $thelength) echo "...";
                        ?>
                    </a>
                </h2>
            </div>
            <div style="clear:both;"></div>
            <?php the_excerpt(); ?>
        </div><!-- /newspagearticle -->
    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>


codeigniter tank_auth unable to view default forms

First time posting here love the site.

So I started using CodeIgniter and wanted to add acl to my site.
searched and read a lot and decide to go with tank auth.

using:
codeigniter 2.1.4

tank auth cluster manager

IIS

Download everything ran the scripts connected to the db and nothing...

I can't view the register_form.php in the view/auth folder or any view for that matter, all i get is a blank page no errors or anything. i assume its a problem with the routing i tried a 100 different stuff and was unable to get any thing beside a blank page.

any ideas how to solve this?

your help would be most appreciated.

$route['default_controller'] = 'auth/view';
$route['404_override'] = '';

edit:
what have i dont so far....

so i change the route to this:
$route['default_controller'] = 'auth/login';
$route['404_override'] = '';

enable all logging nothing shows there

made sure im in develoment mode
still nothing blank page

edit:

so sloved the problem it was with the database load ($this->ci->load->database();)
no error were showen only thing in log of CI was (Database Driver Class Initialized)
problem was that php 5.5 doesnt come enable , need to enable it.
locate the php.ini (cmd->run c:\php\php.exe --ini for location)
edit the next stuff in file:
extension=php_mysql.dll
extension=php_mysqli.dll
extension_dir = "C:\PHP\ext"

then make sure that in apachee httd.conf u have it ponted to the location of the right php.ini
PHPIniDir "C:\php\PHP.ini"

hopes this help some one in the future :)