text:
Q: Common Lisp: Why does this create circular list: (setf (car ) (append ))? I am trying to understand why this produces what seems to be circular list.
 * (progn
 (setf (car *x*) (append '(3) *x*))
 2)

2  ;; No "apparent issue setting the value. Hence it is related to printing `*x*`
*x* ;; infinite loop, perhaps due to the structure of *x*??

Why is it a circular list? I would expect that it should not be a circular list
What is different between this question and the "duplicate" question:
In this question, I believe *x* should not be a circular list. In the duplicate answer chain, it is shown how to create a circular list, and neither of the example uses the result of append in the setf.
Alright, I found the answer:
My confusion arises from misunderstanding the spec where they say that append returns a new list.
Evidently a new list does not mean that each and every member of it is new (does not mean a copy is returned). The last argument of append is actually shared...

A: It's not the reader, but the printer that is in an infinite loop.
Most implementations have a variable to limit the top level printer,
see *PRINT-LEVEL*, *PRINT-LENGTH*


text:
Q: jQuery sort function performance I'm sorting a list of <li> elements. I adapted a function on a page that I can't link right now. You can see the live site here. Click on "Sort and Filter" and click any of the Sort by methods (English name, material, status...). All sorts are essentially the same, so CPU time is the same.
My jQuery function looks like this:
jQuery.fn.sort = function() {
    return this.pushStack([].sort.apply(this, arguments), []);
};
  function sortAscending1(a, b)  { return $(a).find(".english").text() > $(b).find(".english").text() ? 1 : -1; };
  function sortDescending1(a, b)  { return $(a).find(".english").text() < $(b).find(".english").text() ? 1 : -1; };

And I'm calling it from the following jQuery line (s_alf_eng is a clicable div on the page).
$(document).ready(function() {
    $(".s_alf_eng").toggle(
        function() {
            $('.media-status-specie li').sort(sortAscending1).appendTo('.media-status-
        },
        function() {
            $('.media-status-specie li').sort(sortDescending1).appendTo('.media-status-specie');
        });

I can provide any extra clarification quickly.
Thanks!
EDIT: The question is that executing this sort for large list takes several seconds. In my core2duo it might take up to 20 seconds! I changed the find(".english") to filter(".english") and the speed seems to be the same. Any idea on how to speed that up?

A: Make a copy in memory of the list and sort it, then replace the existing list with the sorted one. That would be faster than manipulating live, visible, DOM elements.

A: I think if you add name as metadata to the node and eliminate looking through the DOM on every comparison, it'll be much faster. Remember, there's O(n2) of them after all.
$(function() {
    $('.media-status-specie li')
        .each(function () {
            $(this).data('name', $(this).find(".english").text());
        })
});

....

function sortDescending1(a, b)  {
    return $(a).data('name') < $(b).data('name') ? 1 : -1;
}

Disclaimer: It's my opinion, I'm no good at guessing slow points as any other developer out there, use profiler to find real performance killer.

redpajama_set_name: RedPajamaStackExchange


text:
Q: git merge some commits from develop branch into existing release branch? I have a develop branch which our team works on and we created a release branch off of it about a month ago. Now some of the commits done in develop need to be merged into the release branch.
I switched to my release branch and then did a cherry pick of commits I wanted. This worked but now when I look at the log, I can't tell which develop commits that I didn't move over. It's very confusing. How can I get a report of what files have been modified in develop that aren't in the release branch?
FYI, I'm using smartgit.

A: You could do git diff develop..release to get the diffs between your two branches.
You could also use gitk develop release to open a GUI which would let you get the same kind of diff.

A: To see what files are different between develop and release use
git diff --name-only release..develop --


text:
Q: Instagram Video not loaded properly loaded in Drupal 7 on iPhone I have an article running in Drupal 7. The content's Embedded Video from instagram didn't load fully and the content after video isn't display on iPhone.
Tested on iPad & Desktop seem fine. it's only have problem in iPhone as this  Screenshot.
Appreciate if you guys have any solutions.

A: It's causing because of height issue. So change the following css to fix issue.
html {
height: 100%;}

to
html {
/*height: 100%;*/}


text:
Q: Ldap getting disabled users I'm using this piece of code
$filter = "(&(objectClass=user)(!(objectClass=computer))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
$attr = array("displayName", "samaccountname", "thumbnailPhoto", "displayName", "mail", "IPPhone","employeeid");
$result = ldap_search($link, $ldap_dn, $filter, $attr);
$entries_full = ldap_get_entries($link, $result);

My objective is to get all users that are not a computer and are not disabled. But I'm struggling with the filters.

A: Is (&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)) working for you?


text:
Q: Multiple sections on same level with diferent labels This is a follow up to this question.
I would like to have multiple subsections with different labels (in this situation the sign off boxes) all in the same numbering sequence. My attempt at this has broken the numbering all together.
Thanks in advance.
\documentclass[a4paper,twoside]{article}
\usepackage[explicit,pagestyles]{titlesec}
\usepackage{enumitem}
\usepackage{changepage}
\usepackage{lastpage}
\usepackage{lipsum}% just to generate text for the example

%Heading formatting
\titleformat{\part}[block]
  {\normalfont\LARGE\bfseries\filcenter}{\partname\ \thepart:}{0.5em}{#1}
\titleformat{\section}
  {\normalfont\Large\bfseries}{}{\TIndent}{\llap{\makebox[0.5\TIndent][l]{\thesection}\hfill}#1}
\titlespacing*{\section}
{0pt}{3.5ex plus 1ex minus .2ex}{.3ex plus .2ex}

%Trainee section signoff
\newcounter{trainee}
\titleclass{\trainee}{straight}[\section]
\titleformat{\trainee}
    {\normalfont\large\bfseries}{}{0em}{\llap{\smash{\makebox[\TIndent][l]{\normalfont\TeBox}}}\thesubsection. #1}
\titlespacing*{\trainee}
    {0pt}{3.5ex plus 1ex minus .2ex}{.3ex plus .2ex}
\renewcommand{\thetrainee}{\Alph{trainee}}

%Trainer section signoff
\newcounter{trainer}
\titleclass{\trainer}{straight}[\section]
\titleformat{\trainer}
    {\normalfont\large\bfseries}{}{0em}{\llap{\smash{\makebox[\TIndent][l]{\normalfont\TrBox}}}\thesubsection. #1}
\titlespacing*{\trainer}
    {0pt}{3.5ex plus 1ex minus .2ex}{.3ex plus .2ex}
\renewcommand{\thetrainer}{\Alph{trainer}}

%Defines the sign off indent distance
\newlength\TIndent
\setlength\TIndent{9em}

\makeatletter
\@addtoreset{section}{part}
\makeatother
\renewcommand\thepart{\arabic{part}}
\renewcommand\thesection{\thepart.\arabic{section}}
\renewcommand\thesubsection{\arabic{subsection}}

%Trainee box
\newcommand\TeBox{%
\fbox{\footnotesize%
\begin{tabular}{cc}
\\[1.2em]
\hline
\\[-.8em]
Trainee & Date \vspace{-.4em}
\end{tabular}}%
}

%Trainer box
\newcommand\TrBox{%
\fbox{\footnotesize%
\begin{tabular}{cc}
\\[1.2em]
\hline
\\[-.8em]
Trainer & Date \vspace{-.4em}
\end{tabular}}%
}

\setitemize{label={\rule{1cm}{0.4pt}},leftmargin=*}

\newcommand\Text{% just to generate text for the example
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel,
wisi. Morbi auctor lorem non justo.}

\begin{document}
\part{Personnel Introduction}

\lipsum[4]

    \section{Division Personnel}
    \begin{adjustwidth}{3cm}{0pt}
        \leavevmode\trainee{Headquarters}

        \Text
        \begin{itemize}
        \item Name Name
        \item Name Name
        \end{itemize}

        \trainer{Production Department}

        \Text
        \begin{itemize}
        \item Name Name

        \begin{center}
        SECONDARY GROUP
        \end{center}

        \item Name Name
        \item Name Name
        \item Name Name
        \end{itemize}
    \end{adjustwidth}

\end{document}

A: You can achieva what you want using just one new sectional unit trainex and a command with an optional argument together with a conditional test to decide whether to use "Trainer" or "Trainee":
\documentclass[a4paper,twoside]{article}
\usepackage[explicit,pagestyles]{titlesec}
\usepackage{enumitem}
\usepackage{changepage}
\usepackage{lastpage}
\usepackage{lipsum}% just to generate text for the example

%Heading formatting
\titleformat{\part}[block]
  {\normalfont\LARGE\bfseries\filcenter}{\partname\ \thepart:}{0.5em}{#1}
\titleformat{\section}
  {\normalfont\Large\bfseries}{}{\TIndent}{\llap{\makebox[0.5\TIndent][l]{\thesection}\hfill}#1}
\titlespacing*{\section}
{0pt}{3.5ex plus 1ex minus .2ex}{.3ex plus .2ex}

%Trainex section signoff
% will be used for both, depending on an optional argument
\newcounter{trainex}
\titleclass{\trainex}{straight}[\section]
\titleformat{\trainex}
    {\normalfont\large\bfseries}{}{0em}{\llap{\smash{\makebox[\TIndent][l]{\normalfont\TeBox}}}\thetrainex. #1}
\titlespacing*{\trainex}
    {0pt}{3.5ex plus 1ex minus .2ex}{.3ex plus .2ex}
\renewcommand{\thetrainex}{\Alph{trainex}}

\def\trainexx{}

% Here we decide whether to use "Trainee" or "Trainer" in the box
% by default, \trainey uses "Trainer"; if the optional argument is "e"
% then "Trainee" will be used.
\newcommand\trainey[2][r]{%
\if#1r\relax
\renewcommand\trainexx{Trainer}
\else
\if#1e
\renewcommand\trainexx{Trainee}
\fi\fi
\trainex{#2}
}

%Defines the sign off indent distance
\newlength\TIndent
\setlength\TIndent{9em}

\makeatletter
\@addtoreset{section}{part}
\makeatother
\renewcommand\thepart{\arabic{part}}
\renewcommand\thesection{\thepart.\arabic{section}}
\renewcommand\thesubsection{\arabic{subsection}}

%Trainee box
\newcommand\TeBox{%
\fbox{\footnotesize%
\begin{tabular}{cc}
\\[1.2em]
\hline
\\[-.8em]
\trainexx & Date \vspace{-.4em}
\end{tabular}}%
}

%Trainer box
\newcommand\TrBox{%
\fbox{\footnotesize%
\begin{tabular}{cc}
\\[1.2em]
\hline
\\[-.8em]
Trainer & Date \vspace{-.4em}
\end{tabular}}%
}

\setitemize{label={\rule{1cm}{0.4pt}},leftmargin=*}

\newcommand\Text{% just to generate text for the example
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel,
wisi. Morbi auctor lorem non justo.}

\begin{document}
\part{Personnel Introduction}

\lipsum[4]

    \section{Division Personnel}
    \begin{adjustwidth}{3cm}{0pt}
        \leavevmode\trainey[e]{Headquarters}

        \Text
        \begin{itemize}
        \item Name Name
        \item Name Name
        \end{itemize}

        \trainey{Production Department}

        \Text
        \begin{itemize}
        \item Name Name

        \begin{center}
        SECONDARY GROUP
        \end{center}

        \item Name Name
        \item Name Name
        \item Name Name
        \end{itemize}
    \end{adjustwidth}

\end{document}

A: So I decided to use subsection to hold my numbering and I manually increment the numbers. I tested it and it works like a charm!
%Set initial subsection counter
\setcounter{subsection}{1}

%Trainee section signoff
\newcounter{trainee}
\titleclass{\trainee}{straight}[\section]
\titleformat{\trainee}
    {\normalfont\large\bfseries}{}{0em}{\stepcounter{subsection}\llap{\smash{\makebox[\TIndent][l]{\normalfont\TeBox}}}\thesubsection. #1}
\titlespacing*{\trainee}                   ^ %Increment subsection counter here
    {0pt}{3.5ex plus 1ex minus .2ex}{.3ex plus .2ex}
\renewcommand{\thetrainee}{\Alph{subsection}}

%Trainer section signoff
\newcounter{trainer}
\titleclass{\trainer}{straight}[\section]
\titleformat{\trainer}
    {\normalfont\large\bfseries}{}{0em}{\stepcounter{subsection}\llap{\smash{\makebox[\TIndent][l]{\normalfont\TrBox}}}\thesubsection. #1}
\titlespacing*{\trainer}                   ^ %Increment subsection counter here
    {0pt}{3.5ex plus 1ex minus .2ex}{.3ex plus .2ex}
\renewcommand{\thetrainer}{\Alph{subsection}}


text:
Q: Generic functions in F# I'm still trying to wrap my head around how F# generalizes (or not) functions and types, and there's a case that's bugging me:
let min(a, b) = if a < b then a else b

let add(a, b) = a + b

let minInt = min(3, 4)
let minFloat = min(3.0, 4.0) // works!

let addInt = add(3, 5)
let addFloat = add(3.0, 5.0) // error: This expression was expected to have type
                             // int but here has type float

Here min has the generic type 'a * 'a -> 'a (requires comparison) while add has a concrete type int * int -> int, apparently inferred from its first use in the program. Both are declared and used in the same way, so why the difference in generalization?
I understand that in the case of add, the problem can be side-stepped by declaring the function inline, which causes it to get a generic type definition, i.e. 'a * 'b -> 'c (requires member (+)), but that doesn't explain why this is needed in this case and not the other.

A: There is an excellent write up on this very issue by @TomasP here: http://tomasp.net/blog/fsharp-generic-numeric.aspx

When writing simple generic code that has some type parameter 'T, we
  don't know anything about the type parameter and there is no way to
  restrict it to a numeric type that provides all the operators that we
  may need to use in our code. This is a limitation of the .NET runtime
  and F# provides two ways for overcoming it.

But why are < and > (and by extension, =, <= and >=) OK?
The F# compiler treats equality and comparison differently (see section 5.2.10 Equality and Comparison Constraints in the specs, thanks @Daniel). You get the special comparison constraint, which is allowed when (simply, see the spec for more detail):

If the type is a named type, then the type definition does not have,
  and is not inferred to have, the NoComparison attribute, and the type
  definition implements System.IComparable or is an array type or is
  System.IntPtr or is System.UIntPtr.

There is no such special handling for the + operator. Why couldn't there be a constraint such as numeric?
Well isn't that operator also defined for strings? In some languages for lists and collections? Surely it would be an addable constraint and not numeric. Then many such overloaded operators can be found in a program with different semantic meaning. So F# provides a 'catch-all' method with static member constraints and the inline keyword. Only equality and comparison are special.

A:
why the difference in generalization?

There is a trade-off between generality and performance. The comparison constraint provides generality for functions like min that can act upon any value of any F# type but in the general case it resorts to virtual dispatch and is many times slower. The + operator provides restricted generality and can act upon any value of any F# type that has been augmented with an overload but does not work in the general case and, therefore, is always very fast because dispatch is never needed.

A: comparison is a compile-time constraint. So the question remains: why isn't add generalized? As yamen pointed out, generic math ops require inlining, which affects code size and performance—probably not something the compiler should do automatically.


text:
Q: Is it possible to keep an iOS app running for ever listening to location update and enabling Maps Car Routing? How does app like Google Maps keep running in the background, the app is not killed but it runs forever.. how does that work?

A: 1.You can go to .plist  and add one item as "Application does not run in background",then set this to "NO"
2.Add one item as "Required background modes" ,set it with you use type
it is my method,i hope that can help you :)


text:
Q: The clerk concerned VS the concerned clerk

*

*I want to meet the concerned  clerk

*I want to meet  the  clerk concerned

According  the grammar book by  David  Green  the first sentence means I want to meet the clerk  who  is  tense  or  worried
The  second  sentence  means   I want  to meet  the  clerk who is incharge of the section.
Most  of  the nonnative  speakers  I know  say  I want  to meet the  concerned  clerk.
Is  there really  difference between  the  two  sentences?

A: David Green is correct.
The first "concerned" is an adjective describing the clerk. When applied to a human the adjective means "worried".
The second concerned is part of a relative clause

the clerk (who is) concerned (with this matter)

this is from the verb "to concern" which means "to be relevant to"
The meanings of the two sentences are completely different.  The first sentence would hardly ever be used. Usually you don't want to see a worried clerk.


text:
Q: Network balancing/failover on linux I've a CentOS 5.4 server it has 2 nics. Is there any way I can configure this box to use the 2. nic as a failover if the physical connection on the 1. nic fails ?
This is an internal server that has no connectivity to the internet. I can wire the 2 nics to 2 different switches, though all on the same subnet. It should have just 1 IP address.
Can linux now also load share (atleast the outgoing packets) on both these nics ? Any step-by step guide appreciated.

A: What your talking about is usually referred to as bonding.  In alot of cases interfaces are grouped (or bonded) together to increase bandwidth.  In your case, the setup will be the same, only when you configure the mode for the bonded interfaces, you tell the system to use one of the two interfaces as a fail-over.
Check out the how to at http://www.howtoforge.com/network_card_bonding_centos.  It both explains and walks you though bonding interfaces in CentOS.


text:
Q: Hibernate validate dosent work without breakpoint stops on debug mode I have the follow code that call by rest service:
 Validator validator = beanValidationController.createValidator();
 Set<ConstraintViolation<MyBean>> violations = validator.validate(myBean);
 //Interate violations and return messages

If call the rest that call this code, the 'violations' are empty, but if put the breakpoint in first line ( Validator validator = beanValidationController.createValidator();) and break, the 'violations' is not empty. I try put Thread.sleep(); before code but dosent work.
I use Red Hat JBoss EAP 6.1+ with jdk 7

A: I vaguely remember we had some bug a while ago related to the iteration order of sets. This kind of error often manifests itself in the behavior you describe. Can you try with the latest EAP 6.4 and HV 4.3.2.Final?


text:
Q: Why gcc will optimise an if statement but not a question mark operator? With the following code, compiled with -O3,
extern int*  source;
extern int*  dest;

int main(int argc, char **argv)
{
    // dest conditionally written
    if (*source)
    {
        *dest = *source;
    }

    // dest always written?
    *dest = *source ? *source : *dest;
}

gcc generates code that writes to dest in A when *source != 0, but it generates code that always writes to dest for B, even when *source == 0, ie it generates effectively *dest = *dest, which is redundant. What's the reasoning for this and is there a way to improve it?
Thanks.


text:
Q: Save the selection state of the current selected item on a list A macOS app that works with local files need to reload the files when it gets focused again. This is to load any new files that might have been placed there while the app was in the background.
The issue is that when I clear the list, reload the files (rebuilding the list), the first item is always selected, so if I was working on an item I'm being forced to select it again to continue working on it.
I tried keeping the current UUID of the selected note and passing that back, but I have no clue whether this is correct, or how to programmatically select an item in the list matching the UUID saved.
How do I keep the current selected item, and then go to it when I reload the data?
Code I tried:
struct DataItem: Codable, Hashable, Identifiable {
    let id: UUID
    var text: String
}

struct AllData: View {

    @EnvironmentObject private var data: DataModel //array of DataItem's
    @State var selectedItemId: UUID?
    @State var currentItemId: UUID?

     NavigationView {
            List(data.prices.filter { searchText.isEmpty ? true : $0.text.localizedCaseInsensitiveContains(searchText) }) { price in
                NavigationLink(
                    destination: PriceView(price: price, text: price.text),
                    tag: price.id,
                    selection: $selectedItemId
                ) {
                    VStack(alignment: .leading) {
                        Text(getTitle(titleText: price.text)).font(.body).fontWeight(.bold)
                    }
                    .padding(.vertical, 10)
                }
            }

     }
    .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
            self.currentItemId = self.selectedItemId
            if getCurrentSaveDirectory(for: "savedDirectory") != "" {
                if !isDirectoryEmpty() {
                    data.price.removeAll()
                    loadFiles(dataModel: data)
                    self.selectedItemId = self.currentItemId
                }
            }
        }
}

A: I think using the current UUID of the selected note as you do is a good idea.
Without all the code it is difficult to test my answer, however you could
try this approach, using a List selection variable and adding the simple code in onReceive,
such as this example code:
struct AllData: View {

    @EnvironmentObject private var data: DataModel //array of DataItem's
    @State var selectedItemId: UUID?
    @State var currentItemId: UUID?

    @State var listSelection: DataItem?  // <--- here selection

    var body: some View {
        NavigationView {
            List(data.prices.filter { searchText.isEmpty ? true : $0.text.localizedCaseInsensitiveContains(searchText) },
                 selection: $listSelection) { price in  // <--- here selection
                NavigationLink(
                    destination: PriceView(price: price, text: price.text),
                    tag: price.id,
                    selection: $selectedItemId
                ) {
                    VStack(alignment: .leading) {
                        Text(getTitle(titleText: price.text)).font(.body).fontWeight(.bold)
                    }
                    .padding(.vertical, 10)
                }
            }
        }
        .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
            self.currentItemId = self.selectedItemId
            if getCurrentSaveDirectory(for: "savedDirectory") != "" {
                if !isDirectoryEmpty() {
                    data.price.removeAll()
                    loadFiles(dataModel: data)
                    self.selectedItemId = self.currentItemId
                    // --- here ---
                    if let theItem = data.first(where: {$0.id == selectedItemId}) {
                        listSelection = theItem
                    }
                }
            }
        }
    }
}


text:
Q: load another page when slide toggle I want to click a button on my page then another div toggle on and load in that div another page, but it doesn't work.
HTML:

        Click here

A: I believe your function can be simplified to use the normal callback of toggle or slidetoggle
$(function() {
  $('#clickme').on("click",function() {
    $('#me').toggle(function() {
      $(this).load("page2.html");
    });
  });
});

But you might want to load before toggling:
$(function() {
  $('#clickme').on("click",function() {
    $('#me').load("page2.html",function() {
      $('#me').slideToggle();
    });
  });
});


text:
Q: Error Handling in PowerShell Advanced Function I am trying to add error handling to my script so whoever runs it can see errors in a txt file after.
I know i can use try, catch to capture errors, but the problem i have is, i have hundreds of lines of script, some Cmdlets which don't have variables to error capture on, how can i capture the errors for the whole function and export to a txt file to save having to go through each line adding -erroraction stop and put it in a try block with the catch block having an out-file command in it to send to file.
Thanks

A: When I need logging, I always just throw something like this in the catch block:
 $ErrorName = $Error[0].exception.GetType().fullname
 $ErrorDescription = $Error[0].exception.Message
 "Something went wrong gathering the account names. Cannot continue processing, a fatal error has occurred... `r`n $ErrorName `r`n $ErrorDescription `r`n SCRIPT TERMINATED `r`n " | Out-file -filepath $ErrorLog -append


text:
Q: how does serializable work in java? If I have an instance of a class that I store in a session I need to make it serializable. This class has a static variable, will this be serialized in every instance stored?
The static variable is a reference to a cache containing a lot of data in the background. Will all of this data be serialized? If so, it seems preferable to make this variable transient and re-fetch the cache instance each time the instance is restored. Maybe not store the cache instance at all in the class.
Will the constructor execute when a class is restored from a serialized state? if not is there any other method I can use to re-instate a transient variable?

A: static and transient fields are not serialized.  No, the constructor is not called.  For more details, please check this out: http://java.sun.com/developer/technicalArticles/ALT/serialization/

A:
This class has a static variable, will
  this be serialized in every instance
  stored?

No. According to the Java Object Serialization Specificaiton: "Default serializable fields of a class are defined to be the non-transient and non-static fields."

Will the constructor execute when a class is restored from a serialized state?

No. Deserialization bypasses constructors (unless you have a non-serializable superclass).

if not is there any other method I can use to re-instate a transient variable?

You can use the readObject() method for that, as described in the Serializable API doc.


text:
Q: Notation of a dynamically changing set If there is a set D=[2,4,7,8,11] each represent a possible distance to a point. After some time t, the distance t * 2 is subtracted from every element in A. For example, after 2 minutes we subtract 4 from every element so the new A will become:
The new D=[-2,0,3,4].
Say that we want to remove every element that is $\le$  0 so it becomes : D=[3,4]
My question is what is the best and formal way to write that?
I don't wanna keep saying the new D.
Should I say $D_i$ (where i is the passed time)? What about before and after removing the elements that are <= 0?


text:
Q: SubsetSum using recursion and backtracking I have written an algorithm to return whether a subset of a group of numbers will sum to a given target using backtracking and recursion (returns true/false)
Ex: {5, 2, 3, 6} with Target = 8 ==> True ||
{5, 2, 3, 6} with Target = 20 ==> False
I want to modify my algorithm so that it includes all 5's that maybe present in the set. I am having a hard time how to figure this out using backtracking and recursion. Any advice is appreciated
Ex: {5, 2, 3, 6} with Target 8 ==>True ||
    {6, 2, 3, 5, 5} with Target 8 ==> False
I have written an algorithm that recursively includes a number and checks the sum and then omits the number from the sum but I don't know how to modify my algorithm to only pick a certain numbers and include them in the sum
public static void main(String argv[]) {
        int[] ints = { 10, 1, 3, 2 };
        int target = 5;
        int start = 0;
        System.out.println(groupSum(ints, target, 0, start));
    }

    public static boolean groupSum(int[] arr, int target, int sum, int start) {
        if (sum > target) {
            return false;
        }
        if (sum == target) {
            return true;
        }
        if (start >= arr.length) {
            return false;
        }
        //choose
        sum = sum + arr[start];
        //explore
        if (groupSum(arr, target, sum, start + 1))
            return true;
        //un-choose
        sum = sum - arr[start];
        return groupSum(arr, target, sum, start + 1);
    }

A: Force it to only look at including 5 if it sees it, and only check = sum at the end.  Like this:
public static void main(String argv[]) {
    int[] ints = { 10, 1, 3, 2 };
    int target = 5;
    int start = 0;
    System.out.println(groupSum(ints, target, 0, start));
}

public static boolean groupSum(int[] arr, int target, int sum, int start) {
    if (sum > target) {
        return false;
    }
    // NOTE: sum == target inside of end of array check so all 5s are found.
    if (start >= arr.length) {
        return sum == target;
    }
    //choose
    sum = sum + arr[start];
    //explore
    if (groupSum(arr, target, sum, start + 1))
        return true;
    //un-choose
    // NOTE: can't unchoose 5
    if (5 == arr[start]) {
        return false;
    }
    sum = sum - arr[start];
    return groupSum(arr, target, sum, start + 1);
}

Update: Here is advice on how to solve problems like this.

*

*Very clearly state what you want the function to do.

*Very clearly state what the base case or cases are where you know the answer.

*In the complex case, figure out how to reduce it to one or more simpler problems.

As long as you've done that, your recursive code should work.  And if you're in doubt about how to modify, start over from scratch, only copying code from before where you've noticed that it can be left alone.
So for the first step, the statement is, We want groupSum to take an array arr of positive integers, a target target, a partial sum sum and an int start and to return whether it is possible to get the rest of the array to sum to target when you take a subset that has to include all 5s.
For the second step, base cases are:

*

*We've already exceeded target, then it is false.

*We've reached the end of the array and are at target, then it is true.

*We've reached the end of the array and are blow target, then it is false. (I combined this with the last in the code by returning a comparison.)

For the third step, the reductions are as follows.

*

*If we can add the current value and make it, the answer is true.

*If the current value is not 5, we don't add it, and can make it, the answer is true.

*Otherwise it is false.

I was trying to write the code in the way that looked most like what you already had.  But to write it exactly according to this logic it would be like this:
public static boolean groupSumWithAll5s(int[] arr, int target, int sum, int start) {
    // Base cases
    if (sum > target) {
        return false;
    }
    else if ((start >= arr.length) && (sum == target)) {
        return true;
    }
    else if (start >= arr.length) {
        return false;
    }

    // Recursive cases.
    if (groupSumWithAll5s(arr, target, sum + arr[start], start + 1)) {
        return true;
    }
    else if ((arr[start] != 5) && groupSumWithAll5s(arr, target, sum, start + 1)) {
        return true;
    }
    else {
        return false;
    }
}


text:
Q: Is TeraCopy still useful in Windows 7? Is TeraCopy still useful in Windows 7?

A: You might want to take a look at this thread. I've used tera copy on Windows 7 and yes, it does speed up transfering your files. I've used it to transfer files across a single disk and across a network, and in both ways it greatly speeds up the process.
Hope this helps some.

A: Original Answer
Truthfully I haven't tried TeraCopy yet, but your question is interesting because I just found it a couple days ago while trying to delete a large amount of files on a remote server.  So I can at least speak for the Win7 stock behavior:
Windows 7 file copy, move, and delete are absolutely not any faster than any other version of Windows I've used, including 2000, XP, Server2003, and Vista.  I do this stuff a lot on the job and it's still torture in Win7, whether you use the GUI or the command line, excepting robocopy (which won't do deletes).  Need to do multiple file operations on large sets of files at the same time?  Say goodbye to your OS until next week... I usually do these operations on a remote workstation I have setup and let it do the big file operations on shares while I use my desktop workstation for real work.
Updated Answer
I have been using TeraCopy for quite awhile now (since my original answer to this question), and I've found that it significantly increases large copy operation speeds.
My main use has been on a corporate network domain.  At the same moment, my boss and I, sitting side by side on windows 7 laptops, started to copy the same directory from an ntfs share.  The directory contained ~3000 files and totaled ~3GB.  I used teracopy, he used windows explorer, regular old windows 7 copy paste.  My copy operation completed in approximately 1/10th of the amount of time it took for his.  By this, I mean that at the time my teracopy operation completed, his explorer copy window showed about 10% completion.
I know that this is extremely unscientific, but this simple test and my direct experiences with using teracopy on a day-to-day basis have led me to believe that it is FAR faster than windows explorer's copy behavior.

A: TeraCopy is not only a fast way of copying your files but a safe way as well. That's the primary reason I use it—I can count on it completing its job, or at least safely aborting, without damaging the file being moved or copied. The same can't be said of the still-unstable Windows shell, which just crashed on me yesterday, for example.

A: Yes it is for special purposes. If you want to pause your copy and so on, its really useful. (However I just use Total Commander at those times. >.>)


text:
Q: AWS CloudWatch Agent not starting I have an Ubuntu EC2 instance. I manually created the following basic CloudWatch Agent config file in:

/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json

{
    "metrics": {
        "metrics_collected": {
            "collectd": {},
            "mem": {
                "measurement": [
                    "used_percent",
                    "total"
                ]
            },
            "disk": {
                "measurement": [
                    "used_percent",
                    "total"
                ]
            }
        }
    }
}

I'm trying to start the CloudWatch Agent using the command below.
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a start

Then I check the status using the command below to confirm that it's running.
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status

But I get the output below that shows the Agent as being in a stopped status.
{
  "status": "stopped",
  "starttime": "",
  "version": "1.223987.0"
}

I checked the log file below.

/var/log/amazon/amazon-cloudwatch-agent

It contains:
2019/07/23 06:51:04 I! I! Detected the instance is EC2
2019/07/23 06:51:04 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
Valid Json input schema.
I! Detecting runasuser...
No csm configuration found.
No log configuration found.
No structuredlog configuration found.
Configuration validation first phase succeeded

2019/07/23 06:51:04 I! Config has been translated into TOML /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml
2019/07/23 06:51:04 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
2019/07/23 06:51:04 I! Detected runAsUser: root

What do I need to do get the CloudWatch Agent running?

A: The above solution didn't work for me:
yum update && yum install epel-release && yum install collectd

However, I used the following command and the epel and collectd were installed without a problem:
EPEL:
sudo amazon-linux-extras install epel -y

Collected:
sudo amazon-linux-extras install collectd -y

My Linux Distribution:
Amazon Linux 2( Elastic Beanstalk 64bit Amazon Linux 2 running Tomcat 8.5 Corretto 8)

A: For CentOS
yum update && yum install epel-release && yum install collectd

For Ubuntu
sudo apt-get update && sudo apt-get install collectd

A: sudo yum update
sudo amazon-linux-extras install epel
sudo yum install collectd
Worked for me


text:
Q: How do i make this script run faster <?php
header('Content-Type: text/html; charset=UTF-8');
$con    = mysqli_connect("localhost", "*******", "******", '*****');
$result = mysqli_query($con, "SELECT * FROM mybb_streams");
while ($row = mysqli_fetch_array($result)) {
    $json_array = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams/' . strtolower($row['channel']) . '?client_id=' . $clientId), true);
    if ($json_array['stream'] != NULL) {
        // turn them into variables to prevent outside SQL injection
        $displayname = mysqli_real_escape_string($con, $json_array['stream']['channel']['display_name']);
        $title       = mysqli_real_escape_string($con, $json_array['stream']['channel']['status']);
        $game        = mysqli_real_escape_string($con, $json_array['stream']['channel']['game']);
        $viewers     = mysqli_real_escape_string($con, $json_array['stream']['viewers']);
        $preview     = mysqli_real_escape_string($con, $json_array['stream']['preview']['medium']);
        $followers   = mysqli_real_escape_string($con, $json_array['stream']['channel']['followers']);
        mysqli_query($con, "SET NAMES utf8mb4");
        mysqli_query($con, "UPDATE mybb_streams SET `online` = '1', `title` = '$title', `viewers` = '$viewers', `game` = '$game', `preview` = '$preview', `followers` = '$followers' WHERE `channel` = '" . strtolower($row['channel']) . "'") or die("A MySQL error has occurred.
Your Query: UPDATE `streams` SET `online` = `1`, `title` = `$title`, `viewers` = `$viewers`, `game` = `$game`, `preview` = `$preview` WHERE channel = '" . strtolower($row['channel']) . "'
 Error: (" . mysqli_errno($con) . ") " . mysqli_error($con));
    } else {
        mysqli_query($con, "UPDATE mybb_streams SET `online` = '0', `viewers` = '0' WHERE `channel` = '" . strtolower($row['channel']) . "'") or die("A MySQL error has occurred.
Your Query: UPDATE streams SET `online` = '0', `viewers` = '0' WHERE `channel` = '" . strtolower($row['channel']) . "'
 Error: (" . mysqli_errno($con) . ") " . mysqli_error($con));
    }

}
?>

This is the code that I used to update my streams list on the database. Problem is, the database is getting bigger and bigger, and this code is starting to run slow + take up my bandwidth. This script automatically runs every 3 minutes, and sometimes it doesn't update. So any suggestions to this code? So it can run faster, and more efficiently?

A: I see 2 Problems :
1 database access
I think you should use mysqli_multi_query instead of doing one query by loop.
2 HTTP request -file_get_content-
You can make only one call using this
https://api.twitch.tv/kraken/streams/' . strtolower($row['channel']) . '?client_ids=' . implode(',',$array_clientId)

Like that you can get all the datas for all the ids at once.
then you parse the array into the loop.
try this --> https://api.twitch.tv/kraken/streams/?client_ids=2,3,4 Yes, it's working
$con    = mysqli_connect("localhost", "*******", "******", '*****');
$result = mysqli_query($con, "SELECT * FROM mybb_streams");
$array_ids;
while ($row = mysqli_fetch_array($result)) {
  $array_ids[] = $row;
}
$json_array = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams/' . strtolower($row['channel']) . '?client_ids=' . implode(',',$array_ids)), true);
foreach($json_array as $user){ /* do your stuff */}


text:
Q: Hiding an item from KendoUI DDL I am currently using KendoUI DropDownListfor and I am trying to hide an item from my options list.
I could do this with @Html.DropDownListFor with javascript using the following script:
$("#relationDDL").children('option[value="2"]').hide();

But when I wanted to change my dropdownlist to the KendoUI one I couldn't achieve that. I used multiple solutions posted in the forum and in How to modify KendoUI DropDownList items but no chance. How can I solve this?

A: I know this is a very old question but it may still be relevant today, so here's my solution:
Because the dropdown-items are stored in a seperate container you're be able to hide the items from there.
In your case the container element id is: #relationDDL_listbox.
From there it's easy.
Solution to hide specific option per index:
$('#relationDDL_listbox .k-item').eq(1).hide();

Solution to hide specific option per value:
First you need the the index of the value you want to hide so I wrote a simple function to get it:
//for modern browsers only
function getIndex(kendoDropDownList, value) {
    const index = kendoDropDownList.dataSource.options.data.findIndex(x => x.value == value);
    if (~index) return index;
    throw 'value not found in options';
}

//older browsers
function getIndex(kendoDropDownList, value) {
    var d = kendoDropDownList.dataSource.options.data;
    for(var i = d.length; i--;) {
        if (d[i].value == value) return i;
    }

    throw 'value not found in options';
}

var index = getIndex($('#relationDDL').data('kendoDropDownList'), '2'); //you may want to use 'const' instead of 'var' for modern browsers
$('#relationDDL_listbox .k-item').eq(index).hide();

I'm pretty sure there are a few more ways to get the same result...


text:
Q: Twitter Share extra text I'm building my own Twitter share link as explained here:
https://dev.twitter.com/docs/tweet-button#build-your-own
The URL that I'm sharing will look something like this sample URL:
https://twitter.com/intent/tweet?url=http://www.google.com&text=I%20just%20shared%20my%20link%20using%20@eckroth%20-%20Check%20it%20out:
My question:  How can I add text after the URL with some other information?  The URL param sticks itself at the very end of the share string:
"I just shared my link using @eckroth - Check it out: http://www.google.com"
I want it to be something like:
"I just shared my link using @eckroth - Check it out: http://www.google.com  -  Some other text here!"

A: Sorry, Joel, but you can't do that with the Web Intents API, which is what the sample URL you provided posts to.  Check this out:  https://dev.twitter.com/docs/intents.
If you scroll down to "Supported parameters", you'll see the description for the url parameter, which states that it will be shortened and "appended to the end of the tweet".  So we have no control over where the URL goes if we give it to Twitter to take care of.
That said, you could simply include the URL in the text, yourself.  Before Twitter made their own URL shortener, that's how we used to do it.  Pass it through http://bit.ly or similar and then include the resulting URL wherever you want to in the text.
Note - the way your self-shortened links will be rendered on-screen in the timeline may not carry the same authority as a URL you pass to Twitter, though, so you may want to do both.
Good luck!


text:
Q: Efficient way to get median of all subsets. Given a finite discrete set $X \subset \mathbb{R}$ with cardinality $k$.
The are $2^k$ subsets. For any given subset, there is a median associated with it (Define the median of $\emptyset$ as 0).
Wondering if there are any smart ways to get the $2^k$ medians.

A: The possible medians are:

*

*any of the $k$ values

*(if you define the median of an even-sized set as halfway between the two most central  values) any mean of two of the $k$ values

*$0$ for the empty set

That makes $k+{k \choose 2}+1 = \frac12k^2 +\frac12k+1$ potentially distinct values for subset medians and explains how to find them; it may turn out that there are some duplicates.


text:
Q: Junit: What is the best way to check which test is testing a function in Intellij? I am using IntelliJ community edition and I need to edit some application which was made in Java. In that application some functions are covered with tests.
What is the best way to figure out which test(s) is(are) covering some function?
Example: I have function called function1 and I need to find test which is covering that function.

A: Please try to use "Navigate | Test" action.


text:
Q: How to disable disallowadhocaccess in SQL Server 2008 I'm trying to get data from another database using the OPENDATASOURCE command, but I get an error about DisallowAdHocAccess.
The SQL Server version is 2008 Express Edition, running on a remote site.

A:
OPENROWSET can be used to access remote data from OLE DB data sources
  only if the DisallowAdhocAccess registry option is explicitly set to
  0. When this option is not set, the default behavior does not allow ad
  hoc access.

HOW TO: Use the DisallowAdHocAccess Setting to Control Access to Linked Servers
Accessing External Data

An ad hoc name is used for infrequent queries against OLE DB data
  sources that are not defined as linked servers. In SQL Server, the
  OPENROWSET and OPENDATASOURCE functions provide connection information
  for accessing data from OLE DB data sources.   By default, ad hoc
  names are not supported. The DisallowAdhocAccess provider option must
  be set to 0 and the Ad Hoc Distributed Queries advanced configuration
  option must be enabled.
Security Note
Enabling the use of ad hoc names means that any authenticated login to
  SQL Server can access the provider. SQL Server administrators should
  enable this feature only for highly trusted providers that are safe to
  be accessed by any local login.
OPENROWSET and OPENDATASOURCE should be used only to reference OLE DB
  data sources that are accessed infrequently. For any data sources that
  will be accessed more than several times, define a linked server.
  Neither OPENDATASOURCE nor OPENROWSET provide all the functionality of
  linked server definitions. This includes security management and the
  ability to query catalog information. Every time that these functions
  are called, all connection information, including passwords, must be
  provided.


text:
Q: On mobile, open facebook's sharer.php link to load the Facebook app instead of a new tab in the browser These two facebook and twitter share links work properly.

On mobile, twitter link opens the Twitter app, but for the facebook sharer, the browser (Safari) opens a new tab with the facebook login link. I want the same functionality as Twitter - clicking on the facebook sharer.php link should open the Facebook app. Can I control this via code on my HTML page ?


text:
Q: How to install angular 5? I have work to do in angular 5. But now angular 7 is already released, I am not sure how to install angular5 into my computer. Couple of months earlier I have been working in angular 6. Should I remove the current version installed ?
Can anybody tell me how to install angular5 and how to know if it's angular 5/6/7?

A: You can change the angular version and it's dependencies version in package.json to use v5 of the library.
Make sure you have compatible versions in dependencies list. Also you don't need to depend on angular-cli to develop your project
Also when your app runs, you can see angular version attached to your DOM (in the app component). Or you can open your Dev tool in browser and inspect the root node of DOM, there you will find ng-version information.
You can also run ng -v after doing npm install to see the versions of the angular and it's dependencies.

A: Angular cli 1.x creates Angular 5 project. Angular cli version 6 and 7 creates Angular 6 and 7 project respectively.
If you want to creates Angular 5 project from scratch, try this commands:
npm install -g @angular/cli@1
ng new my-project


text:
Q: UDP packets not sending? I have a simple C program that binds a socket so that it can
receive and send UDP packets.  It uses recvfrom to receive packets, and
shortly after receiving one, it constructs and sends a reply
packet, using sendto in the obvious way, sending to the same
address and port that recvfrom reported.
This program worked perfectly in initial testing, when the
packets were coming in and going out over a regular Ethernet
interface, eth0.  But now I'm trying to use it over a PPP
interface, ppp0, and for some reason it's not working.
sendto is not reporting any errors, but tcpdump is not showing
the packets going out.  (It is showing the packets coming in, so
I'm pretty sure tcpdump is working.)
And I have an existing program that's doing essentially the same
thing, but it works properly under all circumstances, on all
interfaces.  I haven't yet worked out how the existing program
might be setting up its sockets or its send/receive logic
differently, that allows it to work while my new, simpler program
fails.
Some of the packets are large (approaching MTU), but plenty
of them are small (<100 bytes), and none of them are getting
through, so I don't think it's an MTU problem.
Can anyone think of anything that would cause a sent packet to fail to
go out in this way?  (I'm not saying it has anything to do with ppp in particular; that it fails under ppp for me may be a coincidence, or it may be a key part of the problem.)
Sorry I can't post the actual code; it's at work and I'm at home.
The relevant part looks something like this:
struct sockaddr_in addr;
socklen_t addrlen = sizeof(addr);
char buf[1600];
int r, r2;

r = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &addrlen);

/* ... */

r2 = sendto(sock, buf2, n2, 0, (struct sockaddr *)&addr, addrlen);

(If you need to see a more complete example, I can post that tomorrow.)

A: If none of traffic works:
There could be routing problem. Check routing table of the host.
You can also check with tcpdump, that traffic is not going out via wrong interface. For example:
If you expect to see traffic in ppp0 by command:

tcpdump -i ppp0 udp port 123

And you don't see the wanted traffic, then check other interfaces by similar command to ensure that traffic does not go out via wrong interface:

tcpdump -i eth0 udp port 123

If part of traffic works:
If you are using some mobile network (often used via ppp0), then your uplink speed may be slower than downlink speed.
So a client may send more traffic to your server (via downlink), than uplink is capable to transfer.
Because UDP doesn't have such reliability and congestion/flow control like TCP have, UDP can discard some packets in overload situation.


text:
Q: Extract value from Python data dictionary column I have a DF with a column that is a dictionary:
import pandas as pd

data = [10,{'self': 'https://elia.atlassian.net/rest/api/3/customFieldOption/10200', 'value': 'IT-Sourced Changes 2022', 'id': '10200'},30]
df = pd.DataFrame(data, columns=['Data'])

How do I create a new column that selects only one value e.g. 'IT-Sourced Changes 2022'?
Thank you!

A: df['new_col']= df['requirement_source'].str['value']
Should get the job done


text:
Q: Adding object properties to another object in Powershell I'm trying to add the properties of the object $mailBox_MBS to the object $mailBox_RP.
I used the following code to define the objects:
$mailBox_MBS = (Get-MailboxStatistics -Identity $identity) | select *
$mailBox_RP = (Get-Recipient -Identity $identity) | select *

Then I used the following ForEach loop to add the properties from mailBox_MBS to mailBox_RP:
Foreach($property in $mailbox_MBS)
{
  $mailBox_RP | Add-Member -MemberType NoteProperty -Name $property.Name -Value $property.Value
}

A: You can't do it the way you're trying to do. Your foreach will only see a single object and you're only catching the name and value properties. What you want to do is actually iterate the properties of an object. Keep in mind that you might loose object complexity while doing this (implicit conversations to strings). Especially with Exchange this can be a problem.
You could either create a custom PSObject to just contain what you need or you'd need to look into using Get-Member to get the actual object Information. That might look like this.
$object | Get-Member -MemberType Property | %{ $object.$($_.Name); }

A: Let me know if this works for you:
$mailbox_MBS = Get-MailboxStatistics -Identity $identity
$mailbox_RP = Get-Recipient -Identity $identity

Get-Member -InputObject $mailbox_MBS -MemberType "*Property" | foreach {
    Add-Member -InputObject $mailbox_RP -Type "NoteProperty" -Name $_.Name -Value $mailbox_MBS.($_.Name)
}

A: I managed to convert the code above into a working function, with the help of Seth's comment and my best friend Google.
Function mailBoxInfo ($identity)
{
    $ExchangeDirectoryObject = New-Object PSObject
    $mailbox_MBS = (Get-MailboxStatistics -Identity $identity) | select *
    $mailbox_RP = (Get-Recipient -Identity $identity) | select *

$mailBox_MBS.psobject.Properties | % {
    $ExchangeDirectoryObject | Add-Member -MemberType $_.MemberType -Name $_.Name -Value $_.Value
}
$mailBox_RP.psobject.Properties | % {
    $ExchangeDirectoryObject | Add-Member -MemberType $_.MemberType -Name $_.Name -Value $_.Value
}

return $ExchangeDirectoryObject
}


text:
Q: How to nest nightwatch.js commands in page sections? I have a page pages/login.js looks like:
function fillAndSubmitLogin(email, password) {
  return this
  .waitForElementVisible('@emailInput')
  .setValue('@emailInput', email)
  .setValue('@passwordInput', password)
  .waitForElementVisible('@loginSubmitButton')
  .click('@loginSubmitButton');
}

export default {
  commands: [
    fillAndSubmitLogin
  ],
  elements: {
    emailInput: 'input#email',
    passwordInput: 'input[type=password]',
    TFAInput: 'input#token',
    loginSubmitButton: '.form-actions button.btn.btn-danger'
  }
};

I have another page pages/hompage.js homepage.js attempts to include pages/login.js as a section
import login from "./login.js";

module.exports = {
  url: 'http://localhost:2001',
  sections: {
    login: {
      selector: 'div.login-wrapper',
      ...login
    }
  }
};

I then have a test case that attempts to login on the hompage section
  'Homepage Users can login': (client) => {
    const homepage = client.page.homepage();
    homepage
    .navigate()
    .expect.section('@login').to.be.visible;

    const login = homepage.section.login;
    login
    .fillAndSubmitLogin('user@test.com', 'password');

    client.end();
  }

This test then fails with the following error
TypeError: login.fillAndSubmitLogin is not a function
       at Object.Homepage Users can login (/Users/kevzettler//frontend/test/nightwatch/specs/homepage.spec.js:32:6)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:182:7)

  login.fillAndSubmitLogin is not a function
       at Object.Homepage Users can login (/Users/kevzettler//frontend/test/nightwatch/specs/homepage.spec.js:32:6)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:182:7)

A: According to the Nightwatch docs, any commands that are exported in page objects should be plain JavaScript objects with a key being a command name and the value being a function.  For example:
var googleCommands = {
  submit: function() {
    this.api.pause(1000);
    return this.waitForElementVisible('@submitButton', 1000)
      .click('@submitButton')
      .waitForElementNotPresent('@submitButton');
  }
};

module.exports = {
  commands: [googleCommands],
  elements: //...etc ...
  // etc...
}

In this example, the module exports googleCommands, which is a command object which has a key (submit) and a corresponding function.  I believe you should refactor your code as follows:
function fillAndSubmitLogin = {
  fillAndSubmitLogin: function(email, password) {
    return this
    .waitForElementVisible('@emailInput')
    .setValue('@emailInput', email)
    .setValue('@passwordInput', password)
    .waitForElementVisible('@loginSubmitButton')
    .click('@loginSubmitButton');
  }
};

Of course, you don't have to make the command name the same in both places (as the example shows (googleCommands/submit).  This allows you to expose a variety of functions in one command.  Hope that answers the question!


text:
Q: How to merge pdf:s using Imagemagick (resolution problem) When I try to merge two .pdf files using Imagemagick
convert pdf1.pdf pdf2.pdf temp.pdf

the resulting temp.pdf file seems to have very low resolution. How can I keep the resolution same as in the source files?

A: If running linux you can also try poppler which provides pdfunite which concatenates without manipulating the resolution.

A: Barns's right, but if pdftk didn't work try ghostscript.
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=temp.pdf pdf1.pdf pdf2.pdf

A: If every file you want to merge is in the same folder:
convert -density 150 $(ls -rt *pdf) output.pdf

the argument -density 150 keeps the quality of the merged PDFs.

A: Imagemagick's convert command is normally used for converting image files from one format to another, and in this case, it is possible that it is actually performing an internal conversion of sorts before outputting the two "images" (PDFs) into a single file.
I would suggest you consider using the PDF Toolkit (pdftk) instead http://www.accesspdf.com/pdftk/
From the examples on the website, this should be as simple as:
pdftk pdf1.pdf pdf2.pdf cat output temp.pdf

A: I always forget how to do this and find this question first when I search.
convert -density 600 file1.pdf file2.pdf -resize 50% new.pdf

The linked example has the density at 144, however, that has never been high enough to not appear pixelated.
http://web.archive.org/web/20130311071316/http://studio.imagemagick.org/pipermail/magick-users/2009-September/022958.html

A: I couldn't find any way of joining two pdf files together while keeping the resolution good and the text intact, but I figured out a way to convert it into a high resolution png file.
pdftoppm -f 1 -l 1 -aa yes -aaVector yes -png -r 300 page.pdf > tmp1.png
pdftoppm -f 2 -l 2 -aa yes -aaVector yes -png -r 300 page.pdf > tmp2.png
convert tmp1.png tmp2.png +append -quality 100 page.png

This takes to first two pages of page.pdf and joins them into a side by side high resolution png file.
Changing the last line to
convert tmp1.png tmp2.png +append -quality 100 page.pdf

will result in a pdf document output as I later figured out after messing around with pngtopnm, pnmtops, ps2pdf.


text:
Q: TypeError: expected bytes, Descriptor found How do I fix the following error traceback regarding tf.record?
(tensorflow1) c:\tensorflow1\models\research\object_detection>python generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record --image_dir=(image directory)
Traceback (most recent call last):
  File "generate_tfrecord.py", line 17, in <module>
    import tensorflow as tf
  File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 15, in <module>
    from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
  File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\node_def_pb2.py", line 15, in <module>
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 15, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 15, in <module>
    from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
  File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 91, in <module>
    __module__ = 'tensorflow.core.framework.resource_handle_pb2'
TypeError: expected bytes, Descriptor found

A: Try this, worked for me
pip install protobuf-py3
pip install --upgrade protobuf

A: I get the same error when I installed tensorflow with conda install -c anaconda tensorflow-gpu over existing tenforflow.
Remove existing environment and create a new one. Then run conda install -c anaconda tensorflow-gpu .

A: Probably it's due to unmatched tensorflow and tensorboard versions.
I solved it after creating a separate conda environment for my code.

A: In my case,
pip install --ignore-installed --upgrade tensorflow-gpu==1.15.0
did the job :).


text:
Q: Why does booting Windows 7 take longer after adding a user account I am using my laptop for school, aswell as for work. In order to access certain network drives at work, i need to be part of a domain. Therefore, when im at work i login to the domain there. Ever since i've added this domain, booting into my normal user account takes considerably longer. Why is this? I used to be very content with the booting speed improvements switching to a ssd resulted in, but now this gain is completely nullified.

A: Your user profile could be in roaming. This means that your user files are downloaded from server during login.


text:
Q: where to place *further* , *considering further* As the closing sentence of a cover letter for an application I would like to write the sentence

I would appreciate your further considering my application and remain...

but is this correct, or should I rather place the word further differently?
The options are

*

*I would appreciate your considering my application further and remain...

*I would appreciate your considering further my application and remain...

Thank you in advance.

A: Since you said "ongoing", as an adjective, further could be used in the sense 'additional.'

The meeting ended without any plans for further discussions.

       I would appreciate your considering my application further....

In the same vein, you could use further in your sentence, however, in my opinion a better construction will be:

I would appreciate your further consideration of my application
  or
As @Joe states, 'I appreciate your consideration of my application
  Further discussion

A:
I would appreciate your further consideration of my application...

However, it still doesn't feel quite right to me but it's hard to be exact without knowing the process. So the following might be helpful (or might not!):

Thank you for my recent interview. I enclose my application for your further consideration as agreed.


text:
Q: Adding aria-label to dropdown using contact7 form plugin Am using contact7 plugin to design form for my client. I want to make it ADA compliant, somehow not able to add aria-label to dropdown boxes.
This is how my code looks in contact7 plugin
[select* companysize class:form-control "10-100" "101-500" "501-1000" "1001-2000"].
I can not add label as clients wants the label as invisible.

A: Since WordPress comes with jQuery bundled, you can either use jQuery or JS. Here are axamples of both. What you would have to do is find the class or id of the input field and change it in the below examples as well as the aria label value you desire. If you have multiple inputs, you would select them using their class and then add the attribute to them in the loop.
jQuery Example

jQuery(document).ready(function( $ ) {

  let $input = $( '#nameInput' );
  $input.attr( 'aria-label','aria-value' );

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="nameInput" />

JS Example

let inputField = document.getElementById( 'nameInput' );

inputField.setAttribute('aria-label','value of label');
<input id="nameInput" />


text:
Q: Super Regeneration Detector This is a circuit for a remote control toy receiver. Can someone help me understand this. Connecting the antennae to the collector makes no sense to me. RF is my weakness.
Datasheet where this came from is here, page 617.
http://www.bitsavers.org/components/samsung/1990_Samsung_Linear_IC_Vol_1_Audio_CDP.pdf

simulate this circuit – Schematic created using CircuitLab

A: A super-regenerative receiver is actually an oscillator that is arranged to be periodically stopped (or Quenched as it is called) then allowed to build up oscillations again.
The time taken for the oscillations to build up depends upon the signal (or noise) level in the circuit. When there is a signal present at the oscillation frequency the oscillations will start more quickly.
The time taken to start oscillation will affect the average current so by filtering this the modulation can be recovered.
They have extremely high gain and be sensitive to microvolts of signal but have rather broad bandwidth as well as radiating at the operating frequency.
Because they can get such high gains from a single active device they were popular when devices were expensive or for very low-cost applications where the limitations were acceptable. The main application until recently was for remote control of garage doors and toys. Garage door openers now use more sophisticated receivers. More stringent FCC requirements also restrict their use.
They were invented in the 1920's by Edwin Armstrong who also invented the Superhet receiver technique (super-sonic-heterodyne).
In the circuit shown Q1 is configured as an oscillator with the frequency set by L1 and C2 with feedback from c3 from collector to emitter.
Since there is a positive feedback loop the antenna can be connected either at the collector or emitter - most circuits I have seen connect it to the tuned circuit (L1/C2).
Oscillations build up from noise or the signal and cause a rectified version to appear at the base and emitter of the transistor charging up C4 modifying the bias of the transistor. At some point, the bias will be such that the oscillations will stop and C4 will discharge through resistors R2 and R3. Eventually, the oscillations will start again and the cycle will repeat typically at a few 10's or 100's of kilohertz (the quench frequency).
The average collector current is sensed with R4 causing a voltage that varies with the signal level although it also has a high level of the quench frequency. This is filtered by the resistors R5 and R6 and C7 and C8 leaving the modulation as an output.


text:
Q: Is there a way to correlate n arrays? I need to correlate n arrays that I have combined into a list which looks like:
array_corr = [array([a1]), array([a2]), array([a3]), .... array([an])]

corr_mat = np.corrcoef([array_corr])

But I am getting the error:

operands could not be broadcast together.

All arrays are the same size. I don't understand the source of error.
I expect the output to be an nxn matrix since there are n arrays.

A: Just make array_corr a pure numpy 2d-array and send it to np.corrcoef without brackets (you are creating a list with only one matrix element this way):
array_corr = np.array([
    [1,2,3,4,5],
    [1,6,3,3,5],
    [1,2,9,4,3],
    [2,1,3,8,5],
    [6,6,2,6,5],
])

corr_mat = np.corrcoef(array_corr)

corr_mat

returns:
array([[ 1.        ,  0.40555355,  0.30460385,  0.74074375, -0.18257419],
       [ 0.40555355,  1.        , -0.05764881, -0.11092108,  0.07404361],
       [ 0.30460385, -0.05764881,  1.        ,  0.16777868, -0.92688   ],
       [ 0.74074375, -0.11092108,  0.16777868,  1.        ,  0.1040313 ],
       [-0.18257419,  0.07404361, -0.92688   ,  0.1040313 ,  1.        ]])


text:
Q: Inform LINQ that a string represents a decimal and not a double value? I am using the following snippet:
var ws = string.Format(" it.{0} >= {1} && it.{0} <= {2} ", column, min, max)

as part of query.
"it" represents the record at hand.
I then use this string in a
Var result = AllRecords
        .Where(ws)
        .OrderBy(it.ProductName);

The problem I have, is that when the column type is Decimal the LINQ interprets the passed in string as double and fails by saying the types double and decimal are incompatible:

The argument types 'Edm.Decimal' and
  'Edm.Double' are incompatible for this
  operation. Near greater than or equals
  expression, line 8, column 12. where:
  (  it.Cost >= 70.5 && it.Cost <= 100 )
  orderby: it.ProductName

how can I ensure that LINQ will realize the string must be interpreted as decimal and not double?

A: Found it:
I need to suffix the string that contains a double with 'M', in my case:
var ws = string.Format(" it.{0} >= {1} && it.{0} <= {2} ", column, min+'M', max+'M');


text:
Q: Is there a quota limit for SoundCloud API? I have an android app using SoundCloud API. Some of my users complaining about connection issues. Is there a quota limit?

A: Yes, there is.
https://developers.soundcloud.com/docs/api/terms-of-use#quotas
But it doesn't tell us the exact number:

We reserve the right, at our discretion, to impose restrictions and
  limitations on the number and frequency of calls made by your app to
  the SoundCloud® API. You must not attempt to circumvent any
  restrictions or limitations that we impose.

As commented by Arsalan, here is more information:
https://developers.soundcloud.com/docs/api/rate-limits#errors

Rate Limits
All rate limits on the SoundCloud API are currently calculated against a client application's client id.
Global Rate Limit
We currently do not enforce any limit on the total number of calls made by a client application in aggregate.
Rate Limit on Play Requests
Effective July 1, all requests that result in access to a playable stream are subject to a limit of 15,000 requests per any 24-hour time window. Currently, this is inclusive of all requests that are made to /tracks/:id/stream.
After a previous time window has expired, a new time window starts from the first request made.
The majority of SoundCloud API rate limits are in the form of 24-hour time windows.

A: According Terms of Use, API calls are limited to 15,000 per app per day.

We reserve the right, at our discretion, to impose restrictions and limitations on the number and frequency of calls made by your app to the SoundCloud® API. You must not attempt to circumvent any restrictions or limitations that we impose. Presently, API calls are limited to 15,000 per app per day.

See https://developers.soundcloud.com/docs/api/terms-of-use#quotas


text:
Q: How to read text in Coded UI? In Coded UI, I have to confirm a particular text is present in text-box.
I am able to reach up to the dialog box and i know how to enter text. However. now i need to read text from the box.
Is there a WinApplication command that can help me to do so?

A: You can just read the text out in the same way that an assertion reads the text to check its value. One way of learning how to do this on any control is to use the Coded UI recorder to create an assertion method on the text shown and copy its code. Commonly the assertion will be on the DisplayText field. In fact that is a neat way of getting the relevant UI Controls created for you.
The method created  for the assertion (in the UIMap.Designed.cs file) will be similar to:
public void AssertMethod1()
{
    SomeUIType uITTextItem = this.UISomeWindow.UISomewhere.UITextItem;
    Assert.AreEqual(this.AssertMethod1ExpectedValues.UITextItemDisplayText,
                    uITextItem.DisplayText,
                    "A message for a failed assertion");
}

Just copy the whole method into the UIMap.cs file, use the commend in the UI Map editor. Then save all the files.
Edit the method that is now in the UIMap.cs file to something like the following:
public string GetTheUITextItem()
{
    SomeUIType uITTextItem = this.UISomeWindow.UISomewhere.UITextItem;
    return this.AssertMethod1ExpectedValues.UITextItemDisplayText;
}

Now the contents of the test can be obtained by calling GetTheUITextItem().


text:
Q: Change Orientation while converting android handset app to tablet I am converting and android handset application to tablet (1024*600 and 1280*720). I have given the support for different screen- size, but stuck in orientation part. I want some pages  to be visible as landscape. For example after logged in by user the next intent should be in landscape form. After searching I found clue but not very understandable answer such as

*

*By adding activity in manifest.xml file

*At runtime by using getOrientation().
Thanks

A: The question is not clear, if you're forcing screen orientation by size (e.g. on tablet device there's only landscape orientation), i think you should get the screen width and height first then evaluate it. If the screen width and height are 1024*600 or 1280*720, you change the orientation with setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
To get the width and height, do this in your activity:
Display display = getWindowManager().getDefaultDisplay();
int width, height;
try {
    Point size = new Point();
    display.getSize(size);
    width = size.x;
    height = size.y;
}
catch (NoSuchMethodError e) {
    width = display.getWidth();
    height = display.getHeight();
}

See this


text:
Q: Finding nearest value in a numpy array produces nan output I have a list. I want to find the value closest to a given number. Everything is working fine. But the problem is, it produces nan output for two unique numbers. Here I am providing my complete data
My code and output:
#### Find the index of nearest value in a array
def find_nearest(array, value):
    array = np.asarray(array)
    idx = (np.abs(array - value)).argmin()
    return array[idx] #for returing nearest value

r = [0.209272  , 0.172816  , 0.1297975 , 0.0777895 , 0.008605  ,
          np.nan,        np.nan,        np.nan,        np.nan,        np.nan]

rc = 0.38420566666666667
rse_ed = find_nearest(r,0.01) ### close to 0.01 is 0.008605
rse_st = find_nearest(r,rc*0.4) #### close to 0.15368226666666668 is 0.172816
print(rse_st,rse_ed)
nan,nan  ###

Expected output:
print(rse_st,rse_ed)
0.172816,0.008605

A: Use nanargmin:
def find_nearest(array, value):
    array = np.asarray(array)
    idx = np.nanargmin(np.abs(array - value))
    return array[idx]


text:
Q: How can I remove the old kernels I have upgraded my OS version a few times. What is the best way to remove the old kernels and free space?

A: Having extra kernels take space up.  You can look for your old kernels manually in the /usr/src folder.  However, the following command can remove the linux kernels quickly and easily.
From a Terminal window, type in:
dpkg -l 'linux-*' | \
   sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | \
   xargs sudo apt-get purge

The above line should only be used if you know that your present kernel is working the way you want it and any other kernels you are not concerned about.  This will remove all kernels but the current active one that is running on your system.  It will remove even newer kernels if you are booted to an older kernel.


text:
Q: Nonpiecewise Function Defined at a Point but Not Continuous There I make a big fuss that my calculus students provide a "continuity argument" to evaluate limits such as $\lim_{x \rightarrow 0} 2x + 1$, by which I mean they should tell me that $2x+1$ is a polynomial, polynomials are continuous on $(-\infty, \infty)$, and therefore $\lim_{x \rightarrow 0} 2x + 1 = 2 \cdot 0 + 1 = 1$.
All the examples they encounter where it is not correct to simply evaluate at $a$ when $x \rightarrow a$ fall into one of two categories:

*

*The function is not defined at $a$.

*The function is piecewise and expressly constructed to have a discontinuity at $a$.

I'd like to find a function $f$ with the following properties:

*

*$f(a)$ exists

*$f(a)$ is not (obviously) piecewise defined

*$f(x)$ is not continuous at $a$

*$f$ is reasonably familiar to a Calculus I student - trigonometry would be admissible, but power series would not (though they might
  still make for interesting reading)

A: A very easy way to construct a function that is piecewise without being "obviously piecewise" is functions defined in terms of limits:
$$f(x) = \lim_{a \to +\infty} \exp\left(-ax^2\right) = \begin{cases}1, & x = 0 \\ 0, & \text{otherwise}\end{cases}$$
This example has the advantage of being easily-comprehensible to beginning calculus students.

A: How about
$$ f(x) = \sup \bigl( \mathbb Z\cap (-\infty,x)\bigr) = \lceil x\rceil -1$$
or
$$ g(x) = \lim_{n\to\infty} \tan^{-1}(nx) = \begin{cases}\pi/2 & x>0 \\ 0 & x=0 \\ -\pi/2 & x< 0 \end{cases} $$
or
$$ h(x) = \limsup_{n\to\infty} \sin(nx\pi) = \begin{cases}0 & x \in \mathbb Z \\ 1 & x \notin \mathbb Q \\ \in(0,1] & \text{elsewhere} \end{cases}$$
or
$$ k(x) = \lim_{y\to+\infty} \frac1y \int_0^y \cos(xt) \, dt =
\begin{cases} 1 & x=0 \\ 0 & x\ne 0 \end{cases}$$
or
$$ g(x) = \int_0^\infty \frac{x}{1+(xt)^2} \,dt =
\begin{cases} \pi/2 & x > 0 \\ 0 & x=0 \\ -\pi/2 & x<0 \end{cases}$$

A: This problem relates to issues discussed by Weyl and embodied in the work of Brouwer on Intuistionist Mathematics. Here is a discussion:
http://www.alternatievewiskunde.nl/QED/brouwer.htm
Weyl stated "Above all, however, there can be no other functions at all on a continuum than continuous functions." After pointing out the absence of discontinuous functions on R, Weyl went on to say that: "When the old analysis allowed the formation of discontinuous functions, it thereby showed most clearly how far it is from grasping the essence of the continuum. What one calls nowadays a discontinuous function, consists in fact (and this also is basically a return to older intuitions) of a number of functions on separated continua."
Brouwer proved, in Intuitionist Mathematics, that a totally defined function on an interval is continuous.

A: You can define $f_n(x)=x^n$ on $[0,1]$, and $f(x)=\lim_{n\to\infty} f_n(x)$. Then the discontinuity of $f$ at $1$ is a little tricky, as all the $f_n$ are continuous.

A: As I stare at a cube-shaped building whose side has length 100 meters, while walking westward parallel to its north wall at a location 100 meters north of the building, the distance to farthest point from me that I can see on the face of the building varies as my position changes. As I cross the line of the western wall, I can suddenly see the southwest corner of the buidling, so that distance as a function of my position has a jump discontinuity that arises naturally from geometry.

A: There's always $[x]$, and $\chi_S(x)$ for any proper subset $S$ of $\mathbb{R}$.

A: This is an interesting case showing why mathematicians should understand non-standard math like constructive math, even when we don't "believe it." It still helps us understand things about standard math.
There's a very deep reason why all the basic discontinuous functions are defined piecewise, or as limits.
It is known that in constructive mathematics, all functions are continuous.
But wait, you ask, what about simple piece-wise function such as:
$$f(x)=\begin{cases}0&x<0\\
1&x\geq 0\end{cases}?$$
I mean, that looks constructive, but it is discontinuous.
It turns out $f$ is not constructive. That's because the test of whether $x<0$ is not computable. There is no computer program which takes a (computable) real number and returns whether that number is negative.
A computable real number is, roughly, a computer program which produces a Cauchy sequence of rational numbers (and the ability to have some idea how fast it converges.)
If $x=(x_n)$ and $y=(y_n)$ are computable real numbers, we define $x<y$ for such real numbers easily enough: $x<y$ if there exists a proof that $x_n<y_n$ for all but possibly finitely many $n.$
We define $x=y$ if we can prove that $x_n-y_n\to 0.$
Under this definition, there are real numbers that are not comparable. We simply can't tell if $x<y, x=y,$ or $x>y$ for some values $x,y.$
Why?
If there was a program that solved the general order problem for computable real numbers,  you could solve the halting problem (by taking a program $P$ and producing the computable sequence
$$x_n=\begin{cases}0&\text{if $P$ does not halt by step $n$}\\
\frac{1}{N}&\text{if $P$ stops at step $N$ and $n\geq N$}
\end{cases}$$
This is computably Cauchy - that is, given a rational $\epsilon>0$ we can compute an $M$ such that $|x_n-x_m|<\epsilon$ for $n,m\geq M.$)
(That is why we choose $\frac{1}{N}$ and not a constant.) The sequence converges to $0$ if the program doesn't halt, or $\frac{1}{N}.$
So if we could solve the whether $x=0$ or $x>0,$ we'd have a solution to the halting poblem.
This is why all the cases of discontinuous functions rely in either cases, or other non-constructive techniques, like point-wise limits of functions.

Note that some piecewise functions can be computed, but only if they are continuous. For example, if $x=(x_n)$ then $|x|=(|x_n|).$ That might seem circular, but the $|x_n|$ is the rational absolute value function, which is computable. Rational piecewise functions are computable (if the pieces are computable in the rationals.)

A: Note: I realize that this may not be the droid your looking for, but it is a droid.
I think that this depends on what one means by a piecewise defined function. I will take a stab at that question first. So let us start with a base set of functions (we may let the domain and codomain vary But insist that both be subsets of some big set, like $\mathbb{R}$) , which we will call $\mathcal{F}$. Then we will also have a set $\mathcal{O}$ which will be a set of operations (these operations [these operations may be partially defined] will typically be functions of the form $\mathcal{F}^n\to \mathcal{F}$, for varying $n$. We may then define $\widehat{\mathcal{F}}$ to be the smallest set of functions such that if $g:\mathcal{F}^n\to\mathcal{F}$ is in $\mathcal{O}$ and $$f_1,f_2,\cdots f_n\in\widehat{\mathcal{F}}$$ then $$g(f_1,f_2,\cdots f_n)\in\widehat{\mathcal{F}}.$$ We may then say that $\widehat{\mathcal{F}}$ is the set of functions (fully) defined by the pair $(\mathcal{F},\mathcal{O})$. Any function not in $\widehat{\mathcal{F}}$ may be defined in a piecewise manner (one piece for each point, provided we have all constant functions).
The question now is what are your sets, $(\mathcal{F},\mathcal{O})$. I would let the set $\mathcal{F}$ be the set
$$\{(x\mapsto any-constant),\mbox{   } (x\mapsto x),\mbox{   }  (x\mapsto\sin x), \mbox{   }\\(x\mapsto e^x), \mbox{   }(x\mapsto \ln x)),\mbox{   }(x\mapsto \sin^{-1}x),\mbox{   }(x\mapsto \cos^{-1}x), \mbox{ other inverse trigs},\mbox{   }(x\mapsto\sqrt[n]{x}) \}$$ (one may add to this or take away at will).
Now the set $\mathcal{O}$ of operations is the following: $$\{(f,g\mapsto f+g), (f,g\mapsto fg),(f\mapsto\frac{1}{f}), (f,g\mapsto f\circ g) ,(f,g\mapsto f^g)\}$$ (the last rule could be tricky for negative values). Now given all of this the piece wise defined functions that you wanted to exclude such as $|x|$ cannot be excluded. Indeed, it may be the case that we can get all kinds of piecewise defined functions this way. If we add to our operations the ability to take certain point-wise limits we may obtain even more piece-wise defined functions.

A: What about a derivative? Something like  $\left(x^2 \sin \frac 1 x\right)'$. You  have to extend the function to say $f(0)=0$, as it is not defined there, but they'll have to extend the derivative, which cannot be computed with the formula at $x=0$.
I also remember a limit I was given in my last calculus exam:
$$ \lim_{m \to \infty} \lim_{n \to \infty}  (\cos^2 (m! x))^n $$
(Zero for the rational numbers, 1 for the irrational ones)

A: An interesting example of "natural discontinuity" that I know, is easy to absorb on any level and it comes from classical textbooks. It requires some basic imagination, however.
Textbooks usually start from defining the function, and then ask a student to prove some technical stuff about it. I prefer to start from the other way around.
Consider $(x,y,z)$-space. Take both $x$- and $y$- axes and exclude the origin. We want our function to go through them, so that whenever $x$ or $y$ equals $0$, $z$ equals $0$ as well.
Now, consider the diagonals $x+y=0$ and $x-y=0$ lifted above $(x,y)$-plane to $z=1$, and exclude the lifted origin $(0,0,1)$ from this construction. What happens if we want our continuous everywhere except for the origin function to go through these lines as well?
To help imagine that. A bisection by any vertical plane $y=c\neq0$ should be a continuous M-shaped function going through $(x,z)=(0,0)$ as well as $(x,z)=(\pm c,1)$. The closer is $c$ to $0$, the closer are the last two points to each other. Similarly, with bisection by any vertical $x$-plane.
When you move to origin from north, east, south or west along $x=0$ or $y=0$ you are always at the bottom of this "canyon" at sea-level height of $z=0$. However, when you are on one of the two diagonals moving, for example, from north-east, you are always on top of the range at height $z=1$.
Interestingly enough, such a function can be easily defined, for example, as follows: $$\frac{x^2y^2}{x^4+y^4},(x,y)\in\mathbb{R}-\{(0,0)\}$$
Now, without specifying the value at $(0,0)$ what should it be? Depending on what direction you are coming from, it can be any value within the whole interval. But in any case it will remain discontinuous.


text:
Q: PHP fputcsv with UTF-8 Problem I'm trying to allow my clients view some of the MySQL data in Excel. I have used PHP's fputcsv() function, like:
public function generate() {
   setlocale(LC_ALL, 'ko_KR.UTF8');

   $this->filename = date("YmdHis");
   $create = $this->directory."Report".$this->filename.".csv";

   $f = fopen("$create","w") or die("can't open file");
   fwrite($f, "\xEF\xBB\xBF");

   $i = 1;
   $length = count($this->inputarray[0]);

   fwrite($f, $this->headers."\n");

   // print column titles
   foreach($this->inputarray[0] as $key=>$value) {
    $delimiter = ($i == $length) ? "\n\n" : ",";
    fwrite($f, $key.$delimiter);
    $i++;
   }

   // print actual rows
   foreach($this->inputarray as $row) {
    fputcsv($f, $row);
   }
   fclose($f);
  }

My clients are Korean, and a good chunk of the MySQL database contains values in utf8_unicode_ci. By using the above function, I successfully generated a CSV file with correctly encoded data that opens fine in Excel on my machine (Win7 in English), but when I opened the file in Excel on the client computer (Win7 in Korean), the characters were broken again. I tried taking the header (\xEF\xBB\xBF) out, and commenting out the setlocale, to no avail.
Can you help me figure this out?

A: If, as you say, your CSV file has "correctly encoded data" - i.e. that it contains a valid UTF-8 byte stream, and assuming that the byte stream of the file on your client's site is the same (e.g. has not been corrupted in transit by a file transfer problem) then it sounds like the issue Excel on the client's machine not correctly interpreting the UTF-8.  This might be because it's not supported or that some option needs to be selected when importing to indicate the encoding.  As such, you might try producing your file in a different encoding (using mb_convert_encoding or iconv).
If you get your client to export a CSV containing Korean characters then you'll be able to take a look at that file and determine the encoding that is being produced.  You should then try using that encoding.

A: Try encoding the data as UTF-16LE, and ensure that the file has the appropriate BOM.
Alternatively, send your clients an Excel file rather than a CSV, then the encoding shouldn't be a problem

A: Try wrapping the text in each fwrite call with utf8_encode.
Then use what is suggested here: http://www.php.net/manual/en/function.fwrite.php#69566


text:
Q: jquery ajax store canvas in folder/on server I have a question regarding this code snippet:
function upload(){
<!-- grab our drawing data from our myCanvas -->
var myDrawing = document.getElementById("requiem");
<!-- start our datastring -->
var drawingString = myDrawing.toDataURL("image/png");
var postData = "canvasData="+drawingString;
var ajax = new XMLHttpRequest();
<!-- specify our php processing page -->
ajax.open("POST",'saveImage.php',true);
<!-- set the mime type so the image goes through as base64 -->
ajax.setRequestHeader('Content-Type', 'canvas/upload');
ajax.onreadystatechange=function(){
     <!-- once the image data has been sent call a simple alert -->
         if (ajax.readyState == 4){
             alert("image saved");
         }
}
    ajax.send(postData);
}

When I call the function upload() within jquery nothing happens.
I get the popup message indicating that the picture was successfully stored but it is not.
I was wondering if maybe the code needs to be rewritten to fit updated libraries?
I think it is quite old?
Thank you!


text:
Q: jQuery ajaxComplete callback execution order Is there a way to get the ajaxComplete callback to be called prior to the individual ajax request callbacks?  I want ajaxComplete to be called prior to any of the success callbacks on an ajax request.
EDIT:  Added psuedo-code.
$(document).ajaxComplete(function(_e, xhr, _settings) {
    alert("This happens after the callbacks for any particular ajax request, but I want it to be executed first");
});

$.ajax("/my-test-endpoint", {
    success: function(data) {
        alert("I happen before the ajaxComplete callback");
    }
});


text: Q: How to create an .exe file for my flash application I've created a game which will load some data onto the frames from an xml file. Now, I want to create an .exe file for my game which is developed using adobe cs6 so that I need not copy the xml file and swf file every time. Thank you


text:
Q: Undefined variable in Laravel Blade view I am trying to create a blade view so that I can see the comments from a particular post in my app, but I am getting an undefined variable error:

ErrorException in a11883d0293a033eba2997ec69df8cdf4ea6a835.php line 9:
  Undefined variable: comment (View:
  C:\xampp\htdocs\directory\resources\views\admin\comments\show.blade.php)

I am new to learning Laravel and apologize if this has been answered before but I have been unable to resolve the issue through research on this site thus far. Thank you!
show.blade.php

@extends('layouts.admin')

@section('content')
    @if($comment)

Comments

                id
                Author
                Email
                Body

                {{$comment->id}}
                {{$comment->author}}
                {{$comment->email}}
                {{$comment->body}}
                post->id)}}">View Post

                    @if($comment->is_active === 1)
                        {!! Form::open(['method'=>'PATCH','action'=> ['PostCommentsController@update', $comment->id]]) !!}
                        <input type="hidden" name="is_active" value="0">

                            {!! Form::submit('Un-approve', ['class'=>'btn btn-info']) !!}

                        {!! Form::close() !!}
                    @else
                        {!! Form::open(['method'=>'PATCH','action'=> ['PostCommentsController@update', $comment->id]]) !!}
                        <input type="hidden" name="is_active" value="1">

                            {!! Form::submit('Approve', ['class'=>'btn btn-success']) !!}

                        {!! Form::close() !!}
                    @endif

                    {!! Form::open(['method'=>'DELETE','action'=> ['PostCommentsController@destroy', $comment->id]]) !!}

                        {!! Form::submit('Delete', ['class'=>'btn btn-danger']) !!}

                    {!! Form::close() !!}

    @else

No Comments

    @endif
@endsection

PostCommentsController.php
namespace App\Http\Controllers;

use App\Comment;
use App\Post;
use Illuminate\Http\Request;

use App\Http\Requests;
use Illuminate\Support\Facades\Auth;

class PostCommentsController extends Controller
{
    public function index()
    {
        $comments = Comment::all();

        return view('admin.comments.index', compact('comments'));
    }

    public function store(Request $request)
    {
        $user = Auth::user();

        $data = [
            'post_id' => $request->post_id,
            'author' => $user->name,
            'email' => $user->email,
            'photo' => $user->photo->file,
            'body' => $request->body
        ];

        Comment::create($data);

        $request->session()->flash('comment_message', 'Your message has been submitted and is waiting moderation');

        return redirect()->back();
    }

    public function show($id)
    {
        $post = Post::findOrFail($id);

        $comments = $post->comments;

        return view('admin.comments.show', compact('comments'));
    }

    public function update(Request $request, $id)
    {
        Comment::findOrFail($id)->update($request->all());

        return redirect('/admin/comments');
    }

    public function destroy($id)
    {
        Comment::findOrFail($id)->delete();

        return redirect()->back();
    }
}

Comment.php Model
namespace App;

use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    protected $fillable = [
        'post_id',
        'author',
        'email',
        'body',
        'is_active'
    ];

    public function replies()
    {
        return $this->hasMany('App\CommentReply');
    }

    public function post()
    {
        return $this->belongsTo('App\Post');
    }
}

A: What you are missing is iterating over the $comments that you have passed to the view.
So try replacing your
 content with the following:
@foreach($comments as $comment)

    {{$comment->id}}
    {{$comment->author}}
    {{$comment->email}}
    {{$comment->body}}
    post->id)}}">View Post

        @if($comment->is_active == 1)
        {!! Form::open(['method'=>'PATCH','action'=> ['PostCommentsController@update', $comment->id]]) !!}
        <input type="hidden" name="is_active" value="0">

           {!! Form::submit('Un-approve', ['class'=>'btn btn-info']) !!}

        {!! Form::close() !!}

        @else

      {!! Form::open(['method'=>'PATCH','action'=> ['PostCommentsController@update', $comment->id]]) !!}

     <input type="hidden" name="is_active" value="1">

       {!! Form::submit('Approve', ['class'=>'btn btn-success']) !!}

     {!! Form::close() !!}
    @endif

  {!! Form::open(['method'=>'DELETE','action'=> ['PostCommentsController@destroy', $comment->id]]) !!}

    {!! Form::submit('Delete', ['class'=>'btn btn-danger']) !!}

          {!! Form::close() !!}

@endforeach

And at the top, replace the @if with
@if($comments->count())


text:
Q: How do I get a versioned asset URL in a Sass stylesheet? In a view, I'm able to use the following code to get the versioned asset URL. How can I achieve this inside of a Sass stylesheet file? I'm effectively looking for the equivalent of Rails' image-url but can't seem to find the same function for the Play Framework (version 2.5).
@routes.Assets.versioned("images/favicon.png")


text:
Q: How do I disable the border on bootstrap 4 cards A grey outline keeps appearing on the img section of my bootstrap card, which I would like to remove.

PPE

PPE is equipment that will protect the user against health or safety risks at work...

                                SHOP NOW

A: If you check the .card class has a border: 1px solid #e5e5e5;
To remove it simply override it to border: none;

A: simply, you can make the border zero,

A: There are border utilities that can help with this. From the link:

Subtractive

So for your scenario, since you want to remove all borders you would add the border-0 CSS Class to your card like so:

A: It's better to play with the bootstrap variables. You can customize default cards style with these variables and it won't override Bootstrap CSS. You can check on here how to do this.
Bootstrap theming
// Cards

$card-spacer-y:                     .75rem !default;
$card-spacer-x:                     1.25rem !default;
$card-border-width:                 $border-width !default;
$card-border-radius:                $border-radius !default;
$card-border-color:                 rgba($black, .125) !default;
$card-inner-border-radius:          subtract($card-border-radius, $card-border-width) !default;
$card-cap-bg:                       rgba($black, .03) !default;
$card-cap-color:                    null !default;
$card-height:                       null !default;
$card-color:                        null !default;
$card-bg:                           $white !default;
$card-img-overlay-padding:          1.25rem !default;
$card-group-margin:                 $grid-gutter-width / 2 !default;
$card-deck-margin:                  $card-group-margin !default;
$card-columns-count:                3 !default;
$card-columns-gap:                  1.25rem !default;
$card-columns-margin:               $card-spacer-y !default;