Affichage des articles dont le libellé est Recent Questions - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Recent Questions - Stack Overflow. Afficher tous les articles

vendredi 11 septembre 2015

Visual studios c#, trying to add objects every click of a button

I'm trying to add a circle every click on button1. For some reason after adding the first circle, I can't add a second. Please help, it's for a school project... Here's the code: http://ift.tt/1FBNY2q



via Chebli Mohamed

Transfer artifact via SFTP using Maven

I'm attempting to add a build task into a Maven pom file so that I can transfer a jar file as well as some xml files to an SFTP server (it's a VM with Tomcat installed) but I have been unable to so far.

I've had a look at a few links, but they either don't quite match the requirements, have missing steps, or don't work. I'm basically a beginner with Maven so I'm not sure if I'm doing it correctly.

The requirement is that I want to invoke a Maven build, with command line arguments for the hostname, username, and password (which I have working) which then will upload a jar file and the xml files to a VM with Tomcat running in it via SFTP (FTP doesn't work, and I don't think SCP will work as I don't have a passfile). I also don't want to mess with the main Maven settings.xml file to add the connection details in, which some of the links I found seem to be reliant upon.

I have the following profile so far, using FTP, but it doesn't work due to not using SFTP.

<profiles>
    <profile>
        <!-- maven antrun:run -Pdeploy -->
        <id>deploy</id>
        <build>
            <plugins>
                <plugin>
                    <inherited>false</inherited>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.6</version>
                    <configuration>
                        <target>
                            <!-- <loadproperties srcFile="deploy.properties" /> -->

                            <ftp action="send" server="${server-url}"
                                remotedir="/usr/share/myappserver/webapps/myapp/WEB-INF/lib"
                                userid="${user-id}" password="${user-password}" depends="no"
                                verbose="yes" binary="yes">
                                <fileset dir="target">
                                    <include name="artifact.jar" />
                                </fileset>
                            </ftp>

                            <ftp action="send" server="${server-url}"
                                remotedir="/var/lib/myappserver/myapp/spring"
                                userid="${user-id}" password="${user-password}" depends="no"
                                verbose="yes" binary="yes">
                                <fileset dir="src/main/resource/spring">
                                    <include name="*.xml" />
                                </fileset>
                            </ftp>

                            <!-- calls deploy script -->
                            <!-- <sshexec host="host" trust="yes" username="usr" password="pw" 
                                command="sh /my/script.sh" /> -->

                            <!-- SSH -->
                            <taskdef name="sshexec" classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec" 
                                classpathref="maven.plugin.classpath" />
                            <taskdef name="ftp"
                                classname="org.apache.tools.ant.taskdefs.optional.net.FTP"
                                classpathref="maven.plugin.classpath" />
                        </target>

                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>commons-net</groupId>
                            <artifactId>commons-net</artifactId>
                            <version>1.4.1</version>
                        </dependency>
                        <dependency>
                            <groupId>ant</groupId>
                            <artifactId>ant-commons-net</artifactId>
                            <version>1.6.5</version>
                        </dependency>
                        <dependency>
                            <groupId>ant</groupId>
                            <artifactId>ant-jsch</artifactId>
                            <version>1.6.5</version>
                        </dependency>
                        <dependency>
                            <groupId>jsch</groupId>
                            <artifactId>jsch</artifactId>
                            <version>0.1.29</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

I tried swapping ftp for sftp, and using org.apache.tools.ant.taskdefs.optional.ssh.SFTP instead, but it didn't seem to work.

So to summarize, the SFTP config needs to be self contained within the pom file as much as possible, with stuff like the host url, username and password being passed in when invoked.



via Chebli Mohamed

Call function inside bxslider callback

I am trying to call a custom function inside a bxslider callback but the function doesn't get recorgnized (aka: Uncaught Reference Error: nextSlideCustom() is not a function)

my current code looks like

    var slider=$('#slider1').bxSlider({
         pager: 'true',
         onSlideNext: nextSlideHandle()
    });

and in a different js file I am defining this function:

function nextSlideHandle(){
    console.log("huhu");
}

so what's the problem with my code, or is it mory likely a wrong configuration of the slider or something?

thanks in advance!



via Chebli Mohamed

How to disable browser auto filling username and password

How to disable browser auto filling form username and password fields. I have already tried autocomplete="off". It's not working for me. Please find the form below. And help me to solve this.



via Chebli Mohamed

MySQL - Check if two values are equal or both NULL?

If I want to compare two values, I can write:

SELECT * FROM table1
JOIN table2 ON table1.col = table2.col;

I've noticed that this does not work if both table1.col and table2.col are NULL. So my corrected query looks like this:

SELECT * FROM table1
JOIN table2 ON 
  (table1.col = table2.col)
  OR
  (table1.col IS NULL AND table2.col IS NULL);

Is this the correct way to compare two values? Is there a way to say two values are equal if they are both NULL?



via Chebli Mohamed

Opening a file in C

I looked at many examples before I wrote this, and I know many languages and clearly understand the syntax and what is going on in the code I listed below, however, when I compile my program for example:

gcc -o /sbin/"name" readfile.c

I get the following error:

enter image description here

This makes no since to me since my code clearly includes #include <stdio.h> which defines the FILE as referenced here ---- stdio.h.

//PROGRAM (readfile.c)

#include <stdio.h>

int main(){
    FILE *fp;
    fp = fopen("dummy.txt","w");
    fprint(fp, "testing...\n");
    fclose(fp);
}

//FILE (dummy.txt) *is in the same directory

Hello World



via Chebli Mohamed

Return the row of first non-blank cell in Excel

Let's say I have the array A1:A5 in excel:

    A  
1    
2  
3  'test'  
4  
5  'test2'

How can I return "3"? I'm looking for something in Excel formulas. The blanks are genuine blanks.



via Chebli Mohamed

SQL connection error from PHP after many operations

I'm currently looping to create a MBTiles map, and add information to my database each time. Here's how I configured my connection and execute actions during the loop:

if ($pdo_mbtiles == null) {
    echo "Opening new database connection".PHP_EOL;
    $pdo_mbtiles = new PDO('sqlite:'.$filename,
            '',
            '',
            array(
                PDO::ATTR_PERSISTENT => true
                )
            );
}
$pdo_mbtiles->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$pdo_mbtiles->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$q = $pdo_mbtiles->prepare("INSERT INTO tiles (zoom_level, tile_column, tile_row,tile_data) VALUES (:zoom_level, :tile_column, :tile_rowTMS, :tile_data)");
$q->bindParam(':zoom_level', $zoom_level);
$q->bindParam(':tile_column', $tile_column);
$q->bindParam(':tile_rowTMS', $tile_rowTMS);
$q->bindParam(':tile_data', $tile_data, PDO::PARAM_LOB);
$q->execute();

After 1018 times looping (this number doesn't change no matter how many times I try), I get this error message:

SQLSTATE[HY000]: General error: 14 unable to open database file

I checked the solution written here: How to prevent SQLITE SQLSTATE[HY000] [14]? but the echoed message only appears at the first time of the loop, so I assume the PDO connection isn't closed.

I didn't find other documentation relevant to this error code.

What could possibly go wrong here?



via Chebli Mohamed

How to compute for the mean and sd

I need help on 4b please

  1. ‘Warpbreaks’ is a built-in dataset in R. Load it using the function data(warpbreaks). It consists of the number of warp breaks per loom, where a loom corresponds to a fixed length of yarn. It has three variables namely, breaks, wool, and tension.

    b. For the ‘AM.warpbreaks’ dataset, compute for the mean and the standard deviation of the breaks variable for those observations with breaks value not exceeding 30.

    data(warpbreaks)
    warpbreaks <- data.frame(warpbreaks)
    AM.warpbreaks <- subset(warpbreaks, wool=="A" & tension=="M")
    
    mean(AM.warpbreaks<=30)
    sd(AM.warpbreaks<=30)
    
    

This is what I understood this problem and typed the code as in the last two lines. However, I wasn't able to run the last two lines while the first 3 lines ran successfully. Can anybody tell me what is the error here? Thanks! :)



via Chebli Mohamed

Select all span elements except those which class contains the word icon

I'm implementing the following CSS Selector

Select all span elements except those which class contains the word icon

So the following seems to be working:

.music-site-refresh span:not([class*="icon"]) {
  font-family:Montserrat, sans-serif;
}

But I thought it should be like this:

.music-site-refresh span:not(span[class*="icon"]) {
  font-family:Montserrat, sans-serif;
}

But the second one doesn't work in my testbed.

Could anyone explain me which one is correct and why?



via Chebli Mohamed

dynamically create div and into a static div

On click of button i am trying to create one div and try to append static div into that and this is giving error.

Uncaught TypeError: elm.appendChild is not a function.

    <script>
        function s()
        {
            var elm = '<div' +
                'style="background-color:orange;height:125px;width:75px;"'+
                '</div>';           
            var x=document.getElementById("ss")         
            elm.appendChild(x);         
        }
    </script>       

    <div id="ss">
        <ul>
            <li style="background-color:grey;">
                <h2 class="wheater_CityName">Mumbai</h2><br><br>
                    <div style= 
                        "margin-left: 30%;
                        margin-top: -21%;"
                    >
                    </div>
                    <hr style= "margin-top: -83px; ">                   
            </li>
            <li>sad</li>
            <li>as</li>             
        </ul>
    </div>    
    <input type="button" value="ss" onclick="s()"/>



via Chebli Mohamed

ActionScript: using variables w/E4X descendant accessor (..)

I'm using a descendant accessor like so:

var myxml:XMLList = new XMLList;

...

myxml..node

and would like to replace it w/

const sNode:String = 'node';
myxml..[{sNode}]

This sort of thing has worked before.

const sAttrib:String = 'attrib';
myxml.@[{sAttrib}]

works, but trying the same sort of thing w/a descendant accessor causes a compiler error.

Yes, I could do

myxml.descendants(sNode)

but I'd rather do it w/operators, if I can.

The XML might be something like:

<map>
    <node>
       <node />
    </node>
</map>



via Chebli Mohamed

Unable to implement user subscription based Push Notifications when implemented with Adapter based authentication

I have defined an Adapter based as authentication.

Doing a custom security test which works successfully.

But when I wanted to implement User Subscription based Push Notifications and added a mobile security test in authentication Config.XML I am facing lot of issues.

As I'm trying to deploy the app and test in android device. I have also included the mobile security test in android tag of application-descriptor.xml. But facing lot of issues to deploy the adapter itself after this.

Can anyone guide me on this please?

Please refer to the below code snippets which I am using

authenticationConfig.xml

    <mobileSecurityTest name="MST1">
        <testUser realm="AdapterAuthRealm"/>
        <testDeviceId provisioningType="none"/>
    </mobileSecurityTest>

    <webSecurityTest name="WST1">
        <testUser realm="AdapterAuthRealm"/>
    </webSecurityTest>

    <customSecurityTest name="Master-Password">
        <test realm="AdapterAuthRealm" isInternalUserID="true"/>
    </customSecurityTest>

Authentication was running fine till I had only the customSecurityTest being defined.

After adding web and mobile security test, there is no response when I give the credentials and click login neither from GUI side nor from the console logs side.

I have also added security test in android tag in application-descriptor.xml as below

<android securityTest="MST1" version="1.0"> 
    <worklightSettings include="false"/>        
    <pushSender key="xxxxxxxxxxx" senderId="xxxxxxxxxxxxxxx"/>

    <security>
        <encryptWebResources enabled="false"/>
        <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
        <publicSigningKey/>
        <packageName/>
    </security>
</android>



via Chebli Mohamed

Angularjs recursive directive

I am trying to write a recursive directive. I have seen this thread: Recursion in Angular directives

It works when you put the recursive directive under ul-li but goes into infinite loop with a table-tr

<table> 
  <tr>
    <td>{{ family.name  }}</td>
  </tr>
  <tr ng-repeat="child in family.children">
    <tree family="child"></tree>
  </tr>
</table>

Here is a plunker : http://ift.tt/1LnI4Uo

EDIT: I am not trying to build a tree directive.In my recursive directive I have to use table and tr tags.



via Chebli Mohamed

Linux Kernel Generic Netlink - Is it concurrent?

Say that i have registered a generic netlink interface using genl_register_family_with_ops with multiple callbacks.

I don't see any warnings about it and I assume the callbacks are serially called but there is no information about how the callbacks are called neither.

Is it possible that multiple callbacks are called concurrently on the same generic netlink interface I have registered? Do I need any synchronization between the callbacks?

To make the question simpler:

Can a single netlink callback be preempted or concurrently run in two cores?



via Chebli Mohamed

Android - API key for GoogleMaps API V2 for release

I have trouble with GoogleAPI in my app. I use Google Maps and Places - both needs API key. Everything works fine, until I upload my signed app to Google Play. From what I know and from what I read so far, the API key has to have the same fingerprint as my signed app to work properly from app downloaded from GP. So I created a new API key, add two fingerprints with package name to this key. First with fingerprint from debug.keystore and second from fingerprint from my keystore which I'm using for singning app when I do release build (I'm using android studio ->generate signed apk). This way I assumed that this will work for debug and release, but it work only for debug. To be sure that fingerprint of my app is the same as I have under Google API key I have implemented method which extract fingreprint of my app on runtime. They are match - when I do debug release I see fingerpring "A", when I do it for release I see "B" and I have both of then are the same as fingerprints which I have under API key (section Restrict usage to your Android apps). Note that package name is also correct.

Summary I don't know what I'm missing, or why this is not working when fingerprints are matched - result after release build is that Places api indicates KEY_INVALID and maps is gray, without titles.



via Chebli Mohamed

gender related translations with transchoice and lingohub

I have been trying to find a solution for this but have not found the answer that works for me. Basically what I want are gender specific translations in Symfony2 using twig and the service lingohub.

Our translations files for English look like this:

<trans-unit id="1234" resname="some_key">
  <source xml:lang="en">My text goes here </source>
  <target xml:lang="en">My text goes here </target>
</trans-unit>

for another language it would look like this:

<trans-unit id="2345" resname="some_key">
  <source xml:lang="en">My text goes here </source>
  <target xml:lang="es">My text in Spanish goes here</target>
</trans-unit>

what I now want is a gender specific translation. I would love to use transchoice and use the translations from my files

On the Symfony doc I can only find the example with static text.

Question is what do I have to put in twig and what into the translations files?

I tried to put the choices in twig but then it does not translate at all. I also tried to put one key and the choices in the translation file but this also does not work. It selects always the second option and also prints the text as it is (including {f} for female)

What I want is something like:

{% transchoice gender with {'%lastname%': user.lastname}  %}
  {f} key_for_female |{m} key_for_male | {u} key_for_unknown
{% endtranschoice %}

which will be replaced by translations like

<trans-unit id="1234" resname="key_for_female">
  <source xml:lang="en">Hello Ms %lastname% </source>
  <target xml:lang="en">Hello Ms %lastname%  </target>
</trans-unit>

so that the output is in the end "Hello Ms Doe". What is the correct syntax? ;)



via Chebli Mohamed

project folder, that contains sub-folder with .git folder seems issue

all the files in the folder are adding except the following one, i dont know what the issue, i guess there is a .git folder is that something related.

enter image description here

enter image description here

There are files and folders in the dompdf-module, need to be added to the repo.

enter image description here

These was the response after i add the files from the folder dino/dompdf-module

enter image description here



via Chebli Mohamed

ExtJs put a tooltip to the horizontal scroll controls Tab Panel

I have a tab panel with some items inside them, when I add many elements the panel puts a horizontal movement controlers, how can i do to put a tooltip in this controls?

Tab Panel

This is the definition of my tab Panel:

        var tabPanel = Ext.create('Ext.tab.Panel',{
        id: 'tabTabla',
        items: [{
            title: 'list1',
            tooltip: 'list1',
            items:[tree]
        }, {
            title: 'list2',
            tooltip: 'list2',
            autoWidth : true,
            autoHeight : true,
            plain : true,
            defaults : {
                autoScroll : true,
                bodyPadding : 0
            },
            items: [{
                xtype : 'label',
                text : 'list description.',
            },
            gridV]
        },{
            title: 'list3',
            tooltip: 'list3',
            autoWidth : true,
            autoHeight : true,
            plain : true,
            defaults : {
                autoScroll : true,
                bodyPadding : 0
            },
            items: [
                    gridC
                    ]
        }]
    });

In this tab Panel I add more panels:

    Ext.apply(this, {
        title: 'TITLE',
        constrain: true,
        header : {
            titlePosition : 2,
            titleAlign : 'center'
        },
        closable : false,
        x : 20,
        y : 270,
        layout : 'fit',
        animCollapse : true,
        collapsible : true,
        collapseDirection : Ext.Component.DIRECTION_LEFT,
        items: [tabPanel]
    });



via Chebli Mohamed

How to get raw User Timings data using Google Analytics Core Reporting API

I'm using User Timings to measure how long something takes, by doing e.g. ga('send', 'timing', 'jQuery', 'Load Library', 20, 'Google CDN');

In Google Analytics web interface at Behavior > Site Speed > User Timings I can see both an average and an histogram (by clicking the tab Distribution).

Using the Analytics Core Reporting API I'm able to retrieve the average user timing by querying on the metric ga:avgUserTimingValue. I was wondering if it's possible to retrieve the histogram or the raw data itself. I'm specifically looking to create a box plot using the user timings data.



via Chebli Mohamed