text:
Q: Query too slow with Include graph I'm trying to retrieve 60.000 record about from my SQL Server through EF 6.
I need to include all relationships of my primary entity without using lazy loading, for instance:
Primary Entity: User
User Graph: Hobbies (Collection)
User Graph: Work (Object)
User Graph: SomeOtherGraph (Collection)
and so on...
for a total of 8 object graph.
Note that each every graph, contains in turn a reference to the primary entity (User) as collection (for one to many relations) or as single entity (for one to one relations).
I think my issue is due to all this circular reference that entity framework builds for me.
Is there some way to get my relationship without circular reference?


text:
Q: how to get data from a sub query and also know if sub query is empty or not? I have three tables
T1 has columns:
Number, ID

T2 has columns:
Number, ID

T3 has columns:
Number, Name

I know an ID value: MYID.
I want to select every row from T3 where the Number is equal to any Number in T2 or T1 where with ID equal to the MYID. Also I want to know all the Numbers that are either in T1 or T2 that have a corresponding ID equal to MYID -- (the subquery below).
I have written this query:
SELECT * FROM T3 where T3.Number in
(SELECT T2.NUMBER FROM T2 where T2.ID=MYID
 union
 SELECT T1.NUMBER FROM T1 where T1.ID=MYID)

With this query some Numbers present in the subquery are not known if they are not present in T3. Now should I split into two queries or is there a way to get all that information in one query.
Thanks in advance.

A: I would suggest writing this as:
SELECT T3.*,
       (CASE WHEN EXISTS (SELECT 1 FROM T2 WHERE T2.ID = MYID AND T2.NUMBER = T3.NUMBER)
             THEN 1
             WHEN EXISTS (SELECT 1 FROM T1 WHERE T1.ID = MYID AND T1.NUMBER = T1.NUMBER)
             THEN 1
             ELSE 0
        END) as flag
FROM T3;

This is better than the UNION form because the subqueries can take advantage of indexes on T2 and T1.

A: In SQLServer try this: (im guessing that you know what MYID is, I don't)
WITH t
AS (SELECT
    T2.number
FROM T2
WHERE T2.ID = MYID
UNION
SELECT
    T1.number
FROM T1
WHERE T1.ID = MYID)

SELECT
*
,CASE
    WHEN EXISTS (SELECT
                *
            FROM t
            WHERE t.number = T3.number) THEN 1
    ELSE 0
END AS ExistsInOtherSets
FROM T3

A: Considering that MYID is a hard coded value; something like this should do the trick ....
SELECT * FROM T3
where EXISTS (SELECT 1
              FROM T2
              where T2.NUMBER = T3.Number
                AND T2.ID = MYID)
OR    EXISTS (SELECT 1
              FROM T1
              where T1.NUMBER = T3.Number
                AND T1.ID = MYID)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Cannot run java application from command line while providing multiple directories as classpath ( with path separator) on linux I just export my java project to executable jar. I have somehow made my project work to access value from DB (hibernate.cfg.xml), config.properties, and log4j.properties & editable for future...
I want to put hibernate.cf.xml, config.properties and log4j.properties in the outside of jar and place them somewhere in other directory.
I've been search for this and got this way :

*

*Created a /path/to/mydir directory at some place in my deployement system.

*Moved log4j.properties and META-INF and hibernate.properties and hibernate.cfg.xml to mydir.

*and use this command
this is just example:
java -cp Myjar.jar:/path/to/mydir MyMainClass
the command that I write is like this:
java -cp coreservice.jar:/mon/properties CoreServiceController.java
I've try like that way but i got this error
Error: Could not find or load main class

anyone can help me to fix it or give the better way will be pleasure ~
====================(EDIT)===================================================
Oh my god ~
I have delete(cut) folder META-INF from my jar and paste to my config folder (/mon/properties)
and try this command again java -cp coreservice.jar;mon/properties/ id.co.bn
i.coreservice.controller.CoreServiceController..... annnndddddd this work ;))
tha-nks for Apostolos, Antoniossss, Yasa and no name :)

A: You should not use
java -cp coreservice.jar:/mon/properties CoreServiceController.java

you should put the class file there and try again, not the source java file
if this is in package let's say com.test, then in parent directory of com/test you type
java -cp coreservice.jar:. com.test.CoreServiceController.
this should work
(Edit) to load hibernate.cfg.xml file from specific location, try this method inside your HibernateUtil class:
public static void setConnectionProperties() {
    URL configFileURL = null;

    try {
        configFileURL = URL_OF_YOUR_CFG_XML_FILE;
        configuration = (new Configuration()).configure(configFileURL);
        sessionFactory = configuration.buildSessionFactory();

    } catch (HibernateException e) {
        e.printStackTrace();
        System.out.println("Error while initializing hibernate: " + e.getMessage());
    }

}

A: If I right understood your question:
When you configure sessionFactory you can write so
new Configuration()
            .configure("/path/to/your/files/hibernate.cfg.xml")
            .buildSessionFactory();

full example

A: So as you have still the same problem than I must say that you are doing something very very wrong, because this is the very basics of java runtime. Principles:

*

*Definetly you have to provide fully qualified class name for java to run, not source file (*.java) so your call has to be proper.package.CoreServiceController

*CoreServiceController cannot be in default page (no package name specified) - if it does, create some package just for test eg. service.core and put CoreServiceController there. As for point 1 - your call will be java -cp coreservice.jar:/mon/properties service.core.CoreServiceController nothing more, nothing else.

*Java has nasty behaviour if you provide wrong entry for classpath - it does not say that eg. file myUberProgram.jar does not exists etc. It will just ignore such entry and go on. I had similar issues on Linux with CP - mispelled jar file and "what the hell is going on here?! Why is it not running" - same problem as you have - no class found

*Check to be 101% sure, if there is CoreServiceController.class file in your jar file - maybe something wrong is with the packaging, and there is no such file in jar.

*Finally, if all previous restrictions are fulfilled and nothing works, last chance for you, is to navigate to change working directory to one that jar file is in (simply go there from command line) and try tu run application without external cp provided. From directory where jar is:

*

*Call java -cp Myjar.jar proper.package.CoreServiceController - should work but next one is 100% checked

*Call java -cp ./Myjar.jar proper.package.CoreServiceController - all my applications on remote Linux server are lunched from bash scripts just like that and it always works.

If none of this helped you, than I must say dump your mashine into the ocean because it is cursed or something xD - I just want to say, that I have no other ideas how to help you.
For your practice build simple HelloWorld jar and try to lunch it from command line (but not runnable jar so you will have to provide classpath). Maybe in this way you will se what you did wrong.
My thinking is done for today, good day sir!
PS. @splatter_fadli I allowed myself to edit your question becouse as for now it is missguiding - you dont have problem with H configuration, only with running app while multiple entries in class path are provided. Maybe it will be accepted. - Aaaaaand it is done.
Last stand edit:
According to this question - QA put classpath entry into commas. Try it out. If Class not found will be gone, than we are half way there. -cp "coreservice.jar:/mon/properties"


text:
Q: Why doesn't the dropdown menu in Django-summernote work? So I have a Django application, am using django-summernote as editor. Everything works fine in the editor, except for the dropdown menu. No matter how many times I click the downward arrow, nothing changes. Let me show you the codes :
settings.py
SUMMERNOTE_CONFIG = {
    'iframe': True,
    'lang' : 'ko-KR',
    'summernote': {
        'width': '100%',
        'height': '450px',
        'placeholder':'위대한 글은 위대한 첫 문장에서 시작됩니다!',
        'toolbar': [
            ['style', ['style',]],
            ['font', ['fontsize', 'bold', 'italic', 'strikethrough']],  # 'fontname', 'clear', ...
            ['color', ['forecolor', ]], # 'backcolor'
            ['para', ['ul', 'ol', 'height']],
            ['insert', ['link']],
            ['misc', ['fullscreen', 'print', 'help', ]], # 'codeview', 'picture' ...
        ],
    },
    'js': (
        '/static/summernote-ext-print.js',
    ),
    'js_for_inplace': (
        '/static/summernote-ext-print.js',
    ),
    'css': (
        '//cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.0/theme/base16-dark.min.css',
    ),
    'css_for_inplace': (
        '//cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.0/theme/base16-dark.min.css',
    ),
    'codemirror': {
        'theme': 'base16-dark',
        'mode': 'htmlmixed',
        'lineNumbers': 'true',
    },
    'lazy': False,
}

BOOTSTRAP4 = {
    'include_jquery': True,
}

SUMMERNOTE_THEME = 'bs4'
X_FRAME_OPTIONS = 'SAMEORIGIN'

# I'm not really sure what brought me these settings below... Might be related to django-summernote?
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    # 'djangobower.finders.BowerFinder'
]

BOWER_COMPONENTS_ROOT = '/PROJECT_ROOT/components/'
BOWER_INSTALLED_APPS = (
    'jquery',
    'jquery-ui',
    'bootstrap'
)

# All the STATIC and MEDIA settings are fine.

template
...
{% autoescape off %}

      {{form.media}}
      {{form.contents|as_crispy_field|safe}}

{% endautoescape %}
...

What do you think is the problem? Everything but the dropdown menu works perfectly fine. Please let me know if you need further info. Thank you very much in advance :)
+++
For your information, these are what I have in my  tag.

{% load bootstrap4 %}
{% bootstrap_javascript jquery='full' %}

Could one of these be the cause?

A: I know several causes that can lead to your problem:

*

*Duplicated imports (jQuery, Bootstrap, etc.) in places like head tag and {{ form.media }}

*You must call $("#content").summernote() and $('.dropdown-toggle').dropdown() to initialize


text:
Q: How to add 3 images at the left bottom of the page I am trying to add 3 images of social medias at the left bottom of the page so the effect might looks like this:

And how it looks now (I have got 3 really big images despite setting the width and height):

I am wondering what I am doing wrong. These 3 images are in the social folder.
Index.html
<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>DingDog</title>
  <link rel="stylesheet" href="style.css" >

NEWS FEED

ABOUT DINGDOG

AUTHORS

CONTACT

SIGN IN

style.css
*
{
  margin: 0;
  padding: 0;
}

header
{
  background: #949e9b 0% 0% no-repeat padding-box;
  width: auto;
  height: 78px;
}

body {
  background-image: url("dog.jpg");
  background-color: #cccccc;
}

.main-nav
{
  float: right;
  color: #000000;
  margin-top: 35px;
  margin-right: 0px;
}

.main-nav li
{
  display: inline-block;
}

.main-nav li a
{
  color: #000000;
  text-decoration: none;
  font: Bold 20px/12px Arial;
  padding: 5px;
}

#logo
{
  margin-top: 5px;
  float: left;
}

#sign a
{
  background-color: #DCDFDE;
  padding: 30px 15px 23px 15px;
  border-top: 3px solid black;
  border-bottom: 3px solid black;
  border-left: 3px solid black;
  border-right: 3px solid black;
}

.sociale
{
  display:inline-block;
  height: 20px;
  width: 20px;
}

A: you need to make the children of the social block inline-block

*
{
  margin: 0;
  padding: 0;
}

header
{
  background: #949e9b 0% 0% no-repeat padding-box;
  width: auto;
  height: 78px;
}

body {
  background-image: url("dog.jpg");
  background-color: #cccccc;
}

.main-nav
{
  float: right;
  color: #000000;
  margin-top: 35px;
  margin-right: 0px;
}

.main-nav li
{
  display: inline-block;
}

.main-nav li a
{
  color: #000000;
  text-decoration: none;
  font: Bold 20px/12px Arial;
  padding: 5px;
}

#logo
{
  margin-top: 5px;
  float: left;
}

#sign a
{
  background-color: #DCDFDE;
  padding: 30px 15px 23px 15px;
  border-top: 3px solid black;
  border-bottom: 3px solid black;
  border-left: 3px solid black;
  border-right: 3px solid black;
}

.sociale
{
  display: block;
}
.social > img
{
  display:inline-block;
  height: 20px;
  width: 20px;
}
<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>DingDog</title>
  <link rel="stylesheet" href="style.css" >

NEWS FEED

ABOUT DINGDOG

AUTHORS

CONTACT

SIGN IN

if you want to have it always at the bottom of the page you have to change it to:
.sociale {
  position: absolute;
  display: block;
  bottom: 10px;
  left: 10px;
  height: 20px;
}

.social>img {
  display: inline-block;
  height: 40px;
  width: 40px;
}


text:
Q: How to remove default box outline animation in chrome on touchstart/ hold? I have this code here:
var t

$('#camera').on("touchstart", function(e) {
    event.preventDefault();
    t = setTimeout(function(){ $("#filters").addClass("reveal-filters"); }, 1000);
});

$('#camera').on("touchend", function(e) {
    clearTimeout(t);
});

I've successfully disabled the context menu but how can I remove this black box that appears in chrome when you touch and hold?

Thanks

A: I found those articles useful:

*

*Disable scrolling when touch moving certain element

*Disable Hold Box on ie11 W8.1 Touch Device

*https://msdn.microsoft.com/en-us/library/jj583807(v=vs.85).aspx
Unfortunately, the event "MSHoldVisual" seems only to be supported on Edge/IE, I couldn't find a similar thing for Chrome.


text:
Q: Boot VHDs using only the Windows 7 Bootloader Currently it is possible to boot into a VHD by configuring the boot manager of Windows 7 once it has been installed. Is it possible to use only the boot loader from the install disk to boot into a VHD.
What I am trying to avoid is having two copies of Windows. One that I log into once and configure, and one that I use day-to-day. I would like to have only one copy of Windows, that being my VHD. Any thoughts?

A: I am not aware of any way to just install the Windows 7 boot loader without the full OS being installed. There is also at this point no boot loaders that support VHD booting apart from the  Windows 7 boot loader. The question has also been addressed here and the one of the reasons for allowing this is explained here.

A: Read the post here http://intellects.in/2009/10/23/boot-from-vhd-replacing-vista-or-windows-2008-bootloader-with-windows-7-bootloader
Sameer Dhoot


text:
Q: Salt concentration in flowing water
A basin contains $N_s(t)$ moles of salt dissolved in $N_w(t)$ moles of water. The basin receives fresh water at a constant rate $\Omega_w^{in}$. This water is assumed to be thoroughly mixed in the basin so the salt concentration is homogeneous. The salty water comes out of the bassin at a constant rate $\Omega_{sw}^{out}=\Omega_s^{out}(t)+\Omega_w^{out}(t)$. Determine the salt concentration $c_s(t)=\dfrac{N_s(t)}{N_s(t)+N_w(t)}$.

We have $\dot{N}_w(t)=\Omega_w^{in}-\Omega_w^{out}(t)$ and $\dot{N}_s(t)=-\Omega_s^{out}(t)$ so that $N_{sw}(t)=N_S(0)+N_w(0)+\left(\Omega_w^{in}-\Omega_{sw}^{out}\right)t$.
At $t+dt$, we have $N_w(t+dt)=N_w(t)+(\Omega_w^{in}-\Omega_w^{out}(t))dt$ and $N_s(t+dt)=N_s(t)-\Omega_s(t)dt$ so that $c_s(t+dt)=\dfrac{N_s(t+dt)}{N_s(t+dt)+N_w(t+dt)}=\dfrac{N_s(t)-\Omega_s(t)dt}{N_w(t)+(\Omega_w^{in}-\Omega_w^{out}(t))dt}$. How do I continue?


text:
Q: can we perform SVD in spectral clustering to get top-$k$ eigenvector? In spectral clustering, we need to compute top-k eigenvector for k-means clustering
I have been told that SVD and eigendecomposition is equal for symmetric matrix here  page 9.
I try in matlab
a = rand(4,4);
a = a + a';
[t,t1]= eig(a)

t =

-0.3154    0.1601    0.7063   -0.6132
    0.2735   -0.8645   -0.0458   -0.4192
   -0.5975    0.0612   -0.6654   -0.4433
    0.6847    0.4724   -0.2370   -0.5018

t1 =

   -1.7108         0         0         0
         0   -0.7419         0         0
         0         0   -0.1196         0
         0         0         0    4.9958

>> [t,t1]= svd(a)

t =

   -0.6132    0.3154   -0.1601    0.7063
   -0.4192   -0.2735    0.8645   -0.0458
   -0.4433    0.5975   -0.0612   -0.6654
   -0.5018   -0.6847   -0.4724   -0.2370

t1 =

    4.9958         0         0         0
         0    1.7108         0         0
         0         0    0.7419         0
         0         0         0    0.1196

It seems that there are a slight different. Can we still use the singular vectors as eigenvector in spectral clustering?


text:
Q: como puedo dar un rango de caracteres con mask jquery <input id="Tel0" type="text" name="campoT[]" class="form-control telefono" pattern="[0-9]{13}" placeholder=" _ _ _-_ _ _-_ _ _ _">

en mi js tengo
$(".telefono").mask("(999) 999-9999999")

hay ocasiones en las que solo se escriben 10 caracteres y en ocasiones 13, al momento de escribir solo 10 me borra todo mi numero, habrá alguna manera que no me borre mi dato?


text:
Q: Unable to install .NET Framework 4.5.2 I am trying to upgrade to .NET 4.5.2 on Windows 8.1. When I run the the installer(NDP452-KB2901907-x86-x64-AllOS-ENU.exe), it is opening the maintenance dialog and asking me to "Repair or Remove" .NET 4.5.2 although I do not have it installed. Choosing repair, it says repair successful but does not seem like it installed it. Choosing remove tells me that it cannot be uninstalled and must be uninstalled from Control Panel(I cannot find it in Control Panel). Any help will be greatly appreciated.

A: Windows 8.1 ships with .NET Framework 4.5.2. Of course that won't list with normal programs but you can check installed Windows component list.
Update: There is an even easier way to tell which version is installed.


text:
Q: Passenger not writing fragment cache. Works when run from console as root I have deployed my rails application onto a VPS which I have configured using Nginx/Passenger.
It seems to have issues when writing to a cache (if the cache exists it works fine).
When I run rails s -e production from the terminal it works fine and writes the fragment cache as it should.
I have attempted to change the file permissions on the tmp/ folder, but this failed to resolve the issue.
I imagine it is a nginx issue or server configuration, any help would be greatly appreciated.

A: The problem was the passenger process did not have permission to write to the /var/www directory, and using @itsnokolay's advice worked. (Moving to a user directory)


text:
Q: Queue stuck in loop I implemented queue in C as below. But it stuck in loop.
If I remove free() from the deQueue() then it work fine.
What is the reason of this behavior.
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>

struct item{

    int value;
    struct item* next;
};

struct item *front = NULL, *rear = NULL;

bool isEmpty(){

    return (front == NULL);
}

bool isFull(){

    return false;
}

bool enQueue( int value ) {

    struct item *temp = (struct item*) malloc( sizeof( struct item ) );
    if( temp == NULL ) {

        return false;
    }

    temp->value = value;
    temp->next = NULL;

    if( front == NULL ) {

        printf("Front is NULL\n");

        front = temp;
    }

    if( rear == NULL ) {

        printf("Rear is NULL\n");
        rear = temp;
    } else {

        printf("Rear Value %d \n", rear->value );

        rear->next = temp;
        rear = rear->next;

        printf("Rear Value %d \n", rear->value );
    }

    return true;
}

struct item* deQueue() {

    struct item *temp = front;
    front = front->next;

    return temp;
}

struct item* getFront(){

    return front;
}

struct item* getRear(){

    return rear;
}

void display(){

    struct item* temp = front;
    printf("\n[ ");
    while( temp ){

        printf("%d, ", temp->value);
        temp = temp->next;
    }
    printf("]\n");
}

int main(){

    enQueue(1);
    display();
    free(deQueue());
    display();
    enQueue(2);
    display();

    return 0;
}

A: deQueue updates front but not rear. The latter is left a dangling pointer, after the item is destroyed from under it.


text:
Q: Image quality is decresing when MMX SSE to C code conversion I am Converting an MMX SSE to Equivalent C Code. I have almost converted it but the image quality what I am getting is not proper or I can see some noise is coming in image. I am debugging the code from last 5 days but I am not getting any reason why it is happening. I will be very very happy if you guys look into the issue and help me out.
ORIGINAL SSE CODE:
void unpack_8bit_to_16bit( __m128i *a, __m128i* b0, __m128i* b1 )
{
    __m128i zero = _mm_setzero_si128();
    b0 = _mm_unpacklo_epi8( a, zero );
    b1 = _mm_unpackhi_epi8( a, zero );
}

void convolve_cols_3x3( const unsigned char* in, int16_t* out_v, int16_t* out_h, int w, int h )
{
    using namespace std;
    assert( w % 16 == 0 && "width must be multiple of 16!" );
    const int w_chunk  = w/16;
    __m128i*    i0       = (__m128i*)( in );
    __m128i*    i1       = (__m128i*)( in ) + w_chunk*1;
    __m128i*    i2       = (__m128i*)( in ) + w_chunk*2;
    __m128i* result_h  = (__m128i*)( out_h ) + 2*w_chunk;
    __m128i* result_v  = (__m128i*)( out_v ) + 2*w_chunk;
    __m128i* end_input = (__m128i*)( in ) + w_chunk*h;

    for( ; i2 != end_input; i0++, i1++, i2++, result_v+=2, result_h+=2 )
    {
        *result_h     = _mm_setzero_si128();
        *(result_h+1) = _mm_setzero_si128();
        *result_v     = _mm_setzero_si128();
        *(result_v+1) = _mm_setzero_si128();
        __m128i ilo, ihi;
        unpack_8bit_to_16bit( *i0, ihi, ilo );
        *result_h     = _mm_add_epi16( ihi, *result_h );
        *(result_h+1) = _mm_add_epi16( ilo, *(result_h+1) );
        *result_v     = _mm_add_epi16( *result_v, ihi );
        *(result_v+1) = _mm_add_epi16( *(result_v+1), ilo );
        unpack_8bit_to_16bit( *i1, ihi, ilo );
        *result_v     = _mm_add_epi16( *result_v, ihi );
        *(result_v+1) = _mm_add_epi16( *(result_v+1), ilo );
        *result_v     = _mm_add_epi16( *result_v, ihi );
        *(result_v+1) = _mm_add_epi16( *(result_v+1), ilo );
        unpack_8bit_to_16bit( *i2, ihi, ilo );
        *result_h     = _mm_sub_epi16( *result_h, ihi );
        *(result_h+1) = _mm_sub_epi16( *(result_h+1), ilo );
        *result_v     = _mm_add_epi16( *result_v, ihi );
        *(result_v+1) = _mm_add_epi16( *(result_v+1), ilo );
    }
}

The code that I converted is given below
void convolve_cols_3x3( const unsigned char* in, int16_t* out_v, int16_t* out_h, int w, int h )
{
    using namespace std;
    assert( w % 16 == 0 && "width must be multiple of 16!" );
    const int w_chunk  = w/16;

    uint8_t*    i0       = (uint8_t*)( in );
    uint8_t*    i1       = (uint8_t*)( in ) + w_chunk*1*16;
    uint8_t*    i2       = (uint8_t*)( in ) + w_chunk*2*16;
    int16_t* result_h  = (int16_t*)( out_h ) + 2*w_chunk*16;
    int16_t* result_v  = (int16_t*)( out_v ) + 2*w_chunk*16;
    uint8_t* end_input = (uint8_t*)( in ) + w_chunk*h*16;
    for( ; i2 != end_input; i0+= 16, i1+= 16, i2+= 16, result_v+= 16, result_h+= 16 )
    {
        for (int i=0; i<8;i++)
        {
            result_h[i]     = 0;
            result_h[i + 8] = 0;
            result_v[i]        = 0;
            result_v[i + 8] = 0;
            result_h[i]     = (int16_t)(i0[i]) + result_h[i] ;
            result_h[i + 8] = (int16_t)(i0[i + 8]) + result_h[i + 8] ;
            result_v[i]     = (int16_t)(i0[i]) + result_v[i] ;
            result_v[i + 8] = (int16_t)(i0[i + 8]) + result_v[i + 8] ;
            result_v[i]     = (int16_t)(i1[i]) + result_v[i] ;
            result_v[i + 8] = (int16_t)(i1[i + 8]) + result_v[i + 8] ;
            result_v[i]     = (int16_t)(i1[i]) + result_v[i] ;
            result_v[i + 8] = (int16_t)(i1[i + 8]) + result_v[i + 8] ;
            result_h[i]     = result_h[i] - (int16_t)(i2[i]);
            result_h[i + 8] = result_h[i + 8] - (int16_t)(i2[i + 8]);
            result_v[i]     = (int16_t)(i2[i]) + result_v[i] ;
            result_v[i + 8] = (int16_t)(i2[i + 8]) + result_v[i + 8] ;
        }
    }
}

Sorry if the code is not that readable. w and h represents width and height. out_h and out_v are two parameters that are later used for other purpose.

A: The bugs appear to be in your pointer math and reading of the source data. The pointer variable i0, i1, i2 are unsigned char. Lines like this in your code:
 result_h[i + 8] = (int16_t)(i0[i + 8]) + result_h[i + 8] ;

Should be this:
result_h[i + 8] = (int16_t)(i0[i*2 + 16]) + result_h[i + 8] ;

The cast to int16_t doesn't affect the offset within the square brackets of i0. You're working with 16-byte structures (__m128i), but accessing them at 8-byte offsets. You're also only using the lower 8 bits of the integers pointed to by i0 and i1. In the original SSE code you're reading 16-bit integers. The final corrected code might look like this if you need to read 16-bit integers before the addition:
result_h[i + 8] = *(int16_t *)(&i0[i*2 + 16]) + result_h[i + 8];


text:
Q: Google API: Notification when marker will be into shape i am using google maps API V2 and i have geozones  like shape. now want get alert when unit(Simple Markers) will be into shape coordinats. how i can do this?

A:
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server" >

Multiple Markers :

</asp:Content>

There are 2 parts in your question

*

*Construct a polygon and introduce some markers in the map

*when ever it finds a marker in the area you have to alert
so for 1 you can refer above js as the sample for 2 you can refer below discussion which already contains in this forum....

hope this helps:D
google maps v3: check if point exists in polygon


text:
Q: IE8 creates an extra floated div I've been pulling my hair out for days over this one.
http://djembefola.com
In ie 8 there is 5 columns, even though there is only for 4 subcontentcols in the markup.
I've tried removing all the content of the columns and I'm now stumped.
Anybody have any ideas?


text:
Q: Make ul tags behave properly when having a float element wrapping it #wrap{
    border: 1px solid black;
    margin: 10px;
    float: left;
    width: 200px;
    height: 150px;
}

ul{
    list-style: square;
}

    MEH!

Test

Test

Test

Perfect stuff!

http://jsfiddle.net/Z2p8Z/3/
As you can see, the bullet points appears inside the box.
The requirement is not changing the HTML or the #wrap CSS. Is it possible? If so, how?

A: Either shift the bullets in:
ul {
    list-style: square inside;
}

Or shift the entire list in with some margin/padding:
ul {
    list-style: square;
    margin-left: 1em; /* Or padding-left: 1em */
}

There is a slight difference between these two: the margin/padding solution lets you adjust how far out you want to push the list items. Either solution works here, though.
The difference is more significant if your li text spans multiple lines; having an inside list position means only the line with the bullet point gets pushed in. Margin/padding on the ul or the li elements doesn't cause this issue.

A: You need to set margin-left:236px on the ul.
Or the easy way would be to set:
ul{
 list-style-position:inside;
}

They both have the same effect.
EDIT:  If you want to make sure that both the ul and the text below it are aligned then you should wrap them in a div and add the margin to that div:

bullet

text

CSS:
div#right-col{
  margin-left:236px;
}


text:
Q: Requests Session with local HTTP adapter output-ing junk I am reading a HTML file, saved in local disk, using requests and a LocalFileAdapter, as per @b1r3k on  Python requests fetch a file from a local url. the relevant part is:requests_session = requests.session()
requests_session.mount('file://', LocalFileAdapter())
ra=requests_session.get('file://X:\somefile.htm')
print ra.content.
I am getting some junk on console  . If you see closely, it is actual alphabets separated by these weird squares. What can I do to make it human-readable?

A: You have UTF-16 encoded data, with a BOM, printed out to a console that uses the Windows 1252 codepage:
>>> contents = u'''\
... <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head>
... <meta http-equiv="Content-Type" content="text/html; charset=unicode">
... <meta name="ProgId" content="Word.Document">[snip]
... </body></html>'''
>>> contents.encode('utf16').decode('cp1252')
u'\xff\xfe<\x00h\x00t\x00m\x00l\x00 \x00x\x00m\x00l\x00n\x00s\x00:\x00v\x00=\x00"\x00u\x00r\x00n\x00:\x00s\x00c\x00h\x00e\x00m\x00a\x00s\x00-\x00m\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00-\x00c\x00o\x00m\x00:\x00v\x00m\x00l\x00"\x00 \x00x\x00m\x00l\x00n\x00s\x00:\x00o\x00=\x00"\x00u\x00r\x00n\x00:\x00s\x00c\x00h\x00e\x00m\x00a\x00s\x00-\x00m\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00-\x00c\x00o\x00m\x00:\x00o\x00f\x00f\x00i\x00c\x00e\x00:\x00o\x00f\x00f\x00i\x00c\x00e\x00"\x00 \x00x\x00m\x00l\x00n\x00s\x00:\x00w\x00=\x00"\x00u\x00r\x00n\x00:\x00s\x00c\x00h\x00e\x00m\x00a\x00s\x00-\x00m\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00-\x00c\x00o\x00m\x00:\x00o\x00f\x00f\x00i\x00c\x00e\x00:\x00w\x00o\x00r\x00d\x00"\x00 \x00x\x00m\x00l\x00n\x00s\x00:\x00m\x00=\x00"\x00h\x00t\x00t\x00p\x00:\x00/\x00/\x00s\x00c\x00h\x00e\x00m\x00a\x00s\x00.\x00m\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00.\x00c\x00o\x00m\x00/\x00o\x00f\x00f\x00i\x00c\x00e\x00/\x002\x000\x000\x004\x00/\x001\x002\x00/\x00o\x00m\x00m\x00l\x00"\x00 \x00x\x00m\x00l\x00n\x00s\x00=\x00"\x00h\x00t\x00t\x00p\x00:\x00/\x00/\x00w\x00w\x00w\x00.\x00w\x003\x00.\x00o\x00r\x00g\x00/\x00T\x00R\x00/\x00R\x00E\x00C\x00-\x00h\x00t\x00m\x00l\x004\x000\x00"\x00>\x00<\x00h\x00e\x00a\x00d\x00>\x00\n\x00<\x00m\x00e\x00t\x00a\x00 \x00h\x00t\x00t\x00p\x00-\x00e\x00q\x00u\x00i\x00v\x00=\x00"\x00C\x00o\x00n\x00t\x00e\x00n\x00t\x00-\x00T\x00y\x00p\x00e\x00"\x00 \x00c\x00o\x00n\x00t\x00e\x00n\x00t\x00=\x00"\x00t\x00e\x00x\x00t\x00/\x00h\x00t\x00m\x00l\x00;\x00 \x00c\x00h\x00a\x00r\x00s\x00e\x00t\x00=\x00u\x00n\x00i\x00c\x00o\x00d\x00e\x00"\x00>\x00\n\x00<\x00m\x00e\x00t\x00a\x00 \x00n\x00a\x00m\x00e\x00=\x00"\x00P\x00r\x00o\x00g\x00I\x00d\x00"\x00 \x00c\x00o\x00n\x00t\x00e\x00n\x00t\x00=\x00"\x00W\x00o\x00r\x00d\x00.\x00D\x00o\x00c\x00u\x00m\x00e\x00n\x00t\x00"\x00>\x00[\x00s\x00n\x00i\x00p\x00]\x00\n\x00<\x00/\x00b\x00o\x00d\x00y\x00>\x00<\x00/\x00h\x00t\x00m\x00l\x00>\x00'
>>> print contents.encode('utf16').decode('cp1252')[:2]
ÿþ

The UTF16 byte order mark is printed as ÿþ, the Unicode U+00FF and U+00FE codepoints.
Decode your response data UTF-16:
print ra.content.decode('utf16')

You probably want to open the files in binary mode, otherwise your newlines are going to be broken up. Use:
with open(file_path, 'rb') as file:

I've corrected the code in the answer you referenced.


text:
Q: Benjamini-Hochberg procedure with equally ranked p-values I struggling with Benjamini-Hochberg correction due to equally ranked p-values and I would gladly appreciate some help.
My problem is as follow:
I've got 11 comparisons to do and the threshold is set at 0.05.
My ranked p-values are: p1=0.03125, p2=0.0312, p3=0.0312; p4=0.0312; p5=0.0312; p6=0.0312, p7=0.0312, p8=0.3984, p9=0.5182, p10=0.7912, p11=1.
And the new threshold with Benjamini-correction are : (1) 0.0045, (2) 0.0091; (3) 0.01364; (4) 0.01818; (5) 0.02273; (6) 0.02727; (7) 0.0318; (8) 0.03636; (9) 0.0409; (10) 0.0455; (11) 0.05.
Now if I compare the p-value to the threshold, the first 6 p-values are larger than the p-value so the null hypothesis cannot be rejected. However the seventh p-value is smaller than the corresponding threshold (p7=0.0312<0.0318)…
In this case, should the null hypothesis corresponding to the seven first p-value be rejected or not ?

A: In your example, you would reject the first seven. The BH procedure is a step-up procedure: after ordering your pvalues as $p_1,\dots,p_m$, you should take the last $k$ such that $p_k \leq \frac{k}{m}\alpha$ regardless of whether you have some $p_{k'}$'s with $k'<k$ that do not satisfy this.
Maybe someone else can do a better job of providing intuition, but here's how I think of it. The TL;DR is that what you observed actually happens quite often, and this is perfectly all right: we order the $p_k$'s to get the inverse CDF so that we can approximate the FDR, there is nothing inherently important about the ordering necessarily except that it is computationally easy... we really just need to calculate $\hat{F}_m(u)$, which approximates the (unknown) distribution of the pvalues, and the method you take by ordering does this quickly and easily. To expand on this:
BH works in the following way: suppose you have $\pi$ tests that do reject the null, and thus $1-\pi$ tests that are truly null. Under the null, a pvalue $p$ is uniformly distributed, and so F_{null}(u) = u. The distribution of pvalues that are under the false null have some unknown distribution $F_{notnull}(u)$. Then the distribution of pvalues $p$ is
$$F(u) = (1-\pi)F_{null}(u) + \pi F_{nonnull}(u) = (1-\pi)u + \pi F_{nonnull}(u)$$
You can show that for any level $u$ (let me know if you want a proof of this, but it can probably be found online),
$$FDR(u) \approx \frac{(1-\pi)u}{F(u)}$$
and the whole point of FDR is that we want to find $u$ so that $FDR(u) = \alpha$ (which is precisely setting the FDR to level $\alpha$.
We don't know $F(u)$, so we approximate it by ordering the $p_k$'s and have
$$\hat{F}_m(u) = \frac{1}{m} \sum_i 1\{P_i\leq u\}$$
and when we ignore ties (it's easy to adjust for this so it makes no difference, pvalues are continuous, so youll always have some difference between them in reality, and your example still holds if you add some small perturbation and re-order), we have $\hat{F}_m(P_i) = \frac{i}{m}$.
We also don't know $\pi$, so we conservatively set it to $\pi = 0$. Then we have that we want the $p_i$ so that
\begin{align*}
\alpha = FDR(p_i) & \approx \frac{p_i}{\hat{F}_m(u)} \\
& = \frac{p_im}{i} \\
\end{align*}
and so we want $p_i$ so that $\alpha\frac{i}{m} = p_i$ (or realistically, we want to get as close as possible to this, so we take the max $i$ so that $\alpha\frac{i}{m} \geq p_i$ and reject all the ones below this $p_i$, and so we really don't care about anything before this value.


text:
Q: Couldn't open my raw code from github repo (ERR_SSL_PROTOCOL_ERROR) I tried to open the raw code from my GitHub repo but its either showing "CONNECTION NOT SECURE" or "Hmmm, Cant reach this page".
ERR_SSL_PROTOCOL_ERROR

ERR_CONNECTION_RESET

This happens when I am trying to open when I am connected to my house Wi-Fi. When I change the connectivity to my mobile hotspot this just works as usual.


text:
Q: Drop down menu does not work on username I have made a login system and I am trying to add a dropdown to the username for settings. However, I can make it look like it has a dropdown but no menus appear.
<?php else:?>

      A09hopper.xyz

Home

Page 1

Page 1-1

Page 1-2

Page 1-3

Page 2

    <?php if(!empty($_SESSION['username'])):?>

 <?php echo $_SESSION['username'];?>

1-1

1-2

    <?php else:?>

 Sign Up

    <?php endif;?>

<?php endif; ?>

I have tried everything I can think of but to no avail.

A: I have just fixed my issue. The code below is the fix.

      A09hopper.xyz

Home

Page 1

Page 1-1

Page 1-2

Page 1-3

Page 2

    <?php if(!empty($_SESSION['username'])):?>

 <?php echo $_SESSION['username'];?>

Page 1-1

Page 1-2

Page 1-3

        <?php else:?>

 Sign Up

    <?php endif;?>


text:
Q: PHP Date / GMT Weirdness Either I'm losing my mind, or I've not got the faintest idea what I'm doing.  I'm leaning towards the latter.
I'm trying to convert this: 1316826000, which I'm pretty confident should be Sat, 24 Sep 2011 01:00:00 GMT
http://www.onlineconversion.com/unix_time.htm confirms this.
http://www.unixtimestamp.com/index.php tells me 09 / 23 / 11 @ 8:00:00pm EST, so far so good. I happen to be in EST, this is the result I'd like to get back from PHP.
When I do date('l, M d, Y, h:ia', $iTime), I get: Friday, Sep 23, 2011, 12:00am, a full 20 hours off.
I've confirmed the server's time is correct using date('c').  date('c') output is: 2012-05-19T03:19:20+00:00.  The server is in the central time zone, where it is currently 10:20pm. May 18.
echo date_default_timezone_get() outputs "GMT" (set somewhere else in the script using date_default_timezone_set('GMT'))
What am I missing?  Nothing I've read so far can explain how I'm getting a result 20 hours behind what it should be.  Were it an hour fast or slow, I could at least wrap my head around it being some sort of DST idiotry, but 20?  Crazyness!  Thanks for reading!

A: Check what your php.ini says for date.timezone.
In unix it is usually here: /etc/php.ini
Then use a proper timezone recognized by PHP:
http://www.php.net/manual/en/timezones.php
date.timezone = 'America/New_York'
Then reload your web server.
Unix time just means the number of seconds since epoch.  Has nothing to do with timezones. Timezones simply add or subtract 1 hour (3600 seconds) from the unix time for each zone you move away from GMT.
An example:
$userTimezone = new DateTimeZone('America/New_York');
$gmtTimezone = new DateTimeZone('GMT');
$myDateTime = new DateTime('2014-01-22 11:44', $gmtTimezone);
$offset = $userTimezone->getOffset($myDateTime);
echo $offset;

That will output: -14400 or 4 hours. Which is the difference between New York and GMT

A: Using some Java code with the Joda-Time 2.3 library, as I don't know PHP…
long m = 1316826000L;

DateTime dateTimeUtc = new DateTime( m * 1000L, DateTimeZone.UTC );
DateTime dateTimeNewYork = dateTimeUtc.toDateTime( DateTimeZone.forID( "America/New_York" ) );

System.out.println( "dateTimeUtc: " + dateTimeUtc );
System.out.println( "dateTimeNewYork: " + dateTimeNewYork );

I can tell you that 1316826000 seconds from the beginning of 1970 UTC/GMT (Unix Epoch) is…
dateTimeUtc: 2011-09-24T01:00:00.000Z
dateTimeNewYork: 2011-09-23T21:00:00.000-04:00

So, as the commenter stated, it would be 8 PM in EST but EST was not in effect on that day. DST (Daylight Saving Time) (idiocy, as you correctly noted) was in effect until November 9 of that year (2011). So the time of day is pushed forward one hour, to 9 PM.
In GMT/UTC, that means 1 AM in the morning of the next day.
Standard time in east coast US is 5 hours behind UTC/GMT. With DST it is 4 hours behind UTC/GMT (one hour closer).
Where you got confused:

*

*Your time format/conversion in incorrect.I can't help with that as I don't know PHP.

*You should be using a competent date-time library for this kind of work.Date-time work is complicated, tricky, confusing, and error-prone.This question discusses possibilities of Joda-Time (for Java) sorts of libraries for PHP.

*You used three-letter time zone codes. Avoid these.Those codes are neither standardized nor unique -- there are common duplicates. Instead, use proper time zone names. In your case of east coast US, "America/New_York". Furthermore, in this case you confused the time zone area and rules (east coast US) with a particular application of those rules (EST). Saying "America/New_York" means "whatever time zone rules were in effect on that date, whereas saying "EST" (if interpreted to mean Eastern Standard Time in US) means "UTC-05:00". So either (a) use a time zone name such as "America/New_York", or (b) use a specific offset such as "-05:00".


text:
Q: Error in windows api program: cannot convert from 'LRESULT (__stdcall *)(HWND,UINT,LPARAM,WPARAM) to WNDPROC i've made a simple windows api program having the functions WinMain() and WinProc() , but i'm getting this error :
 error C2440: '=' : cannot convert from 'LRESULT (__stdcall *)(HWND,UINT,LPARAM,WPARAM)'    to 'WNDPROC'
 1> This conversion requires a reinterpret_cast, a C-style cast or function-style cast

  #include<windows.h>

 LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, LPARAM lParam, WPARAM wParam);

 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
  WNDCLASSEX WindowClass;

  static LPCTSTR szAppName = L"OFWin";
  HWND hWnd;
  MSG msg;

  WindowClass.cbSize = sizeof(WNDCLASSEX);

  WindowClass.style = CS_HREDRAW | CS_VREDRAW;
  WindowClass.lpfnWndProc = WindowProc;               // error
          ....
  }

  LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, LPARAM lParam, WPARAM wParam)
  { ..... }

the program's taken word to word from my book (ivor horton's beginning visual c++ 2010), what's wrong?

A: LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, LPARAM lParam, WPARAM wParam);

Here's your problem: the LPARAM and WPARAM are backwards, it should be:
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

WPARAM and LPARAM have two different types (UINT_PTR and INT_PTR respectively - for historical reasons mostly), so you get a type related error if you accidentally swap them around. Which is a lucky thing in your case: if they were the same type, then instead of getting a compiler error, the code would compile fine, and you'd instead spend some time wondering why your wndproc was apparently getting mixed up parameters passed to it!


text:
Q: interact with system level alert dialog in calabash ios I am using calabash cucumber to test my iphone app. In my app i am using system level alert dialog for enabling current location. I need to identify whether there is any alert dialogs displayed on the screen. But i am not able to identify the system level alert dialog. I tried below script. but not working.
query("view:'UIAlertView'",:message)
element_exists("alertView child label marked:'#{message}'")

please help me. I need to click on "OK" button in the dialog.

A: I think that by 'system level alert' you mean an alert generated by the OS.
Examples of this kind of alert are 'Some App wants to use your location' and 'Some App wants to send you notifications'.
To interact with these alerts, you must use the uia_* functions and you must allow calabash to launch your app with Instruments.
# check if the alert exists
if uia_query(:alert).count > 0
   # dismiss by touching 'OK'
   uia_tap_mark 'OK'
end


text:
Q: Issue when plotting specific rows in a stock chart I'm using pandas to plot a chart of stock data with datetime index in the dataframe. I'd like to plot black markers for rows where df_raw[col_name]!=0 but it is acting funky. When no dataframe rows meet the condition, the plot displays fine.
Can you help me understand what I'm doing wrong? Note that data for this stock is available for several decades, but I'm pulling only last 7 days of 1m data.
Thanks so much!
fig.add_trace(go.Scatter(
    x=df_raw[df_raw[col_name]!=0].index,
    y=[df_raw['Close'][j] for j in df_raw[df_raw[col_name]!=0].index],
    mode='markers',
    marker=dict(
        size=8,
        color='black',
        symbol='cross'
    ),
    name='Cdl Pattern'
))

A: I may have found the answer and wanted to post it here in case it helps others. Here's the complete plotting code. Notice that it first plots the 'Close', and then the markers.
When plotting 'Close', the system uses row numbers instead of indices, but when plotting the markers, it is explicitly being directed to use indices. Since indices are Datetime, the two plots end up with mismatched x-axis.
fig = go.Figure()
fig.add_trace(go.Scatter(
    ###No x-axis provided, the system uses dataframe row numbers###
    y=validation_df['Close'],
    mode='lines+markers',
    name='Original Plot'
))

fig.add_trace(go.Scatter(
    ###Explicitly using .index on x-axis###
    x=df_raw[df_raw[col_name]!=0].index,
    y=[df_raw['Close'][j] for j in df_raw[df_raw[col_name]!=0].index],
    mode='markers',
    marker=dict(
        size=8,
        color='black',
        symbol='cross'
    ),
    name='Cdl Pattern'
))

To correct this, the x-axis had to be converted to row numbers for which I used pd.Series. Please suggest a better method if you know one.
fig = go.Figure()
fig.add_trace(go.Scatter(
    y=validation_df['Close'],
    mode='lines+markers',
    name='Original Plot'
))

fig.add_trace(go.Scatter(
    ###using pd.Series to get row numbers for x-axis###
    x=pd.Series(df_raw[col_name].to_list())[pd.Series(df_raw[col_name].to_list())!=0].index,

    y=[df_raw['Close'][j] for j in df_raw[df_raw[col_name]!=0].index],

    mode='markers',
    marker=dict(
        size=8,
        color='black',
        symbol='cross'
    ),
    name='Cdl Pattern'
))


text:
Q: SQL - Check for dependents of a single table Lets say you have a table(A) holding a limited amount of data, and one of the fields being a primary key is being referenced by not one, but many foreign keys from other tables.
The foreign keys of these tables have constraints against the before mentioned table(A) where should a row from table(A) be deleted and one of the other tables FKs holds a reference to it, the deletion will fail.
OK, with the database design taken care of, it is now a matter of the software, PHP in this case.  An attempt is made to delete a row from table(A), how should a check be made to ensure that the row cannot be deleted if a reference is held?
I have seen cases where every table is checked before hand, however that involves coding in every check which becomes a maintenance nightmare.  Additionally, I can't simply let the deletion be attempted, as this needs to be a cross database application, therefore the returned error codes wont be consistent.
I am interested to know how people usually tackle this scenario.  I mentioned I am using PHP, but this situation should apply in any language.

A: In general, you handle this by attempting to execute the DELETE statement on the PRIMARY KEY table, trapping for an exception, and rolling back the transaction when it happens.  You can then report the failure in whatever form you want to the user.  This works if all the referencing tables really declare the FOREIGN KEY back to the PRIMARY KEY table.
If you really need to check first you'll need to write code to "introspect" the keys that exist in the database, extract the table and column name(s) for each referencing foreign key, and issue SELECT COUNTs against each table.  Unfortunately, each database engine has its own methods to learn about the database structure, so you'll have to write some code for each database engine you want to support.


text:
Q: CSS - dynamic length text input field and submit button in one row I have:

    <input id="input" type="text" />
    <button id="submit">submit</button>

which gives me this

If I expand the main panel by dragging it with the mouse cursor the width the new space is empty:

I want that the <input type="text" /> fills the whole horizontal new space but that the submit button remains in the same row.
I tired to use <input style="width:100%" type="text"/> but then it fills the whole row and the submit button appears in the next row:

I also tried a table as mentioned in that thread:
Liquid textfield width
The result was that it works "a little bit" the submit button overlaps the input text and a certain space on the right always remains empty:

Can somebody help me with an code idea for fill the whole space except the (static) size of the submit button.
Thanks!

A: The "table" method you linked to will work, but you're missing one crucial property on your input elements:  box-sizing.
http://cssdeck.com/labs/sbffl3l2

<input type="text">

<input type="submit">

.foo {
  display: table;
  width: 100%;
}

.bar {
  display: table-cell;
}

.bar:first-child, input[type="text"] {
  width: 100%;
}

input {
  box-sizing: border-box; /* this is the key */
}

Prefixes may be required:  http://caniuse.com/#feat=css3-boxsizing

A: I believe you can do this:
<input type="text" style="width:calc(100%- widthofbuttoninpixels);" />

It's not advisable to do inline styles though.
Edit: Make sure you also define a fixed width for the button

A: Why not give width of 70% to input and 20% to button?


text:
Q: Firebase Console View Bundle detail values I'm aware of Google Analytics for capturing the stats etc in android app.
Recently migrated to firbease Console and setup couple of Bundle Id's as mention in Firebase Document https://firebase.google.com/docs/analytics/android/events problem is I don't see rest of bundle Id only see primary ID.
Can you please guide where to see rest of values in firebase console ( values i'm looking for are QuizName, Questions, CorrectAnswers, CorrectAnsRatio)
I can see these data correctly send in logcat but don't see QuizName, Questions in firebase console. Only see UserData value.
Am i missing anything?
//Log analytics result into bundle
        Bundle bundle = new Bundle();
        Player player = PreferencesHelper.getPlayer(getActivity());
        bundle.putString("QuizName",mCategory.getName());
        bundle.putString("Questions",Integer.toString(iCount));
        bundle.putInt("CorrectAnswers",iSolve);
        bundle.putFloat("CorrectAnsRatio",(float)(iSolve *100.0)/iCount);
        mFirebaseAnalytics.logEvent("UserData",bundle);

A: Actually you can't view that raw data directly in Firebase Analytics Console. But you can use those to create audiences. I didn't remember but this was also said in one of the Firebase Dev Summit analytics event(may be in this one).
However, you can export it to the BigQuery (only in BLAZE plan) and then there you can query the data however you want. There was also a talk about this in recent firebase dev summit. (https://youtu.be/zssCC6rXyGk?t=18m21s)


text:
Q: Omitting war file name in URL in apache tomcat I don't want war file name in URL in apache tomcat meaning when I open http://:
then my application should be loaded. What config changes should I do for this .I know context path has to be changed in server.xml, but how to do this I don't know.


text:
Q: Is it possible to activate and play Mortal Kombat X in Germany? I'm wondering if it's possible to activiate and play Mortal Kombat X over Steam, in Germany, even though I would have to get it from another country.
I know it's against Steam's rules to use a VPN or Proxy to activate a game not available in your country.
So you have to use a VPN to activate a (virtual) key, but how does it work if you order the box version of the game from another country and try to activate it then?
May it be possible to do so without breaking Steam's rules?

A: After asking around in the Mortal Kombat X subreddit, which I knew would have more hope, a user (Denitorious) and stated the following:

Confirmed. Bought the US version from the PSN Store (US) because it is banned in my country and I can't play with my friend that has the EU (Norway PSN) Version of the game.
I only get matchmade with people from the US now and have input lag every match + many disconnects.

Hope it helps you with your descision.


text:
Q: pyzmq - undefined symbol: zmq_msg_gets I have problem with zeromq, I get this error:
    Traceback (most recent call last):   File "BasicPub.py", line 1, in <module>
    import zmq   File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/__init__.py", line 66, in <module>
    from zmq import backend   File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/__init__.py", line 40, in <module>
    reraise(*exc_info)   File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/__init__.py", line 27, in <module>
    _ns = select_backend(first)   File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/select.py", line 27, in select_backend
    mod = __import__(name, fromlist=public_api)   File "/home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
    from . import (constants, error, message, context, ImportError: /home/przemek/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/zmq/backend/cython/message.so: undefined symbol: zmq_msg_gets

I installed it this way:
tar xzvf zeromq-4.1.4.tar.gz
./configure
./configure --without-libsodium
make
sudo make install
pip install pyzmq

I use python2.7 and Ubuntu 14.04
Could you help me?

A: If you use pip for installing pyzmq, I'd suggest to try installing zmq bundled to pyzmq:
  pip install pyzmq --install-option="--zmq=bundled"

A: The fact that zeromq 4.0.4 (ubuntu / trusty version) does not have function zmq_msg_gets and zeromq 4.1.4 has that function, suggests that wrong version of C library is being used.
New version of the C library was probably found when pyzmq was built, but for some reason old version is loaded when the module is loaded.


text:
Q: Encrypt a private key with Password using BouncyCastle I am new to BouncyCastle. I have a private key generated using the below code.
     final CertAndKeyGen keypair = new CertAndKeyGen("RSA", "SHA1WithRSA", null);
     keypair.generate(1024);
     final PrivateKey privKey = keypair.getPrivateKey();

I would to encrypt it with a password using AES or some openssl supported algorithm using BouncyCastle. I am trying to find where to start, since I am not able to find any good tutorial on this.

A: If you just want to output your private key to a passphrase "12345" protected PEM formatted and file "privatekey.pem" you can use this BC code:

    JceOpenSSLPKCS8EncryptorBuilder encryptorBuilder = new JceOpenSSLPKCS8EncryptorBuilder(PKCS8Generator.PBE_SHA1_3DES);
    encryptorBuilder.setRandom(EntropySource.getSecureRandom());
    encryptorBuilder.setPasssword("12345".toCharArray());
    OutputEncryptor oe = encryptorBuilder.build();
    JcaPKCS8Generator gen = new JcaPKCS8Generator(privKey,oe);
    PemObject obj = gen.generate();

    PEMWriter pemWrt = new PEMWriter( new FileWriter("privatekey.pem"));
    pemWrt.writeObject(obj);
    pemWrt.close();

then afterwards you can get at the private key with openssl with

$ openssl rsa -in privatekey.pem -check
Enter pass phrase for privatekey.pem:
RSA key ok
writing RSA key
-----BEGIN RSA PRIVATE KEY-----
.....
-----END RSA PRIVATE KEY-----

The "standard" use of PEMWriter will not passphrase protect your private key:(

A: If you'd prefer to protect your private keys with AES-256 instead of one of the old DES variants supported by PKCS8, this will work:
public String toPem(String password) throws IOException {

  StringWriter sw = new StringWriter();

  try (JcaPEMWriter pemWriter = new JcaPEMWriter(sw)) {

    PEMEncryptor encryptor =
        new JcePEMEncryptorBuilder("AES-256-CBC").build(password);

    // privateKey is a java.security.PrivateKey
    JcaMiscPEMGenerator gen = new JcaMiscPEMGenerator(privateKey, encryptor);
    pemWriter.writeObject(gen);
  }

  return sw.toString();
}

You can verify the output with openssl. In my case the key is EC so this command is used:
$ openssl ec -in key.txt -passin pass:password -text

Adapt as required for RSA keys.


text:
Q: Python/Pandas/Matplotlib - Iterating/Looping Through Charts - Duplicate Charts Issue Trying to produce one chart for every 'query' with the 'keyword' on the x-axis and the 'trend' value on my y-axis.
This is my dataframe, called 'df'.
                   query    keyword                     trend   sequence
1592    womens underwear    women's underwear on sale   1.40    1
1593    womens underwear    sale on womens underwear    1.40    2
1594    womens underwear    women's underwear for sale  1.40    3
1595    womens underwear    womens underwear sale       1.40    4
3687    womens underwear    womens underwear sale       1.40    5
3802    womens bra          lingerie sleepwear          124.00  1
1705    womens bra          women's n i t bracket       3.00    2
3852    womens bra          best bras for women         2.22    3
3826    womens bra          fantasy bra                 1.75    4
3851    womens bra          32 c bra                    1.71    5

What is happening is that I am producing 'n' charts in my for loop for each query. Many duplicates!
for i in df['query']:
   loopChart = df[df['query']==i]
   plt.figure(figsize=(10,4))
   plt.bar(loopChart['keyword'], loopChart['trend'])
   plt.title(i)
   plt.xticks(rotation=90)
   plt.show()

I have tried a few things here with no luck:
1) Creating a sequence field (in my DF example) and using that to limit the output in my loopChart line
loopChart = df[df['query']==i & df['sequence']==1]
2) Using my sequence field as a nested while loop criteria
for i in df['query']:
while df['sequence'] <2:
Any insights on how else I might approach this challenge? Tried to think of ways to only go through and chart each 'query' once, but am stumped.
My end result should just be two bar charts, but right now it is 10.

A: disregard - I solved the issue with a small bit of code...added a .unique() to my for loop header and it all worked out.
for i in df['query'].unique():
   loopChart = df[df['query']==i]
   plt.figure(figsize=(10,4))
   plt.bar(loopChart['keyword'], loopChart['trend'])
   plt.title(i)
   plt.xticks(rotation=90)
   plt.show()


text:
Q: How to show suggestions when p-autoComplete gets focused I am using PrimeNG from primefaces.org
Everything is working well. But I have a small problem. When using p-autoComplete, when p-autoComplete is focused it does not show suggestions. I mean I have to type something to get suggestions. I think it is the default behavior. But I want to change it.
What I have tried:
I have tried to set [minLength]="0", but no luck!!!!!!!!

A: This works for me .
(onFocus)="autoComplete.handleDropdownClick()"

A: You need to set some default items in to the suggestions property as
<p-autoComplete [(ngModel)]="val" [suggestions]="results" field="name"></p-autoComplete>

and you should be using in component code
results = ['a', 'b']

When you are loading from service you need to either clear or append to same array

A: You can go to the autocomplete.js file and add some code to onInputFocus like this
    AutoComplete.prototype.onInputFocus = function (event) {
    this.focus = true;
    var queryValue = this.multiple ? this.multiInputEL.nativeElement.value : this.inputEL.nativeElement.value;
    if (this.dropdownMode === 'blank')
      this.search(event, '');
    else if (this.dropdownMode === 'current')
      this.search(event, queryValue);
    this.onDropdownClick.emit({
      originalEvent: event,
      query: queryValue
    });
    this.onFocus.emit(event);
};

you can right-click on p-autoComplete to get you there, beware of updates, when you update prime-ng you will have to do it again.


text:
Q: pandas return column name apply function for each row I am working on the pandas dataset. For 2D dataframe try to return/append one column which return the column name whose value is over 0.95.
import pandas as pd
import numpy as np

Exp_day_list = ["EXP_DAY_1","EXP_DAY_2","EXP_DAY_3","EXP_DAY_4","EXP_DAY_5","EXP_DAY_6","EXP_DAY_7","EXP_DAY_8","EXP_DAY_9","EXP_DAY_10","EXP_GT_DAY_10"]

test = raw_databased.head()
Exp_day_percentage = test[Exp_day_list]

def over_95_percent(x):
    for column in x:
        if x[column] > 0.95:
            return column
            break
Exp_day_percentage.apply(over_95_percent,axis = 1)

I test Exp_day_percentage and result is as what I need.
Exp_day_percentage
Out[2]:
   EXP_DAY_1  EXP_DAY_2  EXP_DAY_3  EXP_DAY_4  EXP_DAY_5  EXP_DAY_6  \
0        0.0        0.0       0.52       0.94       0.94        1.0
1        0.0        0.0       0.00       0.66       1.00        1.0
2        0.0        1.0       1.00       1.00       1.00        1.0
3        0.0        0.0       0.92       1.00       1.00        1.0
4        0.0        0.0       0.95       0.97       1.00        1.0

   EXP_DAY_7  EXP_DAY_8  EXP_DAY_9  EXP_DAY_10  EXP_GT_DAY_10
0        1.0        1.0        1.0         1.0            0.0
1        1.0        1.0        1.0         1.0            0.0
2        1.0        1.0        1.0         1.0            0.0
3        1.0        1.0        1.0         1.0            0.0
4        1.0        1.0        1.0         1.0            0.0

but when I run the apply function to that dataframe, error function as following:
TypeError: ("cannot do label indexing on <class 'pandas.indexes.base.Index'>
with these indexers [0.0] of <type 'numpy.float64'>", u'occurred at index 0')

ideal result will be following:
   EXP_DAY_1  EXP_DAY_2  EXP_DAY_3  EXP_DAY_4  EXP_DAY_5  EXP_DAY_6  \
0        0.0        0.0       0.52       0.94       0.94        1.0
1        0.0        0.0       0.00       0.66       1.00        1.0
2        0.0        1.0       1.00       1.00       1.00        1.0
3        0.0        0.0       0.92       1.00       1.00        1.0
4        0.0        0.0       0.95       0.97       1.00        1.0

   EXP_DAY_7  EXP_DAY_8  EXP_DAY_9  EXP_DAY_10  EXP_GT_DAY_10  Column
0        1.0        1.0        1.0         1.0            0.0  EXP_DAY_5
1        1.0        1.0        1.0         1.0            0.0  EXP_DAY_5
2        1.0        1.0        1.0         1.0            0.0  EXP_DAY_2
3        1.0        1.0        1.0         1.0            0.0  EXP_DAY_4
4        1.0        1.0        1.0         1.0            0.0  EXP_DAY_3

if anyone can help me on that, I would much appreciate that. I search all internet and could not find similar thing. thank you

A: Use pd.DataFrame.idxmax
df.assign(Column=df.gt(.95).assign(zip5=1).idxmax(1))

   EXP_DAY_1  EXP_DAY_2  EXP_DAY_3  EXP_DAY_4  EXP_DAY_5  EXP_DAY_6  EXP_DAY_7  EXP_DAY_8  EXP_DAY_9  EXP_DAY_10  EXP_GT_DAY_10     Column
0        0.0        0.0       0.52       0.94       0.94        1.0        1.0        1.0        1.0         1.0            0.0  EXP_DAY_6
1        0.0        0.0       0.00       0.66       1.00        1.0        1.0        1.0        1.0         1.0            0.0  EXP_DAY_5
2        0.0        1.0       1.00       1.00       1.00        1.0        1.0        1.0        1.0         1.0            0.0  EXP_DAY_2
3        0.0        0.0       0.92       1.00       1.00        1.0        1.0        1.0        1.0         1.0            0.0  EXP_DAY_4
4        0.0        0.0       0.95       0.97       1.00        1.0        1.0        1.0        1.0         1.0            0.0  EXP_DAY_4


text:
Q: How to get iframe's refreshed src after interacting I have an iframe tag that is linked with a Grafana graph, which supports interaction (zoom in/zoom out on x axis by clicking/double clicking on the iframe).
When I open the url of the iframe's src on a new tab I can interact with the graph and see that my browser's url params keeps refreshing with new from/to values (which indicates the range of the graph's x axis). Unfortunately when it is on an iframe I don't see any changes on the 'src' attribute, on any situation. I need the url parameters changes to apply on other graphs being displayed (sync them all).
How can I solve this situation?
My iframe on Angular's component.html:

Iframe after being rendered:

Some screenshots:

*

*Before changes: https://i.imgur.com/6M5JoHX.png

*After changes: https://i.imgur.com/MN0KIha.png
You can see that src keep the same value on both situations.

A: The attribute of src is not changing, but the location object should behaves the same as it behaves when grafana is outside of the iframe.
You have 2 options,

*

*if the frame of grafana & its parent are served from the same origin, you can access the location object with iframe.contentWindow.location.href.

*if they are with different origins, you need to communicate between the frame and its parent, you can use postMessage for that.

check this example: https://robertnyman.com/html5/postMessage/postMessage.html

A: You can detect the onload event, but to get the URL, you will have to store a cookie or localStorage.

var firstTimeLoad = true; // Because the function will call on the initial page

function iframeLoad(iframe) {
  if (firstTimeLoad) {
    firstTimeLoad = false;
    return;
  }
  alert("New page load");
}

A: In case when you are not the owner of the content in an iframe, you can't do much. The best you can do is to have a loop (setInterval), that will check the value against the last value you have seen.

@ViewChild('graph', { static: true }) graph!: ElementRef<HTMLIFrameElement>;

private srcWatcher = new Observable(observer => {
  const interval = setInterval(() => {
    observer.next(this.graph && this.graph.nativeElement && this.graph.nativeElement.src);
  }, 10);

  return () => clearInterval(interval);
}).pipe(
  distinctUntilChanged(),
);

having observable as this one, you can now react to any changes on it.
NOTE: I would also suggest that the observable should run outside of zoneJS if the interval timeout should be low. Otherwise Angular would run global change detection on every interval. By global I mean, that it would check the whole app any all of the subtrees, that uses the default change detection strategy.

A: You just need to set the src of the iframe to the same old src. You may need to add a query string variable with random number like timestamp to avoid caching issues.

function refresh(){
  var iframe = document.getElementById('myframe');
  iframe.src = iframe.src;
 }
iframe{
width:100%;
height:300px;
}

 <button onclick="refresh()">Refresh</button>


text:
Q: How to get UIBarButtonItem to open a new view controller swift 3 I want to open new view controller from UIBarButtonItem.
func readQrCode(_ sender:UIBarButtonItem!) {
            print("working")
            let vc = self.storyboard?.instantiateViewController(withIdentifier: "QRCodeViewController")
        }

A: You could actually go through the storyboard, right-click the UIBarButtom, dragging its connection to the view controller you want to make the segue happen. As soon as you release the click on the view controller, an interface is going to pop up asking what type of segue you would like to use. Then, you could choose show detail. That would allow you to create a segue without typing any code.

A: two possibilities.  If you don't have a navigation controller (I usually do), add this line right before the closing brace:
self.present(vc, animated:true, completion:nil)

If you have a navigation controller add this instead:
self.navigationController?.pushViewController(vc, animated: true)

Edit: (to debug whether your navigation controller is there)
if you change the ? to a ! and you get an exception when you run it, then the navigation controller isn't there.  please show the code where you defined the navigation controller. I would do it in the AppDelegate like this:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let startupVC = SomeViewController()
        self.window! = UIWindow(frame: UIScreen.main.bounds)
        let mainNavConn = UINavigationController(rootViewController: startupVC)
        self.window!.rootViewController = mainNavConn
        self.window!.backgroundColor = UIColor(red: 1.0, green: 0.0, blue: 0.5, alpha: 1.0)
        self.window!.makeKeyAndVisible()
        return true
        }


text:
Q: Bayes' Theorem and Agresti-Coull: Will it blend? I'd like to use Bayes' Theorem on data obtained through a small random sample, and I want to use Agresti-Coull (or any other alternative technique) to know how big the uncertainty is.
Here is Bayes' Theorem:
$P(A|B) = \frac{P(B|A)\cdot P(A)}{P(B)}$
Now, all the data I have on this system is obtained from small random samples, so there's a large uncertainty involved with all three variables, $P(B|A)$, $P(A)$ and $P(B)$.
I've been using Agresti-Coull to obtain both the value and the uncertainty for each of these three variables. (I represent the number+-uncertainty as a ufloat object using the uncertainties package.)
But using Agresti-Coull three times separately for these three variables is a problem; They are dependent on each other. So I've been getting impossible results. For example, if you let $P(B)$'s uncertainty pull it downward, and the respective uncertainties of $P(B|A)$ and $P(A)$ pull them upwards, you get a total probability bigger than one.
Is there a way to do Agresti-Coull-style approximation on the whole Bayes expression instead of doing it on the three pieces separately?

A: When applying the formula for P(B|A) for Agresti-Coull, it seems important to me to use, for the denominator (ñ), a number with uncertainty.  The formula ñ=P(A)*N+4 (where N is the size of your sample) gives you this number, after you calculate P(A) with an uncertainty.  With the uncertainties package, this would be:
# Calculation of P(A):
P_A = ufloat(…, …)
# Calculation of P(B|A):
P_B_A = …/(P_A*N+4)

Thus, P(B|A) is automatically correlated to P(A).
Furthermore, you must make sure that you feed ufloat() with standard deviations.  This mean using a particular z_{1-alpha/2} value, in the Agresti-Coull formula.
Hope this helps!

A: Error propagation won't work in the way handled by the uncertainties package.  As you note, they're dependent, so you have to take the covariances into account.
You can obtain the variance of your distribution P(B|A) using the Delta Method and use that to obtain a confidence interval.
With Bayesian inference, you might find it simpler to use a credible interval.  The following slides do a good job of explaining how to obtain this:

*

*Bayesian analysis of one, two, and n-parameter models

*A Brief Tutorial on Bayesian Thinking

A: Brown, Cai, and DasGupta, AS, 2002
Brown, Cai, and DasGupta, Stat Sci, 2001
I don't know if I understand you correctly, but in my knowledge the above two papers are the most cited ones recently when it comes to binomial proportions' CI and estimation.
Sorry if this is not what you wanted.

A: This is a potential answer to the title of the original question and not necessarily the body of the question...
Looking at the Agresti confidence interval measurement, to my eyes it bears a resemblance to a Bayesian estimator.
https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Agresti-Coull_Interval
Looking at p = 1/n * ( X + 1/2 * z^2), I suspect the 1/2 could be considered Bayesian prior knowledge.
Let's say for example, that one conducts a congressional approval poll and historically those polls have an approval rating of 0.35.  Using a Bayesian train of thought perhaps one could use that information as prior knowledge and feed it in by using 0.35 instead of the 1/2 coefficient?
I suspect one could do so successfully.


text:
Q: KDE5 Plasma Launcher does not find some files, but baloosearch does - how to fix? The Plasma Launcher and KRunner of KDE5 have a plugin providing indexed file search. To the best of my knowledge, they use baloo as their backend.
In my literature directory, I have many files named by the pattern
YEAR - AUTHOR - TITLE.pdf

Now I often find that I cannot find some of the files in the results. However, it doesn't seem to be an issue of baloo. For instance
2011 Smith

will give the paper ~/Documents/Papers/2011 - Smith, et al. - New Research.pdf in Plasma Launcher, KRunner and baloo search 2011 Smith equally. However, when I type
2009 Jones

I will get the paper ~/Documents/Papers/2009 - Jones, et al. - Previous Research.pdf from baloosearch 2009 Jones, but not in KRUnner or Plasma Launcher. Even more confusingly, after I opened the file manually from the directory, the search query
2009

now gives it as the first result, while 2009 Jones still returns nothing.
I already tried resetting baloo with
balooctl stop
sleep 10
rm /home/kdbauer/.local/share/baloo/index
rm /home/kdbauer/.local/share/baloo/index-lock
sleep 10
balooctl start

but that helps only if baloo is stuck in a manner such that baloosearch doesn't find the result either.
So I was wondering: Am I wrong about baloo being used? Or is there some unnecessary caching taking place? Is there any way to diagnose the issue?
The issue has been recurring and isn't resolved by reboots or waiting. It came up yesterday both with a newly added document, and with one I had since months and, due to the missing search result, thought I hadn't obtained yet.
The device is Running openSUSE Leap 15.1.


text:
Q: Automatic backup of Mysql database to Amazon s3 server using script and crontab I am new to this concept so can someone please guide me the script code details and the proper usage of crontab while backing up database to amazon s3 server at a desired time.
I went through different links but none of them explained how the backup takes place. And i am using ubuntu 14.04lts.

A: Some Basics
cron
A user can utilize the crontab utility to edit his/her crontab. The cron daemon will consume all crontabs and run the commands at the defined interval.
A crontab entry basically looks like this:
* * * * * /path/to/some/command

mysql backup
Backup of a mysql database can be achieved through various methods; depending on database engine and amount of data different tools and variants are applicable.
The most basic way of backing up a database would be to use mysqldump:
# mysqldump -u USERNAME -pPASSWORD -h HOSTNAME -P PORTNUMBER DATABASENAME > DATABASENAME.sql

How To Backup MySQL Using Cron
To have backups on every saturday evening at 10 pm use those two tools together (and additionally transfer it to s3) to form a crontab entry like this:
00 10 * * 1 /usr/bin/mysqldump -u USERNAME -pPASSWORD -h HOSTNAME -P PORTNUMBER DATABASENAME > DATABASENAME_$(date '+%F').sql && aws s3 cp DATABASENAME_$(date '+%F').sql s3://BUCKETNAME/db_backups/DATABASENAME_$(date '+%F').sql

A: Assuming you have installed aws-cli (and the machine has a IAM role with permission to upload to S3) and mysqldump in the machine you want to run the cron job, this is the way I do it:
mysqldump --defaults-file="path_to_config_file_with_password" -u db_user -h db_hostname db_name_you_need_backup | gzip -9 > db_name.sql.gz;
now=$(date +"%m_%d_%Y")
aws s3 cp db_name.sql.gz s3://bucket_name/dbs/db_name_$now.sql.gz


text:
Q: Integrating Team Foundation Server with external quality/configuration mamanegement systems I'm evaluating Team Foundation Server and am interested to know as much as possible about integrating it to external systems in particular the (custom) ones we use for source control and issue management.
Has anyone got any experience/insight/links to share on this topic?

A: There is a Rangers product on Codeplex to migrate or sync TFS Source Control with external systems. See http://tfsintegration.codeplex.com/ for more information on this topic.

A: Team foundation is centered around source control and provides most of what you would need around issue management (e.g. work items).  If you already have both of those, I'm not really sure what you would be using TFS for.
I'll second what Ewald mentioned about the TFS Integration Platform-- that's a good start for converting from one source control system to TFS.  Beyond that, there are a number of ways that you can integrate with the TFS Workitem store.  There are other questions here on StackO that cover the details, but in a nutshell:

*

*Excel Integration:  TFS has excellent integration with Microsoft Excel, and this can be a way to do intermittent, one-way conversions of your WorkItems.  In this approach, you export them to Excel, manipulate the results as necessary, then import them into your other system using whatever methods are available.

*Programmatic integration:  TFS gives you an excellent API for retrieving and manipulating WorkItems.  It is a matter of a few lines of code to retrieve the WorkItem records that you want, then you can import them into your other system as appropriate.

A: A good example is how our Gemini Issue Tracker integrates with the TFS Source Control bit.
http://blogs.countersoft.com/index.php/2010/08/tfs-source-control
Not sure if this helps you -- it helps us as our "issue management" part is used by us internally as well as external partners, whilst the TFS source code bit is just internal.


text:
Q: ffmpeg convert TS video file to raw rgb32 video file I have a transport steam file containing H.264 video and would like to extract the video stream to a file containing raw uncompressed RGB32 video frames. So the H.264 video would need to be decoded and converted to RGB32 frames that would be dumped into a file.
Is there a ffmpeg command that would do this, or any other method?

A: Using FFmpeg command line,
ffmpeg -i in.ts -pix_fmt rgba -c:v rawvideo -map 0:v -f rawvideo in-rgba.raw


text:
Q: How do I get animation in OSG to playback? I'm relatively new to c++ and open scene graph. I'm trying to make something that I have recorded in the application to playback, however I have an error that just won't budge - hoping it's something easy to fix.
if (!robotInputDeviceState->paused) {
            bodycb->setPause(false);

            robotInputDeviceState->outline->setWidth(0);
        }
        else {
            bodycb->setPause(true);

            findNode.getFirst()->setUpdateCallback(new updateRobotPosCallback(robotInputDeviceState, "BodyRotator"));
            robotInputDeviceState->bodyPath->clear();

        }
        return false;
        break;

The error code is in the screenshot below, and the red underline is on the bracket '(' after new updateRobotPosCallback and before the robotInputDeviceState.
Any ideas?

A: I agree with the comment above by Jonathan - this is a fairly generic C++ compilation error, not really OSG-related. You are trying to use a version of the constructor that does not exist. Did you write the class updateRobotPosCallback? If so, does it have the 2-argument constructor in both the header file and the implementation file? If you didn't write it, where did you get it from, and are there more files that you are missing?


text:
Q: Web browsers conflicts with Windows timezones I am trying to solve an issue in a web application where the timezone detected is wrong for Windows users. I'm really not sure how the Windows timezones work internally vs. IANA timezones, but in the web application the timezone picked up from the user browser is different from the one displaying on the clock (and the one selected in the Windows settings).
The Windows timezone in question is (UTC-07:00) Chihuahua, La Paz, Mazatlan, notice the UTC-7.
When you set this timezone in Windows the right time is displayed on the clock (UTC-7). The problem is in the web browsers, somehow it keeps detecting a UTC-6 timezone:
new Date() would print at the end: "GMT-0600 (Central Standard Time)"
and Intl.DateTimeFormat().resolvedOptions().timeZone would give "America/Chihuahua" (which is a UTC-6 timezone).
Without relying on geolocation or manually setting the timezone through code, is there any additional step that needs to be made to detect the right timezone in this particular case?
What is the exact difference between Windows timezones and IANA timezones and why does Windows group toghether clearly different timezones into one (Chihuahua, UTC-6 together with Mazatlan, UTC-7)?


text:
Q: How to generate an confirmation email (replace values in template, make html and txt version & confirm)? EDIT After staring at the documentation for another hour I think I have finally realized what I need to adjust and how. I'll update this question tomorrow(*EDIT2*the 25th, have to attend to my family today. But I already have most of the functions working ;), most likely with a full solution to all my problems ;)
I know I am asking for a lot, but I figured it would be better to keep everything in one place rather than starting multiple questions. I am trying to implement this tutorial into my CI project. Everything was fine up until the mail confirmation part. In the tutorial they use Swift Mailer, but I would like to stick to the CI's mail helper.
The problem is that the code is somewhat complicated, due to the use of templates and the confirmation link itself. The current state of my code is below, along with short summary of each part. I am not asking you to answer everything at once, just give me some directions and I will slowly implement them and hopefully at the end of the week we will get it to work.
HTML Template *mamp/htdocs/assets/templates/signup_template.html*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

                Hello {USERNAME}, please click on the link below to finish the registration process

                Link: {SITEPATH}{KEY}

I assume this is how the HTML template should look like? I take it the site path should be something like this base_url('controller/method/') so that the key is sent as an argument to my function that finishes up the registration.
TXT Template *mamp/htdocs/assets/templates/signup_template.txt*
//I have 0 clue how this file should look like

But ts is to be used when the receiver's email client doesn't support HTML emails.
Controller
$info = array(
    'name' => $name,
    'email' => $email,
    'confkey' => $confkey
);
if ($this->User_m->sendMail($info) == 'error') {
    //error reporting
    $data['msg'] = "Something wen't wrong";
    $this->load->view('registration_v',$data);
} else {
    $this->load->view('success_v');
}

This I understand. :D The $info contains the name & email input from my form and the $confkey holds my unique key used for validation. Then the email is sent and if there is an error it gets reported or I load the success_v view.
Model
private function format_email($info, $format){

    //set the root
    $root = base_url() . 'assets/templates/;  //Modified for CI

    //I am not sure if I can just keep this code or should also modify it
    //grab the template content
    $template = file_get_contents($root.'/signup_template.'.$format);

    //replace all the tags
    $template = ereg_replace('{USERNAME}', $info['name'], $template);
    $template = ereg_replace('{KEY}', $info['confkey'], $template);
    $template = ereg_replace('{SITEPATH}','http://site-path.com', $template);

    //return the html of the template
    return $template;

}

This function is called from within the sendMail function to generate the two bodies for the actual email. The function finds the template and replaces the values inside {} with the values provided in arguments. The problem is I don't know if the replacing part will work in CI.
 public function sendMail($info){
    //loading the CI's mail helper
    $ci = get_instance();
$ci->load->helper('mail');
    //format each email
    $body = this->format_email($info,'html'); //Modified for CI
    $body_plain_txt = this->format_email($info,'txt'); //Modified for CI

    //setup the mailer
    //This is what I need to rewrite for CI's mail helper
    $transport = Swift_MailTransport::newInstance();
    $mailer = Swift_Mailer::newInstance($transport);
    $message = Swift_Message::newInstance();
    $message ->setSubject('Welcome to Site Name');
    $message ->setFrom(array('noreply@sitename.com' => 'Site Name'));
    $message ->setTo(array($info['email'] => $info['username']));

    $message ->setBody($body_plain_txt);
    $message ->addPart($body, 'text/html');

    $result = $mailer->send($message);

    return $result;

}

And finally the function that actually sends the email. I tried to rewrite what I thought I understand into CI's syntax, but the actual email creation is untouched. If you could tell me how to rewrite this function into CI's mail helper syntax, that would be just awesome.
Thank you all for reading and for your replies. If you would need any additional information ask straight ahead. Also, MERRY CHRISTMAS!

A: Take a break and start reading this page: http://ellislab.com/codeigniter/user-guide/libraries/email.html
Sending an email with codeigniter is quite simple, your controller can look like this
public function sendEmail() {
$this->load->library('email');

$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send();
}

Then if you want to replace values on a view parse the data to the view with $data as you already did here:
$data['msg'] = "Something wen't wrong";
    $this->load->view('registration_v',$data);

In this example just echo $msg on registration_v - you could make it the emailaddress entered or another value.
Hopefully this will help you.


text:
Q: SQL Server 2012 Explicit transactions taking time with Always on Setup We have a weird issue while we setup the AlwaysOn on Azure VM. We have explicit transactions in our stored procedures, and which are causing some delays and blocking when till the time we get the response from Secondary Server. We are in Synchronous commit mode of AlwaysOn to achieve High-Availability. But it seems we are seeing issues there as when we do the explicit commit the transactions are taking lot of time to complete and causing blockings. The transaction generaly gets stuck at "HADR_SYNC_COMMIT" wait type.
When we removed the explicit transactions from the stored procedures, the execution of the stored procedures was pretty faster and there were no blockings post that.
Anyone aware of any specifics about behaviour of AlwaysOn on Azure VM
Thank you.

A: Got all the answers to my question mentioned above. If anyone facing the same problem I would like to point them to the answer :
Here's the answer to all the questions why explicit commit takes time :
[A commit transaction (FlushToLSN/StartLogFlush) can trigger similar behavior, even when the block is not full, so a commit transaction does not have to wait for the block to become full.]
Please find more details on following link :
https://support.microsoft.com/en-gb/kb/230785]
Thank you.


text:
Q: How do I reduce the scannable area in my app? I've written an app which is used to scan barcodes in a paper-based product catalogue which can then be ordered.
The app is written with Xamarin and is using ZXing barcode scanner.
Unfortunately the barcodes are a bit small in the catalogue and very close to each other, which means sometimes more than 1 barcode will fit in the scannable rectangle and leads to the wrong barcode being picked up. It does not appear as though it begins scanning in the middle, it can sometimes pick something up above or below the middle.
I am using the following code base: https://github.com/Redth/ZXing.Net.Mobile/tree/master/src/ZXing.Net.Mobile/Android
I have managed to reduce the size of the overlay rectangle in GetFramingRect(), however this is obviously presentational only and does not modify the actual area that is being scanned.
In the surfaceview class I have used setPreviewSize and setPictureSize to reduce the height/width to mirror the size of the rectangle overlay (hardcoded in testing to ensure exact same sizes), yet the app is still scanning from way outside the rectangle.
I've been searching for days on a way to do this but have not been able to find anything that has worked.
Any help/pointers would be greatly appreciated.


text:
Q: Second click to Vaadin link with StreamResource doesn't work I have an InputStream from another server (PDF file from JasperReports) and user is able to download it.
...
VerticalLayout content;
OperationResult<InputStream> jresult;
...
final InputStream ent=jresult.getEntity();
if (ent.available()<=0) return;
Link link = new Link();
link.setCaption("Download the report");
link.setResource(new StreamResource(new StreamSource(){
    private static final long serialVersionUID = 1L;
    @Override
    public InputStream getStream() {
        return ent;
        }
}, "FileName.pdf"));
content.addComponent(link);

If the print server returns the page, "Download the report" will appear and the user can download PDF file by click. But second click on the same link fails. It probably returns empty content. What is wrong? Maybe I must rewind the input stream. How?

A: That's because your getStream() method returns the same stream and streams are expected to read from them only once. Once you consume data in the stream, the data is not available anymore.
You may need to firstly convert your InputStream to bytes using this method (taken from this SO question)
public static byte[] readFully(InputStream stream) throws IOException
{
    byte[] buffer = new byte[8192];
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    int bytesRead;
    while ((bytesRead = stream.read(buffer)) != -1)
    {
        baos.write(buffer, 0, bytesRead);
    }
    return baos.toByteArray();
}

and then in getStream() method return new InputStream every time:
@Override
public InputStream getStream() {
    return new ByteArrayInputStream(ent);
}

edit Solution #2: Like @Hink suggested in the comment you can also call reset() on your Stream object.


text:
Q: Rename namespace in Visual studio I had a collection of classes and forms that I have since re-organised into folders. I thought I should rename the namespaces to match the folder structure, but now I have a whole heap of errors like

The name 'xyz' does not exist in the current context.

What is the proper process to rename a namespace in Visual Studio (2010)


text:
Q: "cd /ect/mysql/" gives error "-bash: cd /ect/mysql : No such file or directory" when it exists I recently started an EC2 AWS Linux server instance with Ubuntu 14.04. I am very new to ubuntu and launching websites on servers, but here is (in short) what I have done so far.
I successfully installed LAMP server and I am able to access the webpage and its phpMyAdmin through pasting the instance's URL in Chrome.
I successfully edited the index.html file using nano that is located in /var/www/html and the website changes accordingly.
I successfully created a database in phpMyAdmin and I now wish to access it using php and mysql.
Upon connecting the database using the mysqli_connect function the connection fails.
I read that in order to connect the database to an external server one must edit the my.cnf file here: https://mariolurig.com/coding/connect-remotely-mysql-database-amazon-ec2-server/
I am having trouble to access the file.
I used locate my.cnf and tried to use cd to access it as follows:
ubuntu@ip-172-31-18-130:/usr/local$ locate my.cnf
/etc/mysql/my.cnf
ubuntu@ip-172-31-18-130:/usr/local$ cd /ect/mysql
-bash: cd: /ect/mysql: No such file or directory

I read about how a 32-bit binary can't run on a 62-bit system here: No such file or directory? But the file exists!
So I entered the command
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

It seemed to install just fine, the only odd thing I noticed is that the installation ends with the line:
Processing triggers for libc-bin (2.19-0ubuntu6.14) ...
and I can type commands on my terminal again. I tried entering cd /ect/mysql/ again, but I am met with the same error.
I noticed while searching through my file directories the error happens whenever I try to access the /ect directory, for example, the following happens:
ubuntu@ip-172-31-18-130:/usr/local$ l
bin/  etc/  games/  include/  lib/  man@  sbin/  share/  src/
ubuntu@ip-172-31-18-130:/usr/local$ cd /usr/local/ect
-bash: cd: /usr/local/ect: No such file or directory

Does anyone know why this is happening and how I can fix it? I have been struggling with it for long and the similar questions' solutions I find doesn't seem to work. Any help would be greatly appreciated
edit:
As requested I checked the directory permissions where /etc is and got the following:
ubuntu@ip-172-31-18-130:~$ cd /usr/local
ubuntu@ip-172-31-18-130:/usr/local$ l -l
total 32
drwxr-xr-x 2 root root 4096 Sep 13 15:29 bin/
drwxr-xr-x 2 root root 4096 Sep 13 15:29 etc/
drwxr-xr-x 2 root root 4096 Sep 13 15:29 games/
drwxr-xr-x 2 root root 4096 Sep 13 15:29 include/
drwxr-xr-x 4 root root 4096 Sep 13 15:31 lib/
lrwxrwxrwx 1 root root    9 Sep 13 15:29 man -> share/man/
drwxr-xr-x 2 root root 4096 Sep 13 15:29 sbin/
drwxr-xr-x 7 root root 4096 Oct 27 11:58 share/
drwxr-xr-x 2 root root 4096 Sep 13 15:29 src/

A: It turns out I made a spelling mistake when trying to access the my.cnf file. I retyped the directory and the following happened:
ubuntu@ip-172-31-18-130:/var$ cd /etc/mysql
ubuntu@ip-172-31-18-130:/etc/mysql$

I got in with no problem. Thank you so much for pointing out my silly mistake.


text:
Q: Linear algebra (n x n) matrix Having an exam tomorrow in linear algebra. Can someone help me to understand how to do this type of problem solving?
Problem: Let $A$ be one $(n \cdot n)$ matrix and let $R$ be its reduced step mode. Suppose that $R$ is not the identity matrix. Show that $(R)=0$.
I can't understand how I should work with this type of problem if its not an identity matrix.

A: Do you mean that $R$ is the reduced row echelon form of $A$ and $\det R=0?$
Matrix $R$ is already upper triangular, so if it is different from the identity matrix, then it has zeros on the tail of the main diagonal (why$?$). Thus $\det R=0$, since the determinant of a triangular matrix equals the product of its diagonal entries (do you know who to expand a determinant along a row or column with few non-zero entries$?$)