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

Bash readline history previous line before history expansion

There are usually the keys Up and Ctrl+P mapped to previous-history Readline command in Bash which moves back in history to previous line with history expanded.

How to move to the previous line before History expansion? E.g. to line like

!!:gs/20010910/20010911/



via Chebli Mohamed

Should I use sync or blocking channels?

I have several go routines and I use unbuffered channels as sync mechanism. I'm wondering if there is anything wrong in this(e.g. compared with a WaitGroup implementation). A known "drawback" that I'm aware of is that two go routines may stay blocked until the 3rd(last) one completes because the channel is no buffered but I don't know the internals/what this really means.

func main() {
    chan1, chan2, chan3 := make(chan bool), make(chan bool), make(chan bool)
    go fn(chan1)
    go fn(chan2)
    go fn(chan3)
    res1, res2, res3 := <-chan1, <-chan2, <-chan3
}



via Chebli Mohamed

Polymer 1.0: google-signin sign in still success when user revoke permissions

I am using a google-signin element to have access to user's access scopes. I found, if I as a user authorize the my app with certain scopes, then revoke those scopes without clicking on "Sign out" button (basically the google-signin element), the google-sign is result as onSigninSuccess event even without the authorization.

This is weird. It should be onSigninFailure because the app doesn't have the corresponding scopes of authorizations from the user.



via Chebli Mohamed

Difference between \z and \Z and \a and \A in Perl

Hello Can you please tell me the difference between \z and \Z as well as \a and \A in Perl with a simple example ?



via Chebli Mohamed

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

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

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

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

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

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

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

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

Printing numbers

I am writing a program to display as below

when n=3
1 2 3
7 8 9
4 5 6

when n=5
1 2 3 4 5
11 12 13 14 15
21 22 23 24 25
16 17 18 19 20
6 7 8 9 10

my program is

#include<stdio.h>
#include<conio.h>
int main()
{
    int n=5,r=1,c=1,i=1,mid=0;
    if(n%2==0)
      mid=(n/2);
    else 
      mid=(n/2)+1;
      printf("mid = %d\n",mid);
    while(r<=n)
    {
      while(c<=n)
      {
        printf("%d ",i);
        c++;
        i++;
      }
      r++;
      if(r<=mid)
       i=i+n;
      else
       i=i-(2*n);
      printf("\n");
      c=1;
    }
    getch();
    return 0;
}

when I give n=3, I am getting my expected output. but when I give n=5 I am getting as below

1 2 3 4 5
11 12 13 14 15
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15

Could someone please help how to achieve expected output.



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