text:
Q: Applescript only attaches once and then no longer I have an Applescript that attaches a bunch of spams to a reporting email flawlessly ONCE. Then it stops attaching any spams in subsequent runs regardless of whether it's the same batch of spams or another new batch of spams.  Even though it stops attaching any spams in subsequent runs, it otherwise runs fine in that it creates the reporting email, addresses it and tacks on the subject line which gives a tally of spams being reported.  I have a gut feeling that it's likely an aliasing issue (in that it's looking for the wrong alias and thus can't attach the spam) but I can't quite see how to fix it.  I enclose the Applescript below with personal info redacted.  Running it under Applescript Editor provides me no errors except for the "--> missing value" (what does this even mean?) after each iteration of the attachment loop.  What am I overlooking?
-- User settable constants
set SPAMCOP_ACCOUNT to "REDACTED"
set SENDER_ADDRESS to "REDACTED"
set SPAMCOP_FOLDER_NAME to "SpamCop"

-- Variable initialization
set rawSpamFileList to {} -- List of names of spam files
set spamsProcessed to 0 -- Number of spams processed
set theOutputFolderPath to path to desktop folder -- Desktop folder path
set fullSpamCopFolderPath to (theOutputFolderPath & SPAMCOP_FOLDER_NAME & ":") -- Spam folder on Desktop

tell application "Finder"

    -- Create a SpamCop folder on Desktop if there isn't already one
    if (exists folder (fullSpamCopFolderPath as string)) = false then
        make new folder at theOutputFolderPath with properties {name:SPAMCOP_FOLDER_NAME}
    end if

    -- Count number of Spams to be processed
    set spamsProcessed to number of items of folder (fullSpamCopFolderPath as string)

    -- Set the list of names to the raw source folder to loop through
    set rawSpamFileList to name of every file of folder (fullSpamCopFolderPath as string)

    if (spamsProcessed > 0) then
        tell application "Mail"
            -- Create a blank spam-reporting email & set sender in it
            set spamReport to (make new outgoing message with properties {visible:true, content:" ", sender:SENDER_ADDRESS})

            -- Address it and add a tally of junk being reported
            tell spamReport
                make new to recipient at end of to recipients with properties {address:SPAMCOP_ACCOUNT}
                set subject of spamReport to ((spamsProcessed) & " spam(s) being submitted for processing" as string)
                set visible to true

                -- Attach all the spams in SpamCopFolder as attachment(s) to spamReport.
                -- I SUSPECT THE PROBLEM IS IN THE REPEAT LOOP BELOW BUT I CAN'T SEE WHAT'S WRONG!

                repeat with thisSpamName in rawSpamFileList
                    try
                        set fullSpamPath to ((fullSpamCopFolderPath as string) & thisSpamName) -- Cast fullSpamCopFolderPath alias to string first!
                        make new attachment with properties {file name:(fullSpamPath as string)} at after the last word of the last paragraph
                    on error errmsg
                        display dialog ("Failed with errmsg: " & (errmsg as string)) buttons {"OK"} default button "OK"
                    end try
                end repeat
            end tell
        end tell

        set responseButton to button returned of (display dialog "Clean up SpamCop folder now?" buttons {"Yes", "No"} default button "No")
        if responseButton is "Yes" then
            delete every item of folder (fullSpamCopFolderPath as string) -- Send spams to trash
        else
            display dialog "Spam deletion aborted." buttons {"OK"} default button "OK"
        end if
    else
        display dialog "No spam to process!  Are you hallucinating?" buttons {"OK"} default button "OK"
    end if
end tell

Here is a sample run of 35 spams using the corrected Applescript provide by regulus6633:
tell current application
    path to desktop
        --> alias "Macintosh HD:Users:username:Desktop:"
end tell
tell application "Finder"
    exists folder "Macintosh HD:Users:username:Desktop:SpamCop:"
        --> true
    count folder "Macintosh HD:Users:username:Desktop:SpamCop:"
        --> 35
    get name of every file of folder "Macintosh HD:Users:username:Desktop:SpamCop:"
        --> {"Spam-20140908064824.eml", "Spam-20140908081508.eml", "Spam-20140908082049.eml", "Spam-20140908082642.eml", "Spam-20140908083224.eml", "Spam-20140908091214.eml", "Spam-20140908091848.eml", "Spam-20140908092708.eml", "Spam-20140908093615.eml", "Spam-20140908093946.eml", "Spam-20140908101749.eml", "Spam-20140908101834.eml", "Spam-20140908102327.eml", "Spam-20140908102809.eml", "Spam-20140908102920.eml", "Spam-20140908103417.eml", "Spam-20140908104041.eml", "Spam-20140908104110.eml", "Spam-20140908112201.eml", "Spam-20140908113458.eml", "Spam-20140908124138.eml", "Spam-20140908124750.eml", "Spam-20140908125605.eml", "Spam-20140908130207.eml", "Spam-20140908130508.eml", "Spam-20140908132133.eml", "Spam-20140908132909.eml", "Spam-20140908134147.eml", "Spam-20140908134736.eml", "Spam-20140908143459.eml", "Spam-20140908143618.eml", "Spam-20140908160051.eml", "Spam-20140908160448.eml", "Spam-20140908173043.eml", "Spam-20140908191450.eml"}
end tell
tell application "Mail"
    make new outgoing message with properties {visible:true, content:" ", sender:"REDACTED"}
        --> outgoing message id 47
    make new to recipient at end of every to recipient of outgoing message id 47 with properties {address:"REDACTED"}
        --> to recipient 1 of outgoing message id 47
    set subject of outgoing message id 47 to "35 spam(s) being submitted for processing"
    set visible of outgoing message id 47 to true
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908064824.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908081508.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908082049.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908082642.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908083224.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908091214.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908091848.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908092708.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908093615.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908093946.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908101749.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908101834.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908102327.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908102809.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908102920.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908103417.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908104041.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908104110.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908112201.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908113458.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908124138.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908124750.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908125605.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908130207.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908130508.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908132133.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908132909.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908134147.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908134736.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908143459.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908143618.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908160051.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908160448.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908173043.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
    make new attachment with properties {file name:"Macintosh HD:Users:username:Desktop:SpamCop:Spam-20140908191450.eml"} at after last word of last paragraph of outgoing message id 47
        --> missing value
end tell
tell application "AppleScript Editor"
    display dialog "Clean up SpamCop folder now?" buttons {"Yes", "No"} default button "No"
        --> {button returned:"No"}
    display dialog "Spam deletion aborted." buttons {"OK"} default button "OK"
        --> {button returned:"OK"}
end tell
Result:
{button returned:"OK"}

A: I see a mistake here:
set fullSpamCopFolderPath to (theOutputFolderPath & SPAMCOP_FOLDER_NAME & ":")

It should be:
set fullSpamCopFolderPath to (theOutputFolderPath as text & SPAMCOP_FOLDER_NAME & ":")

Notice "as text". You want to add strings and theOutputFolderPath is not a string so you need to make it one before you add the string SPAMCOP_FOLDER_NAME to it.
Here's another error:
set subject of spamReport to ((spamsProcessed) & " spam(s) being submitted for processing" as string)

It should be:
set subject to (spamsProcessed as text) & " spam(s) being submitted for processing"

Again, "spamsProcessed" is a number and you need to make it a string before adding another string to it. Plus you're inside "tell spamReport" and therefore don't need "of spamReport".
Finally, you should move all of your "Mail" code outside the Finder block of code. It doesn't make sense to tell the Finder to tell Mail to do something and it often results in hard-to-find errors when you embed application tell blocks inside of each other.
So try the following. I fixed a few other small errors and removed all of your "as string" stuff because once you fix those errors you don't need it. I didn't try this code but it should work.
-- User settable constants
set SPAMCOP_ACCOUNT to "REDACTED"
set SENDER_ADDRESS to "REDACTED"
set SPAMCOP_FOLDER_NAME to "SpamCop"

-- Variable initialization
set rawSpamFileList to {} -- List of names of spam files
set spamsProcessed to 0 -- Number of spams processed
set theOutputFolderPath to path to desktop folder -- Desktop folder path
set fullSpamCopFolderPath to ((theOutputFolderPath as text) & SPAMCOP_FOLDER_NAME & ":") -- Spam folder on Desktop

tell application "Finder"

    -- Create a SpamCop folder on Desktop if there isn't already one
    if not (exists folder fullSpamCopFolderPath) then
        make new folder at theOutputFolderPath with properties {name:SPAMCOP_FOLDER_NAME}
    end if

    -- Count number of Spams to be processed
    set spamsProcessed to number of items of folder fullSpamCopFolderPath

    -- Set the list of names to the raw source folder to loop through
    set rawSpamFileList to name of every file of folder fullSpamCopFolderPath
end tell

if (spamsProcessed > 0) then
    tell application "Mail"
        -- Create a blank spam-reporting email & set sender in it
        set spamReport to (make new outgoing message with properties {visible:true, content:" ", sender:SENDER_ADDRESS})

        -- Address it and add a tally of junk being reported
        tell spamReport
            make new to recipient at end of to recipients with properties {address:SPAMCOP_ACCOUNT}
            set subject to (spamsProcessed as string) & " spam(s) being submitted for processing"
            set visible to true

            -- Attach all the spams in SpamCopFolder as attachment(s) to spamReport.
            -- I SUSPECT THE PROBLEM IS IN THE REPEAT LOOP BELOW BUT I CAN'T SEE WHAT'S WRONG!

            repeat with thisSpamName in rawSpamFileList
                try
                    set fullSpamPath to fullSpamCopFolderPath & thisSpamName
                    make new attachment with properties {file name:fullSpamPath} at after the last word of the last paragraph
                on error errmsg
                    display dialog ("Failed with errmsg: " & errmsg) buttons {"OK"} default button "OK"
                end try
            end repeat
        end tell
    end tell

    set responseButton to button returned of (display dialog "Clean up SpamCop folder now?" buttons {"Yes", "No"} default button "No")
    if responseButton is "Yes" then
        tell application "Finder"
            delete every item of folder fullSpamCopFolderPath -- Send spams to trash
        end tell
    else
        display dialog "Spam deletion aborted." buttons {"OK"} default button "OK"
    end if
else
    display dialog "No spam to process!  Are you hallucinating?" buttons {"OK"} default button "OK"
end if

A: I solved the problem myself.  The solution was just to replace this line:
make new attachment with properties {file name:(fullSpamPath as string)} at after the last word of the last paragraph

with this:
make new attachment with properties {file name:fullSpamPath as alias} at after the last word of the last paragraph

As to why the former just worked once or twice and then not again thereafter, I have no idea.  Theoretically, the former shouldn't have worked at all.  If anybody has any feasible explantion, I'm all ears.  But my code now works as expected.


text:
Q: Iterate multiple Dataframe and write into excel spreadsheets within an excel xlsxwriter python I am working on writing multiple dataframes in excel spreadsheets within an excel file.
The dataframes generates using for loop , so in every iteration I get next available dataframe but I can not able to write every dataframe in spreadsheets.
I could only write the first dataframe in first spreadsheet.
Below is the code snippet:
 writer = pd.ExcelWriter('output.xlsx', engine='xlsxwriter')
    workbook = writer.book
    web_ClassID=df_stag["Web-Class ID"].unique()
          for data_id, df in df_stag.groupby('Web-Class ID'):
             for workbook_Id in web_ClassID:
                 if workbook_Id == data_id:
                    for index, col in enumerate(df):
                    df.to_excel(writer,sheet_name=workbook_Id,index=False )
                    writer.save()
    workbook.close()

Note:
The webclass_id here is type of object
Df_stag: is a dataframe which is grouped by Webclass_id
df is the dataframe which I want to write into excel spreadsheets
Also, I am creating spreadsheets whenever a new Webclass_id is found , so the tab gets created with corresponding Webclass_id when found.One file having few tabsanother file having few tabs
Output: I want a single excel file having all the tabs from all the files and appended data from those file which have same tab in both the files. ie. 11111,22222,33333 and data from 11111 should be from both the files.

A: Simply move writer.save() outside of for loop:
writer = pd.ExcelWriter('output.xlsx', engine='xlsxwriter')
workbook = writer.book
web_ClassID=df_stag["Web-Class ID"].unique()

for data_id, df in df_stag.groupby('Web-Class ID'):
    for workbook_Id in web_ClassID:
        if workbook_Id == data_id:
            for index, col in enumerate(df):
                df.to_excel(writer,sheet_name=workbook_Id,index=False )
writer.save()
workbook.close()

And for shorter code, simply filter iteratively with no need for workbook object:
writer = pd.ExcelWriter('output.xlsx')
for d in df_stag["Web-Class ID"].unique():
    df_stag[df_stag["Web-Class ID"]==d].to_excel(writer, sheet_name=d, index=False)

writer.save()

A: It is definitely possible to write multiple dataframes into separate worksheets or to different positions within the same worksheet using XlsxWriter.
See the Handling multiple Pandas Dataframes section of the XlsxWriter docs or the examples here and here.
If it isn't working in your case then I'd guess:

*

*workbook_Id isn't unique and you are overwriting the same worksheet.

*workbook_Id == data_id is only true once.

*You have some old version of either Pandas or XlsxWriter.

I would start with 1. and 2. and put in some debug statements.

A: I finally found answer to my question!!
I simply have to assign the object to sheet_name attribute and it will automatically copy every instance of dataframe into the excel sheet having sheet name as workbook_Id. ie. df.to_excel(writer,sheet_name=workbook_Id)

A: @Parfait: earlier my code was creating new excel sheets but it wasnot copying the instance of dataframe inside excel sheets.
I only had sheet names as web-class id.
Even if I enumerated the df and tried to write df inside excel sheets. It was only writing content of first dataframe
for index, col in enumerate(df):
                df.to_excel(writer,sheet_name=workbook_Id,index=False )
writer.save()

Assigning workbook_id to sheet_name will not create a new sheet and assign the content inside the sheet_name.
df.to_excel(writer,sheet_name=workbook_Id)

Also, I found no need of explicit writing of writer.save . Even if we write workbook.close() after iteration to_excel() it writes and saves the data.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Probability Puzzle - secret four-digit binary message I got stuck on this interesting question from one the probability app.
Alice would like to send Bob a secret four-digit binary message, e.g. 0000 or 0011, via the post office, but she's worried that her letter will be intercepted by a third party. Fortunately, Alice and Bob have a way of encrypting their messages: last time they met, they generated a secret one-time pad, which is a four-character sequence of Xs and underscores, e.g. XX_X. They'll use the pad to encrypt their message.
There are 2^4 possible pads: Alice chose one of them uniformly at random and shared it with Bob before they parted ways. They agreed on the following protocol: when Alice needs to send Bob a four-digit binary message, she'll encrypt it using the pad. Wherever the pad says X, she will flip the corresponding bit in the message (i.e. 1 is flipped to 0 and 0 is flipped to 1); she leaves the remainder of the message unchanged (i.e. in the places where the pad says _). She'll send the scrambled message in the mail, and Bob will use his copy of the pad to decipher it.
Eve is the spy reading Alice and Bob's mail. She knows the methodology behind the one-time pad, and she knows that Alice chose a pad uniformly at random. Furthermore, Eve believes there's a 30% chance that Alice's true (unscrambled) message will be 0000, a 60% chance that it will be 1111, and a 10% chance it'll be 0011.
Eve intercepts Alice's letter to Bob and finds the (scrambled) message 1110. Given what Eve has observed, what's the probability that Alice's true message to Bob is 1111?

A: If the X and the _ have the same probablity, and alice picks a pad at random, the probablity after Eve observed the message remain unchanged, so it is 60%.
Let $P(u1111|s1110)$ be the probabilty that the unscrambled message is 1111 when Eve sees 1110 so:
$P(u1111|s1110) = \frac{P(s1110|u1111).P(u1111)}{P(s1110|u1111).P(u1111)+P(s1110|u0000).P(u0000)+P(s1110|u0011).P(u0011)}$
$P(u1111) = 0.6 $
$P(u0000) = 0.3 $
$P(u0011) = 0.1 $
$P(s1110|u1111)$ is that alices chose the pad _ _ _ X so is $1/2^4$
$P(s1110|u0000)$ is that alices chose the pad X X X _ so is $1/2^4$
$P(s1110|u0011)$ is that alices chose the pad X X _ X so is $1/2^4$
$P(u1111|s1110) = \frac{1/2^4.P(u1111)}{1/2^4.P(u1111)+1/2^4.P(u0000)+1/2^4.P(u0011)}$
$P(u1111|s1110) = \frac{P(u1111)}{P(u1111)+P(u0000)+P(u0011)} = P(u1111) = 0.6$


text:
Q: Why isn't vector.clear() working while in a loop? I am trying to create an application to calculate multiplicative persistence, like in this video: https://youtu.be/Wim9WJeDTHQ?t=197.
However my problem is that it does not appear that my vector is being cleared during iterations of the while loop. Which means the output produced is growing exponentially instead of working down to 0.
I am very new to coding c++ so any feedback would be appreciated.
std::vector<int> per;
int input;
int result;
int new_total = 1;
int loop_total;

std::cin >> input;

//Moving the user input into a vector

while (input > 0)
{
    result = input % 10;
    input = input / 10;

    per.push_back(result);
}

//loops to multiply new sets of numbers together until "new_total" is 0

while (new_total > 0) {

    for (int i = per.size() - 1; i >= 0; i--)
    {
        new_total = new_total * per[i];
    }

    per.clear();

    std::cout << "\n" << new_total << "\n";

    loop_total = new_total;

    while (loop_total > 0)
    {
        result = loop_total % 10;
        loop_total = loop_total / 10;

        per.push_back(result);
    }
}

I expected for the vector to be cleared each time so that the new sets of numbers were moved into the vector to be multiplied.
However the previous set of numbers appeared to remain present in the vector.

A: Thanks for all the help everyone. The solution to my problem was fixed by setting new_total=1; at the beginning of the while loop which makes sense as before new_value was being continually multiplied into.
Thanks for all the help :)


text:
Q: Find a unit vector w that is perpendicular to v. Find a unit vector w that is perpendicular to v. The vector v = (1, 1, ..., 1) in 9 dimensions
Solution: w = (1, −1, 0, . . . , 0)/√2 is a unit vector in the 8D hyperplane perpendicular to v.
My questions is why we say w is 8D vector?

A: The dimension of the hyperplane is $8$ dimensional because it is perpendicular to a single vector which has dimension $1$. This is a consequence of the rank-nullity theorem as $9-1=8$.


text:
Q: Typescript map over list of functions Coming from a Haskell background, I would like to map over a list of functions. For example I have:
functions fnA(x){ return true }
function  fnB(x){ return false }

// I would like to write this code that applies the same value to all functions
[ fnA, fnB ] .map ( (fn : any) => fn('hello world') )

However I am getting error:
(x : any) => boolean' cannot be used as an index type.

A: Prefix the last line with a semicolon:
;[ fnA, fnB ] .map ( (fn : any) => fn('hello world') )
Background: semicolons are optional in Javascript. However there are some edge-cases which require you to apply some style rules.
Starting a line with a bracket [ or parenthesis ( is one of those edge cases.


text:
Q: VBScript from outlook to Create files/folders on network drive my first post here but I've been lurking for a long time. I'm working for a company that is using Outlook's VB to macro everything they're doing from custom Task Forms. Well I want to add to this by being able to activate a sub that will:

*

*Create a folder on our local server/network drive (where everyone has permissions)

*Copy Files and folders from a pre-made "template" folder to a new destination

*Rename files in the new directories with variable names

Currently I'm at:
Dim     fso
Dim     sourceFol
Dim     DestFol
Dim     variable1
Dim     variable2

Set fso = CreateObject("Scripting.FileSystemObject")
If ClientCode = "1" Then
    sourceFol = "\\S:\sourcepath"
    DestFol = "\\S:\destination\"& variable1 &" - "& variable2
    ElseIf ClientCode = "2" Then
    sourceFol = "\\S:\sourcepath"
    DestFol = "\\S:\destination\"& variable1 &" - "& variable2
        ElseIf ClientCode = "3" Then
        sourceFol = "\\S:\sourcepath"
        DestFol = "\\S:\destination\"& variable1 &" - "& variable2
End If

If Error Then
    WScript.Echo "Error: " & Err.Number
    WScript.Echo "Source: " &  Err.Source & "Description:" & Err.Description
    Err.Clear
    Else
    'Cancel
End If

The only problem is that I'm getting nothing from this, no reaction, no error, no thinking from what I'm seeing. Seeing as this is only number 1 on my list and I'm getting nothing it's very frustrating. Anyone have any good tips, pointers, or things to check in this case? Thanks.

A: This code needs to go a long way. But here's a revision of the code so you can get output.
Dim     fso
Dim     sourceFol
Dim     DestFol
Dim     variable1
Dim     variable2
Dim     result

Set fso = CreateObject("Scripting.FileSystemObject")
If ClientCode = "1" Then
    sourceFol = "\\S:\sourcepath"
    DestFol = "\\S:\destination\"& variable1 &" - "& variable2
    result = "Succeeded in string set: 1"
ElseIf ClientCode = "2" Then
    sourceFol = "\\S:\sourcepath"
    DestFol = "\\S:\destination\"& variable1 &" - "& variable2
    result = "Succeeded in string set: 2"
ElseIf ClientCode = "3" Then
    sourceFol = "\\S:\sourcepath"
    DestFol = "\\S:\destination\"& variable1 &" - "& variable2
    result = "Succeeded in string set: 1"
Else
    result = "Client Code did not match comparison results [" & ClientCode & "]"
End If

If Err.Number<>0 Then
    WScript.Echo "Error: " & Err.Number
    WScript.Echo "Source: " &  Err.Source & "Description:" & Err.Description
    Err.Clear
Else
    wscript.echo result
End If

A: Dim fso
Dim clientcode
Dim variable1
Dim variable2
Dim Folder

ClientCode = Trim(Item.UserProperties("Client"))

If ClientCode = "1" Then
    folder = "R:\path"& variable1 &"-"& variable2
    ElseIf ClientCode = "2" Then
    folder = "R:\01 - CHA\"& variable1 &"-"& variable2
        ElseIf ClientCode = "3" Then
        folder = "R:\03 - REOR\"& variable1 &"-"& variable2
End if

Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(folder) Then
        fso.CreateFolder (folder)
        MsgBox "Folder Successfully Created and Named"
    Else
        MsgBox folder & " already exists!", vbExclamation, "Folder Exists"
    End If


text:
Q: Is accepting a request without a Referer evidence of CSRF? I use Fiddler to look at some attack-vectors on my site.
I copy the http-request from my validate-function and changed it: I cut off the referer-line. And it works. Is that an evidence for CSRF?
The Question in other Words: When I reproduce the HTTP-Request in Fiddler without the Referer, is that an evidence that my Site is vulnerable against CSRF? Or can I look for CSRF-Attacks by using only Fiddler?

A: Not necessarily, no. Referer-checking is one way to attempt to prevent CSRF, but it's generally not the best choice because some intermediaries strip this header, and if the client  browser or one of its plugins had a bug, an attacker could send a fake referer. Most sites today send a nonce in the HTTP POST body that the server uses to validate that the request was generated by a page on the 1st party site and not a cross-site request.


text:
Q: It's possible wait for a variable in Ruby, (without sleep)? I'm trying to get data from an ssh server, but this action takes some time to run, so I need to wait for them, once I have them, I'll use this data to send them through my Bot to Slack.
Here my code:
def sshPingRequest()
    Net::SSH.start('xxxx.xxxxx.xxxxx', 'root', :port => "3132") do |ssh|
        output = ssh.exec!("ansible -m ping c3")
        result = output.split("\n").select { |line| line.include?("SUCCESS") || line.include?("FAILURE") }
        puts "############## Done #############"
        return result
    end
end

SlackRubyBotServer::Events.configure do |config|
    data = sshPingRequest() # Help
    config.on :command, '/ans-ping' do |command|
        command.logger.info 'Received a ping, responding with pong.'
        { text: data }
    end
end

Basically I need to wait for the "result" variable to be ready from the first function, and after sending it in the second function.
Thanks in advance.

A: According to the documentation

Requests are sent from the client to the server, and are answered asynchronously. This gives great flexibility (since clients can have multiple requests pending at a time), but it also adds complexity. Net::SSH tries to manage this complexity by providing some simpler methods of synchronous communication (see Net::SSH::Connection::Session#exec!).

So,I think that you could call SlackRubyBotServer::Events.configure intro channel NET::SSH
def foo()
  SlackRubyBotServer::Events.configure do |config|
  data = sshPingRequest() # Help
  config.on :command, '/ans-ping' do |command|
    command.logger.info 'Received a ping, responding with pong.'
    { text: data }
  end
end

def sshPingRequest()
  Net::SSH.start('xxxx.xxxxx.xxxxx', 'root', :port => "3132") do |ssh|
    output = ssh.exec!("ansible -m ping c3")
    result = output.split("\n").select { |line| line.include?("SUCCESS")
      || line.include?("FAILURE") }
    puts "############## Done #############"

    foo() # while the channel is open

    return result
  end
end

A: What about promises? Could it be what you are looking for?
https://ruby-concurrency.github.io/concurrent-ruby/1.1.5/Concurrent/Promise.html
From the docs:

Promises are similar to futures and share many of the same behaviours.
Promises are far more robust, however. Promises can be chained in a
tree structure where each promise may have zero or more children.
Promises are chained using the then method. The result of a call to
then is always another promise. Promises are resolved asynchronously
(with respect to the main thread) but in a strict order: parents are
guaranteed to be resolved before their children, children before their
younger siblings. The then method takes two parameters: an optional
block to be executed upon parent resolution and an optional callable
to be executed upon parent failure. The result of each promise is
passed to each of its children upon resolution. When a promise is
rejected all its children will be summarily rejected and will receive
the reason.

Also you can see this guide:
https://medium.com/@gauravbasti2006/lets-keep-our-promise-in-ruby-e45925182fdc


text:
Q: Text of textbox doesn't update in submit button click I have two radiobutton. If one of them be checked a textbox be active and get data.
They are in update page. In page-load fill them by data from database and I check ispostback.
If textbox have text in page load, its text change and everything work fine but if it haven't text in first place, it keep default text and doesn't update in submit button click.
    String val = "0";
    if (radiobutton2.Checked && textbox1.Text.Length != 0)
            val = textbox1.Text;

in page load use this code for initialize radiobuttons:
    t.ReadOnly = true;
    t.BackColor = System.Drawing.Color.Gray;

and there's a javascript code for active and inactive this textbox
    function CheckedChanged(rbtnelement, txtelement) {
                    if (document.getElementById(rbtnelement).checked) {
                        document.getElementById(txtelement).readOnly = false;
                        document.getElementById(txtelement).style.backgroundColor = "white";
                    }
                    else {
                        document.getElementById(txtelement).readOnly = true;
                        document.getElementById(txtelement).style.backgroundColor = "grey";
                    }
                }

A: It's because the textbox readonly property become false in c# code (it run in server side) and it become true in javascript (it run in client side). In server side (c# codes) textbox remain readonly and don't send its text.
if remove one of them and manage textbox in one side (client or server) it will work fine.


text:
Q: COM Automation From Web Application Currently we have a document management system that is implemented as a windows desktop application.
We want to convert it to web application using ASP.NET; however we are facing a major problem.
The application depends heavily on COM automation specially to work with Microsoft Office documents and AutoCad drawings in order to insert the generated document number in the documents.
What are the possible solutions to achieve the same functionality using web application?

*

*ActiveX is not supported in modern browsers.

*COM automation in the server is not a good idea! or is it?

*3rd party tools do not support all the required file formats e.g (word , excel , project, visio, autocad .. etc).

Your help is appreciated.
Thank you.
Emad-Eddin

A: Just use COM automation on the Server.
It is not ideal and if you were designing from scratch you probably wouldn't do it, but for this kind of situation it is fine.
However I think you should actively plan to remove reliance on COM interfacing with server applications on your server as it will cause you more trouble in the future.


text:
Q: `brew install openvpn` vs. Tunnelblick for OpenVPN client I recently switched to Macbook pro (Mojave) and would like to have an OpenVPN client installed. In Linux systems I've been always using openvpn from within command line. I just want to know if it would work flawlessly as in macOS.
I see that everyone recommend Tunnelblick, or paid options such as Viscosity but i prefer free and open source solutions.

A: According to it's official website:

Tunnelblick is a free, open source graphic user interface

When I used Tunnelblick, it worked flawlessly with macOS. So I would recommend to go forward to run:
brew install --cask tunnelblick

When you choose a software for Mac, if it's included in home brew or home brew cask package list or not is one point to consider. See if it's useful enough or popular enough to be a brew package.

A: I find the feature comparison from the OpenVPN website quite helpful:

Alternative: OpenVPN open source Tunnelblick program
The open source project has a client for the macOS operating system as well. It is called Tunnelblick and it is less limited in functionality than the OpenVPN Connect Client because it does support the option to connect to multiple OpenVPN servers at the same time.
  On the other hand, it does miss some features that Connect Client does have as well like Python support for post-auth scripting and other functions that integrate Connect Client with Access Server, like the ability to import connection profiles directly from an Access Server, or the ability to authenticate any valid user on your Access Server and have them connect without having to install a connection profile for each separate user account. This is accomplished on the Connect Client with a universal server-locked profile which is not supported by the OpenVPN GUI program.
This program supports drag and drop to place OpenVPN connection profiles into Tunnelblick. These can be of .conf or .ovpn file extension. You can for example download a user-locked or an auto-login profile from the OpenVPN Access Server web interface, and drag and drop it on the Tunnelblick icon. The tray menu in the system tray will then show you options to use this connection profile – to start or stop the connection. Server-locked profiles are not supported, as mentioned earlier.
This program does support connecting to multiple OpenVPN servers at the same time, but there is a catch. You have to be careful not to implement conflicting routes and subnets when connecting to multiple OpenVPN servers at the same time. Unlike on Windows platform however, you do not need to worry about adding multiple virtual network adapters. These are provisioned automatically.


text:
Q: Continue stream based on result of a DB query I'm developing an ETL. The first step is a Text File Input, that adds to the stream some metadata from "Additional output fields", including filename and last modified.
I must make a query to DB verifying if that filename with that last modified datetime has already been processed. If so, the stream must stop and next steps must not be processed.
Is that possible? I've googled about it and found no example.

A: Pentaho processes all steps in parallel, so this kind of linear abstraction can be a little confusing.
What you need to do is to return no rows if don't want to continue your processing. If subsequent steps receive 0 rows, they will do nothing.
There are some ways to do this:

*

*Build your SQL query in a way that it just returns a row if there is NO FILE with the same name

*Use a Switch step + Detect Empty Stream + Filter rows to ensure that only when you have no result from your query a row will go to next steps

A: The issue you'll face very soon is: "What if I try to start my transformation when it is already running?". This sounds like an academic question until your crontab starts a deadlock or you users complain about you a double count on the data of three weeks ago.
You need to check this in a job. Contrary to transformation in which all steps run in parallel, the job entries run one after the other. You can use a Scripting/SQL entry and put a condition such as logdate<now()-10minutes like explained in this question.
Now, there a more robust architecture for your spec: put all the incoming file in a specific folder, process them then move them to an archive directory. In facts, move them in the archive just before processing, protecting from duplicate load.


text:
Q: Type mismatch required: Option[Any] => Option[Nothing] How can I fix this type error?
object Test extends App {
  def printOption[A](a: Option[A]): Option[A] = { println(a getOrElse("none")); a }

  def printHashCodeAndMap[A, B](fn: Option[A] => Option[B], list: List[Option[A]]): List[Option[B]] = {
    for (elem <- list) yield fn(elem.map{a => println(a.hashCode()); a})
  }

  val optListA = List(Some("aa"), None, Some(5))

  val optListB = printHashCodeAndMap(printOption, optListA)
  for (x <- optListB) printOption(x)
}

The error I get is:
error: type mismatch;
found   : Option[Nothing] => Option[Nothing]
required: Option[Any] => Option[Nothing]
val optListB = printHashCodeAndMap(printOption, optListA)

A: The problem is with how scala infers type parameters. Types information flows from left to right across parameter groups but not within the same parameter group.
What that means is: the type parameter of printOption, A can be inferred only if A has been bound to a real type in a parameter group that precedes it's occurrence. In your printHashCodeAndMap, this is not the case. So, there are two ways to get this to work.
i. You can forsake the type inference and explicitly specify the types of fn by passing it printOption[Any]. Or you could just specify the type parameters of printHashCodeAndMap when you call it (i.e. printHashCodeAndMap[Any, Any](printOption, optListA))
ii. If you wanted to use scala's type inferrence, you'd want the type information for A to come from optListA which is of type List[Option[Any]]. To make that happen the parameter list has to be in a parameter group that precedes fn. Like this:
def printHashCodeAndMap[A, B](list: List[Option[A]])(fn: Option[A] => Option[B]): List[Option[B]] = { ... }

Then you will be able to call it like this:
printHashCodeAndMap(optListA)(printOption)

A: val optListB = printHashCodeAndMap(printOption[Any], optListA)


text:
Q: android kotlin mlkit transtation library version error I am using MLKit to transalte text but whenever i run there is no direct error but the log shows the following and the translated text is always null
W/LibraryVersion: Failed to get app version for libraryName: shared-installation-id D/TransportRuntime.JobInfoScheduler: Scheduling upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) with jobId=-653056373 in 86400000ms(Backend next call timestamp 0). Attempt 1 W/LibraryVersion: Failed to get app version for libraryName: shared-remote-config D/MLKit RemoteConfigRestC: Got remote config. I/TetheringManager: registerTetheringEventCallback:com.example.agrithonapp D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning... D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning... D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning... D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...


text:
Q: Проблема с простой формой ajax Суть проблемы в том, что меня настигла ошибка

Access to XMLHttpRequest at 'http://искомый_сайт.tmweb.ru/catalog/shuby/'
  (redirected from
  'http://искомый_сайт.ru/local/templates/newfurs/components/bitrix/catalog/catalog/bitrix/catalog.element/.default/send.php')
  from origin 'http://искомый_сайт.ru' has been blocked by CORS policy:
  Response to preflight request doesn't pass access control check: No
  'Access-Control-Allow-Origin' header is present on the requested
  resource.

Объясняю, задача стоит в то, что бы запихнуть на страницу сайта (на битрикс) самую простую форму для захвата имени и телефона.
Реализовал самую простую форму на ajax. Но с такой ошибкой столкнулся впервые, прошу помощи, спасибо. Ниже форма, js и php.
ФОРМА
<form id="razmer">
   <select name="rarmer_v" title="Указать размер">
      <option value="40" name="rv40">40</option>
      <option value="42" name="rv42">42</option>
      <option value="44" name="rv44">44</option>
      <option value="46" name="rv46">46</option>
      <option value="48" name="rv48">48</option>
      <option value="50" name="rv50">50</option>
      <option value="52" name="rv52">52</option>
      <option value="54" name="rv54">54</option>
      <option value="56" name="rv56">56</option>
   </select>
   <input type="text" name="name" placeholder="Ваше имя" /><br>
   <input type="text" name="phone" placeholder="Ваш телефон">
   <button>Узнать</button>
</form>

JS
$(document).ready(function(){
    $("#razmer").submit(function(){
         $.ajax({
              type: "POST",
              url: "/local/templates/newfurs/components/bitrix/catalog/catalog/bitrix/catalog.element/.default/send.php",
              data: $(this).serialize()
         }).done(function(){
         alert("Спасибо!");
    });
    return false;
});

});
PHP
<?php

$rec = "почта_реципиента@mail.ru";
$title = "Новая заявка с сайта искомый_сайт";

$name = trim($_POST["name"]);
$phone = trim($_POST["phone"]);
$rarmer_v = trim($_POST["rarmer_v"]);

$message = "Имя: $name \n Телефон: $phone \n Размер: $razmer_v";

mail($rec, $title, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $rec");

?>

A: Если не можете исключить редирект на сторонний сайт посмотрите в сторону jsonp. Попробуйте добавить в ваш код:
type: "POST",
dataType: 'jsonp',


text:
Q: error when booting Recently my laptop has been unable to boot, I have been having hard drive problems over three past few weeks but I would like to know if I need a new hard drive or not.
When booting I get,
Error: unknown filesystem
Entering rescue mode...
Grubrescue>

I have tried to fix it by following online guides, knew of Wichita told me to do this,
# on the grub shell do:
set root=(hd0,6)
set prefix=(hd0,6)/boot/grub
insmod normal
normal
# boot into the system, then in the shell do
sudo update-grub
sudo grub-install /dev/sda

This failed after insmod normal and it stated error: unknown filesystem
I need some advice about if it's a hard drive fault or if it's fixable and if so how?

A: I would suggest repairing grub from a live disk. After you login run the following commands:
sudo fdisk -l /dev/sda

This will output your partitions to see which one contains your Ubuntu OS. Mine is on /dev/sda6 so I will use that as an example, however, yours may be /dev/sda1 or something else.
sudo mount /dev/sda6 /
sudo chroot /
sudo update-grub
sudo reboot

If this does not work, you may need to install grub again before you update grub. If this is the case, boot a live disk and run the following commands:
sudo fdisk -l /dev/sda

This will tell you the partition you need to use in the following commands, again, I will use /dev/sda6 as an example, however, yours may be /dev/sda1 or something else.
sudo mount /dev/sda6 /mnt
sudo grub-install --root-directory=/mnt/ /dev/sda

Notice the last command uses /dev/sda with no number, this installs grub to the MBR. A successful installation will report no errors.
Next, don't forget to change /dev/sda6 to the corresponding partition.
sudo mount /dev/sda6 /
sudo chroot /
sudo update-grub
sudo reboot


text:
Q: ng-repeat inside a directive template - access index I have the following problem:
I have a custom directive, which shows one or more tables, by using ng-repeat inside the template string. Inside each table, several other custom directives are placed. I want these to know the index of the element used, but cant manage to get this done. My code looks like this now:
.directive('myStuffText', function ($rootScope){
    return {
        restrict: 'A',
        require: '^form',
        replace: true,
        scope: true,
        template:
        ......
        '

        ......

        '
' +
        '
	' +
        '
'
        '
',

        link: function (scope, elt, attrs){
            scope.cockpitPolicyModel.newPolicyList = [];
        }
    };

})

Independently from how I try, I always get the string $index or {{$index}} in the template function of the my-add-some-editor directive, not the value of it..
Edit - added the nested directive:
.directive('myAddSomeEditor', function($rootScope){
    return {
        restrict: 'A',
        require: '^form',
        scope: true,

        template: function ($scope, $attr){

            return
            .....
            ''
            .....
            ;
            }
    };
})

A: That probably happens because in your my-add-some-editor directive you have this definition in the isolate scope:
myElementIndex: '@'

That's why you're getting the literal string of what you're writing there in the HTML.
Change that to:
myElementIndex: '='

EDIT: Since you said you're not using isolated scope, try this in the parent directive:  try doing my-element-index="{{$index}}". And this in the child directive's link function:
link: function (scope, elem, attr) {
    attr.$observe('index', function(val) {
      scope.index = val;
    });
}


text:
Q: MySQL reports syntax error using create index inside if statement I have the following code in a db update script:
set @index1 = ifnull((select count(1) from information_schema.statistics
    where table_name = 'Entries' and index_name = 'IX_Entries_EmailAddress'),0);

set @index2 = ifnull((select count(1) from information_schema.statistics
    where table_name = 'Entries' and index_name = 'IX_Entries_FirstLastName'),0);

if (@index1 = 0) then create index IX_Entries_EmailAddress on Entries (EmailAddress);
if (@index2 = 0) then create index IX_Entries_FirstLastName on Entries (FirstName, LastName);

MySQL reports:
SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if (@index1 = 0) then create index IX_Entries_EmailAddress on Entries (EmailAddr' at line 1
All the syntax looks correct according to the MYSQL docs, what am I missing?
Edit: Got it, thanks to Ryan's answer.
set @sqlcmd := if(@index1 = 0, 'create index IX_Entries_EmailAddress on Entries (EmailAddress);', '');
prepare stmt from @sqlcmd;
execute stmt;

set @sqlcmd := if(@index2 = 0, 'create index IX_Entries_FirstLastName on Entries (FirstName, LastName);', '');
prepare stmt from @sqlcmd;
execute stmt;

A: And IF statement like that can't be used in a regular script - it's a MySQL compound statement. They can only be used in triggers, stored procedures, etc.
In a regular script, you'd need to update the logic to not use the IF construct, but rather some of the built-in functions such as IFNULL().


text:
Q: All my internet connections have disintegrated Up until last week I had no problems. I have a Dell Latitude 3340 which was bought with 14.04 a couple of years ago and I recently upgraded to 16.04. And everything was fine. I'm a dev and use Vagrant - but I'm no expert with Linux (I just write code).
When trying to install a new VM I did a couple of stupid things (changing permissions for whole folders). So I screwed up sudoers but sorted that out.
Then I lost wireless. It just vanished. But ethernet was fine, and then that broke. And now I have nothing. OK, that's the background.
I've been at this for a couple of days, and I've read and tried everything I could find but nothing is improving (in some ways worse). Permissions may be an issue I already found one place where the suggested permissions fix was too restrictive
At the very least I need to get the ethernet back. But wireless would be good.
Here's all the data I think you'll need:
Results from lspci -knn | grep Net -A2
03:00.0 Network controller [0280]: Intel Corporation Wireless 7260 [8086:08b1] (rev bb)
    Subsystem: Intel Corporation Dual Band Wireless-AC 7260 [8086:c470]
    Kernel driver in use: iwlwifi

Results from lspci | egrep -i 'network|ethernet':
00:19.0 Ethernet controller: Intel Corporation Ethernet Connection I218-LM (rev 04)
03:00.0 Network controller: Intel Corporation Wireless 7260 (rev bb)

Results from `lshw -C network`:
  *-network
       description: Ethernet interface
       product: Ethernet Connection I218-LM
       vendor: Intel Corporation
       physical id: 19
       bus info: pci@0000:00:19.0
       logical name: eth0
       version: 04
       serial: 20:47:47:12:68:40
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k duplex=full firmware=0.6-4 ip=192.168.1.149 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
       resources: irq:42 memory:f7e00000-f7e1ffff memory:f7e3c000-f7e3cfff ioport:f080(size=32)
  *-network
       description: Network controller
       product: Wireless 7260
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:03:00.0
       version: bb
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=iwlwifi latency=0
       resources: irq:47 memory:f7c00000-f7c01fff

Results from nmcli d:
DEVICE           TYPE      STATE      CONNECTION
br-5de25754fda4  bridge    connected  br-5de25754fda4
docker0          bridge    connected  docker0
eth0             ethernet  connected  Wired connection 1
lo               loopback  unmanaged  --

Results from ifconfig:
br-5de25754fda4 Link encap:Ethernet  HWaddr 02:42:8f:0e:ca:d0
          inet addr:172.18.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

docker0   Link encap:Ethernet  HWaddr 02:42:80:b1:f0:c8
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 20:47:47:12:68:40
          inet addr:192.168.1.149  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::50ee:e26f:5e57:7d64/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2801 errors:0 dropped:0 overruns:0 frame:0
          TX packets:597 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:349073 (349.0 KB)  TX bytes:77039 (77.0 KB)
          Interrupt:20 Memory:f7e00000-f7e20000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:10832 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10832 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:811344 (811.3 KB)  TX bytes:811344 (811.3 KB)

Results from ip a:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 20:47:47:12:68:40 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.149/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 85423sec preferred_lft 85423sec
    inet6 fe80::50ee:e26f:5e57:7d64/64 scope link
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:80:b1:f0:c8 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
4: br-5de25754fda4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:8f:0e:ca:d0 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 scope global br-5de25754fda4
       valid_lft forever preferred_lft forever

Results from cat /etc/network/interfaces:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

I have tried this:
sudo touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf

So that empty file still exists on the system.
And as a final note: On the front end it claims I'm connected to ethernet when I first switch on. I can then disconnect but when I re-connect it instantly disconnects again.

A: The two "bridge" interfaces are surely the problem.
This is my stdout for nmcli -d
DISPOSITIVO  TIPO      ESTADO       CONEXIÓN
eth0         ethernet  conectado    Wired connection 1
wlan0        wifi      conectado    WiFilibr3
lo           loopback  sin gestión  --

You should bring down the interfaces
sudo ifconfig docker0 down
sudo ifconfig br-5de25754fda4 down

And modify your /etc/network/interfaces which should only have
auto lo
iface lo inet loopback

That should be enough.


text:
Q: Switch from Fabric to Firebase Crashlytics problem: The Crashlytics build ID is missing After switch from Fabric to Firebase Crashlytics SDK I have a problem. Problem is as in the title: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
I have json file generated from console(double checked these and keys with everything else looks ok). I have libs added in gradle. I'm calling 'throw new RuntimeException("Test Crash");' and getting an error with build ID which I have no idea what it is...

A: Be sure to have 2 things below:
In the root build.gradle:
buildscript {
    ...
    dependencies {
        ...
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.0'
    }
    ...
}

and under app/build.gradle:
...
apply plugin: 'com.google.firebase.crashlytics'
...

A: Seems like instruction could have been missed out
apply plugin: 'com.google.firebase.crashlytics'

A: It sounds like you're using Fabric dependencies in your Firebase app. This error occurs when your Crashlytics Gradle plugin isn't correctly configured. I recommend going through these onboarding instructions once more to make sure everything looks right in your integration.


text:
Q: Newlines in shell script variable not being replaced properly Situation: Using a shell script (bash/ksh), there is a message that should be shown in the console log, and subsequently sent via email.
Problem: There are newline characters in the message.
Example below:
   ErrMsg="File names must be unique. Please correct and rerun.
Duplicate names are listed below:
File 1.txt
File 1.txt
File 2.txt
File 2.txt
File 2.txt"
   echo "${ErrMsg}"
   # OK. After showing the message in the console log, send an email

Question: How can these newline characters be translated into HTML line breaks for the email?
Constraint: We must use HTML email. Downstream processes (such as Microsoft Outlook) are too inconsistent for anything else to be of use. Simple text email is usually a good choice, but off the table for this situation.
To be clear, the newlines do not need to be completely removed, but HTML line breaks must be inserted wherever there is a newline character.
This question is being asked because I have already attempted to use several commands, such as sed, tr, and awk with varying degrees of success.

A: TL;DR: The following snippet will do the job:
ErrMsg=`echo "$ErrMsg"|awk 1 ORS='<br/>'`

Just make sure there are double quotes around the variable when using echo.

This turned out to be a tricky situation. Some notes of explanation are below.
Using sed
Turns out, sed reads through input line by line, which makes finding and replacing those newlines somewhat outside the norm. There were several clever tricks that appeared to work, but I felt they were far too complicated to apply appropriately to this rather simple situation.
Using tr
According to this answer the tr command should work. Unfortunately, this only translates character by character. The two character strings are not the same length, and I am limited to translating the newline into a space or other single character.
For the following:
ErrMsg="Line 1
Line 2
"
ErrMsg=`echo $ErrMsg| tr '\n' 'BREAK'`

# You might expect:
# "Line 1BREAKLine 2BREAK"
# But instead you get:
# "Line 1BLine 2B"
echo "${ErrMsg}"

Using awk
Using awk according to this answer initially appeared to work, but due to some other circumstances with echo there was a subtle problem. The solution is noted in this forum.
You must have double-quotes around your variable, or echo will strip out all newlines.(Of course, awk will receive the characters with a newline at the end, because that's what echo does after it echos stuff.)
This snippet is good: (line breaks in the middle are preserved and replaced correctly)
ErrMsg=`echo "$ErrMsg"|awk 1 ORS='<br/>'`

This snipped is bad: (newlines converted to spaces by echo, one line break at end)
ErrMsg=`echo $ErrMsg|awk 1 ORS='<br/>'`

A: You can wrap your message in HTML using <pre>, something like
<pre>
${ErrMsg}
and more.
</pre>


text:
Q: Recursion flow in c language and how the output is printed How is the value of I getting printed?
I know the recursion calls itself again and again. According to me, the function should return empty as the function is called before printing. How is the printf working?
recur(int i)
{
  if(i<0)
    return 0;
  recur(--i);
  printf("%d",i);
  recur(--i);
}

main()
{
  recur(2);
}

The output of this program is
-1
0
1
-1

Can someone explain how is it working?

A: To understand what happens, you have to understand how recursion works. Every recursive function requires a test condition to break the recursion and a recursive call. You have if (i < 0) as your test condition and then your have two recursive calls with printf between them.
So How Does This Work?
You can think of recursion and winding-up until the exit condition is triggered -- and then an unwinding as the recursive calls return. Let's see how this works here.
The Recursion
When you start with recur(2) in main, what path does the logic take to wind-up to the exit condition?
If you simplify the function and concentrate on what happens before your test condition is met, you get something similar to:
void recur (int i) {
    if (i < 0)
        return;
    recur (--i);
    /* comes after return */
}

Let's follow it through. On the first call, i = 2 so --1 pre decriment occurs making i = 1, recur (1) executes. Next call i = 0, recur (0) is called again. Finally, i = -1, and the first recur(-1) occurs, so if (i < 0) executes and return is called.
Now What? -- The Unwinding...
Look at the above shortened function. When you return, you are returning from the last call to recur(--i) so control is now passed to the next command after the first recur(-1) (shown as /* comes after return */ above) So what are the next commands in the full function?
    printf("%d\n", i);
    recur (--i);

What was the value of i when this first occured? (hint: -1).
So printf is called and then what comes next? Your second recur(--i). There i = -2, the if (i < 0) return; is triggered and you unwind out of the second recur(-2) -- there is no command that follows and that function call is now complete.
Control now unwinds to within the previous call where i is now 0, the printf is called and the second recur(--i) is entered with i = -1 which simply hits return again and you unwind one more level to where i = 1 returning again from the first recur(--i) call, 1 is output.
The second recur(--i) call is entered where after decrement i = 0 and you now recurse once more into the first where i = -1 again triggering return which causes contol to pass to printf with the final -1 printing.
You now recurse into the second recur(--i) with i = -2 triggering return and completing the function call and the recursion.
So if you go back through the control of your recursive function with two recursive calls and look at each time printf was reached you have output -1, 0, 1, -1.
Still Think Recursive Functions With Multiple Recursive Calls Are A Good Idea?
(they are if you are an Aspirin salesman -- otherwise, they are best avoided unless they are the only reasonable option you have)
The only way to get through something like this is to either (1) make friends with your debugger and single-step through your code keeping a scratch sheet of which call was entered when, or (2) copy and paste the function down the page tracking the state of the recursive call at each level and take it step-by-step.
Always a good learning experience, but if a procedural solution is available, the logic is much more straight-forward and you avoid the function call overhead of every recursive call. Recursive functions have their place, and there are some problems to which they provide very elegant solutions. But you have to be mindful of how many times the recursion will occur as you allocate a separate function stack and space for local variables with every call -- which can lead to StackOverflow.

A: When you call recur(2);, then at this point
recur(--i);

recur(1) is called, and then when it reaches that point again, recur(0); is called and then at that point again, recur(-1); is called. The recur(-1); call immediately returns because if(i<0) return 0;.
The  recur(0); call, where i is now -1, then does the print, and returns (it does recur(--i); again, but that's -2 at this point). Next, the recur(1) call (where i is 0 now) does its print, and the it also hits recur(1), which returns.
Finally, the original recur(2); call (where i is 1) does its print and calls another recur(0);, which as we've seen, results in -1 being printed. This results in the output of -101-1, or if you add a newline to each print, the output that you are seeing.
On a side note, I suggest writing your main function as
int main()
{
    recur(2);
    return 0; // return value of 0 indicates successful program execution
}

and change the signature of recur(int i) to void recur(int i) and its return 0; to just return;.

according to me the function should return empty as the function is
  called before printing. how the printf is working?

To sum it up, it's working because not all recursive calls are doing further recursive calls. They only do recursive calls under certain conditions, and if they don't do that recursive call, they finish at some point, allowing the function that called it to continue.

A: The problem is that you are calling your function before you are printing out the value.
recur(int i)
{
if(i<0)
    return 0;
recur(--i);
printf("%d",i);
recur(--i);
}

You are calling recur(2) in your main function the first if(i<0) does not return 0 because i=2. Then your function recur is called with the value 1 recur(1)
The if(i<0) in this case does also not return 0 because i=1 than your function recur(0) is called with 0.
The if(i<0) does still not return 0 beacuse i=0 and your function is called with recur(-1).
Then you're if(i<0) returns 0 beacuse i=-1.
Now we start to print() out the values we gave the function previously.
Which was print(-1) because it was the last value that our function had.
Then we call recur again with recur(-2) and the if returns 0.
Then we print(0) because that was the second value we "entered" was 0.
Then we call recur with recur(-1) and the if(i<0) returns 0.
This goes on for the next values.
For future problems, I would recommend you to use a debugger. GDB debugger for example.
Here is a like to get started with gdb:
GDB Start guid
I hope this helps you.

A: When the function is called with an argument X >= zero, you'll have these lines executed:
recur(X-1)
print X-1
recur(X-2)
return

When the function is called with an argument X < zero, you'll only have this line executed:
return

Now if you write the function calls with some indentation for each call level you get:
recur(2)
        recur(1)
                recur(0)
                        recur(-1)
                                return
                        print -1
                        recur(-2)
                                return
                        return
                print 0
                recur(-1)
                        return
                return
        print 1
        recur(0)
                recur(-1)
                        return
                print -1
                recur(-2)
                        return
                return
        return
return

Removing everything except the print gives:
                        print -1
                print 0
        print 1
                print -1

So the output is:
-1
0
1
-1

A: ALSO CONSIDER
you are using the variable is as auto variable
the value  of auto variables is limited with the panathesis so the program will print the value of i available within the paranthesis at which the control flow currnetly resides

A: Instead of doing recur(--i), please do recur(i-1)
With --i it will actually decrease i, and so in later printf it will be visible (incorrectly).
For eg. if i is 0 and you do recur(--i) , it will decrease the actual value of i to -1 and then call recur(). And the printf will print -1 later.
With recur(i-1), and i as 0 it will be call with -1 as argument but the actual value of i will not be changed.


text:
Q: How to avoid reassignment of a variable on page load I'm trying to come up with a function which will allow users to alterate data pressing buttons BACK and NEXT respectively.
I'm using this code for it:
         CounterID = IdArray.Length 'array of IDs

        determinator = CounterID 'determining which index is active and putting it on the top of array

        If Ident = 1 Then ' if button back is pressed
            determinator = determinator + 1
            If determinator <= CounterID Then
                'some actions
            End If

        Else
            determinator = determinator - 1
            If determinator >= 0 Then
                'some actions
            End If
        End If

It actually works. But partially. My problem is that whenever a button is presses the value of DETERMINATOR variable is again assigned to the maximum length.
Is there any way to avoid reassignment of this variable and make it happen only once?

A: You may be able to use a session variable, something like this:
If Session("determinator") <> Nothing Then
  determinator = Session("determinator")
else
  CounterID = IdArray.Length 'array of IDs
  determinator = CounterID
  Session("determinator") = determinator
end if

You may want this to be executed depending on IsPostBack.


text:
Q: ProGuard and HoloEverywhere: Export Signed Application Errors I'm using ActionBarSherlock and HoloEverywhere in my project. Everything works perfectly, except when I try to export my signed application, ProGuard gives me grief:
[2013-05-19 00:13:53 - ] Proguard returned with error code 1. See console
[2013-05-19 00:13:53 - ] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.content.Context mContext' in class com.actionbarsherlock.widget.SuggestionsAdapter
[2013-05-19 00:13:53 - ] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced method 'android.database.Cursor getCursor()' in class com.actionbarsherlock.widget.SuggestionsAdapter
[2013-05-19 00:13:53 - ] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.database.Cursor mCursor' in class com.actionbarsherlock.widget.SuggestionsAdapter
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ChooserActivity: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.ChooserActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ChooserActivity: can't find referenced method 'void finish()' in class org.holoeverywhere.ChooserActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ChooserActivity: can't find referenced method 'android.content.res.Resources getResources()' in class org.holoeverywhere.ChooserActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'boolean isRestricted()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'boolean isFinishing()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'void finish()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.ThemeManager: can't find referenced method 'void overridePendingTransition(int,int)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'android.content.res.Resources getResources()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'android.view.Window getWindow()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity: can't find referenced method 'java.lang.ClassLoader getClassLoader()' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Activity$24: can't find referenced method 'boolean requestWindowFeature(int)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'void finish()' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'boolean isFinishing()' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'android.view.Window getWindow()' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'boolean onKeyDown(int,android.view.KeyEvent)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.AlertActivity: can't find referenced method 'boolean onKeyUp(int,android.view.KeyEvent)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'android.support.v4.app.FragmentManager getFragmentManager()' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onActivityCreated(android.os.Bundle)' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'android.view.View getView()' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onDetach()' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onSaveInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onStart()' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'void onStop()' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.DialogFragment: can't find referenced method 'java.lang.CharSequence getText(int)' in class org.holoeverywhere.app.DialogFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ExpandableListActivity: can't find referenced method 'void onRestoreInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.Fragment: can't find referenced method 'void setArguments(android.os.Bundle)' in class org.holoeverywhere.app.Fragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.GridFragment: can't find referenced method 'android.view.View getView()' in class org.holoeverywhere.app.GridFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.GridFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class org.holoeverywhere.app.GridFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ListActivity: can't find referenced method 'void onRestoreInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.Activity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ListFragment: can't find referenced method 'android.view.View getView()' in class org.holoeverywhere.app.ListFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ListFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class org.holoeverywhere.app.ListFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'android.content.res.Resources getResources()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'android.content.Intent getIntent()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'android.content.pm.PackageManager getPackageManager()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'java.lang.String getPackageName()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'void finish()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'void onRestoreInstanceState(android.os.Bundle)' in class org.holoeverywhere.app.AlertActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity: can't find referenced method 'boolean isChangingConfigurations()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity$ResolveListAdapter: can't find referenced method 'void finish()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.ResolverActivity$ResolveListAdapter: can't find referenced method 'android.content.pm.PackageManager getPackageManager()' in class org.holoeverywhere.app.ResolverActivity
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeActivity: can't find referenced method 'boolean isDetached()' in class org.holoeverywhere.app.TabSwipeActivity$InnerFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeFragment: can't find referenced method 'java.lang.CharSequence getText(int)' in class org.holoeverywhere.app.TabSwipeFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeFragment: can't find referenced method 'void notifyDataSetChanged()' in class org.holoeverywhere.app.TabSwipeFragment$TabSwipeAdapter
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.app.TabSwipeFragment$TabSwipeAdapter: can't find referenced method 'android.support.v4.app.FragmentManager getChildFragmentManager()' in class org.holoeverywhere.app.TabSwipeFragment
[2013-05-19 00:13:53 - ] Warning: org.holoeverywhere.internal.AlertController$AlertParams$2: can't find referenced method 'android.database.Cursor getCursor()' in class org.holoeverywhere.internal.AlertController$AlertParams$2
[2013-05-19 00:13:53 - ]       You should check if you need to specify additional program jars.
[2013-05-19 00:13:53 - ] Warning: there were 51 unresolved references to program class members.
[2013-05-19 00:13:53 - ]          Your input classes appear to be inconsistent.
[2013-05-19 00:13:53 - ]          You may need to recompile them and try again.
[2013-05-19 00:13:53 - ]          Alternatively, you may have to specify the option
[2013-05-19 00:13:53 - ]          '-dontskipnonpubliclibraryclassmembers'.
[2013-05-19 00:13:53 - ] java.io.IOException: Please correct the above warnings first.
[2013-05-19 00:13:53 - ]    at proguard.Initializer.execute(Initializer.java:321)
[2013-05-19 00:13:53 - ]    at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-05-19 00:13:53 - ]    at proguard.ProGuard.execute(ProGuard.java:86)
[2013-05-19 00:13:53 - ]    at proguard.ProGuard.main(ProGuard.java:492)

I tried including the following lines in my proguard-project.txt, but it didn't seem to do anything:
-keep class com.actionbarsherlock.** {*;}
-keep class org.holoeverywhere.** {*;}

This is my project.properties:
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}\\tools\\proguard\\proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library.reference.1=../../../Downloads/JakeWharton-ActionBarSherlock-4.3.1-0-gc0d437c/JakeWharton-ActionBarSherlock-071a61c/actionbarsherlock
android.library.reference.2=../../../Downloads/HoloEverywhere-master (1)/HoloEverywhere-master/library

This is my proguard-project.txt
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
-keep class com.actionbarsherlock.**
-keep class org.holoeverywhere.**

Anyone know how to fix this?

A: I needed to add the following two lines:
-libraryjars adt-bundle-windows-x86_64/sdk/platforms/android-17/android.jar
-libraryjars adt-bundle-windows-x86_64/sdk/extras/android/support/v4/android-support-v4.jar

A: Grief is right. I have never used ProGuard but I know what it is. Here is some information I hope it helps.
According to ProGuards website

NoSuchMethodException
Your code is probably calling something like myClass.getMethod, trying to find some method dynamically. Since ProGuard can't always detect this automatically, you have to keep the missing method in using the appropriate -keep option, e.g. "-keepclassmembers class mypackage.MyClass { void myMethod(); }".
More specifically, if the method reported as missing is values or valueOf, you probably have to keep some methods related to enumerations.

Similar Overstack question
Proguard error when exporting signed app using android.support.v4.app honeycomb compatibility package
All so look at the related topics to the right side   ->>                            >>  >>
Hope this helps or helps point you in the right direction.


text:
Q: UTF-8 problems in Python I have googled this and tried every single solution that I have found and nothing is working. I am using Python3. I read a string from a form and try to print/write it. Everything is fine unless it contains non-ascii characters (I am testing with Greek text).
form = cgi.FieldStorage()
name = form.getvalue("Name")
sys.stderr.write(name)
print(name)

The write outputs the Unicode encoding (e.g. \u03bc\u03b5\u03c4\u1f70) which is not what I want, and the print crashes with a
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

So for some reason print and write treat it differently, which is just weird.
Here is everything I have tried to get it to print out the text in its original form (as Greek letters):
print(name.encode("UTF-8"))

This prints it in the wrong format similar to what write did above. The following all crash with the same/similar error:
print(name.encode("UTF-8").decode("UTF-8")) # crashes with same error

ba = bytearray(name,"UTF-8")
n2 = ba.decode("UTF-8")
print(n2) # also crashes

unic = u'' # Nope. Errors still.
unic +=name
print(unic) # also crashes

print(b'{name}') #Prints b'{name}' literally.

If I run similar code locally (instead of on a webserver and getting the string as a response), everything works fine. Somehow the string I am getting back is acting differently and I cannot for the life of me figure out why.
So what very simple thing am I missing here?
In case it is relevant, I executed locale (I am using Centos 7) and get the following:
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Update
I printed sys.stdout.encoding from the script and it returns ANSI_X3.4-1968, so that may be the problem. Strangely, when I run the same command from a python3 command line prompt I get UTF-8. Now I I guess I need to figure out how to set the encoding for when it runs from the webserver.
Update 2
I added the following:
A = subprocess.run(["locale"])
print(A.stdout)

And the output is:
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL= None

so clearly the encoding is set differently when I run from Apache than from the command line. Hmmm...
Update 3
I tried adding the following lines to /etc/sysconfig/httpd and restarted apache, but no change. (The first two were suggested in one place, the third in another, although none of the sources said WHERE to put these. For Centos 7, the file I tried seemed to be the logical one, but obviously not?)
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
export PYTHONIOENCODING=utf-8

Update 4
I tried locale.setlocale(locale.LC_ALL,'en_US.UTF-8') in my script and it didn't help.
Also, strangely, there is the following in my old error_log files for httpd, but not in the current one (so the last time this printed was several days ago):
Fatal Python error: Py_Initialize: Unable to get the locale encoding

This seems to track with what I am seeing--the environment variables are not being used/seen when my scripts run from Apache.
Update 5
I found a hack that works. Instead of running my python script directly from Apache, I run runMakeArt which is as follows:
#!/usr/bin/sh
export PYTHONIOENCODING=utf-8 ; /usr/bin/python3 makeArt.py

and so far this seems to be working. In some sense maybe this is better than properly configuring Apache since if I move servers (hopefully not!), this should still work without worrying about whether or not Apache is configured correctly.


text:
Q: click icon and open target directly I have a table in my wiki as below.  Right now when I click on the red pdf icon it takes me to the file description page for the target file, myfile.pdf.
Instead, I want it to immediately open the myfile.pdf, not require 2 clicks to get it open.

Below is what that table cell entry looks like (1st row, 2nd col in the table).  How do I modify it to do what i want?
[[Image:Pdf_icon.png|20px|link=File:myfile.pdf]]

A: You can use one of the following methods:
[[Image:Pdf_icon.png|20px|link=Special:FilePath/myfile.pdf]]

or
[[Image:Pdf_icon.png|20px|link={{filepath:myfile.pdf}}]]

The slight difference is that the first method links to an internal special page that automatically redirects to the file, and the second method generates a direct link to the file.


text:
Q: How does assert groupType != null contain 4 branches I need to test the following code.
public List<PatientGroup> findGroups(final String groupType) throws HwBaseAppException
{
    assert groupType != null;//4 branches here
    CriteriaBuilder criteriaBuilder=persistence.getCriteriaBuilder();
    CriteriaQuery<PatientGroup> query = criteriaBuilder.createQuery(PatientGroup.class);
    Root<PatientGroup> patientGroupRoot = query.from(PatientGroup.class);
    Predicate condition=criteriaBuilder.equal(patientGroupRoot.get(PatientGroup_.active), Boolean.TRUE);
    Join<PatientGroup, GroupSubType> groupSubTypeRoot = patientGroupRoot.join(PatientGroup_.groupSubType);
    Predicate condition1=criteriaBuilder.equal(groupSubTypeRoot.get(GroupSubType_.groupTypeCode), groupType);
    query.where(condition,condition1);
    query.orderBy(criteriaBuilder.asc(patientGroupRoot.get(PatientGroup_.name)));
    TypedQuery<PatientGroup> tq = persistence.createQuery(query);
    List<PatientGroup> collections = tq.getResultList();
    return initializeGroupRelationships(collections);
}

In my test case i am passing both null and not null values which should cover both the branches however Code coverage says 1 of 4 branches missed.What are the other 2 branches?
Below are my test cases.
 @Test
    public void testFindGroups_1()
        throws HwBaseAppException
    {
        Mockito.when(persistence.getCriteriaBuilder()).thenReturn(criteriaBuilder);
        Mockito.when(criteriaBuilder.createQuery(PatientGroup.class)).thenReturn(criteriaQuery);
        Mockito.when(criteriaQuery.from(PatientGroup.class)).thenReturn(patientGroupRoot);
        Mockito.when(patientGroupRoot.join(PatientGroup_.groupSubType)).thenReturn(groupSubTypeRoot);
        Mockito.when(persistence.createQuery(Mockito.any(CriteriaQuery.class))).thenReturn(tq);
        Mockito.when(tq.getResultList()).thenReturn(arrayList);
        Mockito.when(arrayList.iterator()).thenReturn(iterator);
        Mockito.when(iterator.hasNext()).thenReturn(true).thenReturn(false);
        Mockito.when(iterator.next()).thenReturn(patientGroup);
        groupServiceDAOImpl.findGroups("groupType");
    }
    @Test(expected=AssertionError.class)
    public void testFindGroups_2()
        throws HwBaseAppException
    {
        groupServiceDAOImpl.findGroups(null);
    }

A: EclEmma Eclipse plugin provides coverage analysis using JaCoCo library, which in his turn analyzes bytecode. Let's take a simplified example:
class Example {
  void example(Object x) {
    assert x != null;
  }
}

And let's have a look on its bytecode:
javac Example.java
javap -v Example

Which looks like:
 0: getstatic     #2                  // Field $assertionsDisabled:Z
 3: ifne          18
 6: aload_1
 7: ifnonnull     18
10: new           #3                  // class java/lang/AssertionError
13: dup
14: invokespecial #4                  // Method java/lang/AssertionError."<init>":()V
17: athrow
18: return

As you can see - there are actually 2 conditions:

*

*assertions enabled (ifne)

*x is not null (ifnonnull)

And so 4 possible variants.


text:
Q: Trouble passing data to a child component with hooks The structure of the project is where my App.js gets the user location when it loads. I want to take this information and pass it down to a child component. The reason I set it up like this is that I will have 3 components that all need to use the location data.
I am really close to getting this to work, but I cannot seem to get the data over to the Weather component. The App compiles successfully but it will not render the data I want it to. I feel like I am so, so close but need that push to get over the cliff.
import { Route } from 'react-router-dom'

import './App.css';
import Navbar from './components/Navbar'
import Weather from './components/Weather'

// Defining our <App /> component the function name matches the file name
function App() {

    const [location, setLocation] = useState({lat: 0, long: 0})

    useEffect(()=>{
      const success = (position) =>{
        let lat = position.coords.latitude
        let long = position.coords.longitude

        console.log(lat, long)
        setLocation({lat: lat, long: long})
        // I have also tried ({lat, long})

      }
      navigator.geolocation.getCurrentPosition(success)

    },[])

  const routes = ['nasa','openweather','zomato']

  return (

    {/* Establish Navigation for the website */}
      <Navbar routes={routes} />
      <Route exact path="/nasa"></Route>

     <Route exact path="/openweather">
        <Weather position={location} />
      </Route>

Here is the Weather component
const Weather = ({ position }) => {
    return(

 long: {position.long}

 lat: {position.lat}

    )
}

export default Weather

A: Great! You've the basic idea but you are missing a little attention to your app state and everything will be okay.
1- note that you didn't pass any value to set the location state
    // first it has started with undefined
    const [location, setLocation] = useState(); // you should have passed an initila state here...

should be
    // put any default long & lat you find suitable
    const [location, setLocation] = useState({ lat: 33.232, long: 35.125 });

and when you set the new state you didn't pass anything to the set function
      setLocation()

where it should be
      setLocation({ long: <xxx>, lat: <xxx> });

2- and as I can see from your code that line should be inside the success callback where you get the actual long and lat.
3- and finally when you've passed down the state to the child component you didn't specify any property from your state(maybe because you didn't have a structure for your state yet)

 {position}

should be

 long: {position.long}

 lat:  {position.lat}


text:
Q: Flutter Custom Text Field I want to create a custom text field in flutter like shown in the picture. Outlined TextField border with label and icon in the middle of the border line.
Is there any way to create such TextField?

Thank in advance.

A: You can use stack to achieve the UI
Stack(
       children: [
         TextFormField(
           ...apply the border here
         ),
         Positioned(
           left: 16.0,
           top: 5.0,
           child: Container(
             padding: EdgeInsets.all(5.0),
             color: AppColors.whiteColor,
             child: Row(
               children: [
                 Image.asset(your_image),
                 Text("Name")
               ],
             ),
           ),
         ),

       ],
    );