vendredi 11 septembre 2015

Boost Geometry doesn't copy the attributes of my custom point class

I am attempting to use Boost Geometry with a custom vertex class that has x,y and many parameters for rendering such as texture coordinates. I registered the custom class using BOOST_GEOMETRY_REGISTER_POINT_2D and the algorithms such as union_ work but only x,y are valid. (I am a C++ veteran but have never learned generic programming.) I can demonstrate the problem when I take an instance of my vertex and use boost::geometry::append( boostPolygon, myVertex );

I can trace the append call in the debugger and I see that a default constructed instance of my vertex is being created and then the accessors of my vertex class are being called to copy the x, and y values leaving all the rest of the parameters as set in the default constructor.

What I really want is for boost::geometry::append() to behave exactly like boostPolygon.outer().push_back( myVertex); So I replaced the append call with the above push_back and it added the points to the polygon as I wanted but then when I called union_() on the polygons they lost all the members other than x and y again.

I figure that what I want is a typical use-case so it is best to ask rather than guess how to handle this. I've seen the examples of how to adapt a class but my template kung-fu isn't enough to follow along. So do I need to add more adaption or is there something simple I need to do?

Scott



via Chebli Mohamed

Java 8 stream processing not fluent

I have a problem with Java 8 streams, where the data is processed in sudden bulks, rather than when they are requested. I have a rather complex stream-flow which has to be parallelised because I use concat to merge two streams.

My issue stems from the fact that data seems to be parsed in large bulks minutes - and sometimes even hours - apart. I would expect this processing to happen as soon as the Stream reads incoming data, to spread the workload. Bulk processing seems counterintuitive in almost every way.

My input is a Spliterator of unknown size and I use a forEach as the terminal operation.



via Chebli Mohamed

Background of user control hide the controls inside of him

http://ift.tt/1NmaMtn

I Have user control i set him background, but the problem is that the background hide the controls inside of him



via Chebli Mohamed

EasyMock record phase mock as argument

Is it possibile with EasyMock during the register phase to register a method call whose arguments is a mock? E.g:

String s = 'a string';

ClassA a = createMock(ClassA.class);
ClassB b = createMock(ClassB.class);
ClassC c = createMock(ClassC.class);

expect(c.bFactoryMethod()).andReturn(b);
a.someMethod(s, b);
replayAll();

ClassToTest toTest = new ClassToTest();
toTest.wrapperMethodThatCallsSomeMethod(s);
verifyAll();

EasyMock complains about:

java.lang.IllegalStateException: missing behavior definition for the preceding method call



via Chebli Mohamed

how to retrieve LogCat data after use Log.d(); statement as we get logcat information earlier

I have just used Log.d(); statement to debug my app and for this I created a filter configuration. I got it working so that it shows the feedback.

But Now I deleted this Log.d(); from my app. But I can't access the Logcat Information as I got earlier. It's not a error. I just want to get my logcat as I used before Log.d(); statement.



via Chebli Mohamed

Encountered the symbol "DECLARE" and Encountered the symbol "end-of-file"

I'm following a tutorial from Oracle, and in the last step I'm trying to execute a SQL script where I get the errors from DECLARE and end-of-file. Any idea where I went wrong? The following is the script:

create or replace
PROCEDURE ENQUEUE_TEXT(
 payload IN VARCHAR2 )
AS
 enqueue_options DBMS_AQ.enqueue_options_t;
 message_properties DBMS_AQ.message_properties_t;
 message_handle RAW (16);
 user_prop_array SYS.aq$_jms_userproparray;
 AGENT SYS.aq$_agent;
 header SYS.aq$_jms_header;
 MESSAGE SYS.aq$_jms_message;
BEGIN
 AGENT := SYS.aq$_agent ('', NULL, 0);
 AGENT.protocol := 0;
 user_prop_array := SYS.aq$_jms_userproparray ();
 header := SYS.aq$_jms_header (AGENT, '', 'aq1', '', '', '', user_prop_array);
 MESSAGE := SYS.aq$_jms_message.construct (0);
 MESSAGE.set_text (payload);
 MESSAGE.set_userid ('Userid_if_reqd');
 MESSAGE.set_string_property ('JMS_OracleDeliveryMode', 2);
 --(header, length(message_text), message_text, null);
 DBMS_AQ.enqueue (queue_name => 'userQueue', enqueue_options => enqueue_options,
message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
 COMMIT;
END ENQUEUE_TEXT;
DECLARE
  PAYLOAD varchar2(200);
BEGIN
  PAYLOAD := 'Hello from AQ !';
  ENQUEUE_TEXT(PAYLOAD => PAYLOAD);
END;



via Chebli Mohamed

int or float to represent numbers that can be only integer or "#.5"

Situation

I am in a situation where I will have a lot of numbers around about 0 - 15. The vast majority are whole numbers, but very few will have decimal values. All of the ones with decimal value will be "#.5", so 1.5, 2.5, 3.5, etc. but never 1.1, 3.67, etc.

I'm torn between using float and int (with the value multiplied by 2 so the decimal is gone) to store these numbers.

Question

Because every value will be .5, can I safely use float without worrying about the wierdness that comes along with floating point numbers? Or do I need to use int? If I do use int, can every smallish number be divided by 2 to safely give the absolute correct float?

Is there a better way I am missing?

Other info

I'm not considering double because I don't need that kind of precision or range.

I'm storing these in a wrapper class, if I go with int whenever I need to get the value I am going to be returning the int cast as a float divided by 2.



via Chebli Mohamed

becomeFirstResponder does not work in cellForRowAtIndexPath

When calling textView becomeFirstResponder from cellForRowAtIndexPath returns false, why?

But from other method i.e. from didSelectRowAtIndexPath it works.

Is it in connection that I am using iOS 8 introduced UITableViewAutomaticDimension row height approach?!



via Chebli Mohamed

scrollView is nil when called from viewdidload

I want to scrolling view when navigationItem clicked. But..here is some error.

  1. I want to make snapchatlike scroll view. It works fine, but... when I call scrollView out of viewdidload function, scrollView is nil!

  2. I already make snapchat like swipe view. but I want to make swipe view when navigation Item(heart mark) clicked.

My ViewController viewdidload func - it works fine

@IBOutlet weak var scrollView: UIScrollView!


var V1 : LeftViewController = LeftViewController(nibName: "LeftViewController", bundle: nil)
var V2 : CenterViewController = CenterViewController(nibName: "CenterViewController", bundle: nil)
var V3 : RightViewController = RightViewController(nibName: "RightViewController", bundle: nil)



override func viewDidLoad() {

    super.viewDidLoad()



    self.addChildViewController(V1)
    self.scrollView.addSubview(V1.view)
    V1.didMoveToParentViewController(self)

    self.addChildViewController(V2)
    self.scrollView.addSubview(V2.view)
    V2.didMoveToParentViewController(self)

    self.addChildViewController(V3)
    self.scrollView.addSubview(V3.view)
    V3.didMoveToParentViewController(self)

    var V2Frame : CGRect = V2.view.frame
    V2Frame.origin.x = self.view.frame.width
    V2.view.frame = V2Frame


    var V3Frame : CGRect = V3.view.frame
    V3Frame.origin.x = 2 * self.view.frame.width
    V3.view.frame = V3Frame

    println(self)
    println(scrollView)
    println(V2.view.frame)

    self.scrollView.setContentOffset(CGPointMake(V2Frame.origin.x, self.view.frame.size.height), animated: false)



    self.scrollView.contentSize = CGSizeMake(self.view.frame.width * 3, self.view.frame.size.height)        }

My ViewController clickEvent func - why scrollView is nil?

    func clickEvent() {
    V2.view.frame = CGRect(x: 375.0, y: 0.0, width: 320.0, height: 568.0)
    let scrollView = UIScrollView(frame: CGRect(x: 0.0, y: 0.0, width: 320.0, height: 568.0))


    self.scrollView?.scrollRectToVisible(V2.view.frame, animated: true)

    println(self)
    println(scrollView)
    println(V2.view.frame)
    //self.scrollView.setContentOffset(CGPointMake(V2.view.frame.origin.x, self.view.frame.size.height), animated: true)
}

I call clickEvent in Viewcontroller from other CenterViewController - it can call fine but...in ViewController clickEvent functions' scrollView is nil.. How can I fix it?

func clickEvent(sender: AnyObject) {

   ViewController().clickEvent()
}



via Chebli Mohamed

How to disable a button until some text field are filled?

Using Java FX 8, I have two text fields and a button to validate. I want this button to be disabled until both fields have a valid value.

What is the best way to do this ?

Thanks,



via Chebli Mohamed

Batch script for loop

I have a problem with for loop in batch script. When I try:

for /f "delims=;" %g in ('dir') do echo %g%

i see this

'dir' is not recognized as an internal or external command,
operable program or batch file.

Did I miss somethig? Why windows command doesn't work?



via Chebli Mohamed

single web page cache prevention

Is it possible to create a basic single page web page which doesn't get stored into a users browser cache?

Or

Is it possible to create a basic single page web page which deletes itself from the users browser cache?

I understand that such a page can't be fool proof because the user could simply take a screenshot to capture the data on the web page.



via Chebli Mohamed

Specifying a Range of Rows Based on Checkbox

So I have scoured the internet to put together this small macro, but I haven't had any luck figuring out what I'm doing wrong. I know the answer is going to be simple, but it certainly beyond me. The goal is to have a checkbox insert several rows from a separate sheet, then delete those same rows if you uncheck the box. The copy and insert functions are working perfectly, but I do not know how to write the line for the range of rows to delete. The Code below is obviously not correct, because rngD is specified for testing. rngD should be the 7 rows below the check box, or maybe there is a better way to do it. Thanks a lot for checking this out, and I'm open to any constructive criticism.

Working in Excel 2013

Sub Insert_LL()


Dim ws As Worksheet
Dim chkB As CheckBox
Dim rngA As Range
Dim rngD As Range
Dim lRow As Long
Dim lRowD As Long
Dim llRows As Range


Set llRows = Range("Lesson_Learned")
Set ws = ActiveSheet
Set chkB = ws.CheckBoxes(Application.Caller)
lRow = chkB.TopLeftCell.Offset(1).Row
lRowD = chkB.TopLeftCell.Offset(7).Row
Set rngA = ws.Rows(lRow)
Set rngD = ws.Rows("18:24") 'needs to specify the range of rows dependant where the checkbox is located'


Application.ScreenUpdating = False


    Select Case chkB.Value
        Case 1
            llRows.Copy
            rngA.Insert Shift:=xlDown
        Case Else
            rngD.Delete
    End Select

Application.CutCopyMode = False
Application.ScreenUpdating = True


End Sub



via Chebli Mohamed

Insert only paid account numbers into a new sheet

Very new to VBA. I need to copy all paid account numbers into Column A of the current sheet. The Accounts sheet has the account numbers in column A and in column B either "Paid" or "Unpaid". I just keep getting error after error and I'm not sure if I'm fixing it or making it worse, but the last error I couldn't get past was for the line Cells(t,1).Value =i: "Application Defined or Object Defined Error."

Sub Button1_Click()

  Dim t As Integer
  Dim i As Range

  Dim sheet As Worksheet
  Set sheet = ActiveWorkbook.Sheets("Accounts")

  Dim rng As Range
  Set rng = Worksheets("accounts").Range("A:A")

  'starting with cell A2
  target = 2
  'For each account number in Accounts
  For Each i In rng
  'find if it's paid or not
    If Application.WorksheetFunction.VLookup(i, sheet.Range("A:B"), 2, False) = "PAID" Then
      'if so, put it in the target cell
      Cells(t, 1).Value = i
      t = t + 1
    End If
  Cells(t, 1).Value = i
  t = t + 1
  Next i

End Sub



via Chebli Mohamed

Coding array with NSCoder Swift

I'm trying to implement the NSCoder, but am currently facing a stubborn issue. My goal is to save the array of strings via NSCoder to a local file and load it when the app opens next time.

Here is the class i've created, but i'm not sure how i should handle the init and encoder functions:

class MyObject: NSObject, NSCoding {

var storyPoints: [String] = []

init(storyPoints : [String]) {
    self.storePoints = storePoints
}


required init(coder decoder: NSCoder) {
    super.init()

???

}

func encodeWithCoder(coder: NSCoder) {
???
}

}

Moreover, how do i access it in my view controller? where should i declare a path for saving the NSCoder? It's not really clear enough.

Looking forward to any advices.

Thank you.



via Chebli Mohamed

Ember.js how to observe array keys changed by input

I have an object with a couple decades of settings, some settings depend on other settings, so, I need to observe if some setting changed.

import Ember from 'ember';

export default Ember.Controller.extend({
   allPermissionChanged: function () {
      alert('!');
  }.observes('hash.types.[].permissions'),
  permissionsHash: {
    orders:{
      types: [
        {
          label: 'All',
          permissions: {
            view: true,
            edit: false,
            assign: false,
            "delete": false,
            create: true
          }
        },

        }
      ],
      permissions:[
        {
          label:'Просмотр',
          code:'view'
        },
        {
          label:'Редактирование',
          code:'edit'
        },
        {
          label:'Распределение',
          code:'assign'
        },
        {
          label:'Удаление',
          code:'delete'
        },
        {
          label:'Создание',
          code:'create'
        }
      ]
    }
  }

});

Next I try to bind each setting to input

<table class="table table-bordered">
    <thead>
    <tr>

      {{#each hash.types as |type|}}
          <th colspan="2">{{type.label}}</th>
      {{/each}}
    </tr>

    </thead>
    <tbody>
    {{#each hash.permissions as |perm|}}
        <tr>
          {{#each hash.types as |type|}}
            {{#if (eq (mut (get type.permissions perm.code)) null)}}
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            {{else}}
                <td>{{perm.label}}</td>
                <td>{{input type="checkbox"  checked=(mut (get type.permissions perm.code)) }}</td>

            {{/if}}
          {{/each}}
        </tr>
    {{/each}}
    </tbody>

</table>

But observer doesn't work.

Also I prepared Jsbin example - http://ift.tt/1NmaLWj



via Chebli Mohamed

AngularJS Directive Isolated Scope Issue

I'm fairly new to AngularJS and am trying to put together a small demo application. The part I'm trying to get working is as follows:

  • User enters stock market code into text field that is two-way bound with ng-model.
  • Directive has a bind-to-click function that retrieves some data from an API.
  • Once data is returned, the directive is compiled and appended to a div.
  • The directive is supposed to accept a text variable through an isolated scope and display it. This is the part that is not working properly.

Code

Directives

financeApp.directive('watchlistItem', function () {
    return {
        restrict: 'E',
        templateUrl: 'app/directives/watchlistItem.html',
        replace: true,
        scope: {
            asxCode: "@"
        }
    }
});

financeApp.directive('myAddCodeButton', ['$compile', '$resource', function ($compile, $resource) {
    return function(scope, element, attrs){
        element.bind("click", function () {
            scope.financeAPI = $resource('http://ift.tt/1qXLaIk', {callback: "JSON_CALLBACK" }, {get: {method: "JSONP"}});
            //scope.financeResult = 
            scope.financeAPI.get({q: decodeURIComponent('select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22' + scope.asxcodeinput + '.AX%22)'),
                format: 'json', env: decodeURIComponent('store%3A%2F%2Fdatatables.org%2Falltableswithkeys')})
            .$promise.then(function (response) {
                scope.quote = response.query.results.quote;
                console.log(scope.quote);
                angular.element(document.getElementById('watchlistItemList')).append($compile("<watchlist-item asx-code=" + scope.quote.Symbol + "></watchlist-item")(scope));
            }, function (error) {
                console.log(error);
            });
        });
    };
}]);

Directive Template

<div class="watchItem">
    <a href="#/{{asxCode}}">
        <div class="watchItemText">
            <p class="asxCodeText"><strong>"{{asxCode}}"</strong></p>
            <p class="asxCodeDesc"><small></small></p>
        </div>
        <div class="watchItemQuote">
            <p class="asxPrice lead"></p>
            <p class="asxChangeUp text-success"></p>
        </div>
    </a>
</div>

HTML

<html lang="en-us" ng-app="financeApp">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta charset="UTF-8">

    <title>ASX Watchlist and Charts</title>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="http://ift.tt/1K1B2rp">
    <link rel="stylesheet" href="css/styles.css">

    <script src="http://ift.tt/1FBSnCz"></script>
    <script src="http://ift.tt/1NmaLWh"></script>
    <script src="http://ift.tt/1FBSkGR"></script>
    <script src="app/app.js"></script>
</head>
<body>

    <div class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#/">ASX Watchlist and Charts</a>
            </div>
        </div>
    </div>

    <div class="container-fluid" id="mainContainer">
        <div class="row">
            <div class="floatLeft" id="leftDiv" ng-controller="navController">
                <form class="inline-left">
                    <div class="form-group floatLeft">
                        <label class="sr-only" for="asxinput">ASX Code</label>
                        <input type="text" class="form-control" id="asxinput" placeholder="ASX Code" ng-model="asxcodeinput" />
                    </div>
                    <button class="btn btn-default floatRight" my-add-code-button>Add</button>
                </form>
                <div id="watchlistItemList">
                    <!-- Test item -->
                    <div class="watchItem">
                        <a href="#/AFI">
                            <div class="watchItemText">
                                <p class="asxCodeText"><strong>AFI</strong></p>
                                <p class="asxCodeDesc"><small>Australian Foundation Investments Co</small></p>
                            </div>
                            <div class="watchItemQuote">
                                <p class="asxPrice lead">$6.50</p>
                                <p class="asxChangeUp text-success">+ 5%</p>
                            </div>
                        </a>
                    </div>
                </div>
            </div>
            <div class="floatLeft" id="rightDiv" ng-view>

            </div>
        </div>
    </div>

</body>
</html>

The directive "compiles" and is appended to the DOM element as expected, but the asxCode variable is not interpolating within the directive template.

Any suggestions greatly appreciated.



via Chebli Mohamed

Select column header and first column of a cell in datagridview when selected

I need to change the color of the Header Cell and first column called "col_row" when one or more cells are selected with the mouse like this:

enter image description here

I use this code and its working:

    Private Sub gdv_PatioAcopio_CellStateChanged(sender As Object, e As DataGridViewCellStateChangedEventArgs) Handles gdv_PatioAcopio.CellStateChanged
    If e.Cell.ColumnIndex = 0 Then
        e.Cell.Selected = False
    Else

        If e.Cell.Selected = True Then
            Me.gdv_PatioAcopio.Columns(e.Cell.ColumnIndex).HeaderCell.Style.BackColor = Color.LightBlue
            Me.gdv_PatioAcopio.Rows(e.Cell.RowIndex).Cells("col_row").Style.BackColor = Color.LightBlue
        ElseIf e.Cell.Selected = False Then
            Me.gdv_PatioAcopio.Columns(e.Cell.ColumnIndex).HeaderCell.Style.BackColor = Color.Navy
            Me.gdv_PatioAcopio.Rows(e.Cell.RowIndex).Cells("col_row").Style.BackColor = Color.Navy
        End If

    End If
End Sub

but when i deselect, for example, the third column, the first column changes its color to Color.Navy.

enter image description here

How can i prevent this?

Thanks!



via Chebli Mohamed

spring-mvc mail not working with the ZK framework

I have a problem replicating the following example on my site created with the ZK-framework: http://ift.tt/1lesONx

When submitting the form, I get:

HTTP ERROR 404

Problem accessing /backend/sendEmail.do. Reason:

Not Found

even though I've specified in my my web.xml to map .do files to the dispatcherservlet.

The relevant entries in web.xml are:

 <servlet>
    <servlet-name>SpringController</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-mail.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>SpringController</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

In pom.xml:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-aop</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context-support</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-web</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-expression</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-beans</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-orm</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>

In spring-mail.xml:

<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/GArMu6
http://ift.tt/GAf8ZW">

<bean id="mailSender"      class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="smtp.gmail.com" />
    <property name="port" value="587" />
    <property name="username" value="username" />
    <property name="password" value="password" />

    <property name="javaMailProperties">
        <props>
            <prop key="mail.smtp.auth">true</prop>
            <prop key="mail.smtp.starttls.enable">true</prop>
        </props>
    </property>
</bean>

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/" />
    <property name="suffix" value=".zul" />
</bean>

<bean
    class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    <property name="exceptionMappings">
        <props>
            <prop key="java.lang.Exception">Error</prop>
        </props>
    </property>
</bean>

The form .zul:

<zk xmlns:h="native">
    <window title="Recupera password">
        <h:form method="post" action="sendEmail.do">
            <grid hflex=" 1">
                <columns>
                    <column align="right" hflex="min" />
                    <column />
                </columns>
                <rows>
                    <row>
                        E-mail :
                        <hlayout>
                            <textbox id="email" cols="24" tabindex="1" />
                        </hlayout>
                    </row>
                    <row>
                        <label />
                        <button id="invia" type="submit" label="Invia" />
                    </row>
                </rows>
            </grid>
        </h:form>
    </window>
</zk>

and finally, the controller:

@Controller
@RequestMapping("/backend/sendEmail.do")
public class RecuperaPasswordController {

    @Autowired
    private JavaMailSender mailSender;

    @RequestMapping(method = RequestMethod.POST)
    public void invia(HttpServletRequest request) throws MessagingException {
    }

}

In theory everything should be in place, as far as I see, but it still gives me this error. Judging from similar posts, the problem might be that the .zul is not in the WEB-INF folder, but as far as I've understood, that folder is inaccessible, and for good reasons, since it might contain configuration files with sensitive information, so I'm kind of lost.

Otherwise, if someone knows a good way to integrate maildispatching with ZK, I'm all ears for other alternative solutions!

EDIT: As requested, the whole web.xml:

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4" xmlns="http://ift.tt/qzwahU"
    xmlns:xsi="http://ift.tt/ra1lAU"
    xsi:schemaLocation="http://ift.tt/qzwahU http://ift.tt/16hRdKA">

    <description><![CDATA[MyEfm]]></description>
    <display-name>MyEfm</display-name>

    <!-- //// -->
    <!-- ZK -->
    <listener>
        <description>ZK listener for session cleanup</description>
        <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
    </listener>
    <servlet>
        <description>ZK loader for ZUML pages</description>
        <servlet-name>zkLoader</servlet-name>
        <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>

        <!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet). It 
            must be the same as <url-pattern> for the update engine. -->
        <init-param>
            <param-name>update-uri</param-name>
            <param-value>/zkau</param-value>
        </init-param>
        <!-- Optional. Specifies whether to compress the output of the ZK loader. 
            It speeds up the transmission over slow Internet. However, if you configure 
            a filter to post-processing the output, you might have to disable it. Default: 
            true <init-param> <param-name>compress</param-name> <param-value>true</param-value> 
            </init-param> -->
        <!-- [Optional] Specifies the default log level: OFF, ERROR, WARNING, INFO, 
            DEBUG and FINER. If not specified, the system default is used. <init-param> 
            <param-name>log-level</param-name> <param-value>OFF</param-value> </init-param> -->
        <load-on-startup>1</load-on-startup><!-- Must -->
    </servlet>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zul</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zhtml</url-pattern>
    </servlet-mapping>
    <!-- [Optional] Uncomment it if you want to use richlets. <servlet-mapping> 
        <servlet-name>zkLoader</servlet-name> <url-pattern>/zk/*</url-pattern> </servlet-mapping> -->
    <servlet>
        <description>The asynchronous update engine for ZK</description>
        <servlet-name>auEngine</servlet-name>
        <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>

        <!-- [Optional] Specifies whether to compress the output of the ZK loader. 
            It speeds up the transmission over slow Internet. However, if your server 
            will do the compression, you might have to disable it. Default: true <init-param> 
            <param-name>compress</param-name> <param-value>true</param-value> </init-param> -->
        <!-- [Optional] Specifies the AU extension for particular prefix. <init-param> 
            <param-name>extension0</param-name> <param-value>/upload=com.my.MyUploader</param-value> 
            </init-param> -->
    </servlet>
    <servlet-mapping>
        <servlet-name>auEngine</servlet-name>
        <url-pattern>/zkau/*</url-pattern>
    </servlet-mapping>

    <!-- [Optional] Uncomment if you want to use the ZK filter to post process 
        the HTML output generated by other technology, such as JSP and velocity. 
        <filter> <filter-name>zkFilter</filter-name> <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class> 
        <init-param> <param-name>extension</param-name> <param-value>html</param-value> 
        </init-param> <init-param> <param-name>compress</param-name> <param-value>true</param-value> 
        </init-param> </filter> <filter-mapping> <filter-name>zkFilter</filter-name> 
        <url-pattern>your URI pattern</url-pattern> </filter-mapping> -->
    <!-- //// -->

    <!-- ///////////// -->
    <!-- DSP (optional) Uncomment it if you want to use DSP However, it is turned 
        on since zksandbox uses DSP to generate CSS. -->
    <servlet>
        <servlet-name>dspLoader</servlet-name>
        <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
        <init-param>
            <param-name>class-resource</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>dspLoader</servlet-name>
        <url-pattern>*.dsp</url-pattern>
    </servlet-mapping>

     <servlet>
        <servlet-name>SpringController</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring-mail.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

<!--     <servlet-mapping> -->
<!--         <servlet-name>SpringController</servlet-name> -->
<!--         <url-pattern>*.zul</url-pattern> -->
<!--     </servlet-mapping> -->

    <servlet-mapping>
        <servlet-name>SpringController</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <!-- Less compiler ZK Less Servlet da commentare in produzione / collaudo -->

    <!-- <servlet> -->
    <!-- <servlet-name>zkLess</servlet-name> -->
    <!-- <servlet-class>org.zkoss.less.ZKLessServlet</servlet-class> -->
    <!-- <init-param> -->
    <!-- <param-name>org.zkoss.less.LessResource</param-name> -->
    <!-- specify to the folder that contains *.less -->
    <!-- <param-value>/common/less</param-value> -->
    <!-- </init-param> -->
    <!-- <init-param> -->
    <!-- <param-name>org.zkoss.less.OutputFormat</param-name> -->
    <!-- specify output file suffix, default .css.dsp -->
    <!-- <param-value>.css.dsp</param-value> -->
    <!-- </init-param> -->
    <!-- <init-param> -->
    <!-- <param-name>org.zkoss.less.CompressOutput</param-name> -->
    <!-- compress output, default true -->
    <!-- <param-value>true</param-value> -->
    <!-- </init-param> -->
    <!-- <load-on-startup>1</load-on-startup> -->
    <!-- </servlet> -->
    <!-- <servlet-mapping> -->
    <!-- <servlet-name>zkLess</servlet-name> -->
    <!-- specify to folder that contains *.less -->
    <!-- <url-pattern>/common/less/*</url-pattern> -->
    <!-- </servlet-mapping> -->

    <!-- End Less compiler -->

    <!-- /////////// -->
    <!-- [Optional] Session timeout -->
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>


    <!-- Spring configuration -->
    <!-- Initialize spring context -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        /WEB-INF/applicationContext.xml
        /WEB-INF/applicationContext-security.xml
    </param-value>
    </context-param>
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:log4j.properties</param-value>
    </context-param>
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>root-pf</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <filter><!-- the filter-name must be preserved, do not change it! -->
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter>
        <filter-name>OpenEntityManagerInViewFilter</filter-name>
        <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>OpenEntityManagerInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>




    <!-- [Optional] MIME mapping -->
    <mime-mapping>
        <extension>doc</extension>
        <mime-type>application/vnd.ms-word</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>gif</extension>
        <mime-type>image/gif</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>htm</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>html</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>jpeg</extension>
        <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>jpg</extension>
        <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>js</extension>
        <mime-type>text/javascript</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>pdf</extension>
        <mime-type>application/pdf</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>png</extension>
        <mime-type>image/png</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>xls</extension>
        <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>xml</extension>
        <mime-type>text/xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>zhtml</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>zul</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>

    <welcome-file-list>
        <welcome-file>index.zul</welcome-file>
        <welcome-file>index.zhtml</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
    </welcome-file-list>
</web-app>



via Chebli Mohamed

How do you get get absent rows from a SQL table?

I am not sure if I had asked the question correctly in title, but here the proper scenario.

Suppose I have SQL table in which rows are inserted everyday. In these rows there is one column which has one set of values. That means in this column, let's call it Source_system, we receive 20 values each day. Same distinct values everyday. Now is there any way I can get the name of the source system which is not inserted for that day?

EDIT: Sorry for bad English.



via Chebli Mohamed

pagination for a table contents in yii

I'm using Yii application. In that how to give pagination to a table contents( not using cgridview).

In view,

<table data-provides="rowlink" data-page-size="20" data-filter="#mailbox_search" class="table toggle-square default footable-loaded footable" id="mailbox_table">
                                <thead>
                                    <tr>

                                        <th></th>
                                        <th data-hide="phone,tablet">To</th>
                                        <th>Subject</th>
                                        <th data-hide="phone" class="footable-last-column">Date</th>
                                    </tr>
                                </thead>
                                <tbody>

                                    <?php


                                    foreach ($model as $item) {
                                        if ($item->email_status == 1)
                                            echo '<tr id="' . $item->emailid . '" class="unreaded rowlink" style="display: table-row;">';
                                        else
                                            echo '<tr id="' . $item->emailid . '" class="rowlink" style="display: table-row;">';
                                        echo '<td class="nolink footable-first-column">';
                                        echo '<span class="footable-toggle"></span>';

                                        echo '</span></td>';
                                        echo '<td>' . $item->touser->username . '</td>';
                                        echo '<td>' . $item->email_subject . '</td>';
                                        $originalDate = $item->time;
                                        $newDate = date("Y-M-d H:i:s", strtotime($originalDate));


                                        echo '<td class="footable-last-column">' . $newDate . '</td></tr>';
                                    }
                                    ?>
                                </tbody>

                            </table>

In Controller,

   public function actionOutbox() 
   {
       $criteria = new CDbCriteria;
       $criteria->order = 'time DESC';
       $model = Email::model()->findAllByAttributes(array(
              'from_userid' => Yii::app()->user->id
           ), 
           $criteria
       );

       $this->render('outbox', array(
          'model' => $model,
       ));
   }

In this code how to add pagination. I tried following different techniques but found none of them to work. Please help me.



via Chebli Mohamed

UIImagePickerController with cameraOverlayView - misplaced views

I have a UIImagePickerController with a custom cameraOverlayView.

I create the imagePicker like this:

self.overlay = [self.storyboard instantiateViewControllerWithIdentifier:@"OverlayViewController"];
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;

// Insert the overlay
self.picker.cameraOverlayView = self.overlay.view;
self.overlay.pickerReference = self.picker;

self.picker.edgesForExtendedLayout = UIRectEdgeAll;
self.picker.extendedLayoutIncludesOpaqueBars = YES;

self.picker.delegate = self.overlay;


[self presentViewController:self.picker animated:NO completion:^{

}];

For some reason, the OverlayViewController's view is misplaced. It seems as if the constraints haven't been calculated. However, if I explicitly call [self.overlay viewWillAppear:NO]; in the completion block, they layout seems to render correctly.

After some investigation it seems as if viewWillAppear and viewDidAppear is not called for the OverlayViewController.

However, these methods are called if I come back to the imagePicker from a modal 'custom gallery viewcontroller'.

I.e: rootVC-> (No calls) -> imagePicker -> customGalleryVc customGalleryVc (dismiss modal) -> (Calls to willAppear) -> imagePicker

What is this? Am I missing something with the fundamentals of the view-hierarchy?

Thank you!



via Chebli Mohamed

In Pandoc, how do I add a newline between authors through the YAML metablock without modifying the template?

I am trying to add a a couple of authors to a report I am writing. Preferably, the second author would appear on a new line after the first. I know I can modify the template to add a new field or the multiple author example given in the Pandoc readme. However, I wonder if there is any character I can use to insert a new line between authors directly in the metablock. So far I have tried \newline, \\, | with newline and space, <br>, <div></div>, and making the author list a string with newline or double spaces between author names, but nothing has worked. My desired output is pdf.



via Chebli Mohamed

Angular $modal scope - Passing an object to $modal

I am attempting to pass angular's bootstrap modal the url of the image that was clicked in a angular masonry gallery. What I have is very close to the demo in the documentation with only a few changes. I know this is completely an issue with my own understanding of scope.

My modal HTML:

    <div class="modal-header">
        <h3 class="modal-title">I'm a modal!</h3>
    </div>
    <div class="modal-body">
        <ul>
            <li ng-repeat="item in items">
                <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a>
            </li>
        </ul>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
        <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
    </div>

And in my Controller:

angular.module('testApp').controller('GalleryCtrl', function ($scope, $modal, $log) {
  $scope.animationsEnabled = true;
  $scope.items = ['item1', 'item2', 'item3'];
  // Temporary Generation of images to replace with about us images
  function genBrick() {
      var height = ~~(Math.random() * 500) + 100;
      var id = ~~(Math.random() * 10000);
      return {
        src: 'http://placehold.it/' + width + 'x' + height + '?' + id
      };
  };
  this.bricks = [
    genBrick(),
    genBrick(),
    genBrick(),
    genBrick(),
    genBrick(),
    genBrick()
  ];
  this.showImage = function(item){
    alert(item.src); // gives me exactly what im trying to pass to the modal
    var modalInstance = $modal.open({
      animation: $scope.animationsEnabled,
      templateUrl: 'views/modal.html',
      scope: $scope,
      controller: 'GalleryCtrl',
      resolve: {
        items: function () {
          return $scope.items;
        }
      }
    });

    modalInstance.result.then(function (selectedItem) {
      $scope.selected = selectedItem;
    }, function () {
      $log.info('Modal dismissed at: ' + new Date());
    });

  }
});

Lastly for clarity, this is my masonry code

<div masonry>
    <div class="masonry-brick" ng-repeat="brick in gallery.bricks">
        <img ng-src="{{ brick.src }}" alt="A masonry brick" ng-click="gallery.showImage(brick)">
    </div>
</div>

Right now this works fine to return the items objects 3 values in li tags to the modal just like in the original example. What id really like to pass into the model is the (item.src) but no matter what i change it never seems to get passed in so that i can display it.



via Chebli Mohamed

JMeter: Is Windows not capable of handling a hundreds of thousands of users in single system

My linux (i5 Processor, RAM: 16GB) machine is able to handle 100k users easily however same does not happen with Windows 8 (i7 Processor 2600 @ CPU 3.40GHz, RAM: 32GB) and thread creation stops after specific amount of thread is created somewhere around 20k in JMeter.

Is there any reason as why Windows in not able to handle huge number of users?



via Chebli Mohamed

Way to check at least one of X field validation in CakePHP?

I've been using CakePHP 2.7 to develop a web application. I have a Staff add form where I want to check that at least one of a selection of fields has been filled in before Cake will call a SQL procedure.

I've done a little bit of research and came across the following questions: Example 1 and Example 2

However, I have tried all the variations of results that others have suggested and still have the issue where the form will still ask for firstname, lastname, jobtitle, email and telephone to all be filled in before it will process the request.

Can anyone help?

Form code:

<?php
    echo $this->Form->create('Staff', array('inputDefaults' => array('div' => true)));
    echo $this->Form->input('Salutation', array('label' => 'Salutation'));
    echo $this->Form->input('FirstName', array('label' => 'First name *'));
    echo $this->Form->input('LastName', array('label' => 'Last name *'));
    echo $this->Form->input('Qualifications', array('label' => 'Qualifications'));
    echo $this->Form->input('JobTitle', array('label' => 'Job Title *'));
    echo $this->Form->input('Email', array('label' => 'Email *'));
    echo $this->Form->input('Telephone', array('label' => 'Telephone *'));
    echo $this->Form->input('NTLogon', array('label' => 'NT logon *'));
    echo $this->Form->end('Save');
?>

Model code:

<?php
class Staff extends AppModel {
    var $useTable = false;

    public $validate = array(
        'FirstName' => array(
            'check_details' => array(
                'rule' => 'hasDetails',
                'message' => 'Name or job title are required.'
            )
        ),
        'LastName' => array(
            'check_details' => array(
                'rule' => 'hasDetails',
                'message' => 'Name or job title are required.'
            )
        ),
        'JobTitle' => array(
            'check_details' => array(
                'rule' => 'hasDetails',
                'message' => 'Name or job title are required.'
            )
        ),
        'Email' => array(
            'check_contact' => array(
                'rule' => 'hasContact',
                'message' => 'Email or telephone is required.'
            )
        ),
        'Telephone' => array(
            'check_contact' => array(
                'rule' => 'hasContact',
                'message' => 'Email or telephone is required.'
            )
        )
    );

    function hasDetails(){
        if ((!empty($this->data['Staff']['FirstName']) && !empty($this->data['Staff']['LastName'])) || !empty($this->data[$this->name]['JobTitle'])) {
            return true;
        } else {
        return false;
        }
    }

    function hasContact(){
        if (!empty($this->data['Staff']['Email']) || !empty($this->data['Staff']['Telephone'])) {
            return true;
        } else {
        return false;
        }
    }
}

?>



via Chebli Mohamed

Could not enter data: You have an error in your SQL syntax? Check line 1 ())

Here is the error it's returning:

Could not enter data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near  '() )' at line 1

How do i fix it, it's very annoying. Im a noob at programming MySQL and PHP. So any help would be appreciated.

Here is my code:

<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$conn = mysql_connect($dbhost, $dbuser, $dbpass);

if(! $conn )
{
   die('Could not connect: ' . mysql_error());
}

$sql = 'INSERT INTO users '.
   '(ID,Points) '.
   'VALUES ( "2222", "999"() )';

mysql_select_db('database1');
$retval = mysql_query( $sql, $conn );

if(! $retval )
{
   die('Could not enter data: ' . mysql_error());
}

echo "Entered data successfully\n";

mysql_close($conn);
 ?>

Thanks in advance.

Edit: Sry for asking this question, would delete it if i could.



via Chebli Mohamed

Speech Recogniton in Android Error

i am interesting in speech recogniton android but i cant do it it is not continous if you stop the speaking it doesn t continue you have to click on button again and i dont want to do it again do you have any solves pleas help!

And sorry for my english it is not good



via Chebli Mohamed

Change x-values in gnuplot

I'm plotting a column of data which represents a time series in gnuplot. Every value represents a time value after 500 iterations / time units. Can I tell gnuplot to multiply the x-values it displays by 500?

I thought this would be a standard problem since every time one has to plot a time series one needs to tell the plotting program what time unit each iteration has.

I don't want to create an extra column with x-values manually, since I have a lot of different data of different length. I don't want to create a x column for everyone of them.



via Chebli Mohamed

Place python list in excel column

Say I have two lists in Python:

A_List=["jim", "go"]
B_List=["kkj", "nmh",123]

how can I get those lists into a .csv Excel file, where in column A, A1 contains jim, B2 contains nmh, A2 contains go.

In other words, each list's items needs to go into a column in Excel, with each list item in a separate cell.



via Chebli Mohamed

Regex:javascript

I am trying to make regex for email my regex is:

^(?:[0-9a-zA-z.!!@#$%^&*+={}'/-]+@[a-zA-Z]{1}[a-zA-Z]+[/.][a-zA-Z]{2,4}|)$

According to this regex it should accept special characters as mentioned in rule but should not accept [ and ] but it accepting [ and ].

I want to use this regex but it should exclude [ and ].



via Chebli Mohamed

Getting image icon

Studying webpages to learn html/css/javascript

Got confused when I thought that most images were linked to or loaded locally... It seems like on spotify their search button is using something I don't understand to load the magnifying glass.

.spoticon-search-32:before {
    content: "\f141";
    font-size: 32px;
}

If I edit content the picture of the search button goes away so I know its the content that is responsible for the picture. But where the hell is it loading it from? it's not a .png or .jpg extension either...



via Chebli Mohamed

how can i grep the interface names given in following output of netstat -i

Hi i want grep the interfaces names as a list , am getting the table of interfaces with netstat -i and it looks like this : enter image description here

thanks .



via Chebli Mohamed

Dropdown links do not display on hover

After a long break from HTML/CSS, I recently created a menu with dropdown links using a method I have used once before, and was surprised to find that this application of them is not working.

I used this

ul li:hover ul{ display:block;}

to "turn on" my menus when hovering, but they simply never appear. I have tried adding div tags around various blocks of code to no avail. What tricks am I missing?

jsfiddle here: http://ift.tt/1M1PijL



via Chebli Mohamed

After Xcode Crash app doesn't do anything but eat memory.

I'm using Xcode Version 6.4 (6E35b)on a mid 2013 MacBook Air running OS X 10.10.5.

A few days ago, with my code in something of a tangle, Xcode crashed. After the crash, my app built and ran, but didn't do anything except eat memory at a fantastically fast rate.

I keep a git repository and every now and then a put a copy of the whole project folder on an offsite location.

I've tried both using earlier commits and reloading saved projects. All of these had compiled and worked properly previously.

All copies of the same project (by name) now do the same thing. Eat memory, and nothing else.

I tried removing DerivedData, removing contents of /var/folders/, removing and replacing schema (in schema -> manage), removing all projects, emptying trash, and have removed Xcode (using "trash me") and reinstalling. No joy. Still the same thing.

I'm able to move my project forward by copying the project to a new folder and changing the project name, so I don't have a complete disaster on my hands.

But I can't figure out how to find whatever it is that is messed up in Xcode in the original project.



via Chebli Mohamed

PDO fetch single class not working

i am making a database abstraction class that binds objects like an ORM. I'm having issue with a particular case, fetching a single row and binding to a class. While the same is working well with fetchAll() i can't figure out why using fetch(PDO::FETCH_CLASS) the object returns null. if i use PDO::FETCH_LAZY it works, but isn't a correct binding to the passed class. Here the code. The Database() class is connects to db using PDO. Products() is a class made of public attributes with same name of tables. The controller:

public function editProducts($params) {
    $products = new Products();
    $db = new Database ();
    $id = array_keys($params);
    $products = $db->findById($products, $id[0]); // auto Bind object fetched=no and POST params?
    $this->template = new Template();
    $this->template->renderArgs("product", $products);
    $this->template->renderArgs("page_title", "Edit product " . $products->title);
    $this->template->render(get_class($this), "editProducts");

}

The DB class:

public function findById($object,$id) {
    try {
    $table = $this->objectInjector($object);
    } catch (Exception $e) {
        if (APP_DEBUG) {
            d($e->getTrace());
        }
        return;
    }
    $statement = "SELECT * FROM $table WHERE id=:id";
    $this->stm = $this->pdo->prepare($statement);
    $this->bindValue(":id",$id);
    return $this->fetchSingleObject($object);
}

the method that abstract fetch:

public function fetchSingleObject($object) {
    $this->execute();
    $this->stm->setFetchMode(PDO::FETCH_CLASS, get_class($object));
    return $this->stm->fetch(PDO::FETCH_CLASS);
    //return $this->stm->fetch(PDO::FETCH_LAZY); this works!
}

I missed something? the fetchAll() works nicely in this way:

 public function fetchObjectSet($object) {
        $this->execute();
        $this->stm->setFetchMode(PDO::FETCH_CLASS, get_class($object));
        return $this->stm->fetchAll(PDO::FETCH_CLASS);
    }

Thank you so much. PS: some methods like $this->execute() are just abastractions to pdo->statment method since pdo and stm are db class instance variables.



via Chebli Mohamed

How to test application using app authenticity enabled on remote worklight server?

We are trying to test our IBM MobileFirst Platform Foundation-based mobile application with IBM Rational Test Workbench MobileTest version 8.7.

One issue we are running into is that the testing fails due to application authenticity tests failure when trying to test against a remote worklight server. We tried to test it locally and that works. However, we are wondering if turning off the app authenticity is the only way to test using a remote worklight server. If anyone knows of any setting etc to get around the issue without having to turn off app authenticity every time we test on a pre-production build ( using remote server ) please let us know. It will be a great help.



via Chebli Mohamed

Download large files using ftp protocol

i know this is probably not the first time, this is asked. But i can't find the solution to the problem..

  private void bgftpdownload_DoWork(object sender, DoWorkEventArgs e)
    {
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpurl + "/" + clientlabel.Text + "/data.7z");
        request.Credentials = new NetworkCredential(ftpuser, ftppass);
        request.Method = WebRequestMethods.Ftp.GetFileSize;
        request.Proxy = null;

        FtpWebResponse response = (FtpWebResponse)request.GetResponse();
        long fileSize = response.ContentLength;

        request = (FtpWebRequest)WebRequest.Create(ftpurl + "/" + clientlabel.Text + "/data.7z");
        request.Credentials = new NetworkCredential(ftpuser, ftppass);
        request.Method = WebRequestMethods.Ftp.DownloadFile;
        using (FtpWebResponse responseFileDownload = (FtpWebResponse)request.GetResponse())
        using (Stream responseStream = responseFileDownload.GetResponseStream())
        using (FileStream writeStream = new FileStream(LocationFile, FileMode.Create))
        {

            int Length = 2048;
            Byte[] buffer = new Byte[Length];
            int bytesRead = responseStream.Read(buffer, 0, Length);
            int bytes = 0;

            while (bytesRead > 0)
            {
                writeStream.Write(buffer, 0, bytesRead);
                bytesRead = responseStream.Read(buffer, 0, Length);
                bytes += bytesRead;
                int totalSize = (int)(fileSize / 1048576);
                bgftpdownload.ReportProgress((bytes / 1048576) * 100 / totalSize, totalSize);
            }
        }
    }
    private void bgftpdownload_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
            progresslabel.Text = e.ProgressPercentage * (int)e.UserState / 100 + " Mb / " + e.UserState + " Mb";
            progressBar1.Value = e.ProgressPercentage;
    }

I have this code, and its working great.. until its hitting a 2 gb file on the ftp server

I can read on other forums, the value limit for (int) is = 2147483591 So the problem is off cause my byte is getting higher than limit (2147483591)

An exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll but was not handled in user code

Additional information: Værdien '-45' er ugyldig for 'Value'. 'Value' skal være mellem 'minimum' og 'maximum'.

What can i do to fix this problem?



via Chebli Mohamed

Imgae overlay and responsive design

I have to overlay two images to obtain the fade effect on the page scroll, and this not a problem, it works well. The problem is that if I don't set a height to the .square-banner class, the banners are overlapped by the following ones (second picture). Because the website is responsive I need to eliminate the height to the .square-banner class and I don't have found a solution for this.

<div id="banner-1-1" class="square-banner">
    <img class="img-bottom" id="img-bottom-1" src="images/prodigio-wording.jpg">
    <img class="img-top" id="img-top-1" src="images/prodigio.jpg">
</div>

.square-banner {
  position:relative;
  float:left;
  width:100%;
  height: 430px;
  cursor: pointer;
}

.img-bottom, .img-top {
width: 100%;
height: auto;
display:block;
float:left; 
}

.square-banner img {
  position:absolute;
  left:0;
  -webkit-transition: opacity 1s ease-in-out;
  -moz-transition: opacity 1s ease-in-out;
  -o-transition: opacity 1s ease-in-out;
  transition: opacity 1s ease-in-out;
}

Because of the image position:absolute (to have them overlay), the .square-banner doesn't occupy space in height. This is the real problem I have to solve

enter image description here

enter image description here



via Chebli Mohamed

MYSQLI Logical ordering when using ORDER BY

How do I get order by to logically order the buyers numbers?

The query:

SELECT * FROM $auction_id ORDER BY buyer_num

Results:

> 1 2 23 3 32 4 5 6 62 7 8 9 10

What I need the results to output:

> 1 2 3 4 5 6 7 8 9 10 23 32 62



via Chebli Mohamed

Angular - modularly define all services

Say I have service modules like so

// services/someService.js
export default function($q) {
  return $q.doSomething();
}

// services/anotherService.js
export default function($state) {
  return $state.doAnotherThing();
}

And say I have a services index file

// services/index.js
import someService from 'someService';
import antoherService from 'anotherService';

export default {
  someService: someService,
  anotherService: anotherService,
}

In my angular module, I want to be able to register all of them (eloquently).

// awesomeModule.js
import services from './services';

angular.module('awesomeModule', [])
.services(services); // Want to emulate something like this

I'm having troubling finding a nice clean way to register the index module so that I can prevent registering each service individually in the awesomeModule. Any way to do this?



via Chebli Mohamed

ZF2 Class PDO not founf but PDO is enabled in php config

My zf2 application always worked fine but suddenly I started getting this error

Fatal error: Class 'PDO' not found in /home/doaminName/public_html/http://ift.tt/1F1z0aY on line 21

My PHP version is native (5.4) and here is the Configure Command from phpinfo. PDO is enabled with this line --enable-pdo=shared.

'./configure' '--enable-bcmath' '--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-mbstring' '--enable-pdo=shared' '--enable-soap' '--enable-sockets' '--enable-zip' '--prefix=/usr/local' '--with-bz2' '--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libexpat-dir=/usr' '--with-libxml-dir=/opt/xml2' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-pic' '--with-png-dir=/usr' '--with-tidy=/opt/tidy/' '--with-xmlrpc' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'

Any idea of where the problem is coming from?



via Chebli Mohamed

C# Deserialize string to Object

I have response from Jira API, require to be deserialized into data model:

com.atlassian.greenhopper.service.sprint.Sprint@40675167[id=10151,rapidViewId=171,state=CLOSED,name=Sprint 37.1,startDate=2015-07-30T16:00:22.000+03:00,endDate=2015-08-13T16:00:00.000+03:00,completeDate=2015-08-13T14:31:34.343+03:00,sequence=10151]

This is actually the information of current sprint for issue. I need to deserialize it to model like:

public class Model
{
    public string name { get; set; }
    ...
}

I have already removed all not-required information, like com.atlassian.greenhopper.service.sprint.Sprint@40675167 using Regex pattern [(.*?)] so I have brackets and all inside. Now I stopped completely trying to find the way how to convert this string to data model.

Thanks for help



via Chebli Mohamed

Equivalent to parameter expansion in shell script

I understood parameter expansion

a = ${b:-c}

which will assign content of 'b' to a if 'b' is set and else content of 'c'

Is there anyway I can directly do a="123":-"456" rather than storing '123' to variable and '456' to another variable.



via Chebli Mohamed

PDO doesn't recognize a parameter

I have this query:

INSERT INTO user ( username , password , role )
SELECT
  CONCAT( :username1 , "-" , ABS( REPLACE( (
    SELECT username FROM user
    WHERE username LIKE :username2
    ORDER BY ID DESC LIMIT 1
  ), :username3, "" ) ) + 1 ) AS username,
  :password,
  :role

In php I have this code for binding values:

$dbp = $db->prepare( $query );
for( $i = 1 ; $i <= 3 ; $i++ ){
        $dbp->bindValue( ':username' . $i , ( $i == 2 ? 'test%' : 'test' ) );
}
$dbp->bindValue( ':password' , '0' );
$dbp->bindValue( ':role' , 'test' );
$dbp->execute();

I have in the query 5 parameters:

:username1 , :username2 , :username3 , :password , :role

and each of everyone of them are assigned with the bindValue function.

Hovewer it triggers this error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]:
Invalid parameter number: parameter was not defined' in [...]
PDOStatement->bindValue(':username1', 'test') #1 {main} thrown in [...]

But the parameter do exists in my query and in my for loop. Can't I use a parameter in the CONCAT function?

This link, however, doesn't help me:

1) The :parameter name does not match the bind by mistake (typo?)

As I said, every parameter is matched: i echoed right before every bindValue, and every parameter was written correctly.

2) Completely forgetting to add the bindValue()

5 parameters, 5 bindValues , 5 echos with right matching

Third point in not for my question.



via Chebli Mohamed

XSLT access to line and column position in source file of target element

I’m looking for an XPath expression in XSLT that will give me the line and column number of the position in the input XML file where the matched element is. Perhaps looking like this:

<xsl:template match="//foo">
  element foo is at line <xsl:value-of select="...?" /> column <xsl:value-of select="...?" /> of the input file
</xsl:template>

Is there any way to do this with XSLT?



via Chebli Mohamed

Check if an argument is a certain array

I have two arrays, which I want to pass as arguments to another Sub:

Public arr1 As Variant
Public arr2 As Variant

Sub Main()
    arr1 = listSheet.Range("E2:G4").Value
    arr2 = listSheet.Range("H2:J60").Value

    call mySub(arr1)
    call mySub(arr2)
End sub()

In the "other" sub, I need to check which array is passed, but none of the below options is working:

sub mySub(ByRef myArr As Variant)

    if myArr=arr1 Then
    'do actions
    end if
'and I also tried:
    if myArr is arr1 then
    'do actions
    end if
end sub

How can I possibly check this using an IF statement, or is this doable in any other way?



via Chebli Mohamed

NPM Install Error - Node-Pre-Gyp

When I try to run npm-install I get:

npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x8 6)\nodejs\node_modules\npm\bin\npm-cli.js" "install" npm ERR! node v4.0.0 npm ERR! npm v2.14.2 npm ERR! code ELIFECYCLE

npm ERR! v8-debug@0.4.6 install: node-pre-gyp install --fallback-to-build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the v8-debug@0.4.6 install script 'node-pre-gyp install --fal lback-to-build'. npm ERR! This is most likely a problem with the v8-debug package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-pre-gyp install --fallback-to-build npm ERR! You can get their info via: npm ERR! npm owner ls v8-debug npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! C:_Src\Personal\rzaleski\ILikeThis\npm-debug.log

I tried a number of things (installing VS C++ redistrib, npm install --msvs_version=2013, etc). Nothing seems to work.

Do you have any ideas how I can find out the actual error (the log is a bit daunting).

UPDATE: What I ended up doing was reverting from Node v4.0.0 to NODE v0.12. This is not really a fix to the issue, but it got me around my issues.



via Chebli Mohamed

Ractive / Moustache Template for Head Tag

I have been searching for this all over, but can not find an answer or example.

Can a Ractive template be used to construct head elements that are consistant across pages, and can that be loaded from a separate file?

For example: all html, head, and title tag info is loaded via a referencable template from an external file into an index page. +html+ +head+ +title+ +/title+ +/head+

And if so, how do you do it? As I try to wrap my head around it, jquery and ractive.js would need to load. Is there a different/better solution?



via Chebli Mohamed

ClassNotFoundException: Didn't find class

I tried to make a custom keyboard using this tutorial on tuts+, but when I run it and change the keyboard I get the error:

java.lang.RuntimeException: Unable to instantiate service com.ginso.simplekeyboard.SimpleIME: java.lang.ClassNotFoundException: Didn't find class "com.ginso.simplekeyboard.SimpleIME" on path: DexPathList[[zip file "/data/app/com.ginso.simplekeyboard-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

I tried to remove the dot in the manifest in <service android:name=".SimpleIME" />. I also tried the code for manifest someone posted in the comments. But nothing changed. What am I doing wrong?

Edit:
SimpleIME is located in the standard package.



via Chebli Mohamed