text:
Q: Coldfusion + Google Map API v3 — info window and set bounds Simply, I seem to be able to write code that either creates a clickable marker for a pop-up infoWindow OR gets the bounds of the returned markers and resets the map extent and zoom levels.  I can't seem to combine the two.  My example below will nicely set the extent of the map to the results of the query.  But I don't quite know how to include the addListener event to the marker given how my loop is structured, and that in the var mapOptions, I set center: gbounds.getCenter().  These two issues seem to complicate my ability to add events to the map or marker.
    <cfquery name="myquery" datasource="xxxx">
       SELECT name, lat, long
       FROM tblMain
    </cfquery>

    <cfset bridgeCoord=arrayNew(1)>

    <cfloop query="myquery">
   <cfset bridge[CurrentRow] = structNew()>
   <cfset bridge[CurrentRow].lat=lat>
       <cfset bridge[CurrentRow].long=longX>
          <cfset bridge[CurrentRow].name=name>
     </cfloop>

<cfquery name="mi" datasource="xxxx">
SELECT name, lat, long, content
FROM tblName
</cfquery>

<cfoutput query="mi">

#mi.name#

#mi.content#

</cfoutput>

END EDIT
First you have to move the map and mapOptions to the top. Then inside your loop just add the addListener to the map for the marker:
<cfloop index="mi" array="#bridge#">
   <cfoutput>
       //make the point
       var point = new google.maps.LatLng(#mi.lat#,#mi.long#);
       gbounds.extend(point);
       //make the marker
       var marker = new google.maps.Marker({position: point, title:"#JSStringFormat(mi.name)#", map:map});
       google.maps.event.addListener(marker, 'click', function() {
           infowindow.setContent("#JSStringFormat(mi.content)#");
           infowindow.open(this.map, this);
       });
       markers[markers.length] = marker;
    </cfoutput>
</cfloop>

Things to note:
I added JSStringFormat to the name and content variables.
There is a map option in the marker creation that you can just add "map:map" to it so you don't have to run the for loop at the bottom.
Also, since you are now creating the map ahead of the markers you will move the zoom and center options to the bottom.
if(markers.length > 1)
    map.fitBounds(gbounds);
else
    map.setCenter(gbounds.getCenter());

Also once last thing:
Instead of
markers[markers.length] = marker;

You can use this
markers.push(marker);

A: I'm not sure what the problem is but you may find it easier to debug (and extend) if you untangle your JavaScript and ColdFusion code.  You could write all the map logic in JS and then use CF to create the data (array of lat/lng/title) that the JS will process.

Using this approach you could completely eliminate CF and the database during testing by hard-coding the points array.


text:
Q: postfix send double mail when mail is forwarded postfix will forward two mail to user when i configure autoreply, sender_bcc and always_bcc.
i have used postfix with dovecot and mysql for virtual user configuration. i dont found where is the problem is.
when i send mail from lakhaman@sufalam.com to jugal@sufalam.com and
in main.cf i have
always_bcc=pranav@sufalam. following are the log.
May 30 07:25:27 sufalammail postfix/smtpd[7827]: connect from unknown[192.168.0.201]
May 30 07:26:58 sufalammail postfix/smtpd[7827]: 69139222DE: client=unknown[192.168.0.201]
May 30 07:27:13 sufalammail postfix/cleanup[7839]: 69139222DE: message-id=<20090530015658.69139222DE@sufalammail.com>
May 30 07:27:13 sufalammail postfix/qmgr[7824]: 69139222DE: from=<lakhaman@sufalam.com>, size=363, nrcpt=2 (queue active)
May 30 07:27:14 sufalammail postfix/pickup[7823]: 050C4222E0: uid=491 from=<lakhaman@sufalam.com>
May 30 07:27:14 sufalammail postfix/cleanup[7839]: 050C4222E0: message-id=<20090530015658.69139222DE@sufalammail.com>
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 050C4222E0: from=<lakhaman@sufalam.com>, size=475, nrcpt=3 (queue active)
May 30 07:27:14 sufalammail postfix/pipe[7842]: 69139222DE: to=<jugal@sufalam.com>, relay=dfilt, delay=93, delays=92/0.04/0/0.59, dsn=2.0.0, status=sent (delivered via dfilt service)
May 30 07:27:14 sufalammail postfix/pipe[7842]: 69139222DE: to=<pranav@sufalam.com>, relay=dfilt, delay=93, delays=92/0.04/0/0.59, dsn=2.0.0, status=sent (delivered via dfilt service)
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 69139222DE: removed
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<jugal@sufalam.com>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.1, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<pranav@sufalam.com>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.11, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<pranav@sufalam.com>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.11, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 050C4222E0: removed
May 30 07:27:15 sufalammail postfix/smtpd[7827]: disconnect from unknown[192.168.0.201]

active entry of master.cf is show as below.
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -        -       -       -       smtpd
#        -o content_filter=spamfilter:dummy
         -o content_filter=vacation:dummy
         -o content_filter=dfilt:dummy
#       -o cleanup_service_name= cleanupAF
vacation  unix  -       n        n       -       -       pipe
    flags=Rq user=vacation argv=/var/spool/vacation/vacation3.pl -f ${sender} -- ${recipient}
# flags=Rq user=vacation argv=/usr/bin/perl argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}
#submission inet n       -       n       -       -       smtpd
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       n       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
relay     unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
#spamassassin unix -      n       n       -       -       pipe
#    flags=Rq user=spamd argv=/usr/bin/spamc -u ${user} -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
#dovecot    unix  -       n       n       -       -       pipe
#       flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -d ${recipient}
#spamfilter unix         -       n       n       -       -       pipe
#   flags=Rq user=spamfilter argv=/usr/local/bin/spamfilter.sh -f ${sender} -- ${recipient}
#spamfilter unix -       n       n       -       -       pipe
#    flags=Rq user=vmail argv=/usr/bin/spamc -u ${user}@${domain} -e /usr/sbin/sendmail.postfix -oi -f ${sender} ${recipient}
dfilt     unix    -       n       n       -       -       pipe
    flags=Rq user=filterAlt argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}
#vacation  unix  -       n        n       -       -       pipe
#    flags=Rq user=vacation argv=/var/spool/vacation/vacation3.pl -f ${sender} -- ${recipient}
cleanupAF unix n - n - 0 cleanup
#-o always_bcc=pranav@sufalam.com
#-o recipient_bcc_maps=mysql:/etc/postfix/mysql-virtual_always_bcc.cf

same way if i send mail to autoreply user then also sender get two mail.

A: Most likely you have a content filter and the always_bcc is being called both before and after the content filter. Customise the smtpd either before or after the content filter to include
-o receive_override_options=no_address_mappings

(Note that options in master.cf can't contain spaces).

A: For me 'enable_original_recipient = No' in main.cf did the trick.:-)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Solving integral with complex path integrals Dear math stackexchange,
I'm trying to show this:
$$ \int_{-\infty}^{\infty} \frac{e^{ax}}{1+e^x} dx = \frac{\pi}{\sin{(a\pi)}}, 0<a<1$$
I tried:
$$\int_{-\infty}^{\infty} f(x) dx =   \lim_{R\to\infty } \int_{-R}^{R} f(x) dx = \lim_{R\to\infty } \int_{-R}^{R} \frac{e^{ax}}{1+e^x} dx$$
Then i want to split the integration on the boundaries of a rectangle defined by the vertices:
$$ z = \pm R, z = \pm R + 2 \pi i $$
This is obviously $ z \in \mathbb{C}$ so i need to expand on a complex function that covers the real of the normal function. Maybe just: $\frac{e^{az}}{1+e^z}$
Now i should just have to solve 4 path integrals, However they are quite difficult i think so i think i am on wrong path (No pun intended).
I would love some hints and tips to go about this problem

A: So, the thing about those path integrals - the reason you chose that path - is that some will tend to variations on the integral we want to evaluate, and the others will go to zero. That is how we use the residue theorem to evaluate integrals; we don't start with a closed path, so we come back around to close it with pieces we can understand.

*

*$\int_{-R}^R$ : This is simple - it goes to $\int_{-\infty}^{\infty} f(x)\,dx$, the integral we want to evaluate.

*$\int_{R}^{R+2\pi i}$ : $\dfrac{e^{ax}}{1+e^x} = \dfrac{e^{(a-1)x}}{1+e^{-x}}$. When the real part of $z$ is $R$ and $s$ is real, $|e^{sx}|=e^{sR}$. Applied here,
$$\left|\frac{e^{(a-1)x}}{1+e^{-x}}\right| = \frac{e^{(a-1)R}}{|1+e^{-x}|} \le \frac{e^{(a-1)R}}{1-e^{-R}}\to 0$$
Integrate that along a path of fixed length $2\pi i$, and it goes to zero.

*$\int_{R+2\pi i}^{-R+2\pi i}$ : For this, we use the identity $f(x+2\pi i) = e^{2\pi i a}f(x)$; the translation leaves the denominator unchanged, and multiplies the numerator by a fixed quantity. Since we trace this integral backwards, there's an extra $-1$ factor, and this one tends to $-e^{2\pi i a}\int_{-\infty}^{\infty}f(x)\,dx$.

*$\int_{-R+2\pi i}^{-R}$ : On this vertical segment, it's the $1$ term in the denominator that dominates. We get
$$\left|\frac{e^{ax}}{1+e^x}\right| = \frac{e^{-aR}}{|1+e^x|}\le\frac{e^{-aR}}{1-e^{-R}}\to 0$$
Integrate that along a path of fixed length $2\pi$, and it goes to zero.

Adding up the pieces, we get a limit that's a sum of two constant multiples of the integral we're trying to evaluate. In order to solve for that integral, we need a second evaluation of the contour integral - and that calls for the residue theorem. There's exactly one pole in the rectangle enclosed, at $\pi i$.
Can you take it from here?


text:
Q: Checking Scale Out Deployment of SSRS using PowerShell I logged on the SSRS server and from the SSRS Configuration Manager, I can check if it's a scale out deployment. But is there a way to check it using PowerShell? I want to automate this process and check the configuration of SSRS servers in a more efficient way. Can anyone provide me with a PowerShell script or command that can help me check the scale out deployment of SSRS? Any help is greatly appreciated.
Update
I conducted a registry search and yielded no results. I perused the configuration files of SSRS with no avail. My search of the SSRS database also proved fruitless. Where else might the information be located?


text:
Q: How to see this order statistic result and find my error Let W be a random variable with pdf
$f(w)=\theta B^{-\theta}w^{\theta-1}$ for $0 \lt w \lt B$
and 0 otherwise.
Assuming Independence,
Show that ,
$W_{n:n} \to B$ as $n \to \infty$ where $W_{n:n}$
is the largest order statistic.
I am wondering where I go wrong in my approach.
What I did was as follows,
For the original distribution , the CDF is
$\int_{0}^{w} \theta B^{-1}u^{\theta-1}du$
$=B^{-\theta}w^{\theta}$ for w in $(0,B)$
hence the CDF of the max order statistic is
$(B^{-\theta}w^{\theta})^{n}$
$=[\frac{w}{B}]^{\theta n}$
And since $w \lt B$, $\frac{w}{B} \lt 1$ and hence this will go to zero as $n \to \infty$ while the correct answer is $B$.


text:
Q: How do I set expiration settings to Envelope Definition? I'm trying to set expiration settings to my Envelope Definition, but I'm unable to.
I am using the following as a reference to create and send my envelope:
https://github.com/docusign/docusign-csharp-client/blob/master/test/Recipes/CoreRecipes.cs
I have already tried the following:
envDef.ExpireAfter = "1";
envDef.ExpireEnabled = "true";
envDef.ExpireDateTime = DateTime.Now.AddDays(1).ToString("dd MMM yyyy hh:mm ff");

The document does send with every other setting that I've set, however, there are no expiration settings set to it despite the above.

A: As Inbar states, you'll need to create an Expirations object and apply it to your envelope definition. As per DocuSign's Dev blog, you can do so like this:
var expirations = new Expirations("1", "true", "0"); //ExpireAfter, Enabled, Warning days
var reminders = new Reminders("0", "true", "0");  //ReminderDelay, Enabled, Frequency
//results in no reminders and no expiration warning sent, envelope expires one day after sending

and then apply that to the envelopeDefinition.Notification parameter
envelopeDefinition.Notification = new Notification(expirations, reminders, "false"); //Expirations, Reminders, UseDefaults

A: You would need to use the Expiration class in the C# model in the client.
that object would have 3 fields (https://github.com/docusign/docusign-csharp-client/blob/1d125f362ba8ae33edc2a72a713fc1e6e8b55314/sdk/src/DocuSign.eSign/Model/Expirations.cs)
ExpireAfter - string that is a number of days to expire after envelope changed status to "sent"
ExpireWarn - string that is a number of days before envelope is expired that you would warn user (via email) that envelope is about to expire.
ExpireEnabled - "true" - to allow you to customize this envelope (vs. using the account's defaults)
I believe if ExpireAfter == ExpireWarn than the email won't be sent.
I think you can set ExpireAfter to 1 and ExpireWarn to 0 which should result in an email right away, I haven't tested it yet. Otherwise - need to wait a day to test this....


text:
Q: View not refreshed when .onAppear runs SwiftUI I have some code inside .onAppear and it runs, the problem is that I have to go to another view on the menu and then come back for the UI view to refresh. The code is kind of lengthy, but the main components are below, where mealData comes from CoreData and has some objects:
Go to the updated comment at the bottom for a simpler code example
VStack(alignment: .leading) {

            ScrollView(.vertical, showsIndicators: false) {
                VStack(spacing: 2) {
                    ForEach(mealData, id: \.self) { meal in
                        VStack(alignment: .leading) { ... }
                        .onAppear {

                            // If not first button and count < total amt of objects
                            if((self.settingsData.count != 0) && (self.settingsData.count < self.mealData.count)){
                                let updateSettings = Settings(context: self.managedObjectContext)

                                // If will_eat time isn't nill and it's time is overdue and meal status isn't done
                                if ((meal.will_eat != nil) && (IsItOverDue(date: meal.will_eat!) == true) && (meal.status! != "done")){
                                    self.mealData[self.settingsData.count].status = "overdue"

                                    print(self.mealData[self.settingsData.count])

                                        if(self.settingsData.count != self.mealData.count-1) {
                                            // "Breakfast": "done" = active - Add active to next meal
                                            self.mealData[self.settingsData.count+1].status = "active"
                                        }

                                        updateSettings.count += 1

                                    if self.managedObjectContext.hasChanges {
                                        // Save the context whenever is appropriate
                                        do {
                                            try self.managedObjectContext.save()
                                        } catch let error as NSError {
                                            print("Error loading: \(error.localizedDescription), \(error.userInfo)")
                                        }
                                    }
                                }
                            }
                        }
                    }
                 }
             }
         }

Most likely since the UI is not refreshing automatically I'm doing something wrong, but what?
UPDATE:
I made a little example replicating what's going on, if you run it, and click on set future date, and wit 5 seconds, you'll see that the box hasn't changed color, after that, click on Go to view 2 and go back to view 1 and you'll see how the box color changes... that's what's happening above too:
import SwiftUI

struct ContentView: View {

@State var past = Date()
@State var futuredate = Date()

var body: some View {

    NavigationView {
        VStack {
            NavigationLink(destination: DetailView())
            { Text("Go to view 2") }

            Button("set future date") {
                self.futuredate = self.past.addingTimeInterval(5)
            }

            VStack {
                if (past < futuredate) {
                    Button(action: {
                    }) {
                        Text("")
                    }
                    .padding()
                    .background(Color.blue)
                } else {
                    Button(action: {
                    }) {
                        Text("")
                    }
                    .padding()
                    .background(Color.black)
                }
            }
        }
        .onAppear {
            self.past = Date()
        }
    }
}

}

struct DetailView: View {

@Environment(\.presentationMode) var presentationMode: Binding

var body: some View {
   Text("View 2")
}
}

A: You need to understand that all you put in body{...} is just an instruction how to display this view. In runtime system creates this View using body closure, gets it in memory like picture and pin this picture to struct with all the stored properties you define in it. Body is not a stored property. Its only instruction how to create that picture.
In your code, there goes init first. You didn't write it but it runs and sets all the structs property to default values = Date(). After that runs .onAppear closure which changes past value. And only then system runs body closure to make an image to display with new past value. And that's all. It is not recreating itself every second. You need to trigger it to check if the condition past < futuredate changed.
When you go to another view and back you do exactly that - force system to recreate view and that's why it checks condition again.
If you want View to change automatically after some fixed time spend, use
DispatchQueue.main.asyncAfter(deadline: .now() + Double(2)) {
    //change @State variable to force View to update
}

for more complex cases you can use Timer like this:
class MyTimer: ObservableObject {
    @Published var currentTimePublisher: Timer.TimerPublisher
    var cancellable: Cancellable?
    let interval: Double
    var isOn: Bool{
        get{if self.cancellable == nil{
                return false
            }else{
                return true
            }
        }
        set{if newValue == false{
                self.stop()
            }else{
                self.start()
            }
        }
    }

    init(interval: Double, autoStart: Bool = true) {
        self.interval = interval
        let publisher = Timer.TimerPublisher(interval: interval, runLoop: .main, mode: .default)
        self.currentTimePublisher = publisher
        if autoStart{
            self.start()
        }
    }
    func start(){
        if self.cancellable == nil{
            self.currentTimePublisher = Timer.TimerPublisher(interval: self.interval, runLoop: .main, mode: .default)
            self.cancellable = self.currentTimePublisher.connect()
        }else{
            print("timer is already started")
        }
    }
    func stop(){
        if self.cancellable != nil{
            self.cancellable!.cancel()
            self.cancellable = nil
        }else{
            print("timer is not started (tried to stop)")
        }
    }
    deinit {
        if self.cancellable != nil{
            self.cancellable!.cancel()
            self.cancellable = nil
        }
    }
}
struct TimerView: View {
    @State var counter: Double
    let timerStep: Double
    @ObservedObject var timer: TypeTimer
    init(timerStep: Double = 0.1, counter: Double = 10.0){
        self.timerStep = timerStep
        self._counter = State<Double>(initialValue: counter)
        self.timer = MyTimer(interval: timerStep, autoStart: false)
    }
    var body: some View {
        Text("\(counter)")
            .onReceive(timer.currentTimePublisher) {newTime in
                print(newTime.description)
                if self.counter > self.timerStep {
                    self.counter -=  self.timerStep
                }else{
                    self.timer.stop()
                }
            }
        .onTapGesture {
            if self.timer.isOn {
                self.timer.stop()
            }else{
                self.timer.start()
            }
         }
    }
}

See the idea? You start timer and it will force View to update by sending notification with the Publisher. View gets that notifications with .onReceive and changes @State variable counter and that cause View to update itself. You need to do something like that.


text:
Q: Current Transfor Ratio of an opto-coupler What does mean by the current transfer ratio of an opto-coupler for input side of the diode side of the opto-coupler and for the out put side of the transistor side of the opto-coupler.

A: Current transfer ratio is the ratio of receiver current produced divided by the emitter (photodiode) current. Typically 100% CTR means (for example) if the photo-emitter is driven with 1 mA then the photo-transistor (or photo-device) will draw 1 mA from the supply. Of course there are prescribed conditions for the receiver circuitry by which this is measured and other circuits used in the receiver side may not achieve that level of CTR.


text:
Q: what is the kotlin idiom for an equivalent to this python iterator The question is, how to create a python like iterator in Kotlin.
Consider this python code that parses string into substrings:
def parse(strng, idx=1):
    lst = []
    for  i, c in itermarks(strng, idx):
        if c == '}':
            lst.append(strng[idx:i-1])
            break
        elif c == '{':
            sublst, idx = parse(strng, i+1)
            lst.append(sublst)
        else:
            lst.append(strng[idx:i-1])
            idx = i+1
    return lst, i

>>>res,resl = parse('{ a=50 , b=75 , { e=70, f=80 } }')
>>>print(resl)
>>>[' a=50', ' b=75', [' e=7', ' f=80'], '', ' f=80']

This is a play example just to illustrate a python iterator:
def findany(strng, idx, chars):
    """ to emulate 'findany' in kotlin """
    while idx < len(strng) and strng[idx] not in chars:
        idx += 1
    return idx

def itermarks(strng, idx=0):
    while True:
        idx = findany(strng, idx, ',{}"')
        if idx >= len(strng):
            break
        yield idx, strng[idx]
        if  strng[idx] == '}':
            break
        idx += 1

Kotlin has iterators and generators, and as I understand it there can only be one per type. My idea is to define a type with a generator and instance that type. So the for loop from 'parse' (above) would look like this :
for((i,c) in IterMarks(strng){
   ......
   }
But how do i define the generator, and what is the best idiom.

A: Kotlin uses two interfaces: Iterable<T> (from JDK) and Sequence<T>. They are identical, with the exception that the first one is eager, while the second one is lazy by convention.
To work with iterators or sequences all you have to do is implement one of those interfaces. Kotlin stdlib has a bunch of helper functions that may help.
In particular, a couple of functions for creating sequences with yield was added in 1.1. They and some other functions are called generators. Use them if you like them, or implement the interfaces manually.

A: OK, after some work, here is the Kotlin for the iterator:
import kotlin.coroutines.experimental.*

fun iterMarks(strng: String, idx:Int=0)=buildSequence{
    val specials = listOf("\"", "{", "}", ",")
    var found:Pair<Int,String>?
    var index = idx
    while (true){
        found = strng.findAnyOf(specials, index)
        if (found == null) break
        yield (found)
        index= found.first + 1
    }
}

The main discoveries were that an iterator can be returned by any function, so the there is no need to add the iterator methods to an existing object.  The JetBrains doco is solid, but lacks examples so hopefully the above example helps.  You can also work from the basics, and again the notes are good but lack examples.  I will post more on other approaches if there is interest.
The this code for 'parse' then works:
fun parse(strng:String, idxIn:Int=1): Pair<Any,Int> {
    var lst:MutableList<Any> = mutableListOf()
    var idx = idxIn
    loop@ for (mark in iterMarks(strng, idx)){
        if(mark==null ||mark.first <= idx){
            // nothing needed
        }
        else
        {
            when( mark.second ) {
                "}" -> {
                    lst.add(strng.slice(idx..mark.first - 1))
                    idx = mark.first + 1
                    break@loop
                }
                "{" -> {
                    val res: Pair<Any, Int>
                    res = parse(strng, mark.first + 1)
                    lst.add(res.first)
                    idx = res.second
                }

                "," -> {
                    lst.add(strng.slice(idx..mark.first - 1))
                    idx = mark.first + 1
                }
            }

        }
    }
    return Pair(lst, idx)

}

Hopefully this example will make it less work for the next person new to Kotlin, by providing an example of implementing an iterator.  Specifically if you know how to make an iterator in python then this example should be useful


text:
Q: NInject bind classes using third providers I've an interface and an abstract class:
public interface IBackend
{
    Backend.Domain.User me();
    //...
}

And the abstract class:
public abstract class AbstractBackend : IBackend
{

    protected Backend.Infrastructure.Provider.IDataProvider dataProvider;

    public AbstractBackend()
        : this(null)
    {
    }

    public AbstractBackend(Backend.Infrastructure.Provider.IDataProvider dataProvider)
    {
        this.dataProvider = dataProvider;
    }

    #region User

    public abstract Backend.Domain.User me();

    #endregion
    //...
}

All of them are defined on an Assembly: Backend.Infrastructure.
I've developed several AbstractBackend implementations (in separated projects): MemoryBackend, LocalBackend and WebApiBackend.
Each of these implementations needs different information in order to be created:
MemoryBackend has no extra information according to AbstractBackend:
public class MemoryBackend : AbstractBackend
{

    #region Constructors & Initializers

    public MemoryBackend(Backend.Infrastructure.Provider.IDataProvider dataprovider)
        : base(dataprovider)
    {
        this.initialization();
    }
    //...
}

However, WebApiBackend needs some extra information in order to be configured:
public WebAPIBackend(Identity.UserIdentity userIdentity, Identity.ClientIdentity clientIdentity, Backend.Infrastructure.Provider.IDataProvider dataProvider)
        : base(dataProvider)
    {
        this.userIdentity = userIdentity;
        this.clientIdentity = clientIdentity;

        this.initialization();
    }

As you can see, WebApiBackend needs a user and a client are provided.
I've tried to solve that creating a Provider for each concreate backend in each project.
So then, I've several concrete inplementations of an AbstractBackend, I've several NInject Providers on each assembly.
The question is, from a third project I've binded all AbstractBackend implementation by convention:
public class BackendsModule : Ninject.Modules.NinjectModule
{
    public override void Load()
    {
        this.Bind(b => b.FromAssembliesMatching("*Backend*")
            .SelectAllClasses()
            .InheritedFrom(typeof(Backend.Infrastructure.AbstractBackend))
            .BindAllBaseClasses()
            .Configure(c => c.InSingletonScope())
        );
    }

How can I get and bind each Provider with its Backend from a third project?
Example:

*

*UI has a AbstractBackend.

*UI has a NInject Module which's intended for loading whichever AbstractBackend implementation.

*UI looks at MemoryBackend constructors and it's able to activate an MemoryBackend object.

*UI looks at WebApiBackend constructors and it's not able to look for a user or client objects. It needs a provider. How to bind this provider which is on WebApiBackend assembly?

As far I'm able to figure out, a possible solution would be to load NInject Modules provided on each Backend implementation assembly.
So then, I would be able to create NInject modules on each Backend implementation, and then UI would be able to load these modules...


text:
Q: How to get (index of) textfield from in UICollectionField from the barbutton in toolbar xcode ios Let me apologize so many tags because I feel like there are more than one way to make it work and I am not sure what is causing the problem.
I have a UICollectionView, in the cell I have a textfield.  The text field uses only num pad and I added a cancel and done button using solutions posted in How to show "Done" button on iPhone number pad.
The code is
- (void)viewDidLoad
{
[super viewDidLoad];

UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleBlackTranslucent;
numberToolbar.items = @[[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad)],
                     [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                     [[UIBarButtonItem alloc]initWithTitle:@"Apply" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)]];
[numberToolbar sizeToFit];
numberTextField.inputAccessoryView = numberToolbar;
}

-(void)cancelNumberPad{
[numberTextField resignFirstResponder];
numberTextField.text = @"";
}

-(void)doneWithNumberPad{
NSString *numberFromTheKeyboard = numberTextField.text;
[numberTextField resignFirstResponder];
}

I modified the code in done to just
-(void)doneWithNumberPad{
[self.view endEditing:YES];
}

Now I want to apply the cancel button to make the textfield that triggered the toolbar's textfield to become the textfield.placeholder.
I've tried to pass in the textfield in the cancelNumPad and it didn't work.  So I tried the approach to get the selected cell from the textfield invoked.  Usually when I do an IBAction I can just declare the sender and use superview to get the selected cell, but since the barbutton is in a toolbar, I've had no luck.
The set up of my controller is as follows.  Note the UItextfield is declared under implementation.
@interface MenuViewController () <UITextFieldDelegate>{
UITextField *myTextField;
}

then I init the textfield, the textfield value is init to be 0.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *reuseIdentifier = @"Cell2";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
// Configure the cell
myTextField = (UITextField*)[cell viewWithTag:400;
[[myTextField layer] setBorderWidth:1.0f];
[[myTextField layer] setBorderColor:[UIColor blackColor].CGColor];
myTextField.text = [arrayOfQuantities objectAtIndex:indexPath.item];
myTextField.delegate = self;
myTextField.inputAccessoryView = numberToolbar;
}
return cell;
}

Here are my delegate code
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField{
BOOL valid;
BOOL max;
NSCharacterSet *alphaNums = [NSCharacterSet decimalDigitCharacterSet];
NSCharacterSet *inStringSet = [NSCharacterSet characterSetWithCharactersInString:textField.text];
valid = [alphaNums isSupersetOfSet:inStringSet];

//maximum of 100
if([textField.text intValue]>=100){
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Can't be more than 100"
                                                    message:@"Please adjust number"
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
    max = NO;
}
else{
    max = YES;
}
if (valid && max){
    return YES;
}//not valid
else{
    return NO;
}
}

-(void)textFieldDidEndEditing:(UITextField *)textField{
if (textField.text.length == 0) {
    textField.text = textField.placeholder;
}
textField.placeholder = @"";
UITextField *currentTextField = textField;
UICollectionViewCell *selectedCell = (UICollectionViewCell *)[[currentTextField superview]superview];
UICollectionView *collectionViewForSelection = (UICollectionView *)[selectedCell superview];
NSIndexPath *textFieldIndexPath = [collectionViewForSelection indexPathForCell:selectedCell];
textField.text = [NSString stringWithFormat:@"%d",[textField.text intValue]];
[arrayOfQuantities replaceObjectAtIndex:textFieldIndexPath.item withObject:[NSString stringWithFormat:@"%d",[currentTextField.text intValue]]];
}

- (void)textFieldDidBeginEditing:(UITextField *)textField {
textField.placeholder = textField.text;
textField.text = @"";
}

How can I get the cancel button to work?? The done button work just fine.

A: For those that are looking for the answer.  In your .m file,
UITextField *currentTextField;
in textfield delegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
currentTextField = textField;
UICollectionViewCell *selectedCell = (UICollectionViewCell *)[[currentTextField    superview]superview];
UICollectionView *collectionViewForSelection = (UICollectionView *) [selectedCell superview];
NSIndexPath *textFieldIndexPath = [collectionViewForSelection  indexPathForCell:selectedCell];
//do whatever with your cell after


text:
Q: Ignored spring batch Tasklets in Intellij Idea spring butch configuration file:
@Configuration
public class TransitionConfiguration {

    @Autowired
    public JobBuilderFactory jobBuilderFactory;

    @Autowired
    public StepBuilderFactory stepBuilderFactory;

    @Bean
    public Step step1() {
        return stepBuilderFactory.get("step1")
                .tasklet((contribution, chunkContext) -> {
                    System.out.println(">> This is step 1");
                    return RepeatStatus.FINISHED;
                }).build();
    }

    @Bean
    public Step step2() {
        return stepBuilderFactory.get("step2")
                .tasklet((contribution, chunkContext) -> {
                    System.out.println(">> This is step 2");
                    return RepeatStatus.FINISHED;
                }).build();
    }

    @Bean
    public Job jobSimpleNext() {
        System.out.println("starting job");
        return jobBuilderFactory.get("jobNext")
                .start(step1())
                .next(step2())
                .build();
    }
}

in case i've started it:
2019-06-09 23:32:02.052  INFO 19976 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-06-09 23:32:02.190  INFO 19976 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
starting job
2019-06-09 23:32:02.495  INFO 19976 --- [  restartedMain] o.s.b.c.r.s.JobRepositoryFactoryBean     : No database type set, using meta data indicating: MYSQL
2019-06-09 23:32:02.601  INFO 19976 --- [  restartedMain] o.s.b.c.l.support.SimpleJobLauncher      : No TaskExecutor has been set, defaulting to synchronous executor.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.2.0.M2/9a84d456ad8d5151da06fc8a85540da9cc95d734/spring-core-5.2.0.M2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-06-09 23:32:02.705  INFO 19976 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2019-06-09 23:32:02.738  INFO 19976 --- [  restartedMain] o.v.s.b.l.s.t.TransitionsApplication     : Started TransitionsApplication in 2.12 seconds (JVM running for 2.588)
2019-06-09 23:32:02.740  INFO 19976 --- [  restartedMain] o.s.b.a.b.JobLauncherCommandLineRunner   : Running default command line with: []
2019-06-09 23:32:02.891  INFO 19976 --- [  restartedMain] o.s.b.c.l.support.SimpleJobLauncher      : Job: [SimpleJob: [name=transitionJobNext]] launched with the following parameters: [{}]
2019-06-09 23:32:02.931  INFO 19976 --- [  restartedMain] o.s.batch.core.job.SimpleStepHandler     : Step already complete or not restartable, so no action to execute: StepExecution: id=19, version=3, name=step1, status=COMPLETED, exitStatus=COMPLETED, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0, exitDescription=
2019-06-09 23:32:02.945  INFO 19976 --- [  restartedMain] o.s.batch.core.job.SimpleStepHandler     : Step already complete or not restartable, so no action to execute: StepExecution: id=20, version=3, name=step2, status=COMPLETED, exitStatus=COMPLETED, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0, exitDescription=
2019-06-09 23:32:02.954  INFO 19976 --- [  restartedMain] o.s.b.c.l.support.SimpleJobLauncher      : Job: [SimpleJob: [name=transitionJobNext]] completed with the following parameters: [{}] and the following status: [COMPLETED]
2019-06-09 23:32:02.963  INFO 19976 --- [       Thread-7] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2019-06-09 23:32:02.974  INFO 19976 --- [       Thread-7] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Checking logs we can detect that everything is completed.
BUT
Tasklets was not executed. I really confused because of this.
Checking DB I've detected that job status is COMPLETED but exit_code is NOOP.
I've detected also, that using .allowStartIfComplete(true) for step triggers tasklet execution. But that like a hack which can be used for the step only single time in the same job scope (it doesn't work for case double execution step in the same job). For example:
    @Bean
    public Step step2() {
        return stepBuilderFactory.get("step2")
                .allowStartIfComplete(true)
                .tasklet((contribution, chunkContext) -> {
                    System.out.println(">> This is step 2");
                    return RepeatStatus.FINISHED;
                }).build();
    }

In case I start project in terminal - it works correctly.
My env:

*

*OpenJDK Runtime Environment Zulu11.29+3-CA (build 11.0.2+7-LTS)

*Gradle 5.4.1

*Idea community (just installed latest version)

*OS ubuntu 18.04

*command to start application from idea is:

/home/sergii/.sdkman/candidates/java/current/bin/java -javaagent:/home/sergii/IDE/idea-IC-191.7479.19/lib/idea_rt.jar=33229:/home/sergii/IDE/idea-IC-191.7479.19/bin -Dfile.encoding=UTF-8 -classpath /home/sergii/Development/projects/my/spring/spring-batch-learning/out/production/classes:/home/sergii/Development/projects/my/spring/spring-batch-learning/out/production/resources:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-actuator/2.2.0.M3/f7d3810d75b6fb01b7aa1d8df9e21b3bea8c2dbc/spring-boot-starter-actuator-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-devtools/2.2.0.M3/853cb206490a2946646d4bac02446b8dc564be30/spring-boot-devtools-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-batch/2.2.0.M3/fe0bb4352d0c49d9b088db13c6a89fd9619bf2dc/spring-boot-starter-batch-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-mail/2.2.0.M3/ffc975519f3c14e7577d0407845240caa3fc10f9/spring-boot-starter-mail-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-jdbc/2.2.0.M3/fbd92e6461e5e37186c360f0080af27719780811/spring-boot-starter-jdbc-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter/2.2.0.M3/d858f3131933381d6661c0f08b6bd9669f581123/spring-boot-starter-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-actuator-autoconfigure/2.2.0.M3/3a6536cc550e7e555be62d16720c285b40c3c95a/spring-boot-actuator-autoconfigure-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/mysql/mysql-connector-java/8.0.16/6088b7a25188ab4b3ab865422a8ec77ade29236/mysql-connector-java-8.0.16.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.batch/spring-batch-core/4.2.0.M2/60b52cb2d85ead44ecf7b0bf47dfeb6e672316b6/spring-batch-core-4.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/io.micrometer/micrometer-core/1.1.4/96eabfe2343a4a4676d215b2122cbbc4d4b6af9b/micrometer-core-1.1.4.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context-support/5.2.0.M2/fa3009cdce6b4155da8833bb003577991cd71908/spring-context-support-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/com.sun.mail/jakarta.mail/1.6.3/787e007e377223bba85a33599d3da416c135f99b/jakarta.mail-1.6.3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/2.2.0.M3/3d990f3a7716875013570a1ddd9c79a5dc556390/spring-boot-autoconfigure-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-actuator/2.2.0.M3/e08a8914653e13395ddaf23fde41570d919b8109/spring-boot-actuator-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.2.0.M3/fc0b424da418b242c3d953bd6bbf06f03bfb1925/spring-boot-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-logging/2.2.0.M3/ae4dc76f8f14327ca3a792584f666d484f21b5/spring-boot-starter-logging-2.2.0.M3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/1.3.4/a858ec3f0ebd2b8d855c1ddded2cde9b381b0517/jakarta.annotation-api-1.3.4.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.2.0.M2/c85d8095c7765d8d38b9b6a357aa347b617bab79/spring-context-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jdbc/5.2.0.M2/ea5a41f2b01a2a5f88426e3a509f53479e2b6c41/spring-jdbc-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.batch/spring-batch-infrastructure/4.2.0.M2/b522e7c7f1c5ebb575136f149b0408462d391e22/spring-batch-infrastructure-4.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/5.2.0.M2/8deb00a5c5e18b6c594877afe4e82b8b8d64ccb/spring-aop-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-tx/5.2.0.M2/7042f477e471796be677f71ec63575ac7c47a749/spring-tx-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.2.0.M2/c4aa2bb803602ebc26a7ee47628f6af106e1bf55/spring-beans-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework.retry/spring-retry/1.2.4.RELEASE/e5a1e629b2743dc7bbe4a8d07ebe9ff6c3b816ce/spring-retry-1.2.4.RELEASE.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/5.2.0.M2/cdf6909ed2decf704486ca85395e97177fd7535b/spring-expression-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.2.0.M2/9a84d456ad8d5151da06fc8a85540da9cc95d734/spring-core-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.9.8/11283f21cc480aa86c4df7a0a3243ec508372ed2/jackson-databind-2.9.8.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.hdrhistogram/HdrHistogram/2.1.9/e4631ce165eb400edecfa32e03d3f1be53dee754/HdrHistogram-2.1.9.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.latencyutils/LatencyUtils/2.0.3/769c0b82cb2421c8256300e907298a9410a2a3d3/LatencyUtils-2.0.3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/com.zaxxer/HikariCP/3.3.1/bb447db60818ecfdbb1b99e7bd096ba7a252d91a/HikariCP-3.3.1.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.yaml/snakeyaml/1.24/13a9c0d6776483c3876e3ff9384f9bb55b17001b/snakeyaml-1.24.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.9.8/28ad1bced632ba338e51c825a652f6e11a8e6eac/jackson-datatype-jsr310-2.9.8.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/javax.batch/javax.batch-api/1.0/65392d027a6eb369fd9fcd1b75cae150e25ac03c/javax.batch-api-1.0.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.codehaus.jettison/jettison/1.2/765a6181653f4b05c18c7a9e8f5c1f8269bf9b2/jettison-1.2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/com.sun.activation/jakarta.activation/1.2.1/8013606426a73d8ba6b568370877251e91a38b89/jakarta.activation-1.2.1.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-to-slf4j/2.11.2/6d37bf7b046c0ce2669f26b99365a2cfa45c4c18/log4j-to-slf4j-2.11.2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.slf4j/jul-to-slf4j/1.7.26/8031352b2bb0a49e67818bf04c027aa92e645d5c/jul-to-slf4j-1.7.26.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.9.0/7c10d545325e3a6e72e06381afe469fd40eb701/jackson-annotations-2.9.0.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/5.2.0.M2/988d5bac4a51ed2675626378ee79f8447eda2002/spring-jcl-5.2.0.M2.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.9.8/f5a654e4675769c716e5b387830d19b501ca191/jackson-core-2.9.8.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.26/77100a62c2e6f04b53977b9f541044d7d722693d/slf4j-api-1.7.26.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.2.3/864344400c3d4d92dfeb0a305dc87d953677c03c/logback-core-1.2.3.jar:/home/sergii/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.11.2/f5e9a2ffca496057d6891a3de65128efc636e26e/log4j-api-2.11.2.jar org.vl.spring.batch.learning.springbatchlearning.transition.TransitionsApplication

Question
I guess the issues with idea, because of it works in terminal. Is any ways to analyze and detect a reason for my case and fix it, how?
P.S.
I've done next unsuccessful tries to fix it:

*

*reinstal idea;

*recreate project from prepared sources and from spring start;

*restart idea invalidating caches
 -

A: It seem was no intellij idea issues...
I've tried to remove my configured datasource trying experiment with default one using embedded db. It works correctly. Next thing that I've done, I used my first datasource configuration but with different step names. That works. Checking DB I've detected that every executed step has COMPLETED status.
Continue investigation...
Every my step has COMPLETED status in the DB. By default spring batch doesn't allow execute completed steps.
To make COMPLETED steps handled one more time we can:

*

*update COMPLETED status in DB with STOPPED or FAILED - that is really hack

*use in step builder function .allowStartIfComplete(true) - the feature of spring batch.


text:
Q: Why some webpages works different or look strange in Ubuntu? I have my computer for work with Ubuntu and another computer for personal stuff with Windows 10.
I have noticed that some pages loads extremely slow in my Ubuntu (Firefox or Chrome) than they do in my Windows.
For example, here in my contry there is a webpage where you can make transaction on e-commerce. In my Ubuntu I have to reload each page around 3 times to finish the transaction, but in Windows is very fluid and in 1 minute I have everything done.
I've read some questions but I'm not sure if they fit in my issue, cause some people talks about DNS and other one's talks about wireless drivers, so I don't know why is this happening?
Any help?


text:
Q: How can I set an EList as an input in JFace TableViewer? This is my first SO question. I hope i provide enough details.
I have an EMF Model with a class called ScopeContainer, which has two containment References as ELists of Different Types.
I have generated the

*

*model

*model.edit
and

*model.editor

codes with the Genmodel
I am trying to show the contents of one of those lists in a org.eclipse.jface.viewers.TableViewer with only one Column.
This can't be a org.eclipse.swt.widgets.List since i want to be able to edit those entries.
TableViewer viewer;
AdapterFactory adapterFactory = storage.getDomain().getAdapterFactory();
AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
AdapterFactoryContentProvider contentProvider = new AdapterFactoryContentProvider(adapterFactory);

viewer.setLabelProvider(labelProvider);
viewer.setContentProvider(contentProvider);
viewer.setInput(project.getScopecontainer().getFilters());

When I set the input as the the ScopeContainer Object. I can see all the objects in both lists
When i set the input as the EList<Filter> the Table is empty.
What do i have to do to set the Input of the TableViewer as EList?

A: A simple solution would be to override AdapterFactoryContentProvider.getElements() to return an array of Filter elements (derived from the EList<Filter> input).

A: As suggested I overrode the getElements Method Like this:
public class EListContentProvider<T> extends AdapterFactoryContentProvider{

    public EListContentProvider(AdapterFactory adapterFactory) {
        super(adapterFactory);
    }

    @Override
    public Object[] getElements(Object inputElement) {
        Object[] arr = null;
        if(inputElement instanceof EList) {
            arr = ((EList<T>) inputElement).toArray();
        }
        return arr;
    }
}

A: You should check the class org.eclipse.jface.viewers.ArrayContentProvider or the class org.eclipse.jface.databinding.viewers.ObservableListContentProvider, depending on if your list is supposed to change or not.
Those content providers do exactly what you are asking for: manage a collection input for a table or a viewer.


text:
Q: How to set multi colors for value of TextInput in react native I want to change color of value in textinput when the "Done" button is pressed but I cannot set multi colors.
Like this :

this is my react native textinput component
<TextInput
    style={{
        borderColor: '#bdbdbd',
        borderWidth: 2,
        width: width / 1.5,
        height: height / 9,
        borderRadius: 10,
        marginLeft: 20,
        fontSize: 20,
        color: this.state.fc,
        padding: 10,
    }}
    placeholder={'Enter here the text you can hear'}
    multiline={true}
    onChangeText={(text) => this.setState({ write: text })}
    value={this.state.write}
>


text:
Q: H2 and Oracle Compatiability issues I am having an issue executing the following script using Flyway and H2 database.  I assume its a Oracle compatibility issue but I am using H2 with the correct mode.  This script is used to construct my tables in production but I want to use an in-memory database for testing purposes.  Setup and error below.  I don't want rewrite the scripts for an in-memory database if thats possible.
Jdbc.properties
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:file:target/firmsoftDB;MODE=Oracle
jdbc.username=sa
jdbc.password=

Sql Script
CREATE TABLE USER_INFO
(
  USER_INFO_ID      NUMBER                      NOT NULL,
  USER_NAME         VARCHAR2(32 BYTE)           NOT NULL,
  EMAIL             VARCHAR2(320 BYTE)              NULL,
  LAST_NAME         VARCHAR2(32 BYTE)           NOT NULL,
  FIRST_NAME        VARCHAR2(32 BYTE)           NOT NULL,
  LAST_LOGIN        TIMESTAMP(6)                    NULL,
  USER_TYPE         VARCHAR2(32 BYTE)               NULL,
  USER_CN           VARCHAR2(32 BYTE)               NULL,
  SOURCE_DIRECTORY  VARCHAR2(15 BYTE)               NULL,
  PRIMARY_PHONE     VARCHAR2(32 BYTE)               NULL,
  ALT_PHONE         VARCHAR2(32 BYTE)               NULL,
  CREATED_BY        NUMBER                      NOT NULL,
  CREATED_DATE      TIMESTAMP(6)                NOT NULL,
  UPDATED_BY        NUMBER                      NOT NULL,
  UPDATED_DATE      TIMESTAMP(6)                NOT NULL
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;

pom.xml
<profiles>
    <profile>
        <id>h2-test</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <systemPropertyVariables>
                            <flyway.locations>db/migration</flyway.locations>
                        </systemPropertyVariables>
                        <threadCount>1</threadCount>
                    </configuration>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <executions>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.googlecode.flyway</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <version>2.2.1</version>
                    <configuration>
                        <!-- <url>jdbc:hsqldb:file:target/firmsoftDB;sql.syntax_ora=true</url> -->
                        <!-- <url>jdbc:hsqldb:mem:firmsoftDB;sql.syntax_ora=true</url> -->
                        <url>jdbc:h2:file:target/firmsoftDB;MODE=Oracle</url>
                        <!-- <url>jdbc:derby:\temp\db\FAQ\db</url> -->
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

Context
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/jdbc
    http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">

   <!--  Needed for system properties replacement -->
    <!-- Following will only work with spring 3     -->
<context:property-placeholder location="classpath*:jdbc.properties,classpath*:flyway.default.properties,classpath*:flyway.properties"
            ignore-resource-not-found="true"
    system-properties-mode="OVERRIDE"/>

    <!-- flyway part -->
    <bean id="flyway" class="com.googlecode.flyway.core.Flyway" depends-on="dataSourceRef">
        <property name="dataSource" ref="dataSourceRef"/>
        <property name="locations" value="${flyway.locations}"/>
    </bean>

 <bean id="dataSourceRef" name="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

            <property name="driverClassName"><value>${jdbc.driver}</value></property>
            <property name="url"><value>${jdbc.url}</value></property>
            <property name="username"><value>${jdbc.username}</value></property>
            <property name="password"><value>${jdbc.password}</value></property>
            <property name="maxActive" value="-1"/>

</bean>

StackTrace
[ERROR] Failed to execute goal com.googlecode.flyway:flyway-maven-plugin:2.2.1:migrate (default-cli) on project flyway-test: com.googlecode.flyway.core.api.FlywayException: Migration of schema "PUBLIC" to version 1 failed! Please restore backups and roll back database and code! Syntax error in SQL statement "CREATE TABLE USER_INFO
[ERROR] (
[ERROR] USER_INFO_ID      NUMBER                      NOT NULL,
[ERROR] USER_NAME         VARCHAR2(32 BYTE[*])           NOT NULL,
[ERROR] EMAIL             VARCHAR2(320 BYTE)              NULL,
[ERROR] LAST_NAME         VARCHAR2(32 BYTE)           NOT NULL,
[ERROR] FIRST_NAME        VARCHAR2(32 BYTE)           NOT NULL,
[ERROR] LAST_LOGIN        TIMESTAMP(6)                    NULL,
[ERROR] USER_TYPE         VARCHAR2(32 BYTE)               NULL,
[ERROR] USER_CN           VARCHAR2(32 BYTE)               NULL,
[ERROR] SOURCE_DIRECTORY  VARCHAR2(15 BYTE)               NULL,
[ERROR] PRIMARY_PHONE     VARCHAR2(32 BYTE)               NULL,
[ERROR] ALT_PHONE         VARCHAR2(32 BYTE)               NULL,
[ERROR] CREATED_BY        NUMBER                      NOT NULL,
[ERROR] CREATED_DATE      TIMESTAMP(6)                NOT NULL,
[ERROR] UPDATED_BY        NUMBER                      NOT NULL,
[ERROR] UPDATED_DATE      TIMESTAMP(6)                NOT NULL
[ERROR] )
[ERROR] LOGGING
[ERROR] NOCOMPRESS
[ERROR] NOCACHE
[ERROR] NOPARALLEL
[ERROR] MONITORING"; expected "K, M, G, CHAR, )"; SQL statement:
[ERROR] CREATE TABLE USER_INFO
[ERROR] (
[ERROR] USER_INFO_ID      NUMBER                      NOT NULL,
[ERROR] USER_NAME         VARCHAR2(32 BYTE)           NOT NULL,
[ERROR] EMAIL             VARCHAR2(320 BYTE)              NULL,
[ERROR] LAST_NAME         VARCHAR2(32 BYTE)           NOT NULL,
[ERROR] FIRST_NAME        VARCHAR2(32 BYTE)           NOT NULL,
[ERROR] LAST_LOGIN        TIMESTAMP(6)                    NULL,
[ERROR] USER_TYPE         VARCHAR2(32 BYTE)               NULL,
[ERROR] USER_CN           VARCHAR2(32 BYTE)               NULL,
[ERROR] SOURCE_DIRECTORY  VARCHAR2(15 BYTE)               NULL,
[ERROR] PRIMARY_PHONE     VARCHAR2(32 BYTE)               NULL,
[ERROR] ALT_PHONE         VARCHAR2(32 BYTE)               NULL,
[ERROR] CREATED_BY        NUMBER                      NOT NULL,
[ERROR] CREATED_DATE      TIMESTAMP(6)                NOT NULL,
[ERROR] UPDATED_BY        NUMBER                      NOT NULL,
[ERROR] UPDATED_DATE      TIMESTAMP(6)                NOT NULL
[ERROR] )
[ERROR] LOGGING
[ERROR] NOCOMPRESS
[ERROR] NOCACHE
[ERROR] NOPARALLEL
[ERROR] MONITORING [42001-174]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.googlecode.flyway:flyway-maven-plugin:2.2.1:migrate (default-cli) on project flyway-test: com.googlecode.flyway.core.api.FlywayException: Migration of schema "PUBLIC" to version 1 failed! Please restore backups and roll back database and code!
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: com.googlecode.flyway.core.api.FlywayException: Migration of schema "PUBLIC" to version 1 failed! Please restore backups and roll back database and code!
    at com.googlecode.flyway.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:253)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE TABLE USER_INFO
(
  USER_INFO_ID      NUMBER                      NOT NULL,
  USER_NAME         VARCHAR2(32 BYTE[*])           NOT NULL,
  EMAIL             VARCHAR2(320 BYTE)              NULL,
  LAST_NAME         VARCHAR2(32 BYTE)           NOT NULL,
  FIRST_NAME        VARCHAR2(32 BYTE)           NOT NULL,
  LAST_LOGIN        TIMESTAMP(6)                    NULL,
  USER_TYPE         VARCHAR2(32 BYTE)               NULL,
  USER_CN           VARCHAR2(32 BYTE)               NULL,
  SOURCE_DIRECTORY  VARCHAR2(15 BYTE)               NULL,
  PRIMARY_PHONE     VARCHAR2(32 BYTE)               NULL,
  ALT_PHONE         VARCHAR2(32 BYTE)               NULL,
  CREATED_BY        NUMBER                      NOT NULL,
  CREATED_DATE      TIMESTAMP(6)                NOT NULL,
  UPDATED_BY        NUMBER                      NOT NULL,
  UPDATED_DATE      TIMESTAMP(6)                NOT NULL
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING"; expected "K, M, G, CHAR, )"; SQL statement:
CREATE TABLE USER_INFO
(
  USER_INFO_ID      NUMBER                      NOT NULL,
  USER_NAME         VARCHAR2(32 BYTE)           NOT NULL,
  EMAIL             VARCHAR2(320 BYTE)              NULL,
  LAST_NAME         VARCHAR2(32 BYTE)           NOT NULL,
  FIRST_NAME        VARCHAR2(32 BYTE)           NOT NULL,
  LAST_LOGIN        TIMESTAMP(6)                    NULL,
  USER_TYPE         VARCHAR2(32 BYTE)               NULL,
  USER_CN           VARCHAR2(32 BYTE)               NULL,
  SOURCE_DIRECTORY  VARCHAR2(15 BYTE)               NULL,
  PRIMARY_PHONE     VARCHAR2(32 BYTE)               NULL,
  ALT_PHONE         VARCHAR2(32 BYTE)               NULL,
  CREATED_BY        NUMBER                      NOT NULL,
  CREATED_DATE      TIMESTAMP(6)                NOT NULL,
  UPDATED_BY        NUMBER                      NOT NULL,
  UPDATED_DATE      TIMESTAMP(6)                NOT NULL
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING [42001-174]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
    at org.h2.message.DbException.getSyntaxError(DbException.java:197)
    at org.h2.command.Parser.getSyntaxError(Parser.java:504)
    at org.h2.command.Parser.read(Parser.java:2867)
    at org.h2.command.Parser.parseColumnWithType(Parser.java:3788)
    at org.h2.command.Parser.parseColumnForTable(Parser.java:3603)
    at org.h2.command.Parser.parseCreateTable(Parser.java:5354)
    at org.h2.command.Parser.parseCreate(Parser.java:3890)
    at org.h2.command.Parser.parsePrepared(Parser.java:334)
    at org.h2.command.Parser.parse(Parser.java:289)
    at org.h2.command.Parser.parse(Parser.java:265)
    at org.h2.command.Parser.prepareCommand(Parser.java:226)
    at org.h2.engine.Session.prepareLocal(Session.java:437)
    at org.h2.engine.Session.prepareCommand(Session.java:380)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:168)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:156)
    at com.googlecode.flyway.core.dbsupport.JdbcTemplate.executeStatement(JdbcTemplate.java:230)
    at com.googlecode.flyway.core.dbsupport.SqlScript.execute(SqlScript.java:89)
    at com.googlecode.flyway.core.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:72)
    at com.googlecode.flyway.core.command.DbMigrate$2.doInTransaction(DbMigrate.java:252)
    at com.googlecode.flyway.core.command.DbMigrate$2.doInTransaction(DbMigrate.java:250)
    at com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:56)
    at com.googlecode.flyway.core.command.DbMigrate.applyMigration(DbMigrate.java:250)
    at com.googlecode.flyway.core.command.DbMigrate.access$700(DbMigrate.java:47)
    at com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:189)
    at com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:138)
    at com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:56)
    at com.googlecode.flyway.core.command.DbMigrate.migrate(DbMigrate.java:137)
    at com.googlecode.flyway.core.Flyway$1.execute(Flyway.java:872)
    at com.googlecode.flyway.core.Flyway$1.execute(Flyway.java:819)
    at com.googlecode.flyway.core.Flyway.execute(Flyway.java:1200)
    at com.googlecode.flyway.core.Flyway.migrate(Flyway.java:819)
    at com.googlecode.flyway.maven.MigrateMojo.doExecuteWithMigrationConfig(MigrateMojo.java:159)
    at com.googlecode.flyway.maven.AbstractMigrationLoadingMojo.doExecute(AbstractMigrationLoadingMojo.java:151)
    at com.googlecode.flyway.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:251)
    ... 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

A: H2 doesn't recognize the syntax
VARCHAR2(32 BYTE)

Change this to
VARCHAR2(32)

... and it will still work in oracle and will at least remove your first error in H2.

A: Short Answer
Oracle is a huge piece of software, and you can't expect a small embedded database to be 100% compatible.
Long Answer
Compatibility Modes
As documented, for certain features, this database can emulate the behavior of specific databases. However, only a small subset of the differences between databases are implemented in this way. This list is documented.
Compatibility
As documented, H2 is (up to a certain point) compatible to other databases such as HSQLDB, MySQL and PostgreSQL. There are certain areas where H2 is incompatible.
All database engines behave a little bit different. Where possible, H2 supports the ANSI SQL standard, and tries to be compatible to other databases. There are still differences however.


text:
Q: How to download and show on jsp page uploaded image in path config.getServletContext().getRealPath("/") in java My uploaded images are stored in the .metadata folder that is created by Eclipse. How to retrieve them? It's showing "page not found error-404"
itemName = item.getName();
File savedFile = new File(config.getServletContext().getRealPath("/")+"image\\"+itemName);
item.write(savedFile);

A: Probably .metadata is not put in your war file. Put it under WebContent, WebSource, or similarly named folder (I don't know what is your project setup, but you will find it).

A: Your code should be writting your files into you webapp. If you are running it from Eclipse, then the webapp might be in the .metadata folder, but it still should work as any other webapp.
Static resources are managed directly by the server, you don't need to do anything at all.
Once the file is downloaded (your code seems to be ok), the image will be available in the URL
 http://yourserver[:yourport]/yourwebapp/image/itemName  (including the file extension)


text:
Q: Map of coherent sheaves inducing isomorphism on the stalks at the generic point Let $f:X\rightarrow Y$ be a finite morphism between Noetherian integral schemes that is surjective on the underlying topological spaces. Does there exist an integer $n>0$ and a coherent $O_X$-module $F$ such that there is a morphism of $O_Y$-modules $O_Y^n\rightarrow f_*F$ inducing an isomorphism on the stalks at the generic point of $Y$?
It is pretty easy to see that there must be a quasi-coherent $O_X$-module like this. Pick an affine open $V\subset Y$, then its inverse image is an affine open $U\subset X$. It is easy to see that $O_U$ answers the question for the morphism $f|_{U}$. Therefore, if $i:U\rightarrow X$ denotes the inclusion, $i_* O_U$ is a quasi-coherent $O_X$-module (because $i$ is qcqs) answering the question (because the generic stalk can be computed on any non-empty open).
It appears, however, that this way we will rarely get a coherent sheaf. EGA IV, partie quadrieme, Cor. 21.12.7 says that if $X$ is separated, the complement of $U$ has codimension 1 so $i_*$ has little chance to preserve coherence.
P.S. This is Hartshorne Ch. III Ex. 4.2 (a). I have consulted some solutions online and could not convince myself they really produce coherent (rather than quasi-coherent) sheaves. The same question has been asked on Math Stackexchange but we have different perspective on the direction of the attack.

A: I think this can also be solved by taking the "coherent subsheaf generated by finitely many global sections of $i_* \mathcal{O}_U$". I'm not sure this is fundamentally different from Aknazar's solution, but it avoids the direct mention of (co)limits, and might be what Hartshorne had in mind.
As Aknazar, suppose we can solve the problem for affine schemes, and choose an open affine $j: V \hookrightarrow Y$ and let $i: U \hookrightarrow X$ be its preimage. Suppose we have a morphism
$$ \alpha_V:  \mathcal{O}_V^n \to (f|_U)_*\mathcal{O}_U$$
which is an isomorphism at the generic point $\eta$ of $Y$.
The problem is that $i_* \mathcal{O}$ is not in general coherent on $X$. But $\alpha_V$ chooses $n$ global sections $s_1,\dotsc,s_n \in \Gamma(X, i_* \mathcal{O}_U) = \Gamma(U, \mathcal{O}_U)$, which can be used to define a morphism $\alpha_X: \mathcal{O}_X^n \to i_* \mathcal{O}_U$. Let $\mathscr{G}$ be the image of this morphism. Then $\mathscr{G}$ is coherent, because for every open affine $\text{Spec }A = W \subset X$, $\mathscr{G}(W) \subset (i_*\mathcal{O}_U)(W)$ is the $A$-submodule generated by $s_1|_W,\dotsc,s_n|_W$.
This allows us to define the morphism
$$ \alpha_Y: \mathcal{O}_Y^n \to f_* \mathscr{G} \subset (f i)_* \mathcal{O}_U$$
by takting the same global sections $s_1,\dots,s_n \in \Gamma(Y, f_* \mathscr{G})$. At the generic point this yields
$$
\mathcal{O}^n_{Y, \eta} \xrightarrow{\alpha_{Y, \eta}} (f_*\mathscr{G})_\eta \hookrightarrow ((fi)_* \mathcal{O}_U)_\eta,
$$
and the composition is $\alpha_{U, \eta}$ which is an isomorphism. Hence $\alpha_{Y, \eta}$ is an isomorphism as well.

A: The following is basically a copy of dhy's comments with links (any mistakes are mine).
First, assume you know that for a finite surjective morphism $f:X\rightarrow Y$ between Noetherian integral affine schemes, there exists a positive integer $n$ and a morphism of $\mathcal{O}_Y$-modules $\mathcal{O}_Y^{\oplus n}\rightarrow f_*\mathcal{O}_X$ inducing an isomorphism at the generic point. This is shown in the linked question.
Now, we have a finite surjective morphism $f:X\rightarrow Y$ between Noetherian integral schemes. Pick a non-empty affine open $j:V\rightarrow Y$ whose inverse image is a non-empty affine open $i:U\rightarrow X$. The restriction $f|_U:U\rightarrow V$ is a finite surjective map (by definition). We know therefore that there is a positive integer $n$ and a morphism of $\mathcal{O}_Y$-modules $j_*\mathcal{O}_V^{\oplus n}\rightarrow f_* i_* \mathcal{O}_U$ inducing an isomorphism at the generic point. This can be composed with the natural map $\mathcal{O}_Y\rightarrow j_*\mathcal{O}_V$ to get a morphism of $\mathcal{O}_Y$-modules $\mathcal{O}_Y^{\oplus n}\rightarrow f_* i_* \mathcal{O}_U$ inducing an isomorphism at the generic point.
On any qcqs scheme any quasi-coherent sheaf is the directed colimit of its quasi-coherent subsheaves of finite type. Apply this to $i_*\mathcal{O}_U$. Since $X$ is locally Noetherian, these subsheaves are actually coherent.
We claim that the pushforward by a qcqs morphism, considered as a functor on the categories of quasi-coherent modules, commutes with directed colimits. First note that the functor of restriction to an open set commutes with colimits so the question is local on the target. Assume that the target is affine, then express the pushforward as a kernel. The conclusion follows from the fact that kernels commute with directed colimits and the fact that the pushforward by a morphism between affine schemes commutes with directed colimits.
Therefore, we can pushforward the the directed colimit to get a colimit of coherent sheaves on $Y$ (they will be coherent because $f$ is proper) coconverging to $f_*i_*\mathcal{O}_U$.
Finally, use Lemma 34 and Proposition 75 here (the word "concentrated" means qcqs) to conclude that any coherent sheaf on a Noetherian scheme is a finitely presented object of the category of quasi-coherent sheaves (i.e. $\mathrm{Hom}(F, -)$ preserves directed colimits). Therefore, the map $\mathcal{O}_Y^{\oplus n}\rightarrow f_* i_*\mathcal{O}_U$ factors through a coherent $\mathcal{O}_Y$-module $G\subset f_* i_*\mathcal{O}_U$. To see that $\mathcal{O}_Y^{\oplus n}\rightarrow G$ induces an isomorphism at the generic point, first notice that it must induce an injection at the generic point (because its composition with the inclusion is an isomorphism) and second notice that the generic rank of $G$ does not exceed that of $f_* i_*\mathcal{O}_U$. An injective map between finite-dimensional vector spaces such that the dimension of the target does not exceed the dimension of the source must be an isomorphism. Game over.


text:
Q: Change the color of left and right sidebar in shinydashboardPlus when using bs4Dash package In my shinydashboard below Im tryin to change the color of my sidebar and my controlbar to grey but it seems not to work when I combine bs4Dash package. Also my controlBar does not open,
## app.R ##
library(shiny)
library(shinydashboard)

library(bs4Dash)

ui <- dashboardPage(
  dashboardHeader(
    titleWidth = 0,
    controlbarIcon = shiny::icon("filter")

  ),
  dashboardSidebar(
    collapsed = TRUE,

    ),
  dashboardBody(

    tags$head(tags$style(HTML('
        /* logo */
        .skin-blue .main-header .logo {
                              background-color: white;
                              }

        /* logo when hovered */
        .skin-blue .main-header .logo:hover {
                              background-color: white;
                              }

        /* navbar (rest of the header) */
        .skin-blue .main-header .navbar {
                              background-color: white;
        }

        /* body */
        .content-wrapper, .right-side {
                              background-color: white;
                                 }

        /* main sidebar */
        .skin-blue .main-sidebar {
                              background-color: grey;
        }
        /* toggle button when hovered  */
         .skin-blue .main-header .navbar .sidebar-toggle{
                              background-color: black;
         }
        /* toggle button when hovered  */
         .skin-blue .main-header .navbar .sidebar-toggle:hover{
                              background-color: black;
                              }

                              ')))

  ),

  controlbar = dashboardControlbar(id = "dashboardControlbarID", collapsed = TRUE,skin = "grey",icon = icon("filter"))

)

server <- function(input, output) {

}

shinyApp(ui, server)

A: While it is possible to get the grey color for the main sidebar ("left sidebar") I am not sure if this is possible with the controlbar ("right sidebar"), here you can toggle the appearance with skin. After many try and errors I come to the end to use skinSelector().
Beside even after getting the desired color it interferes with hovering effects with strange behaviour.
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(),
    controlbar = dashboardControlbar(collapsed = FALSE, skinSelector()),
    title = "Skin Selector"
  ),
  server = function(input, output) { }
)

Together with this site How to change the background color of the Shiny Dashboard Body which I suppose you already know, you may come to the conclusion to invest some time to https://rinterface.github.io/shinydashboardPlus/articles/more-skins.html


text:
Q: vuejs invoice input binding processors I'm trying to do invoice four, but I couldn't quite figure out how to do it.
First of all, to give an example:
Quantity 1 Unit Price 2000 Percent (18) = net total "2360".
and then if the user changes "net_total" I want the unit price to change.
Then if the user wants to apply a discount, I want it to be reflected in net_total as a percentage, or if he writes it as a currency, not a percentage. It will write net total.

const app = new Vue({
    el: "#app",
    data: {
        invoiceItem: [
            {
                name: "",
                quantity: 0,
                unit_price: 0,
                vat_rate: 18,
                net_total: 0,
                showDesc: false,
                showDiscount: false,
                description: '',
                discount_value: 0,
                discount_rate:'usd'
            },
        ],
    },
    methods: {
        addInvoice() {
            this.invoiceItem.push({
                name: "",
                quantity: 0,
                unit_price: 0,
                vat_rate: 18,
                net_total: 0,
                showDesc: false,
                showDiscount: false,
                description: '',
                discount_value: 0,
                discount_rate:'usd'
            });
        },
        removeIncoiceItem(index) {
            this.invoiceItem.splice(index, 1);
        },
    },
});
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet">

                Name
                Quantity
                Unit Price
                Vat Rate
                Net Total
                Action

                    <input type="text" v-model="item.name">

                    <input type="text" v-model="item.quantity">

                    <input type="text" v-model="item.unit_price">

                    <select v-model="item.vat_rate">
                        <option value="18">%18</option>
                        <option value="8">%8</option>
                        <option value="1">%1</option>
                        <option value="0">%0</option>
                    </select>

                    <input type="text" v-model="item.net_total">

                    <button
                        class="btn btn-primary"
                        v-if="!item.showDesc" @click="item.showDesc = !item.showDesc">Add Description
                    </button>
                    <button
                        class="btn btn-secondary"
                        v-if="!item.showDiscount" @click="item.showDiscount = !item.showDiscount">Add Discount
                    </button>
                    <button class="btn btn-danger" @click="removeIncoiceItem(index)">X</button>

                    <input type="text" placeholder="description">

                        <input type="text" placeholder="discount_value">
                        <select class="form-select-new" v-model="item.discount_rate">
                            <option value="dollar">USD</option>                                       <option value="percent">&</option>
                        </select>

            <button class="btn btn-warning" @click="addInvoice()"> Add Item</button>

A: The easiest would be to create two calculate methods, one when the net_total changed and one when one of the parameters (like the unit_price) changed. I assume your unit_price is the gross unit price.
You have to add the @change property on the inputs.

    <input type="text" v-model="item.unit_price" @change="changed(item)">

    <input type="text" v-model="item.net_total" @change="changedTotal(item)">

An then use the following methods to calculate the gross to net and net to gross.
changed(item) {
    let sum = item.quantity * item.unit_price;
    if (item.discount_rate == 'percent')
        sum -= sum*parseFloat((item.discount_value / 100))
    else
        sum -= item.discount_value
    let percent = parseFloat((item.vat_rate/100)+1);
    item.net_total = sum/percent;
},
changedTotal(item) {
    let percent = parseFloat((item.vat_rate/100)+1);
    var gross = item.net_total * percent;
    if (item.discount_rate == 'percent')
        gross = gross*parseFloat((item.discount_value / 100)+1)
    else
        gross += item.discount_value
    item.unit_price = gross / item.quantity;
},

It could also be possible via the vue watchers, but I think this would be too complicated.


text:
Q: longest string in texts I have following code in Java:
import java.util.*;
public class longest{
public static void main(String[] args){
int t=0;int m=0;int token1, token2;
   String words[]=new String[10];
    String word[]=new String[10];
String common[]=new String[10];
   String text="saqartvelo gabrwyindeba da gadzlierdeba aucileblad ";
     String text1="saqartvelo gamtliandeba da gadzlierdeba aucileblad";
StringTokenizer st=new StringTokenizer(text);
StringTokenizer st1=new StringTokenizer(text1);

token1=st.countTokens();
token2=st1.countTokens();
while (st.hasMoreTokens()){

words[t]=st.nextToken();
  t++;
}
  while (st1.hasMoreTokens()){
     word[m]=st1.nextToken();
  m++;
}
 for (int k=0;k<token1;k++){
     for (int f=0;f<token2;f++){
      if (words[f].compareTo(word[f])==0){
  common[f]=words[f];
}
}
}
   while (i<common.length){
   System.out.println(common[i]);
   i++;
}
}
}

I want that in common array put elements which i in both text or these words

*

*saqartvelo (georgia in english)

*da (and in english)

*gadzlierdeba (will be stronger)

*aucileblad (sure)

and then between these words find string which has maximum length but it does not work more correctly it show me these words and also many null  elements.
How do I correct it?

A: The following snippet should be instructive:
    import java.util.*;
    //...

    String text1 = "saqartvelo gabrwyindeba da gadzlierdeba aucileblad";
    String text2 = "saqartvelo gamtliandeba da gadzlierdeba aucileblad";

    List<String> common = new ArrayList<String>();
    for (String s1 : text1.split(" ")) {
        for (String s2 : text2.split(" ")) {
            if (s1.equals(s2)) {
                common.add(s1);
            }
        }
    }

    Collections.sort(common, new Comparator<String>() {
        @Override public int compare(String s1, String s2) {
            return s2.length() - s1.length();
        }
    });

    System.out.println(common);
    // prints "[gadzlierdeba, saqartvelo, aucileblad, da]"

Key ideas:

*

*Prefer List over arrays

*

*Especially handy if you don't know how many elements there will be in advance

*Prefer foreach

*StringTokenizer is a legacy-class; prefer String.split

*Use a custom Comparator and Collections.sort for sorting a List
Related questions

*

*Sorting an ArrayList of Contacts (good examples of using Comparator)

*Java Integer: what is faster comparison or subtraction?

*

*The comparison-by-subtraction is broken for general int -- use carefully!

An alternative solution
Note that the above solution is O(N^2), since it check each pair of words to see if they're equal. This means that it doesn't scale well when the two texts have many words. Using a Set such as a HashSet, you can do this in expected O(N) time, using Set.retainAll to compute the intersection of two sets.
static Set<String> wordSet(String text) {
    return new HashSet<String>(Arrays.asList(text.split(" ")));
}
//...

String text1 = ...;
String text2 = ...;

Set<String> commonSet = wordSet(text1);
commonSet.retainAll(wordSet(text2));

List<String> common = new ArrayList<String>(commonSet);
System.out.println(common);
// prints "[da, aucileblad, saqartvelo, gadzlierdeba]"
// in no particular order

// sort by string length using Comparator as above

A: Instead of manually searching for common words, why not put each sentence's words into a Set and then compute the intersection of both sets using retainAll()?
This tutorial on the Set Interface may help.
I assume this is homework... have you learned about algorithmic complexity, aka Big-O notation?  If so, consider the complexity of your posted code vs. using a TreeSet vs. using a HashSet.


text:
Q: AspectJ - pass interface instance variable to pointcut I need to pass @interface instance variable value to pointcut and the method but wasn't able to find anything on google.
here is what I have so far:
pointcut:
pointcut auditField(Object t, Object value): set(@ge.shemo.anotations.CaptureChanges * * ) && args(value) && target(t);

before (Object target, Object newValue, FieldChangeName fieldName):
        auditField(target, newValue,fieldName) {
    FieldSignature sig = (FieldSignature) thisJoinPoint.getSignature();
    Field field = sig.getField();
    field.setAccessible(true);
    Object oldValue;
    try {
        oldValue = field.get(target);
    } catch (IllegalAccessException e) {
        throw new RuntimeException("Failed to create audit Action", e);
    }
    System.out.println("changed from " + oldValue + " to " + newValue);
}

and interface:
@Retention(RUNTIME)
@Target(value = FIELD)
public @interface CaptureChanges {
    MethodType fieldType();
}

UPDATED
public enum MethodType {
    NAME(FieldChangeType.STRING),
    ID(FieldChangeType.STRING),
    FIRST_NAME(FieldChangeType.STRING),
    LAST_NAME(FieldChangeType.STRING);

    private FieldChangeType type;

    private FieldChangeName(FieldChangeType type) {
        this.type = type;
    }

    public FieldChangeType getType() {
        return this.type;
    }
}

public enum FieldChangeType {
    ENUM, STRING
}

I want to get the value of 'FieldChangeMethod method' from @interface CaptureChanges and use it in before() function.
How can I do this?

A: While it's unclear to me what you're trying to achieve with the MethodType and FieldChangeType classes, here's a way to access the value of the @CaptureChanges annotation when a field value is about to change:
pointcut auditField(Object t, Object value, CaptureChanges captureChanges):
    set(* *) && @annotation(captureChanges) && args(value) && target(t);

before (Object target, Object newValue, CaptureChanges captureChanges):
        auditField(target, newValue, captureChanges) {

    FieldSignature sig = (FieldSignature) thisJoinPoint.getSignature();
    Field field = sig.getField();
    field.setAccessible(true);
    Object oldValue;
    try {
        oldValue = field.get(target);
    } catch (IllegalAccessException e) {
        throw new RuntimeException("Failed to create audit Action", e);
    }
    System.out.println("changed from " + oldValue + " to " + newValue
            + ", fieldType=" + captureChanges.fieldType()
            + ", fieldChangeType=" + captureChanges.fieldType().getType());
}


text:
Q: Configure Modem for Bittorrent downloads How can I configure the Modem to get maximum download speed for Bit torrents?

A: If you talking about dial up modems then, there is no special configuration that will help you achieve greater speeds. Your p2p speed will depend on overall connection speed of modem 40kbps, 52.6kbps, 128kbps and so on. Also speed will depend on peers who are seeding files to you.

A: You need to configure port forwarding , depending on the modem/ router the steps will vary. Find our what port your client is listening on then visit http://portforward.com/ for steps to configure the modem / router

A: Not exactly sysadmin related, but what the hey:
What a huge can of worms.
Many torrent clients (like Azureus) support UPnP so if your router also supports UPnP (and it is enabled), then the client can take care of it for you.
Other than that, you need to find out what port your software uses (it's usually a high port, like 16000 or something) and forward that port in your router to the downloading machine. Most software will allow you to choose your own port, so it shouldn't be too hard to find out what it is.

A: (I'm not sure that this question is in much relation to Sys Admin stuff)
Have you tried Google yet?
How to configure your router for bittorrent
and you should also configure your client correctly.


text:
Q: Tango - Unity - Depth: xyzij.color_image is now non-NULL! - But is only 900 bytes long? I noticed this morning with the "H" update for Tango Core that the Unity SDK is now seeing a "non-null" color_image returned from the Depth data!  Progress!
However it is only filled with 900 bytes of data?  Which is going to be a pretty tiny image. :)
Tango team :  Am I doing something wrong in the way I'm accessing the IntPtr in C#/Mono or is it still just too early to be actually getting color_images in Unity?
Code:
protected override void _OnDepthAvailable(IntPtr callbackContext, TangoXYZij xyzij)    {
            try {

                if(xyzij.color_image != null){

                    Debug.Log ("_OnDepthAvailable: Copying image");

                    //IntPtr timage = xyzij.color_image;

                    Debug.Log ("_OnDepthAvailable: Copying image 700");
                    //1280x720x3

                    int maxsize = 1280*720*4;

// I found mention in the stackoverflow questions that the expected images from C API are 1280x720x3 (? or 4=RGBA?)
//                      maxsize = 900;
                    lastimage = new byte[maxsize];

                for(int i=0;i<1280;i++){

                        byte b = Marshal.ReadByte(xyzij.color_image,i);

                        Debug.Log ("_OnDepthAvailable: i:"+i+" checking color_image: "+ b);

                    }

//  I get Debug.Log print outs up to 899 for every depth acquisition...
                    Marshal.Copy(xyzij.color_image,lastimage, 0, maxsize);

// My Marshal.Copy fails for any value larger than 900 for maxsize, but runs happily at 900
                    Debug.Log ("_OnDepthAvailable: Copying image 709");
                    string strRequest = Encoding.UTF8.GetString(lastimage);

//  tried to see if it was string being exported, it was just blank...
What am I missing here?

A: The color image buffer in the XYZij is currently not available, it is intend to be the time synced image. The 900 byte buffer might be just some artifacts in the memory.


text:
Q: Passing C style string around function I have a situation as below in which I need to pass a C-style string into a function and stored it into a container that needed to be used later on. The container is storing the char*. I couldn't figure out the efficient way to create the memory and store it into the vector. As in overloadedfunctionA (int), I need to create new memory and copy into buffer, and pass into the overloadedfunctionA(char*) which again create new memory and copy into the buffer again. Imagine I have alot of items in int and other types and I am doing twice the work every time. One way to solve it is to copy the logic from overloadedfunctionA(char*) to overloadedfunctionA(int). But it would resulted in alot of repetitive codes. Any ideas on a more efficient way to do this?
Thanks.
int main(){

overloadedfunctionA(5);
overloadedfunctionA("abc");

}

vector<char*> v1;

void overloadedfunctionA(int intA){
 char* buffer = new char[];
 convert int to char in buffer;
 overloadedfunctionA(buffer1);
 delete buffer;

}

//act as base function that has a lot of logic need to be performed
void overloadedfunctionA(char* string1){
char* buffer = new char[];
copy string to buffer;
insert string into vector1;
}

A: For all that's holy, just use std::string internally. You can assign to a std::string from a const char*, and you can access the std::string's underlying C string through the c_str() method.
Otherwise, you'd need to write a wrapper class that handles memory allocation for you, and store instances of that class in your vector; but then, std::string already IS such a wrapper class.

A: Hopefully making the earlier solutions easier for you to follow...
#include <vector>
#include <string>
#include <sstream>

std::vector<std::string> the_vector;

// template here... use an overload if you prefer...
template <typename T>
void fn(const T& t)
{
    std::ostringstream oss;
    oss << t;
    the_vector.push_back(t.str());
}

int main()
{
    fn(3);
    fn("whatever");
}

A: One optimization you can do is to maintain a static hashmap of strings, so that you can use a single instance for duplicate values.
Another solution is to use std::string and redeclare overloadedfunctionA(char*) as overloadedfunctionA(const std::string&).
Yet another option is to let a Garbage Collector do the memory management.

A: If your strings are long such that copying is likely to be a performance problem, you could consider boost::shared_array as an alternative to std::string. Provided the contents are invariant, this offers a solution where only one copy of the string will need to be held in memory.  Note however that you would be trading reference counting overhead for string copying overhead here.
Some compilers may optimize std::string for you this way anyway, so that a single copy is kept and ref-counted until the contents are changed, when a new array is allocated for the modified contents with its refcount decoupled from the original contents


text:
Q: Write a script to output modified javascript I have javascript files that use an IP address that changes when I move it. I figured I could write a script that parses through my many javascript files and replaces a token string like %IP_ADDRESS% with the result fetched from ifconfig. The resulting file buffer gets saved as the usable scripts for my site.
Is there an easier way to achieve this? If not, what bash commands would help me scan files, replace tokens, and save to a new file?
Thanks

A: Use sed. If you get the IP address into the variable $ip, you can do:
sed "s/%IP_ADDRESS%/$ip/g" template.js > script.js

A:
what bash commands would help me scan files, replace tokens, and save to a new file?

You can replace your token in each file using sed with the bash command:
sed -i 's/%IP_ADDRESS%/127.0.0.1/g' *.js

This will do the replacement in-place (the -i flag) on all .js files in the current directory.
If you want to create a new file instead of modifying the old one, you can use the following command:
sed 's/%IP_ADDRESS%/127.0.0.1/g' input.js > output.js

In that case, you would need to repeat the command for each file.
A good alternative might be to change the Javascript code so that it loads the IP address as needed, instead of containing it hard-coded.

A: I threw this together as a really quick demo.
Click here to view result
Here is the code for the HTML page.  You can view the result from above.
<!DOCTYPE html>

<title>DPoisn.com - demo Page</title>
</head

blank for now

source for vars.js:

var ipIs = '198.168.1.1'
var hostIs = 'http://dpoisn.com'

All this does is pull in a .js file that holds that variables you need.  As long as that import is done before everything else on the page, you can make use of whatever is inside it.  In this case, setting a couple of strings.
The idea is that you can have a "vars.js" that is unique to every server you run it on.  And you can use the variables without ever having to change the code throughout the site again.

A: Place this bash script in the same dir with all js files.
#!/bin/bash
#Remark: $ip should contain your IP address, adjust cut and awk according to your OS.
ip=$(ifconfig eth1 | grep -i bcast | cut -d : -f2 | awk '{ print $1 }')
sed -i "s|%IP_ADDRESS%|$ip|g" *.js

Script works fine in Redhat 6.