text:
Q: In C# i have a issue with List from returned string I am receiving from the database a single string with this content

One;Two;Three

and I want to store those values in the reportTypeCodes property in the following class.
public class ReportTypeCode
{
    public string codeValue { get; set; }
}

public class Root
{
    public string name { get; set; }
    public DateTime creationDateTime { get; set; }
    public List<ReportTypeCode> reportTypeCodes { get; set; }
}

This is my current attempt:
Var Obj = new Root(){
           name="Test",
           creationDateTime=Convert.ToDateTime("2021-11-08),
           reportTypeCodes=?? // Don't know how to assign it.
    }

How can I do it?

A: First you want to take your string and split it on every ';' character. To do this, use Value.Split(';').
Then you want to take each section and turn it into a ReportTypeCode. To do this, you can use the LINQ method Select like so: .Select(s => new ReportTypeCode { codeValue = s }).
Finally, you want to get a list, so you need to call .ToList() (it is another LINQ method).
All put together:
Value.Split(';').Select(s => new ReportTypeCode { codeValue = s }).ToList()

A: With the help of System.Linq you can do it quite easy, see below^^
using System.Linq;

new Root()
{
     name="Test",
     creationDateTime=Convert.ToDateTime("2021-11-08"),
     reportTypeCodes= "One;Two;Three"
           .Split(';')
           .Select(x => new ReportTypeCode(){codeValue = x})
           .ToList()
}

A: You can write it in the following way:
var Obj = new Root()
{
    name = "Test",
    creationDateTime = Convert.ToDateTime("2021-11-08"),
   reportTypeCodes = new List<ReportTypeCode>(){
        new ReportTypeCode(){ codeValue = "one"},
        new ReportTypeCode(){ codeValue = "two" }
   }
};

A: Depends a bit on what you want to do...
        var rootTest = new Root();

        rootTest.reportTypeCodes = new List<ReportTypeCode>()
        {
            new ReportTypeCode()
            {
                codeValue = "hello world"
            },
            new ReportTypeCode()
            {
                codeValue = "hello world 2"
            },
        };

        foreach(var code in rootTest.reportTypeCodes)
        {
            Console.WriteLine(code.codeValue);
        }

A: I think you're looking for this:
Var Obj = new root(){
           name="Test",
           creationDateTime=Convert.ToDateTime("2021-11-08),
           reportTypeCodes= new List<ReportTypeCode>{
               new ReportTypeCode { codeValue = "A"; },
               new ReportTypeCode { codeValue = "B"; }
           }
    }


text:
Q: Are there nonlinear differentiable functions that are positively homogeneous of order 1? A function $f:\mathbb{R}\rightarrow \mathbb{R}$ is positively homogeneous of order 1 if $f(tx) = tf(x) \quad \forall t>0$.
For instance, $f_{\alpha}(x) = \alpha x$ is a positively homogeneous funnction for every $\alpha \in \mathbb{R}$, however all such functions are linear.
Other example is $f(x)=|x|$. $f$ is not linear but also is not differentiable.
Are there any examples of $f:\mathbb{R} \rightarrow\mathbb{R}$ that are positively homogeneous of order 1 and differentiable but not linear? Or can one prove that this cannot exist?

A: No, on both $(-\infty,0)$ and $(0,\infty)$ such functions are given by mappings of the form $x\mapsto\alpha x$. If now the right- and the left-derivative must coincide, the $\alpha$'s on both branches must coincide, implying that such $f$ is already linear.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why is it bad to restrict AngularJS directive to class? We've been avoiding to restrict Angularjs directives to classes. Mostly because we found some sources which advised against it (including John Papas opinionated styleguide). At the same time we've been avoiding restricting it to elements since it would be in conflict with the W3C standards. (We're purists like that).
So, all we've been using is the restrict to attribute (no, we're not going to talk about the comment method). Which works fine in most cases but seems too loose when deploying a concrete object. E.G. A sidebar. This as well as that the replace: true option will be deprecated, made me wonder why not use the restrict to class anyway. It seems to make sense:

In comparison to:

It plays nicely with our CSS files as well. With some research we found some people advise against it. But the main reasons why not are not very clear. So my question actually is: What are the pitfalls of using restrict: 'C'

A: There are a few reasons why restrict: 'E' is generally considered best practice for directives with templates (called 'components' in Angular 2, and encouraged by the new component directive in Angular 1). The reasons are really just about readability and consistency, but I think they are convincing nonetheless.
The main reason is precisely because it conflicts with W3C standards. According to the standards, elements may not contain separate words delimited by a dash. AngularJS encourages developers to use a dash somewhere in the directive name. So, when you see an element with a dash in it, you immediately know it is an Angular directive rather than a standard HTML element. Thus, using restrict: 'E' ends up being more readable and expressive.
Now, for directives without templates (plain old 'directives' in Angular 2), restrict: 'A' is generally preferred. Most HTML attributes do not contain a dash, although there is nothing in the W3C standard that says they can't. The main reason seems to be that they confer a behavior on the element, rather than simply applying a visual style, as do many HTML attributes (e.g. onclick). Furthermore, if the directive takes inputs, you will probably bind the inputs through custom attributes, like so: . This, on the other hand, seems quite confusing: .
Finally, perhaps the main reason to go with the flow on this is that they are enforced in Angular 2. Inevitably, Angular 2 will be the next big thing, and Angular 1 has been moving in a more Angular-2-ish direction anyway (e.g. with the component directive). Be prepared...


text:
Q: How to make space in between two TextView when load in ListView adapter ,y TextView overlap another TextView which display time see this url http://imgur.com/66LWeBM how to add space in between two TextView. I'm showing this TextView in ListView adapter
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="40dp" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="message"
        android:id="@+id/msgDatatextview"
        android:layout_marginLeft="15dp"
        android:paddingRight="10dp"
        android:textSize="20sp"
        android:layout_marginBottom="30dp"
        android:layout_alignParentLeft="true"
        android:textColor="#0000ff" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/msgDatatextview3"
        android:layout_marginLeft="5dp"
        android:textSize="20sp"
        android:layout_marginBottom="30dp"
        android:layout_marginRight="3dp"
        android:layout_alignParentRight="true"
        android:textColor="#0000ff" />

</RelativeLayout>

A: try adding android:layout_toRightOf="@id/msgDatatextview" attribute to msgDatatextview3

A: You can simply add line android:layout_toRightOf="@id/msgDatatextview" to your second TextView.

A: Check your layout params, change to linear layout or check this tutorial for relative layout :
Relative layout
I think you missed params  android:layout_toLeftOf or android:layout_toRightOf


text:
Q: Edit an existing PDF template with parallax / jsPDF How can I load an existing PDF document as jsPDF object and edit using JavaScript library called parallax / jsPDF which is the top popular JavaScript library for generating PDFs as the time I'm writing this.

I am using the version 2.5.1 the latest as of now.

I searched everywhere and finally I got the answer, wasting too much
time. So I decided to put it here so that anyone can refer it faster.

A: As at now(28/12/2022) "JsPdf do not have that functionality and probably will never be able to parse existing PDF files. It would mean a major rewrite of its fundamental architecture." as its contributes states here.

There are other libraries support the same functionality like pdf-lib. I extracted the following from their GitHub page.
pdf-lib was created to address the JavaScript ecosystem's lack of robust support for PDF manipulation (especially for PDF modification).
Two of pdf-lib's distinguishing features are:

*

*Supporting modification (editing) of existing documents.

*Working in all JavaScript environments - not just in Node or the Browser.
There are other good open source JavaScript PDF libraries available. However, most of them can only create documents, they cannot modify existing ones. And many of them only work in particular environments.
UMD Module
You can also download pdf-lib as a UMD module from unpkg or jsDelivr. The UMD builds have been compiled to ES5, so they should work in any modern browser. UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the  tag of an HTML page.

*

*https://unpkg.com/pdf-lib/dist/pdf-lib.js

*https://unpkg.com/pdf-lib/dist/pdf-lib.min.js

*https://unpkg.com/pdf-lib/dist/pdf-lib.min.js

*https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.js

*https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.min.js

NOTE: if you are using the CDN scripts in production, you should
include a specific version number in the URL, for example:

*

*https://unpkg.com/pdf-lib@1.4.0/dist/pdf-lib.min.js

*https://cdn.jsdelivr.net/npm/pdf-lib@1.4.0/dist/pdf-lib.min.js


text:
Q: Find the roots of $f(x)$ that are found on the interval $[0{,}1 ; 3{,}3]$ in subintervals of amplitude $d = 0{,}4$ $$f(x)\ =\ \frac{\left(2x^2-\tan\left(x\right)\right)}{\ln\left(x-1.4\right)}$$
I'm not understanding  what "subintervals of amplitude $d = 0{,}4$" means, if I solve this problem by Newton-Raphson method, how would I get started ?

A: Taking the most de-singularized numerator, the (regular) roots of $f$ are also the roots of
$$
g(x)=2x^2\cos x-\sin x
$$
The case $x=1.4$ needs a separate consideration.
This has the function table at the nodes of the subdivision
\begin{array}{c|ccccccccc}
x& 0.10 & 0.50 & 0.90 & 1.30 & 1.70 & 2.10 & 2.50 & 2.90 & 3.30\\\hline
g(x)&-0.07993 & -0.04063 & 0.22368 & -0.05941 & -1.73639 & -5.31595 & -10.61277 & -16.57077 & -21.34956
\end{array}
This has sign changes in $[0.5,0.9]$ and $[0.9,1.3]$, which now can be refined using bisection or any faster converging bracketing method. You could also use Newton to compute the midpoint of the recent bracketing interval, using another midpoint if it does not stay inside the interval.

A: The way the question is currently posed, there are no roots of $f$ in the proposed interval, except possibly $x=1.4$, if we decide to extend $f$ by continuity to that point.


text:
Q: Ultrafilter principle and Axiom of Dependent Choice as 'nonconstructive and constructive' components of the Axiom of Choice As in the title, in the book 'Handbook of Analysis and its Foundations' by Schechter, the Ultrafilter principle is presented as a nonconstructive component of the Axiom of Choice, while the Axiom of Dependent Choice as a constructive component. As the author emphasizes, anyhow, UF+DC+ZF do not imply AC.
The form I know of the two are the following:
Ultrafilter Principle Any proper filter can be included in an ultrafilter. That is, if $\mathcal{F}$ is a proper filter on a set $X$, then there exists an ultrafilter $\mathcal{U}\supset\mathcal{F}$ on X.
Dependent Choice (without history)
Let $S$ be a nonempty set, let $N=\{M\subset S M\neq\emptyset\}\subset \wp(S)$ be the family of nonempty subsets of S and $f:S\rightarrow N$ a given function.
Then there exists a sequence $(x_n)\subset S$ such that $x_{n+1}\in f(x_n)$
Dependent Choice (with history) Let $S_1,S_2,S_3,...$ be nonempty subsets of $S$, $F_n=\{M\subset S_{n+1} M\neq\emptyset\}$ and let $f_n: S_1\times ...\times S_n\rightarrow F_n$. Then there exists a sequence $(x_1,x_2,x_3,...)$ such that $x_{n+1}\in f_n(x_1,x_2,...,x_n)$
Anyhow, though the idea seems interesting, I can't see why in the first place the Axiom of Dependent Choice should be more constructive than the Ultrafilter Principle, nor why the two should in some sense e complementary.
Thanks for help.

A: Intuitively speaking, Dependent Choice is essentially the following principle:
Suppose that there is a process choosing sets, $X_{n,y}$, such that for every $x\in X_{n,y}$, there is a non-empty set $X_{n+1,x}$. Then there is a function $f$ with domain $\Bbb N$, such that $f(n+1)\in X_{n,f(n)}$.
It lets us have inductive constructions without having to worry about specifying exactly "the next step", and instead just prove that such a step is possible to make.
In contrast, having non-principal ultrafilters, even just on $\omega$, requires a lot more choices to be made, and there is no obvious way to understand them as an iterative construction. Even with choice, working via transfinite recursion, we can easily prove that such a construction must take more than countably many steps, starting from a free filter.


text:
Q: How do we compare MAPEs? if we have two models M1 and M2:
MAPE_{M1} = 100%
and
MAPE_{M2} = 70%$
Does that mean that M2 is better than M1? can we say that M2 is (100/70 -1)*100 = 43% better?

A: Certainly you can say that. You could also say that M2 is $1-\frac{\text{MAPE}_{M2}}{\text{MAPE}_{M1}}=30\%$ better. It depends on what the denominator of your percentage calculation of "better" is.
However, whether all this has a useful meaning is very doubtful. As is the entire notion of MAPE. It looks easy to interpret and compare (which it isn't, this impression is highly misleading), but I have never seen an actual business problem that would best be addressed by a forecast that minimized MAPE, rather than one that minimized MSE or a pinball loss.
You may want to take a look at What are the shortcomings of the Mean Absolute Percentage Error (MAPE)?


text:
Q: ZXing Integration Manual/ help finding other functions Is there any detailed manual for ZXing library integration?
I have already successfully integrated the appusing intents .. but the way i understood it was NOT by looking at the ZXing site(wiki), frankly i read that man page a dozen times and i couldn't figure out how to work it. During my search i found a blog where someone had given the source code for a basic scanner. I finally understood how to call ZXing app from there using:
Intent intent = new Intent(
                    "com.google.zxing.client.android.SCAN");

And i receive data from the app using:
final String code = intent.getStringExtra("SCAN_RESULT");
final String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

My doubt: Are there anymore calls that return other kinds of data. For example just after scanning , there's a piece of text that say stuff like "Plain text found" or "Item found" . can i have this returned to my app via intents?. I've googled a lot on this and also search SE but havent found anything. I know there's a Wiki for this (but I've found nothing like the above posted code there! :S ) Any kind of help will be appreciated! Thanks in advance!

A: This is all you need to know: http://code.google.com/p/zxing/wiki/ScanningViaIntent
I take it you already found it. Did you try it -- what do you mean you couldn't figure out how to work it? It's a few lines of code.
You are trying to manually recreate what the integration code already does for you. You don't need to do what you are trying to do above, which is why the official docs don't tell you to do this. It's easier.
Everything you're asking is already addressed on that page. For example, see the javadoc for the class:
http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java
http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentResult.java


text:
Q: Recovering the data lost due to windows refresh I performed the windows 8 "refresh" and all the applications (downloaded) are gone along with its data.  Is there any way I could get that data back ?

A:
I performed the windows 8 "refresh" and all the applications
  (downloaded) are gone along with its data.

By using the Refresh operation you were told this was exactly what would happen.  You were presented the following warning before you confirmed the operation.

Apps you installed from websites and DVDs will be removed. Apps that
  came with your PC and apps you installed from the Windows Store will
  be reinstalled. Windows puts a list of removed apps on your desktop
  after refreshing your PC.

So you should be looking on the desktop for this folder.

Is there any way I could get that data back ?

If you actually performed a Refresh then a list of your installed programs was generated and placed on your desktop.  Additionally any data that could not be migrated is now located in C:\Windows.old\.
Any files that were located in C:\Users\YOURNAME\AppData\ are now located in C:\Windows.old\users\YOURNAME\AppData\ unless you ran the cleanup tool and deleted the data.  If that happen then data recovery is unlikely.

Related Question
Source
Additional Reading


text:
Q: Disable error_log. Error_log flooding i got an webserver running and old version of gambio (xt:commerce fork). The error_log in the dir over the public_html is flooding with errors. About 30mb in 15min. How can I disable this log? I can't fix all the errors. Here are a few examples of the errors:
[warn] mod_fcgid: stderr: PHP Notice:  Undefined variable:  key in /usr/www/users/foo//includes/classes/class.inputfilter.php on line 98
[warn] mod_fcgid: stderr: PHP Notice:  Undefined index:   in /usr/www/users/foo/templ
[warn] mod_fcgid: stderr: in /usr/www/users/foo/templates/gambio/source/inc/xtc_show_category_sectionc.inc.php on line 47

They are all errors of: "mod_fcgid: stderr". I tried to grep "error_log" and "error_report" in the public html dir, but i did not find anything.
Here is a part from the phpinfo():
PHP Version 4.4.9

System  Linux foobar.com 2.6.26-2-686-bigmem #1 SMP Sat Dec 26 09:26:36 UTC 2009 i686
Build Date  Feb 11 2010 13:00:33
Configure Command  './configure' '--prefix=/usr/local/php4' '--with-config-file-path=/etc/php4/cgi' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-tiff-dir' '--with-ttf' '--enable-force-cgi-redirect' '--enable-safe-mode' '--with-zlib' '--enable-ftp' '--enable-url-includes' '--enable-gd-native-ttf' '--enable-trans-sid' '--enable-dbase' '--with-db4' '--with-ldap' '--enable-bcmath' '--enable-calendar' '--enable-memory-limit' '--with-mcal=/usr' '--with-bz2' '--with-mod-dav' '--enable-sockets' '--with-kerberos' '--with-imap-ssl' '--enable-gd-imgstrttf' '--with-freetype-dir' '--with-curl' '--with-mysql' '--with-mhash' '--with-gdbm' '--with-pgsql' '--with-gettext' '--with-xml' '--with-mcrypt' '--with-openssl' '--with-dom' '--without-pear' '--enable-exif' '--with-zip' '--enable-wddx' '--disable-cli' '--enable-fastcgi' '--with-imap' '--enable-xslt' '--with-xslt-sablot=/usr/local/lib' '--enable-mbstring' '--with-dom-xslt' '--with-dom-exslt'
Server API  CGI/FastCGI
Virtual Directory Support  disabled
Configuration File (php.ini) Path  /home/httpd/php-ini/foo/php.ini
PHP API  20020918
PHP Extension  20020429
Zend Extension  20050606
Debug Build  no
Zend Memory Manager  enabled
Thread Safety  disabled
Registered PHP Streams  php, http, ftp, https, ftps, compress.bzip2, compress.zlib

**Configuration PHP Core**
Directive Local Value Master Value
allow_call_time_pass_reference On On
allow_url_fopen Off Off
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors On On
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 2039 2039
expose_php On On
extension_dir /usr/local/php4/lib/php/extensions/no-debug-non-zts-20020429 /usr/local/php4/lib/php/extensions/no-debug-non-zts-20020429
file_uploads On On
gpc_order GPC GPC
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .:/usr/local/lib/php/ .:/usr/local/lib/php/
log_errors Off Off
log_errors_max_len 1024 1024
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
max_execution_time 120 120
max_input_nesting_level 500 500
max_input_time -1 -1
memory_limit 128000000 128000000
open_basedir /usr/www/users/foo:/usr/home/foo:/tmp:/usr/local/lib/php:/usr/local/rmagic:/usr/www/users/he/_system_ /usr/www/users/foo:/usr/home/foo:/tmp:/usr/local/lib/php:/usr/local/rmagic:/usr/www/users/he/_system_
output_buffering no value no value
output_handler no value no value
post_max_size 128000000 128000000
precision 14 14
register_argc_argv On On
register_globals Off Off
report_memleaks On On
safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t /usr/sbin/sendmail -t
serialize_precision 100 100
short_open_tag On On
SMTP localhost localhost
smtp_port 25 25
sql.safe_mode Off Off
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 128000000 128000000
upload_tmp_dir /usr/foo/foo/.tmp /usr/foo/.tmp
user_dir no value no value
variables_order EGPCS EGPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
y2k_compliance Off Off

A: This is apache right?  You'll need to adjust LogLevel
If you set it to 'crit', that should take care of not displaying these errors, while still logging really bad things, such as failing to start.

A: You have to change error_reporting in php.ini
See:
http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

A: You need to adjust php.ini so that error_reporting does not include errors at the Notice level. You can do this by setting it to a value such as  E_ALL ^ E_NOTICE (Or E_ALL & ~E_NOTICE which means exactly the same thing)


text:
Q: Dropwdown arrow over text in navbar I'm trying to have a dropdown on a navbar item. It works, but the arrow is over the text of the menu item.

Codepen:
https://codepen.io/ogonzales/pen/QWjmorP
Code

    Fixed navbar
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">

    </button>

          Home (current)

          Link

          Disabled

            More

            Support and Consulting
            What is Test-Driven Development?
            Testimonials

        <form class="form-inline ml-auto">
          Log in
          Sign up
        </form>

Bonus
I'd like also to put every navbar item more to the right. I know I can do this with CSS, but is there a Boostrap class am I missing?

A: You ul tag was not closed, I fixed that and answered your bonus question as well.

*

*The reason it was on the over the text because, both the dropdown and the link were within same block, so you have to specify the width for those to fit-in inline, I have just provided 100px under .nav-link{...} and you are free to change that as per you requirement.

*To move contents towards right you can have width property for the yellow block(check in my snipppet/fiddle) OR you can provide flex option for the block and use 'justify-content:space-between;`.

  View in full screen due to media-query you have used.

.nav-link{
 border:1px solid yellow;
 margin:5px;
 width:100px;
}
fiddle to playground.

$(document).ready(function() {

  $('#sidebarCollapse').on('click', function() {
    $('#sidebar').toggleClass('active');
  });

});
/* Sticky footer styles
-------------------------------------------------- */

html {
  position: relative;
  min-height: 100%;
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin-bottom: 60px;
  /* Margin bottom by footer height */
  font-family: 'Poppins', sans-serif;
  background: #fafafa;
  padding-top: 70px;
}

.container {
  max-width: 960px;
}

.pricing-header {
  max-width: 700px;
}

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60px;
  /* Set the fixed height of the footer here */
  line-height: 60px;
  /* Vertically center the text there */
  background-color: #f5f5f5;
}

/* NAVBAR TOP */

#top-navbar ul li.active>a a[aria-expanded="true"] {
  color: #1f1f1f;
  background: #12b556;
}

#top-navbar a:visited {
  color: #fff;
}

#top-navbar a:link {
  color: #fff;
}

#top-navbar a.subitem:link {
  color: #1f1f1f;
}

/* ==== */

/* SIDEBAR */

/* ---------------------------------------------------
    SIDEBAR STYLE
----------------------------------------------------- */

.wrapper {
  display: flex;
  align-items: stretch;
}

#sidebar {
  min-width: 250px;
  max-width: 250px;
  background: #1f1f1f;
  color: #fff;
  transition: all 0.3s;
}

#sidebar.active {
  min-width: 80px;
  max-width: 80px;
  text-align: center;
}

#sidebar.active .sidebar-header h3,
#sidebar.active .CTAs {
  display: none;
}

#sidebar.active .sidebar-header strong {
  display: block;
}

#sidebar ul li a {
  text-align: left;
}

#sidebar.active ul li a {
  padding: 20px 10px;
  text-align: center;
  font-size: 0.85em;
}

#sidebar.active ul li a i {
  margin-right: 0;
  display: block;
  font-size: 1.8em;
  margin-bottom: 5px;
}

#sidebar.active ul ul a {
  padding: 10px !important;
}

#sidebar.active .dropdown-toggle::after {
  top: auto;
  bottom: 10px;
  right: 50%;
  -webkit-transform: translateX(50%);
  -ms-transform: translateX(50%);
  transform: translateX(50%);
}

#sidebar .sidebar-header {
  padding: 20px;
  background: #1f1f1f;
}

#sidebar .sidebar-header strong {
  display: none;
  font-size: 1.8em;
}

#sidebar ul.components {
  padding: 20px 0;
  border-bottom: 1px solid #47748b;
}

#sidebar ul li a {
  padding: 10px;
  font-size: 1.1em;
  display: block;
}

#sidebar ul li a:hover {
  color: #12b556;
  background: #fff;
}

#sidebar ul li a i {
  margin-right: 10px;
}

#sidebar ul li.active>a.sidebar-link a[aria-expanded="true"] {
  color: #fff;
  background: #12b556;
}

a[data-toggle="collapse"] {
  position: relative;
}

#navbarCollapse {
  border: 1px solid red;
}

.nav-link {
  border: 1px solid yellow;
  margin: 5px;
  width: 100px;
}

.dropdown-toggle::after {
  display: block;
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
}

ul ul a {
  font-size: 0.9em !important;
  padding-left: 30px !important;
  background: #12b556;
}

ul.CTAs {
  padding: 20px;
}

ul.CTAs a {
  text-align: center;
  font-size: 0.9em !important;
  display: block;
  border-radius: 5px;
  margin-bottom: 5px;
}

a.download {
  background: #fff;
  color: #12b556;
}

a.article,
a.article:hover {
  background: #12b556 !important;
  color: #fff !important;
}

a.sidebar-link:visited {
  color: #fff;
}

a.sidebar-link:link {
  color: #fff;
}

/* ---------------------------------------------------
  CONTENT STYLE
----------------------------------------------------- */

#content {
  width: 100%;
  padding: 20px;
  min-height: 100vh;
  transition: all 0.3s;
}

/* ---------------------------------------------------
  MEDIAQUERIES
----------------------------------------------------- */

@media (max-width: 768px) {
  #sidebar {
    min-width: 80px;
    max-width: 80px;
    text-align: center;
    margin-left: -80px !important;
  }
  .dropdown-toggle::after {
    top: auto;
    bottom: 10px;
    right: 50%;
    -webkit-transform: translateX(50%);
    -ms-transform: translateX(50%);
    transform: translateX(50%);
  }
  #sidebar.active {
    margin-left: 0 !important;
  }
  #sidebar .sidebar-header h3,
  #sidebar .CTAs {
    display: none;
  }
  #sidebar .sidebar-header strong {
    display: block;
  }
  #sidebar ul li a {
    padding: 20px 10px;
  }
  #sidebar ul li a span {
    font-size: 0.85em;
  }
  #sidebar ul li a i {
    margin-right: 0;
    display: block;
  }
  #sidebar ul ul a {
    padding: 10px !important;
  }
  #sidebar ul li a i {
    font-size: 1.3em;
  }
  #sidebar {
    margin-left: 0;
  }
  #sidebarCollapse span {
    display: none;
  }
}

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <title>{% block title %}DjangoX{% endblock title %}</title>
  <meta name="description" content="A framework for launching new Django projects quickly.">
  <meta name="author" content="">
  <link rel="shortcut icon" type="image/x-icon" href="{% static 'images/favicon.ico' %}">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
  <link href="https://use.fontawesome.com/releases/v5.12.0/css/all.css" rel="stylesheet">
  <link rel="stylesheet" href="{% static 'css/base.css' %}">
  <link rel="stylesheet" href="{% static 'css/price.css' %}">

    Fixed navbar
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">

    </button>

          Home (current)

          Link

          Disabled

            More

            Support and Consulting
            What is Test-Driven Development?
            Testimonials

      <form class="form-inline ml-auto">
        Log in
        Sign up
      </form>

        ELIM

             Capítulo 1

              Introducción

              ¿Qué es la salvación?

              ¿Se pierde la salvación?

          <button type="button" id="sidebarCollapse" class="btn btn-info">

              Toggle Sidebar
            </button>

            {% block content %} {% endblock content %}

            <form class="search-form" action="/search/" method="post">
              <input type="hidden" name="csrfmiddlewaretoken" value="KTlYgVaxnAYKzLle9WWDNIoE0MDSvAVldfbsnKbfpAStWafCb1MVMgwLdArZUEiP">

                <input type="search" class="form-control search-course" placeholder="Buscar curso" name="search_term" required="">
                <input type="hidden" value="3" name="course_id">

            </form>

In this Section:

                  Get the
              full course

              for
              Now Only

              $30

            ↑ Back to top

          Footer...

A: In your code ".dropdown-toggle::after" right value is the problem, change into this code it will work.
.dropdown-toggle::after {
    display: block;
    position: absolute;
    top: 50%;
    right: -7px;
    transform: translateY(-50%);
}

A:
Just remove the below manual css u have designed. bcz it is overriding bootstrap's default css which is not appropiate

.dropdown-toggle::after {
  display: block;
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
}


text:
Q: An expression of non-boolean type specified in a context where a condition is expected, near 'and'. In SQL Server at CASE SELECT
    d.district_id, d.district_name, d1.district_id, d1.district_name
FROM
    tbl_district d, tbl_district d1
WHERE
     CASE
        WHEN (d.district_id % 2) != 0
           THEN d.district_id
     END
     AND d1.district_id = d.district_id+1;

A: "Case when" is a value, it is not a logical operation.
For example:
 SELECT
d.district_id, d.district_name, d1.district_id, d1.district_name
FROM
tbl_district d, tbl_district d1
WHERE
 CASE
    WHEN (d.district_id % 2) != 0
       THEN d.district_id
 END+1 = d1.district_id

A: I guess you are trying to filter the odd numbers
SELECT
    d.district_id, d.district_name, d1.district_id, d1.district_name
FROM
    tbl_district d
INNER JOIN tbl_district d1
        ON d1.district_id = d.district_id+1
WHERE (d.district_id % 2) != 0

Also start using INNER JOIN instead of old style comma separated join
If you are using SQL SERVER 2012+ then you can use LEAD window function
SELECT *
FROM   (SELECT *,
               Lead(district_id)OVER(ORDER BY district_id) AS next_dst,
               Lead(district_name)OVER(ORDER BY district_id) AS next_name
        FROM   tbl_district ) a
WHERE  a.district_id + 1 = a.next_dst
       AND ( district_id % 2 ) != 0

A: CREATE PROCEDURE [dbo].[EvenOdd_District]
AS
BEGIN

      SELECT d.district_id ,d.district_name,d1.district_id ,d1.district_name
      FROM tbl_district d,tbl_district d1 WHERE d.district_id=
         CASE
            when (d.district_id%2)!=0 then d.district_id
         END
         AND d1.district_id=d.district_id+1;
END


text:
Q: Is the bounded coset poset of a boolean interval of finite groups, Cohen-Macaulay? Let $[H,G]$ be a boolean interval of finite groups and let $\hat{C}(H,G)$ be its bounded coset poset (i.e. the poset of cosets $Kg$ with $K \in [H,G]$, bounded below by $\emptyset$ and bounded above by $G$).
Question: Is $\hat{C}(H,G)$ Cohen-Macaulay?
Remark: It is true for $|G:H|<32$, because it is true if $[H,G]$ is group-complemented or if it is of rank $2$ (see this paper Corollary 4.33). It's also true (using the function is_cohen_macaulay on SAGE) for the three first rank $3$ boolean intervals $[H,G]$ with $G$ simple, listed here (my desktop isn't enough powerful   for checking the fourth one).


text:
Q: asp.net core 2.0 GitHub has with GetExternalLoginInfoAsync I config service for GitHub
services.AddOAuth("GitHub", "Github", o =>
{
    o.ClientId = Configuration["Authentication:GitHub:ClientId"];
    o.ClientSecret = Configuration["Authentication:GitHub:ClientSecret"];
    o.CallbackPath = new PathString("/signin-github");
    o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize";
    o.TokenEndpoint = "https://github.com/login/oauth/access_token";
    o.UserInformationEndpoint = "https://api.github.com/user";
    o.ClaimsIssuer = "OAuth2-Github";
    o.SaveTokens = true;
    // Retrieving user information is unique to each provider.
    o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
    o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login");
    o.ClaimActions.MapJsonKey("urn:github:name", "name");
    o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email);
    o.ClaimActions.MapJsonKey("urn:github:url", "url");
    o.Events = new OAuthEvents
    {
        OnCreatingTicket = async context =>
        {
            // Get the GitHub user
            var request = new HttpRequestMessage(HttpMethod.Get, context.Options.UserInformationEndpoint);
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken);
            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var response = await context.Backchannel.SendAsync(request, context.HttpContext.RequestAborted);
            response.EnsureSuccessStatusCode();

            var user = JObject.Parse(await response.Content.ReadAsStringAsync());

            context.RunClaimActions(user);
        }
    };
});

When I login on GitHub I redirect to action and in action has line ...
var info = await _signInManager.GetExternalLoginInfoAsync();//return null

That line always return null.
Can you help me?


text:
Q: How to Fit image into div? I am trying to fit my images into the div which will be a inside a drag slider. I have tried a few object-fit properties but didnt seem to work. All of my images seem to take the entire width/height of the divs they are inside but I want there to be space between the images inside the div

.homes-container{
position: absolute;
left: 10%;
top: 12%;
width: 80%;
height: 50rem;
overflow: hidden;
background: chartreuse;
}

.home-container-item{
position: absolute;
top: 0;
left: 0;
height: 100%;
display: grid;
grid-template-columns: repeat(8, 1fr);
gap: 20px;
pointer-events: none;
transition: 1s;
object-fit: scale-down;
}

A: You can set the image style width and height to 100%. This should fill the div with the image.


text:
Q: Passing enum pointer in parameters in C programming I have some problems passing my enum pointer to a function parameters.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

//Prototypes
void automate(int tddv_estime, int tab_para_automate[][3], enum* Etat);
void fct_test(int scenario[]);

/*-----------------------------------------------------------------------
main()
-------------------------------------------------------------------------*/
int main()
{
int scenario[15] = {21, 21, 20, 12, 12, 20, 22, 22, 22, 22, 22, 22, 22, 22, 500};

fct_test(scenario);
return 0;
}

/*-----------------------------------------------------------------------
Fonction fct_test
-------------------------------------------------------------------------*/
void fct_test(int scenario[])
{
    //PARAMETRES
    int increment = 1;
    int tddv_estime;

int para_1_min = 5;
int para_1_max = 10;

int para_2_min = 1;
int para_2_max = 4;

int tab_para_automate[2][3] = {{0}};
int tab_para_application[2][2] = {{0}};

int i,j,k;

enum Etat {INIT, DECREMENT_PARA_1, INCREMENT_PARA_1, ETAT_INVARIANT_1, DECREMENT_PARA_2, ETAT_INVARIANT_2, INCREMENT_PARA_2, RADAR_SATURE};

/*printf("ETAT INITIAL\n");
printf("Para_1_courant = %d\n" , para_1_courant);
printf("Para_2_courant = %d\n\n\n" , para_2_courant);*/

for (k=0 ; k<16 ;k++)
{
    tab_para_automate[k][0] = para_1_min;
    tab_para_automate[k][1] = para_1_max;
}

for (j=1 ; j<16 ;j++)
{
    tab_para_automate[j][0] = para_2_min;
    tab_para_automate[j][1] = para_2_max;
}

    do {
    for (i=0 ; i<16 ; i++)
   {
        tddv_estime = scenario[i];
        automate(tddv_estime, tab_para_automate, &Etat);
   }
        }while (scenario[i] != 500);
}

/*-----------------------------------------------------------------------
Fonction automate
-------------------------------------------------------------------------*/

void automate(int tddv_estime, int tab_para_automate[][3], enum* Etat)
{
int evenement;

int tddv_worst = 20;
int para_1_min = tab_para_automate[0][0];
int para_1_max = tab_para_automate[0][1];

int para_2_min = tab_para_automate[1][0];
int para_2_max = tab_para_automate[1][1];

int para_2_courant = para_2_max;
int para_1_courant = para_2_max;

if (tddv_estime < tddv_worst)
    evenement = 1; //Etat initial

if (tddv_estime > tddv_worst)
    evenement = 2; //Decrement para1

if (tddv_estime < tddv_worst && tab_para_automate[0][0] < tab_para_automate[0][1])
    evenement = 3; //Increment para1

if (tddv_estime == tddv_worst)
    evenement = 4; //Etat Invariant 1

if (tddv_estime > tddv_worst && tab_para_automate[0][0] <= tab_para_automate[0][0])
    evenement = 5; //Decrement para_2

if (tddv_estime < tddv_worst && para_2_courant < tab_para_automate[1][1])
    evenement = 6; //Increment para2

if (tddv_estime == tddv_worst)
    evenement = 7; //Etat Invariant 2

if (tddv_estime > tddv_worst && tab_para_automate[0][0] <= para_1_min && para_2_courant <= para_2_min)
    evenement = 8; //Etat radar sature

}

I can't pass my enum pointer in parameters, i don't know why. I've been looking for the solution for a while now, can someone help me on this please ?
Maybe the problem is in the prototypes, maybe i don't declare well my enum variable, i can't find the solution.

A: You have to declare the type enum Etat before the first usage (i.e. directly after your includes):
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

enum Etat {INIT, DECREMENT_PARA_1, INCREMENT_PARA_1, ETAT_INVARIANT_1, DECREMENT_PARA_2, ETAT_INVARIANT_2, INCREMENT_PARA_2, RADAR_SATURE};

and fix the prototype and definition to use the new type (remember: the type is enum Etat)
//Prototypes
void automate(int tddv_estime, int tab_para_automate[][3], enum Etat *etat);
void fct_test(int scenario[]);

Then you have to instantiate an enum object before calling automate:
enum Etat etat;
automate(tddv_estime, tab_para_automate, &etat);

This is how you use enums correctly.


text:
Q: python dataframe sum function returning negative number I am working with a test dataset of the Lending Club loan data and am trying to create some analysis with the set.
After loading the csv into a dataframe, I am just trying to do a simple sum on the entire funded_amnt column.  I keep receiving a negative amount for the sum even though there are no negative numbers in the entire set.  How can this be?
In[ ]: loans_df['funded_amnt'].sum()

Out[ ]: -1925852142

In[ ]: len(loans_df[loans_df['funded_amnt']<0])

Out[ ]: 0

A: This could be an overflow problem. But it's hard to tell without a [mcve]...
Example:
pd.DataFrame([2**61]*2).sum()
Out[345]:
0    4611686018427387904
dtype: int64

pd.DataFrame([2**61]*3).sum()
Out[346]:
0    6917529027641081856
dtype: int64

pd.DataFrame([2**61]*4).sum()
Out[347]:
0   -9223372036854775808
dtype: int64

pd.DataFrame([2**61]*5).sum()
Out[348]:
0   -6917529027641081856
dtype: int64


text:
Q: Building an "inner stroke" effect from a Polygon I'm drawing a whole bunch of Polygons onto a canvas, most of which share an edge with at least one other Polygon.  I'd like to indicate a Polygon is "special" by outlining it, however due to the overlapping edges the Stroke on a Polygon tends to be partially drawn over by another Polygon causing the Stroke to look thinner than it should in places.  Additionally, depending on draw order, a Polygon may have its Stroke almost entirely covered by those around it.  Spacing the Polygons out is not a very attractive option, as visible gaps between Polygons are much less preferable to this "thin stroke" problem.
I reason that the effect I'm looking for can be achieved by generating each Polygon as a pair of Polygons instead, such that one Polygon is completely contained within the other and this smaller Polygon's Stroke runs up to (but does not overlap) the outer Polygon's Stroke.  The inner Polygon would have a transparent Fill at all times, and a non-transparent Stroke only when I wish to indicate that the now pair of Polygons are "special".
My question boils down to; how can I derive such an inner Polygon from the outer one, or failing that how else might I achieve this effect?
The Polygon's in question can be constrained to the regular polygons if need be, and the Strokes are simple 1 thickness solid lines with no fancy miters or the like.  I'd like to be able to adjust the thickness of the Stroke at some point, but nothing fancier than that.

A: I think there's actually a few ways to achieve what you want.
First, going with your original idea of drawing a second, slightly smaller polygon within the original polygon; it's not a bad idea.  To answer your original question as to how to generate the smaller polygon: you can find the centroid of each polygon, and offset each vertex by a percentage of the distance to that centroid point of the polygon to get the smaller polygon.  This should give a pleasing effect.
Another way you could go would be to use z-order, and offset the "thicker" polygon by a slight negative z-distance.
Yet another way to go would be to exploit draw order; draw your thicker polygons last, which will prevent them from being overdrawn by the surrounding polygons.
Yet another idea that might work depending on your needs might be not to draw polygons at all, but to draw a series of lines, simply thickening some of the lines.
There's a lot of options for you to try; hope you find one that works out well!


text:
Q: On the determinant $\det[(\frac{i^2+dj^2}p)]_{0\le i,j\le(p-1)/2}$ with $(\frac dp)=-1$ Let $p$ be an odd prime. For $d\in\mathbb Z$ we define
$$T(d,p):=\det\left[\left(\frac{i^2+dj^2}p\right)\right]_{0\le i,j\le(p-1)/2},$$
where $(\frac{\cdot}p)$ is the Legendre symbol.
By (1.17) of my paper arXiv:1308.2900, if$(\frac dp)=-1$ then $(\frac{T(d,p)}p)=1$.
Suppose that $p\equiv3\pmod4$. Then, by (1.14) of arXiv:1308.2900,  $T(d,p)=T(-1,p)$ for any $d\in\mathbb Z$ with $(\frac dp)=-1$. As $T(-1,p)$ is a skew-symmetric determinant of even order, it is an integer square.
In the case $p\equiv1\pmod4$, if $d$ and $d'$ are both quadratic nonresidues modulo $p$, then we clearly have $T(d,p)=\pm T(d',p)$.
I have the following conjecture which seems quite challenging.
Conjecture. Let $p\equiv1\pmod4$ be a prime and write $p=x^2+4y^2$ with $x$ and $y$ positive integers. Then, for any integer $d\in\mathbb Z$ with $(\frac dp)=-1$, there is a positive integer $t(p)$ (not depending on $d$) such that $$|T(d,p)|=2^{(p-1)/2}t(p)^2y.$$
Via Mathematica, I find that
\begin{gather}t(5)=1,\ t(13)=3,\ t(17)=4,\ t(29)=91,\ t(37)=81,\ t(41)=180,
\\t(53)=1703,\ t(61)=87120,\ t(73)=16104096,\ t(89)=3947892146,
\\ t(97)=19299520512,\ t(101)=885623936875,\ t(109)=36548185365.\end{gather}
Your comments are welcome!
PS: I have verified the conjecture for all primes $p<5000$ with $p\equiv1\pmod4$.

A: I have obtained some partial results that seem promising, but not a full solution:
Let $\chi$ be a nontrivial Dirichlet character mod $p$ with $\chi(-1)=1$. Then
$\sum_{j=0}^{(p-1)/2} \left( \frac{ i^2+ dj^2}{p} \right) \chi(j) = \frac{1}{2} \sum_{j=1}^{p-1 } \left( \frac{ i^2+ dj^2}{p} \right) \chi(j) $
If $i=0$, then this sum is zero. Otherwise, we can perform a substitution replacing $j$ by $ij$, getting
$ \frac{1}{2} \sum_{j=1}^{p-1 } \left( \frac{ i^2+ di^2 j^2}{p} \right) \chi(i j) =  \chi(i) \frac{1}{2}\sum_{j=1}^{p-1 } \left( \frac{ 1+ d j^2}{p} \right) \chi( j)  $. So $\chi$ is an eigenvector  of this matrix, with eigenvalue $ \frac{1}{2}\sum_{j=1}^{p-1 } \left( \frac{ 1+ d j^2}{p} \right) \chi( j)  $.
The complement to these eigenvectors has a basis consisting of the function that is $1$ on $0$ and the function that is $1$ on all nonzero $j$. The matrix preserves the space generated by this basis, and acts on it by $$\begin{pmatrix} 0 & - (p-1)/2 \\ 1 & \frac{1}{2} \sum_{j=1}^{p-1}  \left( \frac{1+ dj^2}{p} \right)\end{pmatrix} $$ and therefore with determinant $(p-1)/2$. So the determinant of your matrix is
$$\frac{p-1}{2} \prod_{\chi \textrm { nontrivial, } \chi(-1)=1} \left( \frac{1}{2}\sum_{j=1}^{p-1 } \left( \frac{ 1+ d j^2}{p} \right) \chi( j) \right)$$
We can write $\sum_{j^2 = t} \chi(j)$ as $\chi_1(t) + \chi_2(t)$ where $\chi_1$ and $\chi_2$ are the squareroots of $t$ in the ring of characters, so $$\sum_{j=1}^{p-1 } \left( \frac{ 1+ d j^2}{p} \right) \chi( j)  = \sum_{t=1}^{p-1} \left( \frac{ 1+ d t}{p} \right) \chi_1( t)+ \sum_{t=1}^{p-1} \left( \frac{ 1+ d t}{p} \right) \chi_2( t) $$
If we focus attention on the eigenvector associated to $\chi$ the Legendre symbol, then $\chi_1$ and $\chi_2$ are the two characters of order $4$, so the left term is of the form $a+bi$ and the right term is its complex conjugate $a-bi$. By the evaluation of the absolute value of Jacobi sums, $a^2+b^2=p$, and because the number of $t$ with $\chi_1(t)= \pm 1$ (i.e. $t$ a quadratic residue) and $1+dt \neq 0$ (implied by $t$ a quadratic residue) is $p-1/2$, which is even, $a$ is even, so in fact $a=\pm y,b=\pm x$, and this eigenvalue is $\pm y$.
So it seems when the eigenvalue associated to the Legendre symbol is removed, you would like to have a square determinant. But I don't yet quite see how to obtain that.
I tried to get a square by finding matching pairs of eigenvalues, or by removing this eigenvector and conjugating to a skew-symmetric matrix, but neither approach quite worked.


text:
Q: vb.net Linq Agg Function for Class I have a basic structure, in a list of:
Private Structure strcManagement
Dim Region as string
Dim Boss as string
Dim Employee as string
end Structure

Dim l as new list(of strcManagement)

Sample data looks like this:
l.add(new structure with {.Region = "Boston",.Boss="Joe Blow",Employee="Dan"})
l.add(new structure with {.Region = "Boston",.Boss="Joe Blow",Employee="Steve"})
l.add(new structure with {.Region = "Boston",.Boss="Joe Blow",Employee="Peter"})
l.add(new structure with {.Region = "CT",.Boss="Sam B",Employee="Brian"})

and I want to use linq to agg the data together where Region & Boss are grouped and the derived string is made on employee:
Boston,Joe Blow, [Dan,Steve,Peter]
CT, Sam B, [Brian]
I have seen examples with list(of string) but none with multiple grouped values.  Any help would be appreciated.

A: Using LINQ Query Comprehension,
Dim ans = From m In l
          Group m By m.Region, m.Boss Into Group
          Select Region, Boss, Employees = String.Join(",", (From e In Group Select e.Employee))


text:
Q: Double Rolls on a Dice My code currently rolls 2 dices 1,000 times and the output is how many times each number was rolled. However, I need to improve the code so that the output also includes every time a double is rolled. An example of what I need the output to be similar to is:
Snake Eyes were rolled 5 times

Double 2's were rolled 8 times

Double 3's were rolled 17 times

And so on up til 6...
This is my current code which is working perfectly:
import random

test_data = [0] * 12
n = 1000
for i in range(n):
    result = random.randint(1, 6) + random.randint(1, 6)
    test_data[result - 1] += 1

for i, x in enumerate(test_data, 1):
    print ("Number of ", i, "'s: ", x)

The output is:
Number of  1 's:  0
Number of  2 's:  28
Number of  3 's:  56
Number of  4 's:  82
Number of  5 's:  107
Number of  6 's:  130
Number of  7 's:  172
Number of  8 's:  133
Number of  9 's:  115
Number of  10 's:  93
Number of  11 's:  56
Number of  12 's:  28

How can I improve my code so that "doubles" also appear?

A: split the line
 result = random.randint(1, 6) + random.randint(1, 6)

into
roll1 = random.randint(1, 6)
roll2 = random.randint(1, 6)

now you can test for doubles with:
if roll1 == roll2:
   #log double

A: You can create another list of 6 values for the doubles and slightly change the rest of your code:
import random

doubles = [0] * 6
test_data = [0] * 12
n = 1000

for i in range(n):
    a,b = random.randint(1, 6) , random.randint(1, 6) # create 2 distinct ones
    result = a+b                                      # and the sum
    test_data[result - 1] += 1
    if a == b:                                        # if a==b count up
        doubles[a-1] += 1

for i, x in enumerate(test_data, 1):
     if i > 1: # no sum of 1 possible
         print ("Number of {:>2}'s: {:>6}".format(i,x))

# output for doubles:
for i,x in enumerate(doubles,1):
    # python ternary operator, see link below
    print( ("Snake eyes were rolled {cnt} times" if i == 1
            else "Double {}'s were rolled {cnt} times").format(i,cnt=x))

Output:
Number of  2's:     28
Number of  3's:     64
Number of  4's:     72
Number of  5's:    120
Number of  6's:    139
Number of  7's:    139
Number of  8's:    137
Number of  9's:    114
Number of 10's:     93
Number of 11's:     58
Number of 12's:     36
Snake eyes were rolled 28 times
Double 2's were rolled 28 times
Double 3's were rolled 25 times
Double 4's were rolled 23 times
Double 5's were rolled 28 times
Double 6's were rolled 36 times

Readup:

*

*string formatting mini language here to align output and format numbers into text

*python ternary operator SO-Question explaining that

A: I would use a Counter to store these kinds of dice counts, as it keeps the code nice and clean:
from collections import defaultdict, Counter
import random

dice_combined = Counter()
dice_individual = defaultdict(Counter)

for i in range(1000):
  a = random.randint(1, 6)
  b = random.randint(1, 6)
  dice_combined[a+b] += 1
  dice_individual[a][b] += 1

# print report:
for i in dice_combined:
  print(i, 'was rolled', dice_combined[i], 'times')

for i in range(1, 6, 1):
  print('double', i, 'was rolled', dice_individual[i][i], 'times')

Sample Report:
2 was rolled 25 times
3 was rolled 49 times
4 was rolled 77 times
5 was rolled 99 times
6 was rolled 150 times
7 was rolled 169 times
8 was rolled 140 times
9 was rolled 100 times
10 was rolled 101 times
11 was rolled 67 times
12 was rolled 23 times
double 1 was rolled 25 times
double 2 was rolled 29 times
double 3 was rolled 21 times
double 4 was rolled 23 times
double 5 was rolled 28 times


text:
Q: How do I edit a file after I shell to a Docker container? I successfully shelled to a Docker container using:
docker exec -i -t 69f1711a205e bash

Now I need to edit file and I don't have any editors inside:
root@69f1711a205e:/# nano
bash: nano: command not found
root@69f1711a205e:/# pico
bash: pico: command not found
root@69f1711a205e:/# vi
bash: vi: command not found
root@69f1711a205e:/# vim
bash: vim: command not found
root@69f1711a205e:/# emacs
bash: emacs: command not found
root@69f1711a205e:/#

How do I edit files?

A: After you shelled to the Docker container, just type:
apt-get update
apt-get install nano

A: You can just edit your file on host and quickly copy it into and run it inside the container. Here is my one-line shortcut to copy and run a Python file:
docker cp main.py my-container:/data/scripts/ ; docker exec -it my-container python /data/scripts/main.py

A: If you don't want to add an editor just to make a few small changes (e.g., change the Tomcat configuration), you can just use:
docker cp <container>:/path/to/file.ext .

which copies it to your local machine (to your current directory). Then edit the file locally using your favorite editor, and then do a
docker cp file.ext <container>:/path/to/file.ext

to replace the old file.

A: To keep your Docker images small, don't install unnecessary editors. You can edit the files over SSH from the Docker host to the container:
vim scp://remoteuser@containerip//path/to/document

A: If you use Windows container and you want change any file, you can get and use Vim in Powershell console easily.
To shelled to the Windows Docker container with PowerShell:
docker exec -it <name> powershell

*

*First install Chocolatey package manager
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression;

*Install Vim
choco install vim

*Refresh ENVIRONMENTAL VARIABLE
You can just exit and shell back to the container

*Go to file location and Vim it vim file.txt

A: See Stack Overflow question
sed edit file in place
It would be a good option here, if:

*

*To modify a large file, it's impossible to use cat.

*Install Vim is not allowed or takes too long.
My situation is using the MySQL 5.7 image when I want to change the my.cnf file, there is no vim, vi, and Vim install takes too long (China Great Firewall). sed is provided in the image, and it's quite simple. My usage is like
sed -i /s/testtobechanged/textwanted/g filename
Use man sed or look for other tutorials for more complex usage.

A: It is kind of screwy, but in a pinch you can use sed or awk to make small edits or remove text. Be careful with your regex targets of course and be aware that you're likely root on your container and might have to re-adjust permissions.
For example, removing a full line that contains text matching a regex:
awk '!/targetText/' file.txt > temp && mv temp file.txt

(More)

A: If you can only shell into container with bin/sh (in case bin/bash doesn't work)
and apt or apt-get doesn't work in the container, check whether apk is installed by entering apk in command prompt inside the container.
If yes, you can install nano as follows:
apk add nano
then nano will work as usual

A: You can use cat if installed, with the > caracter.
Here is the manipulation :
cat > file_to_edit
#1 Write or Paste you text
#2 don't forget to leave a blank line at the end of file
#3 Ctrl + C to apply configuration

Now you can see the result with the command
cat file

A: You can open existing file with
cat filename.extension

and copy all the existing text on clipboard.
Then delete old file with
rm filename.extension

or rename old file with
mv old-filename.extension new-filename.extension

Create new file with
cat > new-file.extension

Then paste all text copied on clipboard, press Enter and exit with save by pressing ctrl+z. And voila no need to install any kind of editors.

A: For common edit operations I prefer to install vi (vim-tiny), which uses only 1491 kB or nano which uses 1707 kB.
In other hand vim uses 28.9 MB.
We have to remember that in order for apt-get install to work, we have to do the update the first time, so:
apt-get update
apt-get install vim-tiny

To start the editor in CLI we need to enter vi.

A: Sometime you must first run the container with root:
docker exec -ti --user root <container-id> /bin/bash

Then in the container, to install Vim or something else:
apt-get install vim

A: You can use cat if it's installed, which will most likely be the case if it's not a bare/raw container. It works in a pinch, and ok when copy+pasting to a proper editor locally.
cat > file
# 1. type in your content
# 2. leave a newline at end of file
# 3. ctrl-c / (better: ctrl-d)
cat file

cat will output each line on receiving a newline. Make sure to add a newline for that last line. ctrl-c sends a SIGINT for cat to exit gracefully. From the comments you see that you can also hit ctrl-d to denote end-of-file ("no more input coming").
Another option is something like infilter which injects a process into the container namespace with some ptrace magic: https://github.com/yadutaf/infilter

A: As in the comments, there's no default editor set - strange - the $EDITOR environment variable is empty. You can log in into a container with:
docker exec -it <container> bash

And run:
apt-get update
apt-get install vim

Or use the following Dockerfile:
FROM  confluent/postgres-bw:0.1

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]

Docker images are delivered trimmed to the bare minimum - so no editor is installed with the shipped container. That's why there's a need to install it manually.
EDIT
I also encourage you to read my post about the topic.

A: I use "docker run" (not "docker exec"), and I'm in a restricted zone where we cannot install an editor. But I have an editor on the Docker host.
My workaround is: Bind mount a volume from the Docker host to the container (https://docs.docker.com/engine/reference/run/#/volume-shared-filesystems), and edit the file outside the container. It looks like this:
docker run -v /outside/dir:/container/dir

This is mostly for experimenting, and later I'd change the file when building the image.

A: An easy way to edit a few lines would be:
echo "deb http://deb.debian.org/debian stretch main" > sources.list

A: You can install nano
yum install nano

A: You can also use a special container which will contain only the command you need: Vim. I chose python-vim. It assumes that the data you want to edit are in a data container built with the following Dockerfile:
FROM debian:jessie
ENV MY_USER_PASS my_user_pass
RUN groupadd --gid 1001 my_user
RUN useradd -ms /bin/bash --home /home/my_user \
            -p $(echo "print crypt("${MY_USER_PASS:-password}", "salt")" | perl) \
            --uid 1001 --gid 1001 my_user
ADD src /home/my_user/src
RUN chown -R my_user:my_user /home/my_user/src
RUN chmod u+x /home/my_user/src
CMD ["true"]

You will be able to edit your data by mounting a Docker volume (src_volume) which will be shared by your data container (src_data) and the python-vim container.
docker volume create --name src_volume
docker build -t src_data .
docker run -d -v src_volume:/home/my_user/src --name src_data_1 src_data
docker run --rm -it -v src_volume:/src fedeg/python-vim:latest

That way, you do not change your containers. You just use a special container for this work.

A: First login as root :
docker run -u root -ti  bash
Type following commands:
apt-get update &&
apt-get install nano

A: docker comes up with no editors. so simply install vim, 36MB space don't kill your docker!

A: Make sure to update the container before trying to install the editor.
apt-get update
apt-get install nano vi


text:
Q: Table Prefix Problem or Not? I am trying to determine if I actually have a db table prefix problem or not in my wordpress db.  I am on mysql  Ver 8.0.30-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu)).
Status Quo:

*

*I changed my table_prefix from wp_ to new_prefix

*Within phpmyadmin, I selected all tables and changed the table prefix from wp_ to new_prefix

*I ran the following sql query:
update new_prefix_usermeta set meta_key = 'new_prefix_capabilities' where meta_key = 'wp_capabilities';
update new_prefix_usermeta set meta_key = 'new_prefix_user_level' where meta_key = 'wp_user_level';
update new_prefix_usermeta set meta_key = 'new_prefix_autosave_draft_ids' where meta_key = 'wp_autosave_draft_ids';
update new_prefix_options set option_name = 'new_prefix_user_roles' where option_name = 'wp_user_roles';

Everything seems to be functioning normally...
Points of Confusion
When I enter phpmyadmin, select my db, and search the db for wp_  I these results:
62 matches in new_prefix_actionscheduler_logs
24 matches in new_prefix_itsec_logs
109 matches in new_prefix_options
59 matches in new_prefix_postmeta
38 matches in new_prefix_posts
2 matches in new_prefix_snippets
9 matches in new_prefix_term_taxonomy
56 matches in new_prefix_trp_gettext_en_us
15 matches in new_prefix_usermeta
2 matches in new_prefix_wc_admin_notes
7 matches in new_prefix_wc_admin_note_actions
137 matches in new_prefix_wsal_metadata
11 matches in new_prefix_wsal_occurrences
10 matches in new_prefix_yoast_indexable

*

*With my novice comprehension, I was expecting to see 0 results.

*When I browse some tables, such as new_prefix_actionscheduler_logs above, I can't actually find any instance of wp_ that needs to be changed within the table.
Questions:
1.) Is my method of searching all db tables for wp_ correct?  I ask this because I also have a plugin installed called mainwp and within its tables it has mainwp_, so is my search parameter accidentally catching the last part of mainwp_ and other similarly named plugins,files, and settings in the results?
2.) What is a query that I can use to replace all actually misnamed table prefixes based the results above?  I examined some tables and found wp_ still remained, attempting to manually replace wp_ for over 500 results is not practical.
3.) Is it necessary to run an additional SQL query after renaming all of the table prefix via phpmyadmin? I have read a variety of sources, some recommend a db query after renaming the tables, some do not.


text:
Q: Drupal 7 Display data from database Hi I am new to drupal and I need some direction to start this simple task. My aim is to fetch data from database and display these data on a separate page with specific url but theme is still the same. I tried to using view but it only allows to attach specific content. So where should i start with and there is any specific tutorial that i can have a look.
Thank you very much

A: This is pretty advanced stuff (If you don't want to get the data from the content types). If you do you should install the Panels module, which will allow you to override specific pages depending on the url and allow you through the views module to show the Content Type data any way you want.
If that is not the case then you should implement your own php code. That can happen using the drupal hooks. An example for your case is menu hook. There is a tutorial for creating modules for dupal 7. There are others for drupal 6 etc, but the philosophy is the same.


text:
Q: regular expression matching with awk I'm messing around a little with awk and I am still kind of new to bash/awk so bear with me
when I do this to look for all processes running as root
ps aux | awk '$0 ~ /.*root*./ {print $0, $11}'

it prints out everything as I expect, but it also prints out a line at the bottom that includes MY username (which isn't root) and the process awk.  Why is that? What can I do about it?
Note:  I'm not really interested in alternate solutions to print out all the processes that have root.  I can already do that.  I want to understand what is going on here and how I can use this.

A: The way to avoid the awk process from being printed is this:
ps aux | awk '/[r]oot/ {print $0,$11}'

That hack works like this:  awk will be searching for the sequence of characters 'r' 'o' 'o' 't'. The actual awk process is not matched because the ps output contains the sequence of characters '[' 'r' ']' 'o' 'o' 't'.

A: There seem to be a couple of issues:  One is that you have *. instead of .* after "root".  The other is that you are searching the whole line and not just the column that contains the username.
$0 represents the entire line.  $1 represents the first column.
Something closer to what you want would be
ps aux | awk '$1 ~ /.*root.*/ {print $0, $11}'

but you could also just do
ps aux | awk '$1=="root" {print $0, $11}'

A: is this what you want?
ps aux | awk '$0 ~ /^root/ {print $0, $11}'

the reason that you have the "last line" is your regex was .root.. and your ps|awk line has the same string.  so it is selected.
maybe you can with grep -v "awk" to filter your awk line out.

A: To exactly match the first field you write
ps aux | awk '$1 == "root"' { print $0, $11 }'

you can also ask ps to filter for you
ps -Uroot | awk ' { print $5 } '

A: If you need to match only process owned by root (i.e. records beginning with the string root):
ps aux | awk '/^root/ { print $0, $11 }'

Note that /regex/ and $0 ~ /regex/ are equivalent.


text: Q: Unable to connect TFS server in Visual Studio Code I am new to VS code. So how could I connect my existing TFS server to VS code. I am using own TFS server URL and Its shown Bad Request(400) over the Team icon after enter user name and password in VS code.


text:
Q: epydoc warning with @abstractproperry I dont what I am missing but the following code:
from abc import ABCMeta, abstractproperty

class Abstra(object):
    __metaclass__ = ABCMeta

    def __init__(self):
        self.var = 77

    @abstractproperty
    def varb(self):
        '''
        returns var
        '''

gives the following epydoc error when generating the docs:
/test> epydoc -v abstra.py
+--------------------------------------------------------------------------
| File /test/abstra.py, in abstra.Abstra.varb
|   Warning: Possible mal-formatted field item.
|   Warning: Improper paragraph indentation.
|

The warning disappears when I change the @abstractproperty decorator to a @property decorator. So my question is whether this a bug or I am missing something?


text:
Q: NameError: uninitialized constant Carrierwave (Deploy to Heroku) I'm using Carrierwave to upload images but I having some issues: This is the log from heroku:
 Running `rake db:migrate` attached to terminal... up, run.2276
rake aborted!
NameError: uninitialized constant Carrierwave
/app/config/initializers/carrier_wave.rb:2:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:652:in `block in load_config_initializer'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:166:in `instrument'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:651:in `load_config_initializer'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in `block in <class:Engine>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:in `tsort_each_child'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application.rb:328:in `require_environment!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application.rb:443:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
WARNING: Toolbelt v3.36.4 update available.

Here are my files:
carrier_wave.rb:
    if Rails.env.production?
    Carrierwave.configure do |config|
        config.fog_credentials = {
            :provider => 'AWS',
            :aws_access_key_id => ENV['S3_ACCESS_KEY'],
            :aws_secrety_access_key => ENV['S3_SECRET_KEY']
        }
        config.fog_directory = ENV['S3_BUCKET']
    end
end

Application.rb:
    require File.expand_path('../boot', __FILE__)

require 'rails/all'
require 'carrierwave'

Bundler.require(*Rails.groups)

module MagicRecipes
  class Application < Rails::Application

    config.autoload_paths += %W(#{config.root}/app/uploaders)

    config.serve_static_files = true

    config.active_record.raise_in_transactional_callbacks = true
    config.assets.initialize_on_precompile = false
  end
end

picture_uploader.rb

    class PictureUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick
  process resize_to_limit: [600, 600]

  if Rails.env.production?
    storage :fog
  else
    storage :file

  end

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

    def extension_white_list
      %w(jpg jpeg gif png)
    end

end

Here is my Gemfile:
source 'https://rubygems.org'

gem 'rails', '4.2.0'
gem 'pg', '~> 0.18.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'

gem 'rails_12factor', '~> 0.0.3'
gem 'bootstrap-sass', '~> 3.3.4.1'
gem 'devise', '~> 3.4.1'
gem 'paperclip', '~> 4.2.1'
gem 'aws-sdk', '~> 1.59.1'
gem 'will_paginate', '~> 3.0.7'
gem 'pry', '~> 0.10.1'
gem 'will_paginate-bootstrap', '~> 1.0.1'
gem 'carrierwave', '~> 0.10.0'

enter code heregem 'mini_magick', '~> 3.8.0'
enter code heregem 'fog', '~> 1.23.0'
enter code heregem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
end
I have the gems and versions installed in my gemfile.
I don't know what is the problem, I did a entire research but I can solve the problem.
Thanks

A: In your carrier_wave.rb file, you have a typo in the name. Change Carrierwave to CarrierWave. As in documentation


text:
Q: Object property not being set but console says otherwise I'm trying to set up a stripe verification service using angular. I basically want to call StripeResponse.get() and have it return either the error or the token that Stripe responds with.
My problem is that when I execute this code, if I do var a = StripeResponse.get(); and then log a to the console, I see null.
If I add a console.log(this); right before return this.response;, I see the following:
Object {response:null, get: function}
 > get: function() {
 v response: Object
    code: "invalid_number"
    message: "This card number looks invalid"
    param: "number"
    type: "card_error"

I don't understand the discrepancy between the "response: null" and "response: Object" in that console log. Below is my code for the service/module.
var app = angular.module('StripeVerify', [ ]);

app.service('StripeResponse', function () {
  return {
    response: null,
    get: function () {
      var form = $('form[name="ccForm"]');
      Stripe.createToken(form, $.proxy(function (status, response) {
        if (response.error) {
          return this.response = response.error;
        } else {
          return this.response = response.id;
        }
      }, this));
      return this.response;
    }
  }
});

A: Since the createToken method does not return a promise or does not have a callback mechanism of any kind, You should just utilize angular $q's Defered API and create a promise pattern for your service.
app.service('StripeResponse', ['$q', function ($q) {
  return {
    response: null,
    get: function () {
      var defered = $q.defer(); //Create a deffered object

      var form = $('form[name="ccForm"]');
      Stripe.createToken(form, function (status, response) {
        if (response.error) {
           defered.reject(response.error); //reject the promise

        } else {
            defered.resolve(response.id); //resolve the promise
        }

      });
      return defered.promise;
    }
  }
}]);

And while consuming the service you would just do (PseudoCode):
  StripeResponseService.get()
  .then(function(id){//Handle Success
  })
  .catch(function(error){//Handle failure
  })


text:
Q: Can we Host manifest.Json on other domain? In Blogger, I try To Add Manifest.Json hosted on some other domain. But I'll get a warning in Start_URl.
here My Code:
<link rel='Manifest' href='https://cdn.rawgit.com/ajaymalik14/Js/85c6a386/manifest.json'/>
Is it Safe to Host Manifest.Json on Other Domain

A: You can host the file on another domain, but the server needs to enable CORS. From the specification:

Remote origins (e.g., a CDN) wanting to host manifests for various web applications will need to include the appropriate CORS response header in their HTTP response (e.g., Access-Control-Allow-Origin: https://example.com).

It looks like rawgit.com automatically sends Access-control-allow-origin: *, so you shouldn't need to do anything special.


text:
Q: problem involving series that converges depending on another series converging Not sure how to approach this problem below. I tried assuming the conditional but that doesn't seem to get me anywhere.

If for a sequence of non-negative real numbers $\{a_n\}$, we have $$\sum{a_kb_k}$$ converges whenever $$\sum{b_k^2}$$ converges. then show that $$\sum{a_k^2}$$ converges

A: Suppose that the series $a_k^2$ is divergent, put $S_n=\sum_1^n a_k²$. Then $S_n \to +\infty$; hence we may suppose that $S_n>0$ for $n\geq 1$. Put $b_n=\frac{a_n}{S_n }$. Then as
$$b_n^2=\frac{S_{n}-S_{n-1}}{S_n^2}\leq \int_{S_{n-1}}^{S_n}\frac{dt}{t^2}$$ we see that the series $b_n^2$ is convergent. The hypothesis gives now that the series $u_n=\frac{a_n^2}{S_n}=\frac{S_n-S_{n-1}}{S_n}$ is convergent. Hence $u_n\to 0$, and $\frac{S_{n-1}}{S_n}\to 1$. This imply that $u_n$ is equivalent to $v_n=\frac{S_n-S_{n-1}}{S_{n-1}}$, and hence (the two series are positive) the series $v_n$ is convergent. But
$$v_n=\frac{S_n-S_{n-1}}{S_{n-1}}\geq \int_{S_{n-1}}^{S_n}\frac{dt}{t}$$
and this show that the series $v_n$ is divergent, a contradiction.

A: If $\sum a_kb_k$ and $\sum b_k^2$ converge, then their sum must also converge. Then using AM-GM:
$$\sum b_k(a_k+b_k) \le \frac{1}{2}\sum b_k^2 +\frac{1}{2} \sum (a_k^2+2a_kb_k+b_k^2)<\infty \Rightarrow \sum a_k^2<\infty.$$


text:
Q: Meaning of *((volatile UINT32*)(a)) in C What is the meaning of
 *((volatile UINT32*)(a)) ?

in C langauage?
Give me some example.

A: It dereferences a, after first casting it to type "pointer to volatile UINT32".
There are way more parentheses than needed, it would be better written as:
*(volatile UINT32 *) a

That does the same thing. You'd expect there to be some more code here, of course, either a write:
*(volatile UINT32 *) a = 4711;

that writes 4711 to the address contained in a, making sure (due to the volatile) that the write is not optimized out even if it can seem pointless from the compiler's point of view.
Or a read:
const UINT32 packetCounter = *(volatile UINT32 *) a;

which reads the current value at the address in a, and stores it in a local constant variable called packetCounter. This is how it would look if a is the address of some I/O register. Again due to the volatile, the read must happen, it cannot be optimized out or cached even though it might seem pointless to the compiler. This is common with I/O registers.


text:
Q: Use arguments value in sql statements I am using jsp-jdbc and I want to use the value of a argument in sql statements.

For eg: http://localhost:3232/file.jsp?name="as"

In the jsp file containing jsp I want:
select * from books where name= (the value of argument 'name' in the url)

How will it do?

A: You can use HttpServletRequest#getParameter() to get the request parameter.
String name = request.getParameter("name");
// ...

You can use PreparedStatement#setXxx() to set an user-definied variable in a SQL string.
preparedStatement = connection.prepareStatement("SELECT * FROM books WHERE name=?");
preparedStatement.setString(1, name);
resultSet = preparedStatement.executeQuery();
// ...

Note that this job doesn't belong in a JSP, but in a Servlet (with a service/DAO class).
See also:

*

*Advanced Servlets/JSP tutorial

*JDBC tutorial - Prepared statements


text:
Q: How to use forEach on inline array when using typescript? I am doing something like the below in my TS project:
['components.d.ts', '.eslintrc.js'].forEach(fileName => {
  console.log(fileName)
})

This is valid JS code and TS should infer fileName as string and allow me to loop over it. However, I am getting error saying:
Element implicitly has an 'any' type because expression of type '".eslintrc.js"' can't be used to index type 'void'.
  Property '.eslintrc.js' does not exist on type 'void'

Unsafe call of an `any` typed value. eslint(@typescript-eslint/no-unsafe-call)

Left side of comma operator is unused and has no side effects. ts(2695)

My tsconfig:
{
    "compilerOptions": {

        "target": "ESNext",
        "module": "ESNext",
        "moduleResolution": "node",
        "baseUrl": "./",
        "paths": {
            "@/*": [
                "src/*"
            ],
            "@templates/*": [
                "src/templates/*"
            ],
        },
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "strictFunctionTypes": true,
        "strictBindCallApply": true,
        "strictPropertyInitialization": true,
        "noImplicitThis": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitOverride": true,
        "skipLibCheck": true
    },
    "exclude": [
        "./node_modules",
    ],
    "include": [
        "src/**/*"
    ]
}

Thanks

A: You probably have a method call in the previous line which doesn't end with a ;. Something like this:

console.log()

['components.d.ts', '.eslintrc.js'].forEach(fileName => {
  console.log(fileName)
})

In this case, a semicolon is NOT inserted automatically. So, it ends up being
console.log()['components.d.ts', '.eslintrc.js']

or just
console.log()['.eslintrc.js']

because of the comma operator. This explains the error you are getting:

'.eslintrc.js' does not exist on type 'void'

If you add a ; at the end of the previous line, the error should go way. Here's a link to the TS Payground which reproduces the error

Further reading:

*

*ES6 Array destructuring weirdness

*What are the rules for JavaScript's automatic semicolon insertion (ASI)?


text:
Q: Clipping of overflowing div inside foreignObject during translate in Firefox I'm using D3.js to render g SVG elements, each containing a foreignObject so that I can attach a styled div text. The HTML looks like this:
<g class=node ...>

    <circle ...></circle>
    <clipPath ...>
        <circle ...></circle>
    </clipPath>
    <image ...></image>

    <foreignObject ...>
        <div ...>...</div>
    </foreignObject>

</g>

There are 60 of these elements contained in a parent g element which is translated with transform: translate(...) when the user scrolls.
Here, the foreignObject has height=1 and width=1 with overflow: visible. This allows the contained div to be sized based on the text it contains.
This works fine on Chrome and Edge (and Safari if I remember correctly), however on Firefox, the div element inside foreignObject gets 'clipped' when I call translate on the parent g element. The image below shows the correct rendering:

And the image below shows the rendering during translate.

I suspect this has something to do with the width and height of the g elements (i.e. node class) because the clipping occurs outside the boundary of g. How would I fix this? I've thought of using JavaScript to modify the width and height of g, but these attributes are based on the rendering which I don't know in advance.
Any help is appreciated!

A: Turns out this is fixed by setting the width and height properties of foreignObject to 100%.


text:
Q: How to reinterpret_cast in Swift? Our project depends on a C library that declares a general struct
typedef struct
{
  SomeType a_field;
  char payload[248];
} GeneralStruct

and a more specific one:
typedef struct
{
  SomeType a_field;
  OtherType other_field;
  AnotherType another_file;
  YetAnotherType yet_another_field;
} SpecificStruct

We have some examples of its usage in C++ and in some cases it's needed to cast the general one to the specific one like:
GeneralStruct generalStruct = // ...
SpecificStruct specificStruct = reinterpret_cast<SpecificStruct&>(generalStruct)

Is it something like reinterpret_cast available in Swift? I guess I could read the bytes from payload manually, but I'm looking for an idiomatic way

A: withMemoryRebound(to:capacity:_:) can be used

... when you have a pointer to memory bound to one type and you need to access that memory as instances of another type.

Example: Take the address of the general struct, then rebind and dereference the pointer:
let general = GeneralStruct()

let specific = withUnsafePointer(to: general) {
    $0.withMemoryRebound(to: SpecificStruct.self, capacity: 1) {
        $0.pointee
    }
}

If both types have the same size and a compatible memory layout then you can also use unsafeBitCast(_:to:):

Use this function only to convert the instance passed as x to a layout-compatible type when conversion through other means is not possible.
Warning: Calling this function breaks the guarantees of the Swift type system; use with extreme care.

Example:
let specific = unsafeBitCast(general, to: SpecificStruct.self)


text:
Q: JBoss 7.1 Datasource JDBC 4.1 Java Persistence-Context I have a EJB-Project and a JBoss 7.1 Server and a PostgreSQL database. I want to get a Entitymanager by PersistenceContext like this:
@PersistenceContext(name="PlayerService",unitName="PlayerService")
private EntityManager em;

persistence.xml:
<persistence-unit name="PlayerService" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
  <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
...

I start the JBoss Server, go into the admin console and configure a JDBC Datasource. I copied postgresql-9.3-1101.jdbc41.jar into the deployment-Folder of the Server, so I can choose that driver when I create the datasource. The datasource name is PlayerService, the JNDI path is java:jboss/PlayerService. I enabled the datasource also as default Datasource in the JPA Subsystem.
em.getTransaction().begin();

still throws a null pointer, I guess because I try to access the PersistenceContext from outside the server (from a java-class with a seperate main-function for testing). What do I have to do to get that working. Would it work from the deployed project on the server? I have the feeling I'm missing some last step/s.

A:
I try to access the PersistenceContext from outside the server

In your Unit tests you need to initialize the EntityManager yourself.
EntityManagerFactory factory = Persistence.createEntityManagerFactory("PlayerService");
EntityManager em = factory.createEntityManager();


text:
Q: AWS SQS JMS Acknowledgement I am using default MessageListener for connecting to SQS queue. I want to track and retry for messages which has Exception. So I am using DUPS_OK_ACKNOWLEDGEMENT mode. In this case if I am doing acknowledgement for one message it is acknowledging all the messages in queue.
How do I make each message ack work, and retry for messages with exception?
public class MyListener implements MessageListener {
    public void onMessage(Message message) {
    try{
        //my logic
        message.acknowledge();
    }catch(Exception e){
    }
}}

A: DUPS_OK_ACKNOWLEDGEMENT is a lazy acknowledgement mode which acknowledges message in a batch after a certain interval of time has passed since the last batch was acknowledged.
You should use CLIENT_ACKNOWLEDGEMENT mode if you want to acknowledge each message separately.
Spring message listener with Client_Acknowledge mode will acknowledge the message when the client calls message.acknowledge().
However, if after successful execution of the message, the consumer does not find any acknowledgement from the client side, spring assumes the execution was successful and acknowledges the message.
If at any point of time, consumer got an exception while processing the message, spring listener needs to know some exception has occured in order to redeliver the message to the queue for another consumer thread to pick it up. If you're catching the exception, spring assumes everything was handled and execution was smooth and hence acknowledges the message.
Spring message listener only allows to throw JMS exception from onMessage listener. Catching your custom exception and throwing a JMS exception from listener (after logging the error for future reference) will allow you to redeliver the message.


text:
Q: Python transpose/swap dataframe column and row in csv file I would like transpose/swap all the columns into the row of my csv files.
I tried this code:
import pandas as pd
import glob
import numpy as np

path =r'/Users/orochimaru/Documents/ParisSportif/foo/merge.csv'
stockstats_data = pd.DataFrame.transpose(path)
list_ = []

for file_ in path:
    df = pd.read_csv(file_)
    stockstats_data = pd.concat((df, stockstats_data), axis=1)

    stockstats_data.to_csv('merget.csv', index=False)

but it doesn't work. Any suggestions please? Thanks a lot guys !

A: import glob
import pandas as pd

path =r'/Users/orochimaru/Documents/ParisSportif/foo/*.csv'
files = glob.glob(path)

frame = []
for file in files:
    frame.append(pd.read_csv(file))

df = pd.concat(frame)
df.T.to_csv('merget.csv', index=False)


text:
Q: How to add instances of sub types that have common base class to the same list in FSharp? I have a base abstract class named Tokenand some sub types like NumToken,StrToken.
I want to put their instances to the same list.
I can't declare a variable use let l = list<'a when 'a :> Token>
Then, I write
    let extractToken<'a when 'a :> Token>(lineNum:int, line:string) : 'a list option =
        let mutable result : 'a list = []

It works, but can not add element.result <- new NumToken(lineNum, value) :: result just say it needs 'a but here is NumToken
Now I can use new NumToken(lineNum, value) :> Token and declare Token list.
It wokrs but looks ugly(I know fsharp doesn't do auto up cast..).
list<_ :> Token> doesn't work too, it only accepts one sub type.
Thx for help.

A: When you model tokens using a class hierarchy and you create a list of tokens, the type of the list needs to be specific. You can either return list<Token> or list<NumToken>.
The flexible types with when constraints are useful only quite rarely - typically, when you have a function that takes some other function and returns whatever the other function produces, so I do not think you need them here. You can use list<Token> and write:
result <- (NumToken(lineNum, value) :> Token) :: result

That said, modelling token in F# using a class hierarchy is not very good idea. F# supports discriminated unions, which are much better fit for this kind of problem:
type Token =
  | NumToken of int
  | StrToken of string

Then you can write a function that returns list<Token> just by writing
result <- (NumToken 42) :: result

Although, depending on what you are doing, it might be also a good idea to avoid the mutation.


text:
Q: Update in Nested serializer. not turning off validators. E: this slug already exists I've made a nested serializers which has slugs in both models. Now I learn that in order to be able to do the update on (unique=True) I need to turn off the validator. But somehow I can't seem to turn it off and it'S still throwing the same error. Any way I should be approaching on this problem?
serializers.py
from rest_framework import serializers

from .models import Question, Answer

class AnswerSerializer(serializers.ModelSerializer):
    """Serialize Answer model"""

    class Meta:
        model = Answer
        fields = ('title', 'body', 'slug', 'author', 'question')
        # https://stackoverflow.com/questions/57249850/overwriting-nested-serializers-create-method-throws-typeerror-create-got-mul
        read_only_fields = ('question',)
        lookup_field = 'slug'

# https://stackoverflow.com/questions/55031552/how-to-access-child-entire-record-in-parent-model-in-django-rest-framework
class QuestionSerializer(serializers.ModelSerializer):
    """Serialize Question model"""

    #This answer variable and the fields 'answer' you refer to has to be the SAME but
    #These can change exp: 'aaa'

    answer = AnswerSerializer(read_only=False, source='answers', many=True,)

    class Meta:
        model = Question
        fields = ('title', 'body', 'slug', 'author', 'category', 'answer',)
        lookup_field = 'slug'

    def create(self, validated_data):

        answers_data = validated_data.pop('answers')

        question = Question.objects.create(**validated_data)

        for answer_data in answers_data:
            #The above stackoverflow link at the answer serializers is realted to this
            Answer.objects.create(question=question, **answer_data)
        return question

    def update(self, instance, validated_data):
        instance.title = validated_data.get('title', instance.title)
        instance.body = validated_data.get('body', instance.body)
        instance.slug = validated_data.get('slug', instance.slug)
        instance.author = validated_data.get('author', instance.author)
        instance.category = validated_data.get('category', instance.category)
        instance.save()

        # https://django.cowhite.com/blog/create-and-update-django-rest-framework-nested-serializers/
        answers_data = validated_data.pop('answers')
        aas = (instance.answers).all()
        print("@@@@@@")
        print(aas)
        print("@@@@@@")
        aas2 = list(aas)

        for answer_data in answers_data:
            aas3 = aas2.pop(0)
            aas3.title= answer_data.get('title', aas3.title)
            aas3.body= answer_data.get('body', aas3.body)
            aas3.slug= answer_data.get('slug', aas3.slug)
            aas3.author= answer_data.get('author', aas3.author)
            aas3.question= answer_data.get('question', aas3.question)
            aas3.save()

        return instance

views.py
from django.shortcuts import render
from .models import Question, Answer
from django.conf import settings
from rest_framework import viewsets
from rest_framework.authentication import TokenAuthentication

from .serializers import QuestionSerializer
#from .permissions import UpdateOwnPrice
from rest_framework.permissions import IsAdminUser

class QuestionViewSet(viewsets.ModelViewSet):
    """CRUD """
    serializer_class = QuestionSerializer
    queryset = Question.objects.all()
    authentication_classes = (TokenAuthentication,)
    #permission_classes = (UpdateOwnPrice,)
    lookup_field = 'slug'
    extra_kwargs = {'slug': {'validators': []}}

models.py
from django.db import models
from django.conf import settings
from django.db.models import Q
from django.utils import timezone
from django.urls import reverse

class Category(models.Model):
    name= models.CharField(max_length=100)

    def __str__(self):
        return self.name

class Question(models.Model):
    title= models.CharField(max_length= 100)
    body= models.TextField()
    slug= models.SlugField(unique= True)
    date_posted= models.DateTimeField(default=timezone.now)
    author= models.ForeignKey(settings.AUTH_USER_MODEL, on_delete= models.CASCADE, related_name = 'questions')
    category= models.ForeignKey(Category, on_delete= models.CASCADE, related_name = 'questions')

    #objects= QnAManager()

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('home')

class Answer(models.Model):
    title= models.CharField(max_length= 100)
    body= models.TextField()
    slug= models.SlugField(unique= True)
    date_posted= models.DateTimeField(default=timezone.now)
    author= models.ForeignKey(settings.AUTH_USER_MODEL, on_delete= models.CASCADE, related_name = 'answers')
    question= models.ForeignKey(Question, on_delete= models.CASCADE, related_name = 'answers')

    #objects= QnAManager()

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('home')


text:
Q: Difference between list,vector and array in action script 3 In action script many times I have come across the keywords
1. array
2. list
3. vector
Please explain the difference between these three keywords?

A: ActionScript 3 fundamentals: Arrays
ActionScript 3 fundamentals: Associative arrays, maps, and dictionaries
ActionScript 3 fundamentals: Vectors and ByteArrays


text:
Q: How to overlay a TIF image in openlayers 6? I am using openlayers 6 for rendering map. My map has some layers and I want to add a TIF image dynamically to the map as an overlay. I am using mapnik & mappoxy for tile caching. I tried this https://gis.stackexchange.com/questions/97943/how-to-open-geotiff-as-base-layer-on-openlayers
but didn't work. My code is:
var map = new Map({
  target: 'map',
  layers: [
    new TileLayer({
      title: 'OSM',
      source: new OSM(),
      opacity: 0.5,
    }),
    new TileLayer({
       title: 'District',
       source: new XYZ({
           url: "http://127.0.0.1:8080/tms/1.0.0/dist/distgrid" + "/{z}/{x}/{-y}.png",
           crossOrigin: "anonymous",
           projection:projection,
           tileGrid: createXYZ({
                  extent: extent,
                  maxResolution: 2605.2421875,
                  tileSize: [256, 256],
                  maxZoom: 13,
                }),
       }),
    }),
  ],
view: new View({
    projection: projection,
    units:"metric",
    extent: extent,
    zoom:0,
    maxZoom:13,
    minZoom:0,
    maxResolution:2605.2421875,
    center:[654496.136597752,1155181.26900064],
    numZoomLevels:13,
  })
});

I have a tif image of name analysis_result.tif which I want to overlay to the map. When I add this using qgis it overlay in the right place.

A: You could host it in geoserver, then use URL to show it.
 tiffRaster = new ol.layer.Image({
        title: 'anyName',
        source: new ol.source.ImageWMS({
            url: 'http://urlOrLocalHost:8080/geoserver/faml/wms',
            params: {
                'LAYERS': 'faml:' + f
            },
            ratio: 1,
            serverType: 'geoserver'
        })
    });

In LAYERS compare your name layer with name tiff hosted in Openlayers