vendredi 11 septembre 2015

Split up latest commits into multiple branches

I'm aware of several questions on the subject, but I didn't find any that address this situation. The trick is that I need to pull one commit out from between two others.

My repo looks like this:

A - B - C     <- master
          \
            D  <- devel

and I want it to look like this:

    C  <- feature1
  /
A
  \
    B - D  <- feature2

I know I can probably use rebase for this, but after a year of using Git I'm still not clear on all the jargon.



via Chebli Mohamed

Handling text containing both quote types

I want to append the following text to a file in Linux:

echo He said "I can't append this" >> file.txt
cat file.txt
He said I can't append this

How do I include both sets of quotes in the appended string?



via Chebli Mohamed

Angular ng-repeat best practice to only watch for updates inside the specific iteration

I need to render a table in which the user is allowed to edit some fields for each row, fields that will affect other fields in the same row.

For this reason I could not use bind-once on all the data I'm rendering.

If I got it right, simply using a code like the following

<table class="table table-bordered table-condensed table-hover">
  <thead>
    <tr class="info">
      <th>Header</th>
      <th>Header</th>
      <th>Header</th>
      <th>Header</th>
    </tr>
  </thead>
  <tbody>
    <tr ng-repeat="a in alist">
      <td>{{::a.id}}</td>
      <td>{{::a.cod}}</td>
      <td>
        <input
          ng-model="a.sel"
          type="checkbox"
          class="input-sm"></input>
      </td>
      <td ng-if="a.sel">
        {{::a.desc}}
      </td>
      <td ng-if="!a.sel">
        "Other Content"
      </td>
    </tr>
  </tbody>

will cause that for each time a user checks or uncheks the a.sel checkbox, all the angular {{vars}} in the page (not the {{::vars}}) will be watched for changes.

If this is true (and therefore that's the reason why page is slow when hundreds of rows are loaded) how could I tell angular I only want it to check if something has changed inside that specific row, that specific ng-repeat iteration?

Not sure how to proceed to get good performances, any other tips are appreciated.

Thank you for your help.



via Chebli Mohamed

Accessing environment variables in python

Why does this not print out 'xxx'?

$ SECRET_KEY='xxx' python -c 'import os; print os.environ['SECRET_KEY']'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'SECRET_KEY' is not defined



via Chebli Mohamed

Groovy half-exclusive range strange behaviour

Why is Groovy showing this behaviour when using half-exclusive range. It is supposed to return all but the last element in the range but it sometimes show all elements in the range plus one.

This is the sample.

 class Weekday implements Comparable {
    static final DAYS = [
        'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
    ]
    private int idx = 0

    Weekday(index)     { idx = index }
    Weekday next()     { new Weekday(idx+1) }
    Weekday previous() { new Weekday(idx+1) }
    int compareTo(Object other) { this.idx <=> other.idx }

    String toString() {
        def index = idx % DAYS.size()
        while (index < 0 ) index += DAYS.size()
            DAYS[index]
    }
}

def mon = new Weekday(1)
def fri = new Weekday(5)

7.times { mon++ } // Monday following week

println fri.idx   //  5
println mon.idx   //  8

println 5 .. 8    // [5, 6, 7, 8]
println fri..mon  // [Fri, Sat, Sun, Mon] Ok without half-exclusive
println 5 ..< 8   // [5, 6, 7]
println fri..<mon // [Fri, Sat, Sun, Mon, Tue] ????????



via Chebli Mohamed

ui-router: intermediate templates

We are building a website with Angular Material and ui-router, and all our content page share the same "container", because we always want the same responsive behaviour.

The code of this generic container would be something like:

  <div class="layout-content">
    <div layout="column" layout-align="center">
      <div layout="row" layout-align="center center">
        <section class="layout-fixed-width md-whiteframe-z1" flex-sm="100" flex-gt-sm="90">

        {{content placed here}}

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

The header can differ in all pages, so the structure we have would basically be:

enter image description here

The question is, how can this be achieved in ui-router? We have done some nested views, but I don't see how to do a generic template so the code could be something like:

<form>
  <md-toolbar>
      <div ui-view="generic-template">
          <div ui-view="my-content"></div>
      </div>
  </md-toolbar>
</form>

Ideally we would want to define only one time the generic-template view, and use it in all our modules.

In the nested states and nested views documentation I see mostly nested state stuff, but what we want is really only a plain html template, so maybe we are over-complicating this, and an easier way is possible (I'm quite sure it's the case). I've also checked this issue, where one of the answers say that ui-router should be the solution, but not much more.

Maybe we should do a directive instead?



via Chebli Mohamed

open source html rendering engine suitable for java webbrowser

is There any rendering engine which support HTML5 css3 and javascript etc , I want to use it in my web browser project in java or any other suggestion for me ?



via Chebli Mohamed