text:
Q: Google Cloud Messaging for Android Library - Deprecated I'am following the Stop watch demo from Google 2013 IO
http://www.youtube.com/watch?v=lmv1dTnhLH4&feature=player_detailpage#t=2225
I try to generate App Engine Backend but failed, it says I need to install "Google Cloud Messaging for Android Library" but it is Deprecated!. What do I use?

A: Google Cloud Messaging is now included in the Play Services SDK.
Have a look: http://developer.android.com/google/play-services/setup.html

A: Seems like this package is now obsolete. In order to see it in SDK Manager I had to check "Show obsolete packages" in the "Packages" menu
Edit (clarification of my answer)
I encountered this problem when trying to run Maven Android SDK Deployer. The version of the SDK deployer I used, was expecting gcm package installed (at least when running the deployer in  its default configuration).
For other purposes, it's recommended to use the newer Google Play Services instead, as stated in one of the answers here.


text:
Q: SQLite is not saving my id in an android application Simple problem which got me stuck for hours now...
When I add a value into my database via db.insert(TABLE_NAME, null, myValues) the new id of my item is returned.
Exactly after this call I'd like to update my entry. Therefore I call db.update(TABLE_NAME, values, MY_ID_NAME + " = " + returnedId, null). I'd expect to get 1 returned as one entry is affected by this update.
However, I get 0. My id is simply not saved into the database. If I try more complex queries I always get every value I need but the id, which is always 0.
I've no idea how to find my fault - I get a cursor, try to get the id by long id = cursor.getLong(0) and it will return 0.
My CreateStatement starts with:
"CREATE TABLE " + TABLE_NAME + "("+ MY_ID_NAME + " LONG PRIMARY KEY, "....

Also I need to mention that I work on an In-Memory Database for testing purposes.
What is missing? What am I doing wrong?
Also: I decided to open the database only at the beginning via Singleton-Pattern - this wasn't an issue until now
Edit2: What I also forgot to mention is that I'm currently working in an InstrumentationTestCase-environent for some unit-tests

A: I'm almost positive that the primary ID number in Android's SQLite must be called _id during table creation and referred to when querying the table as _ID.
so in this case:
"CREATE TABLE " + TABLE_NAME + "(_id LONG PRIMARY KEY, "....
Edit:
Try this:
"CREATE TABLE " + TABLE_NAME + "("+ MY_ID_NAME + " LONG PRIMARY KEY AUTOINCREMENT, "...
Although I am curious why you choose to use LONG instead of INTEGER

A: After hours of testing and debugging, Zolnoor's answer was nearly correct:
SQLite does not allow a LONG PRIMARY KEY statement but an INTEGER PRIMARY KEY as described in the SQLite-Documentation:

The data for rowid tables is stored as a B-Tree structure containing one entry for each table row, using the rowid value as the key. This means that retrieving or sorting records by rowid is fast. Searching for a record with a specific rowid, or for all records with rowids within a specified range is around twice as fast as a similar search made by specifying any other PRIMARY KEY or indexed value.
With one exception noted below, if a rowid table has a primary key that consists of a  single column and the declared type of that column is "INTEGER" in any mixture of upper and lower case, then the column becomes an alias for the rowid. Such a column is usually referred to as an "integer primary key". A PRIMARY KEY column only becomes an integer primary key if the declared type name is exactly "INTEGER". Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary table column with integer affinity and a unique index, not as an alias for the rowid.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Automate The Boring Stuff - CH7 Strong Password Detection Practce Projects I am new to coding and python is my first programming language. I am studying with 'Automate the Boring Stuff', and right now I am in CH7- trying to figure out 'Strong Password Detection' project.
(https://automatetheboringstuff.com/2e/chapter7/)
Strong Password Detection
Write a function that uses regular expressions to make sure the password string it is passed is strong. A strong password is defined as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit. You may need to test the string against multiple regex patterns to validate its strength.
I wrote a code like this below.
import re, pyperclip

password_regex = re.compile(r'^(?=.*[a-zA-Z0-9])(?=.*[!@#$%^&*-_]){8,}$')

text = pyperclip.paste()

matches = []

for groups in password_regex.findall(text):
    matches.append(groups[0])
    if len(matches)> 8:
        pyperclip.copy('\n'.join(matches))
        print('\n'.join(matches))

    else:
        print('Your password lenths doesn\'t meet the standard.')

It doesn't run anything after I saved it. Would you please help me and teach me what I did wrong?
Thank you so much in advance.


text:
Q: class > element selector in aphrodite how to implement >elemnt selector in aphrodite. I want to style my child div to width "100%"
 inputContainer: {
        width: '100%',
        "> div": {
            width: '100%'
        }
    },

but it is not working.

A: Its a bit of a hack workaround, but I believe this should work with Aphrodite:
    ':nth-child(1n) > div': {
      width: '100%'
    },

It works because Aphrodite basically will transpose anything verbatim into the style tag it creates if you start the rule with a ":".

A: Use AphroditeJSS instead. It uses the same API as Aphrodite, and handles Aphrodite's some of Aphrodite shortcomings, descendant styling being one of them.
https://github.com/cssinjs/aphrodite-jss
npm i aphrodite-jss --save-dev

const inputCss = Stylesheet.create = ({
    inputContainer: {
        width: '100%',
        "> div": {
            width: '100%'
        }
    },
});

A: Aphrodite does not supported nested element styling. I would suggest using styled-components or glamorous.


text:
Q: Outlook add-in : Get shared mailbox ItemAttachment using EWS Our outlook add-in works in most scenarios on a shared Mailbox, except when the attachment in an email is of type "Office.MailboxEnums.AttachmentType.Item" e.g ".msg" file.
Environment is Outlook web and desktop.

We mostly get all attachment content via REST, as they are returned as base-64, but with "AttachmentType.Item" the body is email body and not a base-64. In this case, we make a call to EWS to download that attachment, process the body and return as byte[];
The problem we are currently having is that, when the attachment is of type ".msg" on a shared mailbox, EWS return with the error "ErrorAccessDenied", This is strange as, other attachments are downloaded and we've made sure that we pass "TargetMailbox"
We get the targetMailbox by: https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access
Once we have the accessToken and targetMailbox we call the backend
GetData(token, Id){
    let sharedMailBox = GetTargetMailbox(token);
    return this.$http.post("DownloadAttachment", {
        token: sharedMailBox.token,
        url: Office.context.mailbox.ewsUrl,
        attachmentId: Id,
        mailbox: sharedMailBox.mailbox
    }, {
        responseType: 'arraybuffer',
    }).then(response => response.data);
}

backend
 DownloadAttachment(Request request){
            var service = new ExchangeService
            {
                Credentials = request.token,
                Url = request.url
            };

            if (request.mailbox != "")
            {
                FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, request.TargetMailbox);
                ItemView itemView = new ItemView(1);
                service.FindItems(SharedMailbox, itemView); //This throws ErrorAccessDenied
            }

            //do other stuff and return data

}

Not sure, what to do to get the itemAttachment for Shared mailbox.

A: EWS is not supported in a shared mailbox, only REST. This might have been missed out in our documentation. We'll update it. To get item attachment via REST, follow "Get MIME content of an Outlook message attached to an Outlook item or group post" in https://learn.microsoft.com/en-us/graph/outlook-get-mime-message


text:
Q: using window.env variables to show/hide React component Is it good idea to show/hide React component using window.env
for example we have feature which we are not ready to release yet,so we are thinking of hiding it using window.env.FEATURE_ENABLED=0 (these vars will be picked by api call to service that serves bundle to browser)
But,I am thinking its risky since user can look at windows.env and set window.env.FEATURE_ENABLED=1 and start seeing the workflow which we intend to hide.
Could anyone please provide their take on this.

A: Yes, it could potentially be risky for the reason you say.
A better approach would be to only include finished features in the production build - unfinished features that are still in testing should not be sent to the client. For such features, have a separate build. Host it:

*

*On a local dev server (usually one running on the developer's personal machine) (great when one is making rapid changes), or

*On a staging server - one that's accessible to all developers, and works similarly to the live site, but isn't the same as the production URL

A staging server is the professional approach when multiple devs need access to it at once. It can take some work at first to integrate it into your build process, but it's worth it for larger projects.


text:
Q: "{:02x}" can't results pairwise hex format for 239557639   >>> "{:02x}".format(13)
     '0d'
  >>> "{:02x}".format(239557639)
    'e475c07'

I know this format result the hex in pair wise. It also works for another integer but not works for 239557639
Actually, I want to do following with the output
>>> bytearray.fromhex('e475c07')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: non-hexadecimal number found in fromhex() arg at position 7
>>> bytearray.fromhex('0e475c07')
bytearray(b'\x0eG\\\x07')
>>>

A: In this case, it might be an issue with your hex number formatting. Try {:08x}:
>>> bytearray.fromhex('{:08x}'.format(239557639))
bytearray(b'\x0eG\\\x07')

A: A more generic function to make a printable byte-aligned hex-string for an integer:
def aligned_hex_string(number, align_by=2):
    length = len(format(number, 'x'))
    mod = length % align_by
    return format(number, '0{}x'.format(length + align_by - mod) if mod else 'x')

print(aligned_hex_string(13))
print(aligned_hex_string(255))
print(aligned_hex_string(256))
print(aligned_hex_string(239557639))
print(aligned_hex_string(239557, 4))

Output:
0d
ff
0100
0e475c07
0003a7c5


text:
Q: Alphatbetically sort MYSQL results ascending, but not sorting 'The' as a T? I was wondering if there was a quick way to sort like this?
Imagine the results being book titles or movie titles etc, i dont want such titles that start with the word 'THE' sorting as a T, i want it to sort as the next word on.. For instance "The Hound of the Baskervilles" would sort as "Hound of the Baskervilles, The" so would be returned as an H and not a T.
Thanks.

A: I would go for:
order (case when title like 'The %' then lower(substr(Title, 5))
            else lower(title)
       end)

The lower() is to handle case-sensitive collations, so it is not always necessary.

A: There isn't a sort that I am aware of that would do that... however it is very easy to action by making a new column, ensuring that doesn't start with "the " and sort by that...
SELECT title,TRIM(LEADING 'the ' FROM LOWER(title)) AS title_without_the
FROM books_and_movies
ORDER BY title_without_the


text:
Q: Нужна помощь в js каррирование Всем привет,помогите пожалуйста,Как написать универсальную функцию для любого типа приветствия и передать этой функции имя человека, которого мы хотим поприветствовать.И при этом создать две частичных функции с шаблонами "Hello, {Name}!" и "Hi! I'm {Name}." И это надо сделать через каррирование)
 var userName = 'Вася';

    function showMessage() {
      userName = 'Петя';

      var message = 'Привет, я ' + userName;
      alert( message );
    }
showMessage();
Что то типо такого,только через каррирование

A: Не вполне понятно чего вы хотите, но допустим так:

function hi(name) {
  return function(greet) {
    return `${greet}, ${name}`;
  };
}

console.log(hi('Alex')('Hi'))

Немного ближе к тексту вопроса:

const hi = name => tpl => tpl.replace(/{Name}/g, name);

console.log(hi('Alex')('Hi, {Name}'))
console.log(hi('Alex')('Привет, я {Name}.'))


text:
Q: Rule tables to avoiding nested ifelse statements Idea is to have manageable approach to define rules from some table:
library(data.table)

a <- data.table(rule = c("rule1", "rule2", "rule3"),
                bool = c(T,T,F))

a
#     rule  bool
# 1: rule1  TRUE
# 2: rule2  TRUE
# 3: rule3 FALSE

ifelse(a[rule == "rule1", bool] & a[rule == "rule2", bool] & a[rule == "rule3", bool], 1,
       ifelse(a[rule == "rule1", bool] & a[rule == "rule2", bool], 2,
              ifelse(a[rule == "rule2", bool] & a[rule == "rule3", bool], 3, 4)))
# [1] 2

Obviously this is not very sustainable or readable as I keep adding rules.
What would an alternative to ifelse here?

A: Here's one way to do it, based on comment from @tmfmnk:
library(data.table)
library(dplyr)

a <- data.table(rule = c("rule1", "rule2", "rule3"),
                bool = c(F,T,T))

case_when(a[(bool), identical(rule, c("rule1", "rule2", "rule3"))] ~ 1,
          a[(bool), identical(rule, c("rule1", "rule2"))] ~ 2,
          a[(bool), identical(rule, c("rule2", "rule3"))] ~ 3,
          TRUE ~ 4)

A: This is a very interesting problem, in particular as the conditions do not always involve all rows of a, i.e., rule1, rule2, and rule3.
I have tried to find a general solution which can be expanded for an arbitrary number of conditions as well as for additional rows in a.
The main idea is to replace the conditions in the nested ifelse() or case_when() statements, resp., by a data.table which then can be joined with a somehow:
library(data.table)
b <- fread(
"rule1, rule2, rule3, result
TRUE,  TRUE,  TRUE,  1
TRUE,  TRUE,  NA,    2
NA,    TRUE,  TRUE,  3
NA,    NA,    NA,    4"
)

E.g., the condition in row 2 specifies to return 2 if rule1 and rule2 both are TRUE while the value of rule3 does not matter and can be ignored as a wildcard.
It is important to note that the order of conditions matters: First, the conditions without any wildcard must be checked. Then, the conditions with one wildcard, and so on. Finally, if no other match is found the default value is applied (all wildcards). The default value must always be given in the last row.
So, the most specialised conditions come first and the most general last.
The OP already has given the test data a in long format:

    rule  bool
1: rule1  TRUE
2: rule2  TRUE
3: rule3 FALSE

Therefore, also the conditions b are reshaped to long format:
lb <- melt(b[, id := .I], c("id", "result"), variable.name = "rule", value.name = "bool", na.rm = TRUE)[
  , nr := .N, by = id][]

lb

   id result  rule bool nr
1:  1      1 rule1 TRUE  3
2:  2      2 rule1 TRUE  2
3:  1      1 rule2 TRUE  3
4:  2      2 rule2 TRUE  2
5:  3      3 rule2 TRUE  2
6:  1      1 rule3 TRUE  3
7:  3      3 rule3 TRUE  2

Before reshaping, a row id has been added which indicates the order of conditions. Wildcards are omitted from the long format as they are not needed for the joins. After reshaping, the number of remaining rows nr per id is appended, i.e.,  the number of non-wildcard entries.
Now, the conditions are tested:
answer <- lb[a, on = .(rule, bool), nomatch = 0L][
  , result[nr == .N], by = .(nr, id)][
    order(-nr, id), first(V1)]
if (length(answer) == 0L) answer <- b[id == max(id), result] # default
answer

This happens in four steps:

*

*a and lb are joined (inner join) on rule and bool,

*as the data to join are in long format, incomplete conditions are removed by checking the number of conditions for each id (nr is included in the by = clause just for convenience as it is required in the next step),

*The remaining rows are ordered to pick the first result from the most specialised condition,

*If above operation does not return an answer, the default value is returned.

For the given a, above code returns
answer

[1] 2

More test cases
To verify above code is working correctly, a more thorough test is required
test <- CJ(rule1 = c(TRUE, FALSE), rule2 = c(TRUE, FALSE), rule3 = c(TRUE, FALSE), sorted = FALSE)
test

   rule1 rule2 rule3
1:  TRUE  TRUE  TRUE
2:  TRUE  TRUE FALSE
3:  TRUE FALSE  TRUE
4:  TRUE FALSE FALSE
5: FALSE  TRUE  TRUE
6: FALSE  TRUE FALSE
7: FALSE FALSE  TRUE
8: FALSE FALSE FALSE

Each row represents a version of a which is turned into OP's long format by
a <- melt(test[i], measure.vars = patterns("^rule"), variable.name = "rule", value.name = "bool")

By looping over i, all possible combinations of TRUE/FALSE values can be tested. In addition some intermediate results are printed which help to understand the workings:
library(magrittr) # piping used here to improve readability
test <- CJ(rule1 = c(TRUE, FALSE), rule2 = c(TRUE, FALSE), rule3 = c(TRUE, FALSE), sorted = FALSE)
for (i in seq(nrow(test))) {
  cat("test case", i, "\n")
  a <- melt(test[i], measure.vars = patterns("^rule"), variable.name = "rule", value.name = "bool") %T>%
    print()
  lb[a, on = .(rule, bool), nomatch = 0L][, result[nr == .N], keyby = .(nr, id)] %>%
    unique() %>%
    print() # intermediate result printed for illustration
  answer <- lb[a, on = .(rule, bool), nomatch = 0L][
    , result[nr == .N], by = .(nr, id)][
      order(-nr, id), first(V1)]
  if (length(answer) == 0L) answer <- b[id == max(id), result] # default from b
  cat("answer = ", answer, "\n\n")
}

test case 1
    rule bool
1: rule1 TRUE
2: rule2 TRUE
3: rule3 TRUE
   nr id V1
1:  2  2  2
2:  2  3  3
3:  3  1  1
answer =  1

test case 2
    rule  bool
1: rule1  TRUE
2: rule2  TRUE
3: rule3 FALSE
   nr id V1
1:  2  2  2
answer =  2

test case 3
    rule  bool
1: rule1  TRUE
2: rule2 FALSE
3: rule3  TRUE
Empty data.table (0 rows and 3 cols): nr,id,V1
answer =  4

test case 4
    rule  bool
1: rule1  TRUE
2: rule2 FALSE
3: rule3 FALSE
Empty data.table (0 rows and 3 cols): nr,id,V1
answer =  4

test case 5
    rule  bool
1: rule1 FALSE
2: rule2  TRUE
3: rule3  TRUE
   nr id V1
1:  2  3  3
answer =  3

test case 6
    rule  bool
1: rule1 FALSE
2: rule2  TRUE
3: rule3 FALSE
Empty data.table (0 rows and 3 cols): nr,id,V1
answer =  4

test case 7
    rule  bool
1: rule1 FALSE
2: rule2 FALSE
3: rule3  TRUE
Empty data.table (0 rows and 3 cols): nr,id,V1
answer =  4

test case 8
    rule  bool
1: rule1 FALSE
2: rule2 FALSE
3: rule3 FALSE
Empty data.table (0 rows and 3 cols): nr,id,V1
answer =  4

As can be seen from the answers, the given conditions are all met.
Test case 1 is worth a closer look. Here, the conditions id 1, 2, and 3 may be applicable but condition 1 precedes the other ones as it is the most specialised.
Expanding
This is to show that the solution can be expanded for more rules in a as well as for more conditions in b.
Here is an example with 7 conditions and 4 rule columns.
b4 <- fread(
  "rule1, rule2, rule3, rule4, result
TRUE,  TRUE,  TRUE,  TRUE,  1
TRUE,  TRUE,  NA,    NA,    2
NA,    TRUE,  TRUE,  NA,    3
NA,    FALSE, NA,    NA,    5
TRUE,  FALSE, NA,    NA,    6
FALSE, FALSE, NA, FALSE,    7
NA,    NA,    NA,    NA,    4"
)

The test code has been simplified to allow for a more compact view of the 16 text cases:
lb <- melt(b4[, id := .I], c("id", "result"), variable.name = "rule", value.name = "bool", na.rm = TRUE)[, nr := .N, by = id][]
test <- CJ(rule1 = c(TRUE, FALSE), rule2 = c(TRUE, FALSE), rule3 = c(TRUE, FALSE), rule4 = c(TRUE, FALSE), sorted = FALSE)
sapply(
  seq(nrow(test)),
  function(i) {
    a <- melt(test[i], measure.vars = patterns("^rule"), variable.name = "rule", value.name = "bool")
    answer <- lb[a, on = .(rule, bool), nomatch = 0L][, result[nr == .N], by = .(nr, id)][order(-nr, id), first(V1)]
    if (length(answer) == 0L) answer <- b4[id == max(id), result] # default from b
    return(answer)
  }
) %>%
  cbind(test, .) %>%
  setnames(".", "result") %>%
  print()

It returns the table of test cases, i.e., different cases of a in wide format, with the result appended:

    rule1 rule2 rule3 rule4 result
 1:  TRUE  TRUE  TRUE  TRUE      1
 2:  TRUE  TRUE  TRUE FALSE      2
 3:  TRUE  TRUE FALSE  TRUE      2
 4:  TRUE  TRUE FALSE FALSE      2
 5:  TRUE FALSE  TRUE  TRUE      6
 6:  TRUE FALSE  TRUE FALSE      6
 7:  TRUE FALSE FALSE  TRUE      6
 8:  TRUE FALSE FALSE FALSE      6
 9: FALSE  TRUE  TRUE  TRUE      3
10: FALSE  TRUE  TRUE FALSE      3
11: FALSE  TRUE FALSE  TRUE      4
12: FALSE  TRUE FALSE FALSE      4
13: FALSE FALSE  TRUE  TRUE      5
14: FALSE FALSE  TRUE FALSE      7
15: FALSE FALSE FALSE  TRUE      5
16: FALSE FALSE FALSE FALSE      7


text:
Q: javascript price calculator rounding results from x,1 -> x+1 I've no clue what I'm doing wrong.
I've to code an price calculator but that's not the problem, it's working.
My Problem is, that if for example it calculates the number 4,3 it has to go further with the number 5 and so on.
But in my Calculator is still by the number 4
        <script type="text/javascript">
        function getPrice() {
            var size = Math.floor(document.getElementsByName('tarpaulin-height')[0].value * document.getElementsByName('tarpaulin-width')[0].value);
            var value = 'Preis nur auf Anfrage';
            var price = 154;

            if (size <= 20) {
                if (size > 4) {
                    if (size > 19) {
                        size = 20;
                    }
                    else if (size > 18) {
                        size = 19;
                    }
                    else if (size > 17) {
                        size = 18;
                    }
                    else if (size > 16) {
                        size = 17;
                    }
                    else if (size > 15) {
                        size = 16;
                    }
                    else if (size > 14) {
                        size = 15;
                    }
                    else if (size > 13) {
                        size = 14;
                    }
                    else if (size > 12) {
                        size = 13;
                    }
                    else if (size > 11) {
                        size = 12;
                    }
                    else if (size > 10) {
                        size = 11;
                    }
                    else if (size > 9) {
                        size = 10;
                    }
                    else if (size > 8) {
                        size = 9;
                    }
                    else if (size > 7) {
                        size = 8;
                    }
                    else if (size > 6) {
                        size = 7;
                    }
                    else if (size > 5) {
                        size = 6;
                    }
                    else if (size > 4) {
                        size = 5;
                    }
                    price += (size - 4) * 7.9;
                }

                value = price.toFixed(2).replace('.', ',') + ' €';
            }

            document.getElementsByName('price')[0].value = value;
            console.log(size)
        }
    </script>

thank you!


text:
Q: how to show the line at the time of tableview edit? I have a problem, how i can show the line between check mark and move at the time of  tableview edit. like same as in below image.

explain the process or else if possible please send me to example code.
Thanks in advance.

A: Look at this :
Declare BOOL checkMark; in .h
check its value.
// This all code in Cell For Row At IndexPath :

for (UIView *ObView in [cell.contentView subviews])

{

    [ObView removeFromSuperview];
}

if(checkMark == YES)  // you can check here by imdexPath.row.

{
     UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(10,5,150,30)];
    lbl.text = @"";
    [cell.contentView addSubview:lbl];

    UIImageView *CheckImage = [[UIImageView alloc]initWithFrame:CGRectMake(160,5,20,20)];
    CheckImage.image = [UIImage imageNamed:@""];
    [cell.contentView addSubview:CheckImage];

    UIImageView *BarImage = [[UIImageView alloc]initWithFrame:CGRectMake(185,5,0.5,30)];
    BarImage.image = [UIImage imageNamed:@""];
    [cell.contentView addSubview:BarImage];

    UIImageView *tblImage = [[UIImageView alloc]initWithFrame:CGRectMake(160,5,20,20)];
    tblImage.image = [UIImage imageNamed:@""];
    [cell.contentView addSubview:tblImage];
}
else
{
    UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(10,5,150,30)];
    lbl.text = @"";
    [cell.contentView addSubview:lbl];

    UIImageView *tblImage = [[UIImageView alloc]initWithFrame:CGRectMake(160,5,20,20)];
    tblImage.image = [UIImage imageNamed:@""];
    [cell.contentView addSubview:tblImage];
}

Note: frames are temporary.

A: SO you basically have a tableView and you want to add that image "|" in your tableViewCell  when you are editing.
I would assume you already have editingEnabled for your tableView, and you will need to implement
- (void)setEditing:(BOOL)editing animated:(BOOL)animate

  {

   if (editing) {
             // Configure self.tableView and individual cells and add the "|" as a subView.
             // It will all be tricky, and you should be able to logically place the vertical bar
             // But whatever you want to be in your EDIT mode, you will have to configure it here.
    } else {
          // Re-configure and implement the 'correct' cells back to normal tableView
    }

 }

A: Create a UIView with 1px as width and grey as backgroundColor, and add this to the right of check mark should be fine.

A: If you Edit option is an image then you can do the code like below to show a line.
Steps
1] First import QuartzCore/QuartzCore.h
2] set border width and border color property of your Edit image.
[editImageView.layer setBorderWidth:2.0];

[editImageView.layer setBorderColor:[[UIColor grayColor] CGColor]];

//If you putting a button for edit then also you can set the same. Just replace the editImageView with your editButton

Hope you get exact you want!:)

A: Take uiimageview in table cell and set its width to 1. Set height according to your tablename.cell.height.
It will definitely solve your problem

A: You can customize your tableview cell.Just add the subviews at the time of cell creation and put it hidden untill click on edit button.


text:
Q: How do I view Windows 8 calculator shortcut keys? Basically the subject says it all. Viewing help, doesn't help (ironically) since it shows just some Calculator: Frequently asked questions.

A: It's weird that this isn't in the help file, you're right. http://windows.microsoft.com/en-US/windows7/Keyboard-shortcuts has a very extensive list of shortcuts for the calculator (as well as other things).
Alt+1           Switch to Standard mode
Alt+2           Switch to Scientific mode
Alt+3           Switch to Programmer mode
Alt+4           Switch to Statistics mode
Ctrl+E          Open date calculations
Ctrl+H          Turn calculation history on or off
Ctrl+U          Open unit conversion
Alt+C           Calculate or solve date calculations and worksheets
F1              Open Calculator Help
Ctrl+Q          Press the M- button
Ctrl+P          Press the M+ button
Ctrl+M          Press the MS button
Ctrl+R          Press the MR button
Ctrl+L          Press the MC button
%               Press the % button
F9              Press the +/– button
/               Press the / button
*               Press the * button
+               Press the + button
-               Press the – button
R               Press the 1/× button
@               Press the square root button
0-9             Press the number buttons (0-9)
=               Press the = button
.               Press the . (decimal point) button
Backspace       Press the backspace button
Esc             Press the C button
Del             Press the CE button
Ctrl+Shift+D    Clear the calculation history
F2              Edit the calculation history
Up Arrow key    Navigate up in the calculation history
Down Arrow key  Navigate down in the calculation history
Esc             Cancel editing the calculation history
Enter           Recalculate the calculation history after editing
F3              Select Degrees in Scientific mode
F4              Select Radians in Scientific mode
F5              Select Grads in Scientific mode
I               Press the Inv button in Scientific mode
D               Press the Mod button in Scientific mode
Ctrl+S          Press the sinh button in Scientific mode
Ctrl+O          Press the cosh button in Scientific mode
Ctrl+T          Press the tanh button in Scientific mode
(               Press the ( button in Scientific mode
)               Press the ) button in Scientific mode
N               Press the ln button in Scientific mode
;               Press the Int button in Scientific mode
S               Press the sin button in Scientific mode
O               Press the cos button in Scientific mode
T               Press the tan button in Scientific mode
M               Press the dms button in Scientific mode
P               Press the pi button in Scientific mode
V               Press the F-E button in Scientific mode
X               Press the Exp button in Scientific mode
Q               Press the x^2 button in Scientific mode
Y               Press the x^y button in Scientific mode
#               Press the x^3 button in Scientific mode
L               Press the log button in Scientific mode
!               Press the n! button in Scientific mode
Ctrl+Y          Press the y√x button in Scientific mode
Ctrl+B          Press the 3√x button in Scientific mode
Ctrl+G          Press the 10x button in Scientific mode
F5              Select Hex in Programmer mode
F6              Select Dec in Programmer mode
F7              Select Oct in Programmer mode
F8              Select Bin in Programmer mode
F12             Select Qword in Programmer mode
F2              Select Dword in Programmer mode
F3              Select Word in Programmer mode
F4              Select Byte in Programmer mode
K               Press the RoR button in Programmer mode
J               Press the RoL button in Programmer mode
<               Press the Lsh button in Programmer mode
>               Press the Rsh button in Programmer mode
%               Press the Mod button in Programmer mode
(               Press the ( button in Programmer mode
)               Press the ) button in Programmer mode
|               Press the Or button in Programmer mode
^               Press the Xor button in Programmer mode
~               Press the Not button in Programmer mode
&               Press the And button in Programmer mode
A-F             Press the A-F buttons in Programmer mode
Spacebar        Toggles the bit value in Programmer mode
A               Press the Average button in Statistics mode
Ctrl+A          Press the Average Sq button in Statistics mode
S               Press the Sum button in Statistics mode
Ctrl+S          Press the Sum Sq button in Statistics mode
T               Press the S.D. button in Statistics mode
Ctrl+T          Press the Inv S.D. button in Statistics mode
D               Press the CAD button in Statistics mode


text:
Q: Avoiding a rebuild if none of the dependencies have changed, but the output file has I have a complicated setup where I generate a Vivado project file, and then run Vivado's synthesis tool to consume said project file and produce a bitfile. During this last step, Vivado updates some fields in the project file.
Below is a self-contained model of the situation:
import Development.Shake
import Development.Shake.FilePath
import Data.Time.Clock
import Control.Concurrent

outDir = "_build"

vivadoXPR :: IO ()
vivadoXPR = do
    putStrLn "vivadoXPR"
    threadDelay $ 1 * 1000 * 1000
    writeFile (outDir </> "xpr") "xpr"

vivadoBitfile :: IO ()
vivadoBitfile = do
    putStrLn "vivadoBitfile"
    threadDelay $ 1 * 1000 * 1000
    time <- getCurrentTime
    writeFile (outDir </> "bitfile") (show time)
    writeFile (outDir </> "xpr") (show time)

main = shakeArgs shakeOptions{ shakeFiles = outDir {-, shakeChange = ChangeModtimeAndDigestInput -} } $ do
    outDir </> "manifest" %> \out -> do
        alwaysRerun
        writeFileChanged out "manifest"

    outDir </> "tcl" %> \out -> do
        need [outDir </> "manifest"]
        writeFileChanged out "tcl"

    outDir </> "xpr" %> \out -> do
        need [outDir </> "tcl"]
        liftIO vivadoXPR

    outDir </> "bitfile" %> \out -> do
        need [outDir </> "xpr"]
        liftIO vivadoBitfile

What I would like to avoid is re-building xpr after a full build, since doing that invalidates all of Vivado's internal state, triggering a full re-synthesis. Note that none of xpr's dependencies change.
Building _build/bitfile twice with --trace shows the following:
$ rm -rf _build && \
  stack exec -- shake --trace --trace _build/bitfile && \
  stack exec -- shake --trace --trace _build/bitfile
% Starting run
% Number of actions = 1
% Number of builtin rules = 9 [FilesQ,DoesDirectoryExistQ,GetDirectoryContentsQ,AlwaysRerunQ,GetDirectoryDirsQ,DoesFileExistQ,GetDirectoryFilesQ,GetEnvQ,FileQ]
% Number of user rule types = 1
% Number of user rules = 4
% Before usingLockFile on _build/.shake.lock
% After usingLockFile
% Missing -> Running, _build/bitfile
# _build/bitfile
% Missing -> Running, _build/xpr
# _build/xpr
% Missing -> Running, _build/tcl
# _build/tcl
% Missing -> Running, _build/manifest
# _build/manifest
% Missing -> Running, alwaysRerun
% Running -> Ready, alwaysRerun
    = ((),"") (changed)
% Running -> Ready, _build/manifest
    = ((Just File {mod=0x540BBC70,size=0x8,digest=NEQ},"")) (changed)
% Running -> Ready, _build/tcl
    = ((Just File {mod=0x540BBC70,size=0x3,digest=NEQ},"")) (changed)
vivadoXPR
% Running -> Ready, _build/xpr
    = ((Just File {mod=0x178FA5A0,size=0x3,digest=NEQ},"")) (changed)
vivadoBitfile
% Running -> Ready, _build/bitfile
    = ((Just File {mod=0xECA7F588,size=0x21,digest=NEQ},"")) (changed)
Build completed in 2.01s

% Starting run
% Number of actions = 1
% Number of builtin rules = 9 [FilesQ,DoesDirectoryExistQ,GetDirectoryContentsQ,AlwaysRerunQ,GetDirectoryDirsQ,DoesFileExistQ,GetDirectoryFilesQ,GetEnvQ,FileQ]
% Number of user rule types = 1
% Number of user rules = 4
% Before usingLockFile on _build/.shake.lock
% After usingLockFile
% Chunk 0 [len 34] 01000100000000000000040000000100000001000000010000000000000000000000 Id 1 = (StepKey (),Loaded (Result {result = "\SOH\NUL\NUL\NUL", built = Step 1, changed = Step 1, depends = [], execution = 0.0, traces = []}))
% Chunk 1 [len 30] 0a000600000000000000000000000100000001000000cd02cc3700000000 Id 6 = (alwaysRerun,Loaded (Result {result = "", built = Step 1, changed = Step 1, depends = [], execution = 2.432e-5, traces = []}))
% Chunk 2 [len 73] 0800050000000f0000005f6275696c642f6d616e696665737414000000000000000000000072bc0b540a000000010000000100000001000000d6ea4439080000000400000006000000 Id 5 = (_build/manifest,Loaded (Result {result = "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NULr\188\vT\n\NUL\NUL\NUL\SOH\NUL\NUL\NUL", built = Step 1, changed = Step 1, depends = [[Id 6]], execution = 1.87795e-4, traces = []}))
% Chunk 3 [len 68] 0800040000000a0000005f6275696c642f74636c14000000000000000000000072bc0b5405000000010000000100000001000000b1ef8d39080000000400000005000000 Id 4 = (_build/tcl,Loaded (Result {result = "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NULr\188\vT\ENQ\NUL\NUL\NUL\SOH\NUL\NUL\NUL", built = Step 1, changed = Step 1, depends = [[Id 5]], execution = 2.70722e-4, traces = []}))
% Chunk 4 [len 68] 0800030000000a0000005f6275696c642f787072140000000000000000000000a2a58f17050000000100000001000000010000002c32803f080000000400000004000000 Id 3 = (_build/xpr,Loaded (Result {result = "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\162\165\143\ETB\ENQ\NUL\NUL\NUL\SOH\NUL\NUL\NUL", built = Step 1, changed = Step 1, depends = [[Id 4]], execution = 1.0015311, traces = []}))
% Chunk 5 [len 72] 0800020000000e0000005f6275696c642f62697466696c651400000000000000000000008af5a7ec23000000010000000100000001000000263a803f080000000400000003000000 Id 2 = (_build/bitfile,Loaded (Result {result = "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\138\245\167\236#\NUL\NUL\NUL\SOH\NUL\NUL\NUL", built = Step 1, changed = Step 1, depends = [[Id 3]], execution = 1.0017745, traces = []}))
% Chunk 6 [len 50] 0000070000000000000000000000010000000100000000000000080000000400000002000000080000001e4500401e450040 Id 7 = (Root,Loaded (Result {result = "", built = Step 1, changed = Step 1, depends = [[Id 2]], execution = 0.0, traces = [Trace {traceMessage = "", traceStart = 2.0042186, traceEnd = 2.0042186}]}))
% Read 7 chunks, plus 0 slop
% Found at most 8 distinct entries out of 7
% Loaded -> Running, _build/bitfile
% Loaded -> Running, _build/xpr
% Loaded -> Running, _build/tcl
% Loaded -> Running, _build/manifest
% Loaded -> Running, alwaysRerun
% Running -> Ready, alwaysRerun
    = ((),"") (changed)
# _build/manifest
% Running -> Ready, _build/manifest
    = ((Just File {mod=0x540BBC70,size=0x8,digest=NEQ},"")) (unchanged)
% Running -> Ready, _build/tcl
    = ((Just File {mod=0x540BBC70,size=0x3,digest=NEQ},"")) (changed)
# _build/xpr
vivadoXPR
% Running -> Ready, _build/xpr
    = ((Just File {mod=0xDC183BD8,size=0x3,digest=NEQ},"")) (changed)
# _build/bitfile
vivadoBitfile
% Running -> Ready, _build/bitfile
    = ((Just File {mod=0x9F9C2120,size=0x21,digest=NEQ},"")) (changed)
Build completed in 2.01s

How can avoid vivadoXPR running on the second shake run?


text:
Q: Run browser commands concurrently in Protractor Is there any way to write a Protractor test in such a way that would allow simulation of many users at once? E.g. simulate 100 users all making a checkout at the same time, or 100 users all logging in at the same time. The purpose being to detect any possible race conditions or locking issues.
Protractor appears to be designed so that everything runs in sync, even across multiple browser instances (i.e. forks). Is there any way to accomplish what I'm doing in Protractor, or am I out of luck?
Note that I'm not referring to running tests concurrently (be that running tests under both Firefox and Chrome or spreading describes over multiple instances to speed it up), rather the ability to spawn new "threads" inside one test case to execute commands in parallel.


text:
Q: React Native can't build APK file I have successfully build react-native app folder according to this http://facebook.github.io/react-native/docs/getting-started documentation
But, when I am running react-native run-android in cmd, it is showing me this -
info Starting JS server...
info Installing the app...
> Task :app:mergeDebugResources FAILED
9 actionable tasks: 8 executed, 1 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Specified AAPT2 executable does not exist: C:\Users\DE\.gradle\caches\transforms-2\files-2.1\e3571e1615ccf7c32524cbf1a8ed0eb8\aapt2-3.4.1-5326820-windows\aapt2.exe

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 55s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Specified AAPT2 executable does not exist: C:\Users\DE\.gradle\caches\transforms-2\files-2.1\e3571e1615ccf7c32524cbf1a8ed0eb8\aapt2-3.4.1-5326820-windows\aapt2.exe

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 55s

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (C:\Users\DE\AwesomeApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:75:39)
    at buildAndRun (C:\Users\DE\AwesomeApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:137:41)
    at C:\Users\DE\AwesomeApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:103:12
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async Command.handleAction (C:\Users\DE\AwesomeApp\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)```

A: I have resolved this problem by deleting the cache of .gradle folder. The path is C:\Users\DE\.gradle\caches . After that, apps are building.

A: I had the same problem. I tried going to the application directory the second one with cmd and running "react-native start". This solved my problem.


text:
Q: making a container class for boost::ptr_vector i am trying to make a container class for boost::ptr_vector and im just having a bit of trouble getting the iterator to work..
here is one of the member functions im trying to implement:
//data is of type boost::ptr_vector<T>
//Date is a custom date class that i made with > operator overloaded

template <class T>
void P_VContainer<T>::addElementByDate(T* item)
{
    boost::ptr_vector<T>::iterator it;

    for(it = data.begin(); it < data.end(); it++)
    {
        T temp = *it;
        Date = *lhs = item->getDate();
        Date = *rhs = item.getDate();

        if(*lhs > *rhs)
        {
            data.insert(it, item);
            return;
        }
    }
    data.insert(it, item);
}

the error i am getting is:
p_vcontainer.cpp: In member function 'void P_VContainer<T>::addElementByDate(T*)':
p_vcontainer.cpp:52:2: error: need 'typename' before 'boost::ptr_vector<T>::iterator' because 'boost::ptr_vector<T>' is a dependent scope
p_vcontainer.cpp:52:33: error: expected ';' before 'it'
p_vcontainer.cpp:54:7: error: 'it' was not declared in this scope

any ideas of how to fix this?

A: Captain Obvious to the rescue!

need 'typename' before 'boost::ptr_vector::iterator'

write typename boost::ptr_vector<T>::iterator it;


text:
Q: Why my slider for 'pure-react-carousel' is gettining disoriented when page is refreshed? I have a question, and it is really making my nights sleepless. I am making a group of cards to be mapped inside of the grid container , and mapping each card into grid item which takes 3 column space (i am using Material-Ui).
Everything is working fine, when I click on a tab say 'contacts' and switches back to the tab which is holding my slides (and therefore cards inside of it), the cards are visible okay, and slider is also working. (I am having horzontal orientation of the slides.). But, when on refreshing the current page (the one which is holding my slides inside of CarouselProvider), the slides, and thus the <CarouselProvider > gets broken, and displaying the overlapped cards.
it is really getting on my nerve, and i am out of solutions.
How to avoid this behaviour of "pure-react-carousel", is this some sort of bug? in it?, or I have to tweak some changes into the "CarouselProvider", or "Slider", or "Slides", to get it working correct?
Suggestions are needed. Thank you in advance


text:
Q: Show that if N is relatively prime to 10, then there exists a multiple that consists only of 1s. show that if $N$
is relatively prime to 10, then there exists a multiple that consists only of 1s.
The multiple can be expressed as :
$$\frac{(10^a-1)}{9}$$
thus if $\gcd(N,3)$ is not 3, using the totient function it would be easy to find $a$ such that this is $0\bmod N$
If $\gcd(N,3)$ is 3, then we would need to find $10^a-1$ divisible by $3N$ which is also possible.
from https://artofproblemsolving.com/articles/files/SatoNT.pdf. It is said that:
"If N is relatively
prime to 10, then we may divide out all powers of 10, to obtain an integer of
the form 111...1 that remains divisible by N."
which I'm not sure I follow. I would want to know what this means since the answer seems concise


text:
Q: Passing a cv2 frame from view to template Basically, my django app needs to create an image in a view, and pass that to a template. This is easy for a string, but I can't find a way to do it with an image. I have read many stack overflow threads but none quite like mine, which is surprising.
I was trying variations of this as my view:
views.py:
def index(request):
  while (True):

    #video_capture = cv2.VideoCapture(0)
    #ret, frame = video_capture.read()

    img = "D:/Desktop/Tap/bsnsFaces.jpg"
    frame = cv2.imread(img)
    facesNumber ="Found {0} faces!".format(len(faces))

    return render(request, 'result.html', {'p': facesNumber}, {'img': frame})`

With the {'img':frame} part at the end not being anywhere close to right. I tried a few things that I found on SO but nothing worked so far. I know that the image is static but eventually I want this to be a frame captured from a webcam so I can't solve this by using models (or can I?).
Thanks in advance for any advice!
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Face detection with Django</title>

{{ p }}

A: I would suggest base64 encoding the frame and passing that string. That way you can pass the dynamically generated image from the views to the result.html to render. You can then display the base64 image in the result.html.
views.py
import cv2
import base64

def index(request):
  #while (True): #Note: This loop is pointless, it will break when you return.

    #video_capture = cv2.VideoCapture(0)
    #ret, frame = video_capture.read()

    img = "D:/Desktop/Tap/bsnsFaces.jpg"
    frame = cv2.imread(img)
    ret, frame_buff = cv2.imencode('.jpg', frame) #could be png, update html as well
    frame_b64 = base64.b64encode(frame_buff)
    facesNumber ="Found {0} faces!".format(len(faces))

    # Note this was fixed to be one dict with the context variables
    return render(request, 'result.html', {'p': facesNumber, 'img': frame_b64})

result.html

Just a note based on your while loop, if you want to be updating the page constantly from the webcam, this should be done clientside. Otherwise you will need to be constantly refreshing the page to see image updates. The client (result.html) can poll the server with AJAX for image updates, and refresh itself without actually reloading the entire result.html page.


text:
Q: Is $F=\{g\in\mathcal C^1([0,1])\mid \exists x\in [0,1]: (f(x),f'(x))=(0,0)\}$ open or close in $\mathcal C^1([0,1])$? Consider $(\mathcal C^1([0,1]),\|\cdot \|)$ where $$\|f  \|=\|f\|_\infty +\|f'\|_\infty $$ where $\|g\|_\infty :=\sup_{[0,1]}|g|.$
Let $$F=\{g\in \mathcal C^1([0,1])\mid \exists x\in [0,1], (f(x),f'(x))=(0,0)\}.$$
1) Is $F$ open or close in $\mathcal C^1([0,1])$ ?
2) Find the interior or $F$.
I'm sorry, but I have no idea how to solve this exercice. I really have problem to visualize such spaces. I know that $$B_\varepsilon(f)=\{g\in\mathcal C^1([0,1])\mid \|f-g\|<\varepsilon\},$$
So for 2) I have to finde all $f\in\mathcal C^1([0,1])$ s.t. there is an $\varepsilon>0$ s.t. $B_\varepsilon(f)\subset D$, but how ?
For 1) I have no idea.


text:
Q: Could not access webservice through client from weblogic server I am trying to access a webservice from my unix machine and the web services are hosted in an apache server. I followed the post javax.xml.ws.WebServiceException: Failed to access the WSDL. Response: '401: Unauthorized' since i faced the same problem of Response with error code 401. But still my issue is not resolved. I tried the solution given by Paulius Matulionis in that post. But, still stuck with establishing the service.
Additional info:
1. Using Weblogic server at client end.
2. Also we are using IBM JVM.
Thanks in advance
Amalraj


text:
Q: Can not make Tensorflow work with pypy3 and conda. Invalid ELF I want to try tensorflow inside pypy.  I tried a few days and no luck.  Following is the detail.
I am using UBuntu 18.04.
I install conda.
I install pypy through conda,  conda install -c conda-forge pypy3.6
I got No matching distribution found for tensorflow if I tried pypy3 -m pip install tensorflow
I got invalid ELF header when I run my python code if I tried pypy3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.14.0-py3-none-any.whl
I even try to install tensorflow I build but I got not a supported wheel on this platform.  The Tensorflow I build can be installed in python3.6 just not in pypy3.
I think the problem is python version different but I don't know hwo to fix it.  I notice the python version is slightly different between my python and pypy3.
I don't know how to make those two python 3.6.9 identical.  Build pypy from source myself?
(pypy3) joseph@joseph-Ubuntu:~/scripts$ python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0] on linux
(pypy3) joseph@joseph-Ubuntu:~/scripts$ pypy3
Python 3.6.9 (5da45ced70e515f94686be0df47c59abd1348ebc, Oct 18 2019, 07:48:38)
[PyPy 7.2.0 with GCC 7.3.0] on linux
Or is there is other way to solve this problem?
Or Not to use conda?
Thanks
Joseph

A: You have to somehow get tensorflow compiled for PyPy, you cannot reuse one for CPython. So far there is no binary available, and I would not advise anyone to try to recompile tensorflow, it is quite hard. So I think for now sticking with CPython for tensorflow is the best course of action.


text:
Q: confusion matrix with threshold python How to print the confusion matrix for a logistic regression if change the value of threshold between [0.5,0.6,0.9] once 0.5 and once 0.6 and so one
from sklearn.linear_model import LogisticRegression
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

X = [[0.7,0.2],[0.9,0.4]]
y = [1,-1]

model = LogisticRegression()
model = model.fit(X,y)

threshold = [0.5,0.6,0.9]

CM = confusion_matrix(y_true, y_pred)

TN = CM[0][0]
FN = CM[1][0]
TP = CM[1][1]
FP = CM[0][1]

A: Let try this!
for i in threshold:
   y_predicted = model.predict_proba(X)[:1] > i
   print(confusion_matrix(y, y_predicted))

predict_proba() returns a numpy array of two columns. The first column is the probability that target=0 and the second column is the probability that target=1. That is why we add [:,1] after predict_proba() in order to get the probabilities of target=1

A: I think an easy approach in pseudo code (based a bit on python) would be:
1 - Predict a set of known value (X) y_prob = model.predict_proba(X) so you will get the probability per each input in X.
2 - Then for each threshold calculate the output. i.e. If y_prob > threshold = 1 else 0
3 - Now get the confussion matrix of each vector obtained.
If you need a deeper explanation on any point let me know!

A: def predict_y_from_treshold(model,X,treshold):
    return np.array(list(map(lambda x : 1 if x > treshold else 0,model.predict_proba(X)[:,1])))


text:
Q: Not able to login into GCE instance via SSH while gcloud compute works perfectly In one of my Google Compute engine instance, I am able to login using the gcloud command:
gcloud compute --project "My-Project" ssh --zone "zone-name" "instance-name"
But I am not able to ssh into it using the ssh button on browser or from command prompt. Below is the serial version output

Sep  7 02:00:35 my-gce-instance sshd[25823]: Invalid user admin from 291.107.144.97
Sep  7 02:00:35 my-gce-instance sshd[25823]: input_userauth_request: invalid user admin [preauth]
Sep  7 02:00:37 my-gce-instance sshd[25823]: Disconnecting: Too many authentication failures for admin [preauth]
Sep  7 02:13:46 my-gce-instance sshd[26019]: Invalid user admin from 198.180.78.102
Sep  7 02:13:46 my-gce-instance sshd[26019]: input_userauth_request: invalid user admin [preauth]
Sep  7 02:13:48 my-gce-instance sshd[26019]: Disconnecting: Too many authentication failures for admin [preauth]
Sep  7 02:40:21 my-gce-instance sshd[26426]: Accepted publickey for gsc from 184.145.49.97 port 56371 ssh2: RSA c6:71:77:6d:56:e2:fb:b9:90:7d:df:bb:76:51:12:9a
Sep  7 02:40:21 my-gce-instance sshd[26428]: Received disconnect from 184.145.49.97: 11: disconnected by user
Sep  7 02:47:00 my-gce-instance sshd[26521]: Invalid user xml2epay from 193.107.155.192
Sep  7 02:47:00 my-gce-instance sshd[26521]: input_userauth_request: invalid user xml2epay [preauth]
Sep  7 02:47:01 my-gce-instance sshd[26521]: Connection closed by 193.107.155.192 [preauth]
Sep  7 02:49:54 my-gce-instance sshd[26567]: Connection closed by 96.58.125.162 [preauth]
Sep  7 02:56:36 my-gce-instance sshd[26673]: Accepted publickey for xxxx from 45.174.197.98 port 57017 ssh2: RSA 89:3a:9c:6e:2a:e3:bb:83:bb:da:4b:ac:c9:b5:c8:64
Sep  7 03:01:21 my-gce-instance sshd[26769]: Invalid user admin from 92.100.179.159
Sep  7 03:01:21 my-gce-instance sshd[26769]: input_userauth_request: invalid user admin [preauth]
Sep  7 03:01:22 my-gce-instance sshd[26770]: Invalid user admin from 92.100.179.159
Sep  7 03:01:22 my-gce-instance sshd[26770]: input_userauth_request: invalid user admin [preauth]
Sep  7 03:01:25 my-gce-instance sshd[26769]: Disconnecting: Too many authentication failures for admin [preauth]
Sep  7 03:01:27 my-gce-instance sshd[26770]: Disconnecting: Too many authentication failures for admin [preauth]
Sep  7 03:01:37 my-gce-instance sshd[26773]: Disconnecting: Too many authentication failures for root [preauth]
Sep  7 03:01:46 my-gce-instance sshd[26775]: Disconnecting: Too many authentication failures for root [preauth]
Sep  7 03:01:51 my-gce-instance sshd[26777]: Invalid user usuario from 92.100.179.159
Sep  7 03:01:51 my-gce-instance sshd[26777]: input_userauth_request: invalid user usuario [preauth]
Sep  7 03:02:01 my-gce-instance sshd[26777]: Disconnecting: Too many authentication failures for usuario [preauth]
Sep  7 03:04:35 my-gce-instance sshd[26838]: Connection closed by 78.195.41.87 [preauth]
Sep  7 03:04:38 my-gce-instance sshd[26840]: Connection closed by 143.188.93.184 [preauth]
Sep  7 03:04:42 my-gce-instance sshd[26842]: Connection closed by 143.188.93.180 [preauth]
Sep  7 03:04:45 my-gce-instance sshd[26844]: Connection closed by 143.188.93.98 [preauth]

A: *

*Take a snapshot for backup purposes in case something goes wrong
you can recover your VM instance.

*SSH into the VM instance via gcloud command.

*Run the command below to remove the older version of GCE daemons:
sudo apt-get purge --auto-remove gce-daemon gce-startup-scripts gce-cloud-config**

*Then run this command to install the new GCE daemons:
sudo apt-get install --reinstall gce-compute-image-packages python-google-compute-engine**

*Reboot the instance, and try to SSH via Web browser.


text:
Q: Windows 11 Keeps Changing Documents & Pictures folders to OneDrive Folder I already force changed the location, but once again it swapped it back to the onedrive folder. Basically instead of being folders under the user, they are put into subfolders inside a onedrive folder.
Any way I can completely and permanently get rid of any onedrive bs from my computer?
For clarity, I am trying to:

*

*Change my documents/pictures location to be the default (C/users/user/xxxx) instead of (C/users/user/onedrive/xxxx)

*Stop windows from changing it back

*Delete anything else related to onedrive that may be related to this

A: I had to change the registry.
Run regedit
Go here:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

edit this stuff:
Desktop - %USERPROFILE%\Desktop
Favorites - %USERPROFILE%\Favorites
Music - %USERPROFILE%\Music
Pictures - %USERPROFILE%\Pictures
Videos - %USERPROFILE%\Videos
Documents - %USERPROFILE%\Documents
Downloads - %USERPROFILE%\Downloads


text:
Q: Modify Javascript Array Element If I have an array element of the following format (with one whitespace character between each pair of letters, ignore the quote marks which are not part of the actual element):
arr[1] = "AB CD EF GH"

How can I edit this to be of the following format (with each pair of letters surrounded by * and two spaces between each pair of letters):
arr[1] = "*AB*  *CD*  *EF*  *GH*"

A: Use split, map, then join:
arr[1] = arr[1].split(' ').map(function (el) {
  return '*' + el + '*';
}).join('  ');

DEMO

A: Replace the single space:
arr[1] = "*" + arr[1].replace(/ /g, "*  *") + "*";

alert(arr[1]);


text:
Q: AppStore distribution certificate/keys on smartcard? Has anyone done any investigation as to whether the Apple AppStore distribution private key/certificate can be stored on a smartcard?  I work for a large company that is about to release several iOS applications and we're concerned about the best way to protect our production distribution keys and certificates.  Is it possible to generate and store these keys/certs on a smartcard and then use that smartcard when signing the app for distribution?  Are their particular smartcard vendors that work well on OSX?

A: You should be able to code sign any app given that your certificate and its matching keys are available in your Keychain.
SmartCard Services looks like the tool you need for the case these assets (cert+keys) are stored on a smart card.

A: An Enterprise Program will let you make distribution builds that will run on all devices without needed to resign.
Sending your key & certificate out is unadvisable, not only does it mean that anyone who gets hold of them can build apps in your name; but it will also become problematic when you have to update the certificate.
Though in direct answer to your question - yes you can store them anywhere you want. They are just files.

A: EDIT:
After your comment, further investigations, and from memory, there are two elements/files to sign an app:

*

*Keychain: The Developer/Distribution Certificate (the one created by you to request a distribution certificate from apple)

*MobileProvision: The Provisioning profile (the certificate provided by Apple, which is invalid without the previous keychain certificate #1 and used by Xcode to sign an app)

These two files are at separate places:

*

*The developer certificate is in the keychain, according to wikipedia by default in ~/Library/Keychains (session) and /Library/Keychains (system), and after checking a bit with "keychain" utility app, it appears that you can register/create any ".keychain" file at any path. So I guess you can add your certificates from an external .keychain file using a smartcard, w/o copying them to your mac (to be verified, would be surprising/strange, but maybe these are cloned to some cache or whatever). I haven't tested this, but then that would makes sense that Xcode use "Keychain services", making these underlying .keychain files transparent. So Xcode should just find  "automagically" the certificate from an external keychain file.

*MobileProvision: ~/Library/MobileDevice/Provisioning Profiles/SOME-UUID.mobileprovision I'm afraid you can't tell Xcode to look to another path.

In both case, I guess you can probably trick the apps (Xcode..)/services(Keychain...) using symlinks... (ln -s ...)
I hope these informations might help you to do the job... Good luck!
Not so off-topic, but I would be curious to know what kind of scenario makes this kind of security legitimate. Once again, only the apple developer admin account has the "god powers"... certificates are pretty much useless w/o that account, unless you are doing ad-hoc/enterprise distribution...
ENDOFEDIT

AFAIK, Apple generates all the certificates = Files.
You can protect these files the way you want, but anyway, to sign an app you will need to copy them on a mac at signing time. (in a particular place, the keychain, where Xcode gets them)
I doubt any "smartcard" or similar solution will be reliable...
What you can do is dedicate one mac to app signing and secure its access (via smartcard, biometrics, just a login/password... or even a locked door!)
Assuming AppStore is your target:
IMHO, being scared of stolen distribution certificates is a bit paranoid and useless.
To submit an app to the AppStore you will need anyway the iTunes account administrator account, the only one that has that power. In other words, a signed package can't be submitted to Apple w/o that account.
So Only that itunes connect admin account/password must really be secured.
(And in worse case I'm pretty sure Apple can block/restitute stolen account)
And with that administrator account, you can cancel any app submission, revoke / regenerate all certificates... (No app is immediatly validated, you have a ~10days approval period to cancel it, with admin notified via email)


text:
Q: LTC4370 load sharing Datasheet LTC4370
Background:  I want to use this chip to combine the power output of two 2.4A USB ports on a USB power bank I have. If this is possible it will output ~25W and w/ my dc-dc converter I should be able to charge my laptop using USB power banks. If possible in the future I may buy 2 chips more to combine 4 USB outputs.
I presume I will be using a design very similar to the typical application on the first page of the datasheet, but with the values listed in the 5V example on page 14. I might need to adjust the resistor on the range pin depending on how close the Vout on the USB ports will be.
Question: page 11 of the datasheet, MOSFET selection, the last paragraph's phrasing confuses me. I can't tell if it wants me to get a Rds(on) value as close to what the equation gives, or if that is a maximum value for Rds(on) and anything below should suffice. The given equation is ΔVIN(SH) = VFR(MAX) – 0.5IL • RDS(ON),
VFR(MAX) is the maximum forward regulation voltage (Vin-OUT)
Vin(sh) is the "sharing capture range"...not sure what that means
what IL is has proven elusive as well... wish I knew what these all were
I could always use a very similar MOSFET to the SUM85N03-06P in the typical application, and ignore the equation altogether but avoiding errors would be cool, and who doesn't like to learn?

A: It means that you need to consider the drop across the mosfet when your considering the voltage that the device can supply.
\$ \frac{I_L}{2}*Rds_{on} = V_{across mosfet}\$
this needs to be lower than 75mV for lower operation. So take your maximum load divide it by two and multiply it by Rdson then make sure its lower than 75mV for optimal performance. That number will also affect your regulated voltage as the mosfet will have a voltage drop across it.


text:
Q: Checking to see what elements in 2 arraylists are the same I'm working on some code to build a wingbox from some the geometry of a wing.  I have an integer arraylist (node) of all the nodes on the wing, and I have an integer arralist (ohnode) of the nodes that I want to trim in order to make my wingbox. How can I compare the 2 arraylists and delete the elements in the node arraylist so that all I'm left with are the nodes that weren't in the ohnode arraylist?
I haven't found many good examples comparing arraylists, most of them were for arrays.  Would code for arrays work for arraylists, like arrays.equal?
Basically, I want to run through through all the nodes on the node arraylist, and if

A: Display common elements from two arraylists
ArrayList a1 = new ArrayList();
ArrayList a2 = new ArrayList();
 a1.add("a");
 a1.add("b");
 a1.add("c");

a2.add("a");
a2.add("b");
a2.add("c");
a2.add("d");
a2.add("e");
    int array1Size = a1.size();
    int array2Size = a2.size();
    if (a1.size() > a2.size()) {
        int k = 0;
        for (int i = 0; i < a2.size(); i++)            {
            if (((String)a1.get(i)).equals((String)a2.get(i)))  {
                System.out.println((String)a2.get(i));
            }
            k = i;
        }
       }
    else {
       int k = 0;
        for (int i = 0; i < a1.size(); i++) {
            if (((String)a1.get(i)).equals((String)a2.get(i))) {
                System.out.println((String)a1.get(i));
            }
            k = i;
        }
     }

then loop through all common elements in 2nd arraylist, and delete it.


text:
Q: For statement not working for every array element? This question is about Android/AndEngine but pertains to Java in general.
I have a for loop for attaching handling rectangles that are in an array. This is my code.
try {
        if ((NPCrectangle.size() > 0) && (NPCbody.size() > 0)) {
            System.out.println("NPCrectangle size is "+NPCrectangle.size());
            for (int i = 0; i < NPCrectangle.size(); i++) {
                System.out.println("For loop ran for NPCrectangle "+i);
                for (int j = 0; j < NPCbody.size(); j++) {
                    NPCrectangle.get(i).setX(NPCbody.get(j).getPosition().x*32);
                    attachChild(NPCrectangle.get(i));
                    System.out.println("RECTANGLE ATTACHED FOR NPC"+i);
                }
            }
        }
    } catch (Exception e) {
        // TODO: handle exception
    }

At
System.out.println("NPCrectangle size is "+NPCrectangle.size());
        for (int i = 0; i < NPCrectangle.size(); i++) {
            System.out.println("For loop ran for NPCrectangle "+i);

I get 'NPCrectangle size is 2', but then I only get 'For loop ran for NPCrectangle 0'. It never does anything with the second element of the array. Why is this?
This is my catch:
04-25 18:45:45.420: W/System.err(2235): java.lang.IllegalStateException: pEntity 'Rectangle' already has a parent: 'GameScene'. New parent: 'GameScene'!
04-25 18:45:45.420: W/System.err(2235):     at org.andengine.entity.Entity.assertEntityHasNoParent(Entity.java:1707)
04-25 18:45:45.420: W/System.err(2235):     at org.andengine.entity.Entity.attachChild(Entity.java:907)

Which is an error when you try to attach the same sprite twice. Suggestions?

A: This loop
for (int j = 0; j < NPCbody.size(); j++) {
                    NPCrectangle.get(i).setX(NPCbody.get(j).getPosition().x*32);
                    attachChild(NPCrectangle.get(i));
                    System.out.println("RECTANGLE ATTACHED FOR NPC"+i);

is run multiple times, depending on NPCbody.size(), but will attach the same rectangle. NPCrectangle.get(i),  each time.  Hence you get the error the second time through the inner loop.


text:
Q: Display date format as DD MM YYYY in active record Codeigniter How would I alter my active record to display my date as DD MM YYYY rather than YYYY MM DD?
Current Display
2016-01-07
Aim Display
07-01-2016
Current
View
<?php echo $row->start_date; ?>

Tried
View
<?php echo $row->DATE_FORMAT(start_date, '%d/%m/%Y'); ?>

Model
class Profiles_model extends CI_Model

    {

        function get_bank()
        {
            $this->db->where('mem_id', $this->session->userdata("id"));
            $query = $this->db->get('bank');
            return $query->result();
        }

    }

A: I always prefer to make a helper function in Codeigniter for date formatting because date is very common to use on many pages.
Codeigniter 3 helper function:
if(!function_exists('dateFormat'))
{
    function dateFormat($format='d-m-Y', $givenDate=null)
    {
        return date($format, strtotime($givenDate));
    }
}

Autoload this helper in your Codeigniter autoload.php and then use it freely anywhere in controller/model/view.
use in view like:
<?= dateFormat('d-m-Y',$info->createdDtm) ?>

A: You can use strtotime() and date() of php as :
$originalDate = $row->start_date;
$newDate = date("d-m-Y", strtotime($originalDate));


text:
Q: Creating a shared library for both C and C++ Say I want to have a small library with some common functionality for TCP sockets. Now for C++ code I want to create classes such as TCPClient, TCPServer, etc. but for C code I want to have just functions and structs.
Is it a common/recommended practice to combine those in the same shared library?

A: You will have problem linking C with a C++ library.
Generate a C library (only functions and structs). Then you can either link it directly within C code, or write a C++ wrapper which declares the wanted Classes and calls C function, wrapped in an extern "C" {} statement.


text:
Q: Why is stationarity in a time series useful? I'm trying to figure out how stationarity can be useful when analysing time series data and I can't find any satisfying explanations online.
I understand that since the mean and variance are constant it helps out a lot for the various models you can apply to the data but at a conceptual level, I have formed an explanation and I would like your opinion on it.
The way I see it, stationarity gives you an overview of the dependence structure of your data, how do the relationships look like. If this structure changes overtime then if you try to forecast your model, you will have a problem since your assumptions are no longer valid. Therefore is you have stationarity, you can be sure that if you find a correlation within the data that you can exploit, then it will not vary with time.
How accurate is this view ?
PS: I know there are a lot of similar questions asked but again I can't find anything that works for me :)


text:
Q: Why this piece of Python code is taking unusually longer time to compute the sum? I like to explore this in terms of Asymptotic Notations: Big(O), Omega and Theta.
Here is a small piece of Python code. And tried running it by giving larger value each time. If you look at the 3rd scenario(image), the code is taking usually longer time to calculate the sum.

I wonder if i can rewrite it sequentially, would there be any difference? How can I optimize this code to take larger values? Thank you

A: You can make the same algorithm a lot faster by using numba:
from numba import jit

@jit
def compute(n):
    x = 0
    for i in range(1, n+1):
        x += 1/i
    return x

print(compute(1000000000))


text:
Q: Preventing certain weights from going to 0 I would like to use a convolutional neural network to study a time series data set. I have experimental measurements taken at three different time intervals. With this I plan to create an input that is $3 \times n \times 1$. The only filter size that I can apply to this that would seem useful is a $3 \times 3$ filter. For a certain reason particular to my experiment, I want to ensure that there is no possibility that the network will learn the filter weights such that any two of the rows are all $0$. In other words, I want to make sure that if the network works well, then it does so by making use of at least two of the time instances that I have measured. How can I ensure that it does this?
One method I was thinking of is along the lines of padding. I can extend the input size to $6 \times n \times 1$ by copying the original input twice. Then, every weight of the filter matrix will at one point be overlaid with an element of the input from each time instance. Would this work? Are there other methods?


text:
Q: Relationship between roots
Suppose we have the equation $x^2 + 2x + 1, x^2 + 3x + 1, \ldots, x^2 + (2 + k) x + 1, k \in \mathbb{N}$, consider all the roots less than $-1$. (see Appendix)
    Is it possible to find the length of any one of the neighboring segments, knowing one of them? For example, if I know the length of a red segment, can I only use the knowledge of the equation and the length of the segment to find the blue segment?

A: Define
$$f_k(x):=x^2+(2+k)x+1$$
for $x<-1$.
When $f_k(x)=0$,
$$
x=\frac{-(2+k)\pm\sqrt{(2+k)^2-4}}{2}
$$
Since $k+2>2$, $$(2+k)^2-4>0$$ so we have two distinct roots. We can show that the case where $x<-1$ is when
$$x=-\frac{(2+k)+\sqrt{(2+k)^2-4}}{2}$$
Define $$r_k:=-\frac{(2+k)+\sqrt{(2+k)^2-4}}{2}$$
Define $$l_k:=r_{k}-r_{k+1}$$
as the lengths between the adjacent roots of $y=f_k$ and $y=f_{k+1}$.
We have
\begin{align}
l_k
&=\frac{(3+k)+\sqrt{(3+k)^2-4}}{2}-\frac{(2+k)+\sqrt{(2+k)^2-4}}{2}\\
&=\frac12\left(1+\sqrt{(3+k)^2-4}-\sqrt{(2+k)^2-4}\right)
\end{align}
which you can then use to calculate back your unknown $k$ from your known $l_k$ to then calculate $l_{k+1}$.


text:
Q: STM32 blinky example does not work Here is a "simplified blinky" example from MikroC meant to toggle the user LED at a rate that is visible to the naked eye:
void main()
{
    GPIO_Clk_Enable(&GPIOA_BASE);
    GPIO_Digital_Output(&GPIOA_BASE, _GPIO_PINMASK_5);
    GPIOA_ODR |= (1<<_GPIO_PIN_5);
    while(1)
    {
      GPIOA_ODR ^= (1<<_GPIO_PIN_5);
      Delay_ms(300);
    }
}

The expected result of this code is that the port A5 pin (LED) will toggle at a 300ms rate.  The microcontroller part is an STM32L476RG on a NUCLEO board.
The actual result is still -- nothing at all.  No blinking.
I have tested the board by loading the hex file from an identical board onto it, restoring the "factory" blinking demo that responds to presses of the user button.  It works.  So the device is fine and the programming process is working.
I have stepped through the code in the debugger and watched GPIOA_ODR register toggle just as intended.
My Scheme, created by using the "Default" button, running the core at 4 MHZ from from the MSI internal oscillator, is as follows:
<?xml version="1.0"?>
<MCU_DEVICE_FLAGS>
  <DEVICE>
    <DEVICE_NAME>STM32L476RG</DEVICE_NAME>
    <SETTINGS>
      <COUNT>32</COUNT>
      <SETTING0>
        <NAME>MSI clock enable</NAME>
        <DESCRIPTION>MSI oscillator ON</DESCRIPTION>
      </SETTING0>
      <SETTING1>
        <NAME>MSI clock PLL enable</NAME>
        <DESCRIPTION>MSI PLL OFF</DESCRIPTION>
      </SETTING1>
      <SETTING2>
        <NAME>MSI clock range selection</NAME>
        <DESCRIPTION>MSI Range is provided in RCC_CSR register</DESCRIPTION>
      </SETTING2>
      <SETTING3>
        <NAME>MSI clock ranges in RCC_CR register</NAME>
        <DESCRIPTION>range 6 around 4MHz</DESCRIPTION>
      </SETTING3>
      <SETTING4>
        <NAME>HSI clock enable</NAME>
        <DESCRIPTION>HSI16 oscillator OFF</DESCRIPTION>
      </SETTING4>
      <SETTING5>
        <NAME>HSI16 always enable for peripheral kernels</NAME>
        <DESCRIPTION>No effect on HSI16 oscillator</DESCRIPTION>
      </SETTING5>
      <SETTING6>
        <NAME>HSI16 automatic start from Stop</NAME>
        <DESCRIPTION>HSI16 oscillator is not enabled by hardware when exiting Stop mode with MSI as wakeup clock</DESCRIPTION>
      </SETTING6>
      <SETTING7>
        <NAME>HSE clock enable</NAME>
        <DESCRIPTION>HSE oscillator OFF</DESCRIPTION>
      </SETTING7>
      <SETTING8>
        <NAME>HSE crystal oscillator bypass</NAME>
        <DESCRIPTION>HSE crystal oscillator not bypassed</DESCRIPTION>
      </SETTING8>
      <SETTING9>
        <NAME>Clock security system enable</NAME>
        <DESCRIPTION>Clock security system OFF</DESCRIPTION>
      </SETTING9>
      <SETTING10>
        <NAME>Main PLL enable</NAME>
        <DESCRIPTION>PLL OFF</DESCRIPTION>
      </SETTING10>
      <SETTING11>
        <NAME>SAI1 PLL enable</NAME>
        <DESCRIPTION>PLLSAI1 OFF</DESCRIPTION>
      </SETTING11>
      <SETTING12>
        <NAME>SAI2 PLL enable</NAME>
        <DESCRIPTION>PLLSAI2 OFF</DESCRIPTION>
      </SETTING12>
      <SETTING13>
        <NAME>System clock switch</NAME>
        <DESCRIPTION>MSI selected as system clock</DESCRIPTION>
      </SETTING13>
      <SETTING14>
        <NAME>Set and cleared by software to control the division factor of the AHB clock</NAME>
        <DESCRIPTION>SYSCLK not divided</DESCRIPTION>
      </SETTING14>
      <SETTING15>
        <NAME>APB low-speed prescaler (APB1)</NAME>
        <DESCRIPTION>HCLK not divided </DESCRIPTION>
      </SETTING15>
      <SETTING16>
        <NAME>APB high-speed prescaler (APB2)</NAME>
        <DESCRIPTION>HCLK not divided </DESCRIPTION>
      </SETTING16>
      <SETTING17>
        <NAME>Wakeup from Stop and CSS backup clock selection</NAME>
        <DESCRIPTION>MSI oscillator selected as wakeup from stop clock and CSS backup clock</DESCRIPTION>
      </SETTING17>
      <SETTING18>
        <NAME>Microcontroller clock output</NAME>
        <DESCRIPTION>MCO output disabled, no clock on MCO</DESCRIPTION>
      </SETTING18>
      <SETTING19>
        <NAME>Microcontroller clock output prescaler</NAME>
        <DESCRIPTION>MCO is divided by 1</DESCRIPTION>
      </SETTING19>
      <SETTING20>
        <NAME>Main PLL, PLLSAI1 and PLLSAI2 entry clock source</NAME>
        <DESCRIPTION>No clock sent to PLL, PLLSAI1 and PLLSAI2</DESCRIPTION>
      </SETTING20>
      <SETTING21>
        <NAME>Division factor for the main PLL and audio PLL (PLLSAI1 and PLLSAI2) input clock</NAME>
        <DESCRIPTION>PLLM = 1</DESCRIPTION>
      </SETTING21>
      <SETTING22>
        <NAME>Main PLL multiplication factor for VCO</NAME>
        <DESCRIPTION>16</DESCRIPTION>
      </SETTING22>
      <SETTING23>
        <NAME>Main PLL PLLSAI3CLK output enable</NAME>
        <DESCRIPTION>PLLSAI3CLK output disable</DESCRIPTION>
      </SETTING23>
      <SETTING24>
        <NAME>Main PLL division factor for PLLSAI3CLK (SAI1 and SAI2 clock)</NAME>
        <DESCRIPTION>PLLP = 7</DESCRIPTION>
      </SETTING24>
      <SETTING25>
        <NAME>Main PLL PLL48M1CLK output enable</NAME>
        <DESCRIPTION>PLL48M1CLK output disable</DESCRIPTION>
      </SETTING25>
      <SETTING26>
        <NAME>Main PLL division factor for PLL48M1CLK (48 MHz clock)</NAME>
        <DESCRIPTION>PLLQ = 2</DESCRIPTION>
      </SETTING26>
      <SETTING27>
        <NAME>Main PLL PLLCLK output enable</NAME>
        <DESCRIPTION>PLLCLK output disable</DESCRIPTION>
      </SETTING27>
      <SETTING28>
        <NAME>Main PLL division factor for PLLCLK (system clock)</NAME>
        <DESCRIPTION>PLLR = 2</DESCRIPTION>
      </SETTING28>
      <SETTING29>
        <NAME>LSI oscillator enable</NAME>
        <DESCRIPTION>LSI oscillator OFF</DESCRIPTION>
      </SETTING29>
      <SETTING30>
        <NAME>MSI range after Standby mode (RCC_CSR)</NAME>
        <DESCRIPTION>Range 6 around 4 MHz (reset value)</DESCRIPTION>
      </SETTING30>
      <SETTING31>
        <NAME>Core Voltage</NAME>
        <DESCRIPTION>VCORE = 1.2 V</DESCRIPTION>
      </SETTING31>
    </SETTINGS>
  </DEVICE>
</MCU_DEVICE_FLAGS>

Question:  What is wrong with this default scheme or this simple code that prevents this from working?
N.B. I have chosen the MikroC tag even though this is an STM32 part.  The definition for the MikroC tag is incorrectly specific to PIC devices.
When I contacted the vendor about this problem, they gave me a scheme file to load.  I attempted to load it but it wouldn't even load.  It had some spelling errors.  After correcting them based on the default scheme above, the example still didn't work.  They had chosen many non-default settings.  My rationale is that if I'm using the default (MSI) clock and default scheme, I should at least be able to get the part to run at 4MHz and have a successful starting point for further improvements.
Finally, the configuration register values from the project configurator are as follows:
RCC_CR      : $40021000 : 0x00000061
RCC_CFGR    : $40021008 : 0x00000000
RCC_PLLCFGR : $4002100C : 0x00001000
RCC_CSR     : $40021094 : 0x00000600
PWR_CR1     : $40007000 : 0x00000200

A: GPIO_Digital_Output() configures the pin as a output but it may not enable the clock to the GPIO peripheral.  Try adding a call to GPIO_Clk_Enable(&GPIOC_BASE).


text:
Q: Vue.js Facebook Login I'm implementing a Facebook Login module which I have already imported and it works, but the trouble comes when I want to bind the response to an input. How could I achieve it? I'm kinda new with Vue.js
I'm using this component
FbLogin.vue
 <template>
  <fb-signin-button
    :params="fbSignInParams"
    @success="onSignInSuccess"
    @error="onSignInError">
    Ingresa con FB
  </fb-signin-button>
</template>

<script>
export default {
  data () {
    return {
      fbSignInParams: {
        scope: 'email,user_likes',
        return_scopes: true,
      },
    }
  },
  methods: {
    onSignInSuccess (response) {
      FB.api('/me', dude => {
      console.log(`Good to see you, ${dude.name}.`)
      })
    },
    onSignInError (error) {
      console.log('Error de fBlogin', error)
    },
  }
}
</script>

Form.vue
<template lang="pug">
  .field
    pm-fb
    label.label
      h1.sutitle
      .control
        input.input.is-hovered(type="text" v-model="username" placeholder="Nombre(s)")
        input.input.is-hovered(type="text" placeholder="Apellido Paterno")
</template>

<script>
import PmFb from '@/components/fBLogin.vue'
export default {
  components: {
    PmFb
  }
}
</script>

It displays the info in the console and that's what I want to bind to the input.

A: You could use string interpolation in Vue templates to display that message.
First, add a data property (e.g., named "message"):
export default {
  data() {
    return {
      message: ''
    };
  }
}

Then, add the message in your template, surrounded by curly brackets:
<template>
  <div>{{message}}</div>
</template>

When your Facebook login result is determined, set this.message to the desired message, similar to this:
methods: {
  onSignInSuccess (response) {
    FB.api('/me', dude => {
      this.message = `Good to see you, ${dude.name}.`
    })
  },
  onSignInError (error) {
    this.message = `Error de fBlogin: ${error}`
  },
}


text:
Q: How to generate the header and footer for WhatsApp's .crypt12 format? WhatsApp stores all messages in an sqlite file which is first zlib compressed and then AES encrypted.
Decryption/decompression can be done quite easily like that:
def decrypt(db_file, key_file):
    """ Function decrypt Crypt12 Database """
    try:
        with open(key_file, "rb") as fh:
            key_data = fh.read()

        key = key_data[126:]
        with open(db_file, "rb") as fh:
            db_data = fh.read()

        iv = db_data[51:67]
        aes = AES.new(key, mode=AES.MODE_GCM, nonce=iv)
        with open("msgstore.db", "wb") as fh:
            fh.write(zlib.decompress(aes.decrypt(db_data[67:-20])))

        print db_file + " decrypted, msgstore.db created."
    except Exception as e:
print "An error has ocurred decrypting the Database:", e

But if you wanted to reverse the process, you would have to generate the header, footer and IV. At first I thought you could just copy them from another already existing crypt12 file like this:
def encrypt(db_file, key_file, db_cript):
    """ Function encrypt msgstore Database """
    try:
        with open(key_file, "rb") as fh:
            key_data = fh.read()

        key = key_data[126:]

        with open(db_cript, "rb") as fh:
            db_cript_data = fh.read()

        header = db_cript_data[:51]
        iv = db_cript_data[51:67]
        footer = db_cript_data[-20:]

        with open(db_file, "rb") as fh:
            data = fh.read()

        aes = AES.new(key, mode=AES.MODE_GCM, nonce=iv)
        with open("msgstore.db.crypt12", "wb") as fh:
            fh.write(header + iv + aes.encrypt(zlib.compress(data)) + footer)

        print "Encrypted msgstore.db created."
    except Exception as e:
        print "An error has ocurred encrypting the Database:", e

But that does not appear to be the case. The .crypt12 files headers and footers are different for every file.
Example 1 header hexdump:
0000000    0100    5802    ee46    bcaf    8968    d43b    bfaf    ca5d
0000010    a774    6b66    53ec    dbae    af60    a09c    3ad2    ba5e
0000020    7341    d224    22e7    55c3    c944    cf77    2c71    9c29
0000030    3a58    3798    d10f    897c    6ffa    f27a    e788    4d7b
0000040    24a7    43a0    f1d3    5f7c    5c74    d64d    58c9    21a4
0000050    771c    7fdc    2e14    ca93    0848    758a    c184    9058
0000060    b7d9    d847    604f    cadf    05a2    a678    4994    b711
0000070    2641    9170    8965    f6a7    9ff3    95a0    860d    aca1
0000080    214c    d644    faa7    ....    ....    ....    ....    ....

Example 2 header hexdump:
0000000    0100    5802    ee46    bcaf    8968    d43b    bfaf    ca5d
0000010    a774    6b66    53ec    dbae    af60    a09c    3ad2    ba5e
0000020    7341    d224    22e7    55c3    c944    cf77    2c71    9c29
0000030    3a58    1898    1435    4cc9    bdbf    e506    f138    41a6
0000040    32a0    71c5    faa9    2499    36f7    d2be    d7a8    bf28
0000050    f3ea    1571    ed80    da14    addb    63b6    1d8e    2de5
0000060    0a9c    bc31    8d86    cb42    b4ce    b603    af7c    c295
0000070    d67f    b787    1ad8    eb69    3180    1c9d    8106    1f98
0000080    e880    edd5    c285    ....    ....    ....    ....    ....

You can see the first 25 bytes are always equal, but the rest is completely different. The last 16 bytes are the IV (nonce) btw.
For the footer you can see the last two bytes are equal and the rest is completely different.
Example 1 footer hexdump:
1464cd0    ....    2feb    12d8    a2bc    92bd    ca30    a99f    621c
1464ce0    9e87    88df    dc82    f7ea    2cfd    3e0b    ecd4    03b1
1464cf0    7720    8d3d    2dcb    382d    0031

Example 2 footer hexdump:
1474330    ....    d4e9    80de    d0e8    9786    4fd3    8bf2    957c
1474340    fdf5    2e24    c4f2    1b55    121a    4410    014d    c516
1474350    7531    7f0a    2d71    382d    0031

So how do I generate those?

A: The paper Chat-App Decryption Key Extraction Through Information Flow Analysis analyzes the crypt12 format:

67-byte header:

*

*cipher-header preamble (2 bytes): 0x0, 0x1;

*key version (1 byte): 0x2;

*server salt (32 bytes): the stored pseudo-random salt from WhatsApp server;

*Google account-name salt (16 bytes): the salt used to produce Google account- name hash, which is to be sent to WhatsApp server (more on
this below);

*IV (16 bytes): the initialization vector value.

20-byte trailer:

*

*MD5 hash value (16 bytes): the MD5 hash value of the encrypted database file;

*Phone no's suffix (4 bytes): which is derived from the last few digits of the device's phone number.

I was unable to reconstruct the 16-bytes MD5 hash so I am wondering if this information is correct. Maybe there is some padding.


text:
Q: How to change the style of a checkbox from holo.light to holo.dark? The title speaks for itself. Is it possible? If so, than how do I do it? I want to use the holo.dark color scheme only for a CheckBox.
Thanks.

A: If you are using android-studio, select your checkbox, and in the properties, set 'buttonTint' property value to whatever color you want using the editor. Or , if you prefer the xml solution, use
android:buttonTint="@color/white"

This assumes of course that the color white is defined.

A: Add in your layout xml file
style="@android:style/Widget.Holo.CompoundButton.CheckBox"


text:
Q: FragmentPagerAdapter android.support.v4.app.fragment can not be applied to android.ap.Fragment First of all, I found hundred of question on this Topic and solution but none of them help me. because I m doing little different workaround.
FragmentPagerAdapter class constructor
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

public class HomePage_Slider extends FragmentPagerAdapter {
    public HomePage_Slider(FragmentManager fragmentManager) {
        super(fragmentManager);
        MyArr.addAll(globalVariable.slider_image_url);
        mCount =MyArr.size();
    }

    public HomePage_Slider(android.app.FragmentManager fragmentManager) {
        super(fragmentManager);
    }
 }

Fragment class
import android.app.Fragment;

public class host extends Fragment {
       public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootview = inflater.inflate(R.layout.content_navigation_drawer, container, false);
         Top_slider = rootview.findViewById(R.id.home_slider_image);
        viewPager = (ViewPager) Top_slider.findViewById(R.id.pager);
        viewPager.setAdapter(new HomePage_Slider(getActivity().getFragmentManager()));
        }

}

I am using Navigation drawer using Support library and follow this tutorial  Navigation Drawer Tutorial . and trying to use FragmentPagerAdapter to display slider.  and My Host Fragment class uses import android.app.Fragment; and FragmentPagerAdapter class uses import android.support.v4.app.Fragment;
Because of My host Fragment class do not import import android.support.v4.app.Fragment;
FragmentPagerAdapter constructor giving error FragmentPagerAdapter android.support.v4.app.fragment can not be applied to android.ap.Fragment
while searching solution I found this changing my import will do the trick but my rest app will stop working. used import android.app.Fragment; to do other work like calling other Fragment class transaction something like this
//Host Fragment have this code  to swap to next Fragment on click event on listview
 ((MainActivity)getActivity()).category_product_page();

  // class contains
  MainActivity.java

// go to wishlist page
    public void category_product_page() {
        // Create new fragment and transaction
        cart_product newFragment = new cart_product ();
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack
        transaction.replace(R.id.frame_container, newFragment);
        transaction.addToBackStack(null);
        // Commit the transaction
        transaction.commit();
    }

and I also did some other work on host Fragment that's why I can not change  import android.app.Fragment " to import android.support.v4.app.Fragment;
any suggestion  will be helpful.
Please suggest how can I overcome this error and prevent these error in future as my second app have slider

A: FragmentPagerAdapter android.support.v4.app.fragment can not be applied to android.ap.Fragment

When you are using android.support.v4.app.FragmentManager then you
  should use getSupportFragmentManager() and if you are using
  android.app.FragmentManager then call getFragmentManager()

You are using import android.support.v4.app.Fragment;
Don't
    viewPager.setAdapter(new HomePage_Slider(getActivity().getFragmentManager()));
    FragmentTransaction transaction = getFragmentManager().beginTransaction();

Do
     viewPager.setAdapter(new HomePage_Slider(getActivity().getSupportFragmentManager()));
     FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

You should call getSupportFragmentManager () instead of getFragmentManager() .

Return the FragmentManager for interacting with fragments associated
  with this activity.

A: getSupportFragmentManager()

instead of
getFragmentManager()

should do the trick.

A: Change
import android.app.Fragment;

to
import android.support.v4.app.Fragment;

After that use
getSupportFragmentManager()

where you are using
getFragmentManager()

Note: Anywher you get error simply use support import statements.

A: You can not use 2 different libraries for same thing. You should use v4.app or app.Fragment for your all fragments and fragment managers to get working result.


text:
Q: Is there anyway to call function after nsDialog show? I wonder if there is any way which I can call function after nsDialog::show.
My case is a custom page that need to run http get request after the nsDialog show.
    Function customPage
        nsDialogs::Create 1018
    Pop $0

    ${NSD_CreateButton} 0 0 100% 12u Test
    Pop $BUTTON

    ${NSD_CreateText} 0 35 100% 12u hello
    Pop $EDIT

    ${NSD_CreateCheckbox} 0 -20 100% 8u Test
    Pop $CHECKBOX

    ${NSD_CreateLabel} 0 40u 75% 40u "* Type `hello there` above.$\n* Click the button.$\n* Check the checkbox.$\n* Hit the Back button."
    Pop $0

    nsDialogs::Show
    Call MyFunc
 FunctionEnd

Actually, the call for MyFunc is occuring only when im closing the nsDialog..

A: Use nsDialogs::CreateTimer with a short timeout and kill the timer in the function callback, it is a bit of a hack but seems to work fine.

A: nsDialog running by solo thread, but actually you can use nsDialogs::CreateTimer to callback a function without specify time which.
You can read more about that on:
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html#ref-createtimer


text:
Q: Mapping nhibernate to several databases that share schema but not data I have multiple databases that should all be active at the same time. They share schema, but not the data.
AFAIK nhibernate use the class type to know what mapping and database it is connected to, right? So once it gets an object, it wouldn't know if it belongs to database a or b.
I think it's possible to solve this using inheritance, but it's a real pain as there are in around 10 different databases...
Any ideas how this might be solved using nhibernate (burrow)?
I found this, but it's not the same as that is just choosing a single database out of many. I need to have them open at the same time using distinct data.
I also looked at NHibernate.Shards, but that wont work either. This is legacy databases that cannot change.

A: If the mappings are the same for each of your databases I think that I would have an ISessionFactory instance per database, mapped using the same mappings, then you would get an ISession from the appropriate one to access the particular database


text:
Q: How to get the Total of current tabs in TabLayoutPanel? We have tabLayoutPanel.selectTab(1) to select the the 2nd tab of the tabLayoutPanel
However, we need to make sure that the tabLayoutPanel must currently have 2 tabs otherwise it will have "out of bound" error.
And if it has "out of bound" error & the rest of the code will not be implemented.
But there is no getTotalTabs method in tabLayoutPanel
do we need to get the Tab header and found the total tabs from the tab header?
How to fix it?

A: Doesn't getWidgetCount() return what you need?

A: getWidgetCount() is the method you're searching for


text:
Q: My Plot is empty when I run code ee = 0.5;
g = 0.1;
gs = Sqrt[g];
f = (Sin[gs*x])^2;
low = gs*Pi/2 ;
up = -low ;
ode = { y''[x] + (2ee - f/g)*y[x] == 0 , y[low]==0 , y[up]==0 }
sol = NDSolve[ode, y[x], {x, low , up}]
Plot[y[x] /. sol, {x, low, up}]

Boundary conditions are y[low]=y[up]=0. But when I plot this, it shows an empty plot.

A: With
ee = 1/2;
g = 1/10;
low = (-Sqrt[g])*(Pi/2);
up = -low;
ode = {Derivative[2][y][x] + (2*ee - Sin[Sqrt[g]*x]^2/g)*y[x] == 0}
sol = FullSimplify[DSolve[ode, y[x], {x, low, up}]]

(I changed low to -low...) you can get a symbolic result in terms of Mathieu functions. Using your boundary conditions y[x] is zero.
Edit:
"12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)"
When I execute the above code using a FRESH kernel I get
(* {(1 - 10*Sin[x/Sqrt[10]]^2)*y[x] + Derivative[2][y][x] == 0}
{{y[x] -> C[1]*MathieuC[-40, -25, x/Sqrt[10]] +
C[2]*MathieuS[-40, -25, x/Sqrt[10]]}} *)